diff options
author | Ted Gould <ted@gould.cx> | 2010-08-20 16:39:12 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-08-20 16:39:12 -0500 |
commit | 8b9843002a14e8954404f4991db2a9a54988c06b (patch) | |
tree | 1655ffbf2c031eab240cd86eddad1d1e4de3fec3 /libdbusmenu-gtk | |
parent | b2ab47c71a8a2e1d517c6594ae3f8bdf9e539285 (diff) | |
download | libdbusmenu-8b9843002a14e8954404f4991db2a9a54988c06b.tar.gz libdbusmenu-8b9843002a14e8954404f4991db2a9a54988c06b.tar.bz2 libdbusmenu-8b9843002a14e8954404f4991db2a9a54988c06b.zip |
Making it so that items show.
Diffstat (limited to 'libdbusmenu-gtk')
-rw-r--r-- | libdbusmenu-gtk/client.c | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index da81544..4938601 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -434,27 +434,52 @@ new_menuitem (DbusmenuClient * client, DbusmenuMenuitem * mi, gpointer userdata) return; } +/* Goes through the tree of items and ensure's that all the items + above us are also displayed. */ +static void +activate_helper (GtkWidget * item) +{ + GtkWidget * parent = gtk_widget_get_parent(item); + + if (parent != NULL && GTK_IS_MENU_SHELL(parent)) { + GtkWidget * attach = NULL; + + if (GTK_IS_MENU(parent)) { + attach = gtk_menu_get_attach_widget(GTK_MENU(parent)); + } + + if (attach != NULL) { + activate_helper(attach); + } + + gtk_menu_shell_select_item(GTK_MENU_SHELL(parent), item); + } + + return; +} + /* Signaled when we should show a menuitem at request of the application that it is in. */ static void item_activate (DbusmenuClient * client, DbusmenuMenuitem * mi, guint timestamp, gpointer userdata) { - gpointer pmenu = g_object_get_data(G_OBJECT(mi), data_menu); - if (pmenu == NULL) { + gpointer pitem = g_object_get_data(G_OBJECT(mi), data_menuitem); + if (pitem == NULL) { g_warning("Activated menu item doesn't have a menu? ID: %d", dbusmenu_menuitem_get_id(mi)); return; } - GtkWidget * parent = gtk_widget_get_parent(GTK_WIDGET(pmenu)); - if (parent == NULL) { - g_warning("Activated menu item's menu doesn't have a parent? ID: %d", dbusmenu_menuitem_get_id(mi)); + gpointer pmenu = g_object_get_data(G_OBJECT(mi), data_menu); + if (pmenu == NULL) { + g_warning("Activated menu item doesn't have a menu? ID: %d", dbusmenu_menuitem_get_id(mi)); return; } - if (!gtk_widget_mnemonic_activate(parent, FALSE)) { - g_warning("Unable to activate item: %d", dbusmenu_menuitem_get_id(mi)); - return; - } + GtkWidget * item = GTK_WIDGET(pitem); + + activate_helper(item); + + gtk_menu_shell_select_first(GTK_MENU_SHELL(pmenu), FALSE); return; } |