diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols index 288a6d187e..a0ed68a75d 100644 --- a/gtk/gtk.symbols +++ b/gtk/gtk.symbols @@ -2272,6 +2272,7 @@ gtk_menu_set_title #if IN_FILE(__GTK_MENU_ITEM_C__) gtk_menu_item_activate gtk_menu_item_deselect +gtk_menu_item_get_accel_path gtk_menu_item_get_right_justified gtk_menu_item_get_submenu gtk_menu_item_get_type G_GNUC_CONST diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c index aa2b27ad1a..5cc129ba4f 100644 --- a/gtk/gtkmenuitem.c +++ b/gtk/gtkmenuitem.c @@ -52,7 +52,9 @@ enum { enum { PROP_0, - PROP_SUBMENU + PROP_RIGHT_JUSTIFIED, + PROP_SUBMENU, + PROP_ACCEL_PATH }; @@ -189,6 +191,21 @@ gtk_menu_item_class_init (GtkMenuItemClass *klass) G_TYPE_NONE, 1, G_TYPE_INT); + /** + * GtkMenuItem:right-justified: + * + * Sets whether the menu item appears justified at the right side of a menu bar. + * + * Since: GSEAL-branch + **/ + g_object_class_install_property (gobject_class, + PROP_RIGHT_JUSTIFIED, + g_param_spec_boolean ("right-justified", + P_("Right Justified"), + P_("Sets whether the menu item appears justified at the right side of a menu bar"), + FALSE, + GTK_PARAM_READWRITE)); + /** * GtkMenuItem:submenu: * @@ -204,6 +221,23 @@ gtk_menu_item_class_init (GtkMenuItemClass *klass) GTK_TYPE_MENU, GTK_PARAM_READWRITE)); + /** + * GtkMenuItem:accel-path: + * + * Sets the accelerator path of the menu item, through which runtime + * changes of the menu item's accelerator caused by the user can be + * identified and saved to persistant storage. + * + * Since: GSEAL-branch + **/ + g_object_class_install_property (gobject_class, + PROP_ACCEL_PATH, + g_param_spec_string ("accel-path", + P_("Accel Path"), + P_("Sets the accelerator path of the menu item"), + NULL, + GTK_PARAM_READWRITE)); + gtk_widget_class_install_style_property_parser (widget_class, g_param_spec_enum ("selected-shadow-type", "Selected Shadow Type", @@ -329,9 +363,15 @@ gtk_menu_item_set_property (GObject *object, switch (prop_id) { + case PROP_RIGHT_JUSTIFIED: + gtk_menu_item_set_right_justified (menu_item, g_value_get_boolean (value)); + break; case PROP_SUBMENU: gtk_menu_item_set_submenu (menu_item, g_value_get_object (value)); break; + case PROP_ACCEL_PATH: + gtk_menu_item_set_accel_path (menu_item, g_value_get_string (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -349,9 +389,15 @@ gtk_menu_item_get_property (GObject *object, switch (prop_id) { + case PROP_RIGHT_JUSTIFIED: + g_value_set_boolean (value, gtk_menu_item_get_right_justified (menu_item)); + break; case PROP_SUBMENU: g_value_set_object (value, gtk_menu_item_get_submenu (menu_item)); break; + case PROP_ACCEL_PATH: + g_value_set_string (value, gtk_menu_item_get_accel_path (menu_item)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -1632,6 +1678,29 @@ gtk_menu_item_set_accel_path (GtkMenuItem *menu_item, } } +/** + * gtk_menu_item_get_accel_path + * @menu_item: a valid #GtkMenuItem + * + * Set the accelerator path on @menu_item, through which runtime changes of the + * menu item's accelerator caused by the user can be identified and saved to + * persistant storage (see gtk_accel_map_save() on this). + * To setup a default accelerator for this menu item, call + * gtk_accel_map_add_entry() with the same @accel_path. + * See also gtk_accel_map_add_entry() on the specifics of accelerator paths, + * and gtk_menu_set_accel_path() for a more convenient variant of this function. + * + * Returns: the accelerator path corresponding to this menu item's + * functionality, or %NULL if not set + */ +G_CONST_RETURN gchar * +gtk_menu_item_get_accel_path (GtkMenuItem *menu_item) +{ + g_return_if_fail (GTK_IS_MENU_ITEM (menu_item)); + + return menu_item->accel_path; +} + static void gtk_menu_item_forall (GtkContainer *container, gboolean include_internals, diff --git a/gtk/gtkmenuitem.h b/gtk/gtkmenuitem.h index 1c51fc45c3..2ea41712c6 100644 --- a/gtk/gtkmenuitem.h +++ b/gtk/gtkmenuitem.h @@ -52,21 +52,21 @@ typedef struct _GtkMenuItemClass GtkMenuItemClass; struct _GtkMenuItem { GtkItem item; - - GtkWidget *submenu; - GdkWindow *event_window; - - guint16 toggle_size; - guint16 accelerator_width; - gchar *accel_path; - - guint show_submenu_indicator : 1; - guint submenu_placement : 1; - guint submenu_direction : 1; - guint right_justify: 1; - guint timer_from_keypress : 1; - guint from_menubar : 1; - guint timer; + + GtkWidget *GSEAL (submenu); + GdkWindow *GSEAL (event_window); + + guint16 GSEAL (toggle_size); + guint16 GSEAL (accelerator_width); + gchar *GSEAL (accel_path); + + guint GSEAL (show_submenu_indicator : 1); + guint GSEAL (submenu_placement : 1); + guint GSEAL (submenu_direction : 1); + guint GSEAL (right_justify: 1); + guint GSEAL (timer_from_keypress : 1); + guint GSEAL (from_menubar : 1); + guint GSEAL (timer); }; struct _GtkMenuItemClass @@ -115,6 +115,7 @@ void gtk_menu_item_set_right_justified (GtkMenuItem *menu_item, gboolean gtk_menu_item_get_right_justified (GtkMenuItem *menu_item); void gtk_menu_item_set_accel_path (GtkMenuItem *menu_item, const gchar *accel_path); +G_CONST_RETURN gchar* gtk_menu_item_get_accel_path (GtkMenuItem *menu_item); /* private */ void _gtk_menu_item_refresh_accel_path (GtkMenuItem *menu_item,