diff options
author | Ted Gould <ted@gould.cx> | 2010-08-20 16:47:06 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-08-20 16:47:06 -0500 |
commit | 49ff3029a6cc08287e39371f079dc2109a896901 (patch) | |
tree | c4efa08af2d2eeb5d3dc57c44f0aca1e6cf051d6 /libdbusmenu-gtk/client.c | |
parent | 8b9843002a14e8954404f4991db2a9a54988c06b (diff) | |
download | libdbusmenu-49ff3029a6cc08287e39371f079dc2109a896901.tar.gz libdbusmenu-49ff3029a6cc08287e39371f079dc2109a896901.tar.bz2 libdbusmenu-49ff3029a6cc08287e39371f079dc2109a896901.zip |
Restructuring so that we pass the menu
Diffstat (limited to 'libdbusmenu-gtk/client.c')
-rw-r--r-- | libdbusmenu-gtk/client.c | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 4938601..44f95fe 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -437,22 +437,25 @@ new_menuitem (DbusmenuClient * client, DbusmenuMenuitem * mi, gpointer userdata) /* Goes through the tree of items and ensure's that all the items above us are also displayed. */ static void -activate_helper (GtkWidget * item) +activate_helper (GtkMenuShell * shell) { - GtkWidget * parent = gtk_widget_get_parent(item); + if (shell == NULL) { + return; + } - 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 (GTK_IS_MENU(shell)) { + GtkWidget * attach = gtk_menu_get_attach_widget(GTK_MENU(shell)); if (attach != NULL) { - activate_helper(attach); - } + GtkWidget * parent = gtk_widget_get_parent(GTK_WIDGET(attach)); - gtk_menu_shell_select_item(GTK_MENU_SHELL(parent), item); + if (parent != NULL) { + if (GTK_IS_MENU(parent)) { + activate_helper(GTK_MENU_SHELL(parent)); + } + gtk_menu_shell_select_item(GTK_MENU_SHELL(parent), attach); + } + } } return; @@ -463,22 +466,13 @@ activate_helper (GtkWidget * item) static void item_activate (DbusmenuClient * client, DbusmenuMenuitem * mi, guint timestamp, gpointer userdata) { - 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; - } - 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; } - GtkWidget * item = GTK_WIDGET(pitem); - - activate_helper(item); - + activate_helper(GTK_MENU_SHELL(pmenu)); gtk_menu_shell_select_first(GTK_MENU_SHELL(pmenu), FALSE); return; |