* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/*
static void
get_arrow_size (GtkWidget *widget,
GtkWidget *child,
- gint *size)
+ gint *size,
+ gint *spacing)
{
GtkStyleContext *style_context;
GtkStateFlags state;
PangoContext *context;
PangoFontMetrics *metrics;
gfloat arrow_scaling;
+ gint arrow_spacing;
g_assert (size);
gtk_widget_style_get (widget,
"arrow-scaling", &arrow_scaling,
+ "arrow-spacing", &arrow_spacing,
NULL);
+ if (spacing != NULL)
+ *spacing = arrow_spacing;
+
context = gtk_widget_get_pango_context (child);
style_context = gtk_widget_get_style_context (child);
state = gtk_widget_get_state_flags (child);
if ((menu_item->priv->submenu && !GTK_IS_MENU_BAR (parent)) || priv->reserve_indicator)
{
- guint arrow_spacing;
- gint arrow_size;
-
- gtk_widget_style_get (widget,
- "arrow-spacing", &arrow_spacing,
- NULL);
-
- get_arrow_size (widget, child, &arrow_size);
+ gint arrow_spacing, arrow_size;
- gtk_widget_style_get (widget,
- "arrow-spacing", &arrow_spacing,
- NULL);
-
- get_arrow_size (widget, child, &arrow_size);
+ get_arrow_size (widget, child, &arrow_size, &arrow_spacing);
min_width += arrow_size;
min_width += arrow_spacing;
GtkPackDirection pack_dir;
GtkPackDirection child_pack_dir;
gint min_height, nat_height;
- gint avail_size;
+ gint avail_size = 0;
min_height = nat_height = 0;
if (child != NULL && gtk_widget_get_visible (child))
{
gint child_min, child_nat;
- gint arrow_size = 0;
- guint arrow_spacing = 0;
+ gint arrow_size = 0, arrow_spacing = 0;
if ((priv->submenu && !GTK_IS_MENU_BAR (parent)) || priv->reserve_indicator)
- {
- gtk_widget_style_get (widget,
- "arrow-spacing", &arrow_spacing,
- NULL);
- get_arrow_size (widget, child, &arrow_size);
- }
+ get_arrow_size (widget, child, &arrow_size, &arrow_spacing);
if (for_size != -1)
{
- avail_size -= arrow_size;
- avail_size -= arrow_spacing;
-
+ avail_size -= (arrow_size + arrow_spacing);
gtk_widget_get_preferred_height_for_width (child,
avail_size,
&child_min,
if ((priv->submenu && !GTK_IS_MENU_BAR (parent)) || priv->reserve_indicator)
{
- guint arrow_spacing;
- gint arrow_size;
-
- gtk_widget_style_get (widget,
- "arrow-spacing", &arrow_spacing,
- NULL);
+ gint arrow_spacing, arrow_size;
- get_arrow_size (widget, child, &arrow_size);
+ get_arrow_size (widget, child, &arrow_size, &arrow_spacing);
if (direction == GTK_TEXT_DIR_RTL)
child_allocation.x += arrow_size + arrow_spacing;
parent = gtk_widget_get_parent (widget);
gtk_style_context_save (context);
- gtk_style_context_set_state (context, state);
gtk_style_context_get_padding (context, state, &padding);
"horizontal-padding", &horizontal_padding,
NULL);
- get_arrow_size (widget, child, &arrow_size);
+ get_arrow_size (widget, child, &arrow_size, NULL);
if (direction == GTK_TEXT_DIR_LTR)
{
gtk_real_menu_item_select (GtkMenuItem *menu_item)
{
GtkMenuItemPrivate *priv = menu_item->priv;
- gboolean touchscreen_mode;
+ GdkDevice *source_device = NULL;
+ GdkEvent *current_event;
+
+ current_event = gtk_get_current_event ();
- g_object_get (gtk_widget_get_settings (GTK_WIDGET (menu_item)),
- "gtk-touchscreen-mode", &touchscreen_mode,
- NULL);
+ if (current_event)
+ {
+ source_device = gdk_event_get_source_device (current_event);
+ gdk_event_free (current_event);
+ }
- if (!touchscreen_mode && priv->submenu &&
+ if ((!source_device ||
+ gdk_device_get_source (source_device) != GDK_SOURCE_TOUCHSCREEN) &&
+ priv->submenu &&
(!gtk_widget_get_mapped (priv->submenu) ||
GTK_MENU (priv->submenu)->priv->tearoff_active))
{
monitor_num = gdk_screen_get_monitor_at_window (screen, priv->event_window);
if (monitor_num < 0)
monitor_num = 0;
- gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+ gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
if (!gdk_window_get_origin (gtk_widget_get_window (widget), &tx, &ty))
{