diff options
author | Tristan Van Berkom <vantr@TheBully.local> | 2009-06-18 15:46:02 -0400 |
---|---|---|
committer | Tristan Van Berkom <vantr@TheBully.local> | 2009-06-22 12:19:56 -0400 |
commit | 515a0b61a173cbea511242823aa6e9418f5ca6ed (patch) | |
tree | 32451b9a7f57d8b1747c445e69d417374fea2d96 /gtk/gtkmenuitem.c | |
parent | d3ae855ce67e66f055174909f98239ff4676fbb2 (diff) | |
download | gtk+-515a0b61a173cbea511242823aa6e9418f5ca6ed.tar.gz |
Accelerators failed for submenus (GNOME bug 582025)
gtk/gtkmenuitem.c: Override custom_tag_finished() for "accelerator" and search
the correct toplevel GtkWindow to attach accelerators to menu items.
gtk/gtkwidget.[ch]: Added _gtk_widget_buildable_finish_accelerator() to allow
subclasses to specify a toplevel window to associate with when parsing <accelerator>
tags
Diffstat (limited to 'gtk/gtkmenuitem.c')
-rw-r--r-- | gtk/gtkmenuitem.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c index ced23c099a..1ab96b00a2 100644 --- a/gtk/gtkmenuitem.c +++ b/gtk/gtkmenuitem.c @@ -132,6 +132,11 @@ static void gtk_menu_item_buildable_add_child (GtkBuildable *buildab GtkBuilder *builder, GObject *child, const gchar *type); +static void gtk_menu_item_buildable_custom_finished(GtkBuildable *buildable, + GtkBuilder *builder, + GObject *child, + const gchar *tagname, + gpointer user_data); static void gtk_menu_item_activatable_interface_init (GtkActivatableIface *iface); static void gtk_menu_item_update (GtkActivatable *activatable, @@ -558,6 +563,7 @@ gtk_menu_item_buildable_interface_init (GtkBuildableIface *iface) { parent_buildable_iface = g_type_interface_peek_parent (iface); iface->add_child = gtk_menu_item_buildable_add_child; + iface->custom_finished = gtk_menu_item_buildable_custom_finished; } static void @@ -573,6 +579,46 @@ gtk_menu_item_buildable_add_child (GtkBuildable *buildable, parent_buildable_iface->add_child (buildable, builder, child, type); } + +static void +gtk_menu_item_buildable_custom_finished (GtkBuildable *buildable, + GtkBuilder *builder, + GObject *child, + const gchar *tagname, + gpointer user_data) +{ + GtkWidget *toplevel; + + if (strcmp (tagname, "accelerator") == 0) + { + GtkMenuShell *menu_shell = (GtkMenuShell *) GTK_WIDGET (buildable)->parent; + GtkWidget *attach; + + if (menu_shell) + { + while (GTK_IS_MENU (menu_shell) && + (attach = gtk_menu_get_attach_widget (GTK_MENU (menu_shell))) != NULL) + menu_shell = (GtkMenuShell *)attach->parent; + + toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menu_shell)); + } + else + { + /* Fall back to something ... */ + toplevel = gtk_widget_get_toplevel (GTK_WIDGET (buildable)); + + g_warning ("found a GtkMenuItem '%s' without a parent GtkMenuShell, assigned accelerators wont work.", + gtk_buildable_get_name (buildable)); + } + + /* Feed the correct toplevel to the GtkWidget accelerator parsing code */ + _gtk_widget_buildable_finish_accelerator (GTK_WIDGET (buildable), toplevel, user_data); + } + else + parent_buildable_iface->custom_finished (buildable, builder, child, tagname, user_data); +} + + static void gtk_menu_item_activatable_interface_init (GtkActivatableIface *iface) { |