summaryrefslogtreecommitdiff
path: root/gtk/gtkmenu.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2009-06-24 01:01:51 -0400
committerMatthias Clasen <mclasen@redhat.com>2009-06-24 01:01:51 -0400
commit724ab5824455f7ec57f56cbd3d0ba05b21e3d305 (patch)
treee071722b2e766a133f3a04e1bf58856a93ca716e /gtk/gtkmenu.c
parent839aa0421eca9c9144caf3c290d017c210670af6 (diff)
downloadgtk+-724ab5824455f7ec57f56cbd3d0ba05b21e3d305.tar.gz
Add a way to turn off toggle spacing in menus
Reserving toggle space is nice for consistency in main menus and context menus, but it gets in the way in special situations, such as combo boxes, tabular menus, etc.
Diffstat (limited to 'gtk/gtkmenu.c')
-rw-r--r--gtk/gtkmenu.c73
1 files changed, 69 insertions, 4 deletions
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index 49d2e2319f..0fd5d3d4ad 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -125,7 +125,8 @@ enum {
PROP_ATTACH_WIDGET,
PROP_TEAROFF_STATE,
PROP_TEAROFF_TITLE,
- PROP_MONITOR
+ PROP_MONITOR,
+ PROP_RESERVE_TOGGLE_SIZE
};
enum {
@@ -596,6 +597,27 @@ gtk_menu_class_init (GtkMenuClass *class)
1,
GTK_PARAM_READABLE));
+ /**
+ * GtkMenu:reserve-toggle-size:
+ *
+ * A boolean that indicates whether the menu reserves space for
+ * toggles and icons, regardless of their actual presence.
+ *
+ * This property should only be changed from its default value
+ * for special-purposes such as tabular menus. Regular menus that
+ * are connected to a menu bar or context menus should reserve
+ * toggle space for consistency.
+ *
+ * Since: 2.18
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_RESERVE_TOGGLE_SIZE,
+ g_param_spec_boolean ("reserve-toggle-size",
+ P_("Reserve Toggle Size"),
+ P_("A boolean that indicates whether the menu reserves space for toggles and icons"),
+ TRUE,
+ GTK_PARAM_READWRITE));
+
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("horizontal-padding",
P_("Horizontal Padding"),
@@ -840,6 +862,9 @@ gtk_menu_set_property (GObject *object,
case PROP_MONITOR:
gtk_menu_set_monitor (menu, g_value_get_int (value));
break;
+ case PROP_RESERVE_TOGGLE_SIZE:
+ gtk_menu_set_reserve_toggle_size (menu, g_value_get_boolean (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -877,6 +902,9 @@ gtk_menu_get_property (GObject *object,
case PROP_MONITOR:
g_value_set_int (value, gtk_menu_get_monitor (menu));
break;
+ case PROP_RESERVE_TOGGLE_SIZE:
+ g_value_set_boolean (value, gtk_menu_get_reserve_toggle_size (menu));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -5284,13 +5312,50 @@ gtk_menu_grab_notify (GtkWidget *widget,
}
}
+/**
+ * gtk_menu_set_reserve_toggle_size:
+ * @menu: a #GtkMenu
+ * @reserve_toggle_size: whether to reserve size for toggles
+ *
+ * Sets whether the menu should reserve space for drawing toggles
+ * or icons, regardless of their actual presence.
+ *
+ * Since: 2.18
+ */
void
-_gtk_menu_set_reserve_toggle_size (GtkMenu *menu,
- gboolean reserve)
+gtk_menu_set_reserve_toggle_size (GtkMenu *menu,
+ gboolean reserve_toggle_size)
{
GtkMenuPrivate *priv = gtk_menu_get_private (menu);
+ gboolean no_toggle_size;
- priv->no_toggle_size = !reserve;
+ no_toggle_size = !reserve_toggle_size;
+
+ if (priv->no_toggle_size != no_toggle_size)
+ {
+ priv->no_toggle_size = no_toggle_size;
+
+ g_object_notify (G_OBJECT (menu), "reserve-toggle-size");
+ }
+}
+
+/**
+ * gtk_menu_get_reserve_toggle_size:
+ * @menu: a #GtkMenu
+ *
+ * Returns whether the menu reserves space for toggles and
+ * icons, regardless of their actual presence.
+ *
+ * Returns: Whether the menu reserves toggle space
+ *
+ * Since: 2.18
+ */
+gboolean
+gtk_menu_get_reserve_toggle_size (GtkMenu *menu)
+{
+ GtkMenuPrivate *priv = gtk_menu_get_private (menu);
+
+ return !priv->no_toggle_size;
}
#define __GTK_MENU_C__