aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-gtk/menu.c
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-04-10 23:40:48 -0500
committerTed Gould <ted@gould.cx>2011-04-10 23:40:48 -0500
commitc8dd7726fb7f906de80ce0790662f568a24f963c (patch)
treee4b680e7c0bc114e80bb6a982825dc775d45d816 /libdbusmenu-gtk/menu.c
parentf3654c0176b8ecc1cc812b9dc93e21da8483659d (diff)
downloadlibdbusmenu-c8dd7726fb7f906de80ce0790662f568a24f963c.tar.gz
libdbusmenu-c8dd7726fb7f906de80ce0790662f568a24f963c.tar.bz2
libdbusmenu-c8dd7726fb7f906de80ce0790662f568a24f963c.zip
Ensuring all the menus are hidden before unref'ing root
Diffstat (limited to 'libdbusmenu-gtk/menu.c')
-rw-r--r--libdbusmenu-gtk/menu.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c
index 0b31069..236a596 100644
--- a/libdbusmenu-gtk/menu.c
+++ b/libdbusmenu-gtk/menu.c
@@ -329,6 +329,18 @@ remove_child_signals (gpointer data, gpointer user_data)
return;
}
+/* Handler for all of the menu items on a root change to ensure that
+ the menus are hidden before we start going and deleting things. */
+static void
+popdown_all (DbusmenuMenuitem * mi, gpointer user_data)
+{
+ GtkMenu * menu = dbusmenu_gtkclient_menuitem_get_submenu(DBUSMENU_GTKCLIENT(user_data), mi);
+ if (menu != NULL) {
+ gtk_menu_popdown(menu);
+ }
+ return;
+}
+
/* When the root menuitem changes we need to resetup things so that
we're back in the game. */
static void
@@ -344,6 +356,8 @@ root_changed (DbusmenuGtkClient * client, DbusmenuMenuitem * newroot, DbusmenuGt
g_signal_handlers_disconnect_by_func(G_OBJECT(priv->root), root_child_moved, menu);
g_signal_handlers_disconnect_by_func(G_OBJECT(priv->root), root_child_delete, menu);
+ dbusmenu_menuitem_foreach(priv->root, popdown_all, client);
+
g_object_unref(priv->root);
priv->root = NULL;
}