aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-gtk/parser.c
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-04-15 14:21:24 -0500
committerTed Gould <ted@gould.cx>2011-04-15 14:21:24 -0500
commit3221bcddba19b5282485cf432da89c0173725274 (patch)
treea67b95de9f1cd29abead0a0b39447f10fdffba39 /libdbusmenu-gtk/parser.c
parentdfc41992ce8acc7d8b85b4e196f88afb38016174 (diff)
parent7c726c9b99b9e02965b63a19e14920a7f6bb78c2 (diff)
downloadlibdbusmenu-3221bcddba19b5282485cf432da89c0173725274.tar.gz
libdbusmenu-3221bcddba19b5282485cf432da89c0173725274.tar.bz2
libdbusmenu-3221bcddba19b5282485cf432da89c0173725274.zip
Make sure we watch new busmenus the same as original ones.
Diffstat (limited to 'libdbusmenu-gtk/parser.c')
-rw-r--r--libdbusmenu-gtk/parser.c43
1 files changed, 20 insertions, 23 deletions
diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c
index 4972856..71474ae 100644
--- a/libdbusmenu-gtk/parser.c
+++ b/libdbusmenu-gtk/parser.c
@@ -271,6 +271,23 @@ new_menuitem (GtkWidget * widget)
}
static void
+watch_submenu(DbusmenuMenuitem * mi, GtkWidget * menu)
+{
+ ParserData *pdata = (ParserData *)g_object_get_data(G_OBJECT(mi), PARSER_DATA);
+
+ pdata->shell = menu;
+ g_signal_connect (G_OBJECT (menu),
+ "child-added",
+ G_CALLBACK (child_added_cb),
+ mi);
+ g_signal_connect (G_OBJECT (menu),
+ "child-removed",
+ G_CALLBACK (child_removed_cb),
+ mi);
+ g_object_add_weak_pointer(G_OBJECT (menu), (gpointer*)&pdata->shell);
+}
+
+static void
parse_menu_structure_helper (GtkWidget * widget, RecurseContext * recurse)
{
/* If this is a shell, then let's handle the items in it. */
@@ -300,19 +317,7 @@ parse_menu_structure_helper (GtkWidget * widget, RecurseContext * recurse)
if (recurse->parent == NULL) {
recurse->parent = new_menuitem(widget);
-
- ParserData *pdata = (ParserData *)g_object_get_data(G_OBJECT(recurse->parent), PARSER_DATA);
-
- pdata->shell = widget;
- g_signal_connect (G_OBJECT (widget),
- "child-added",
- G_CALLBACK (child_added_cb),
- recurse->parent);
- g_signal_connect (G_OBJECT (widget),
- "child-removed",
- G_CALLBACK (child_removed_cb),
- recurse->parent);
- g_object_add_weak_pointer(G_OBJECT (widget), (gpointer*)&pdata->shell);
+ watch_submenu(recurse->parent, widget);
}
gtk_container_foreach (GTK_CONTAINER (widget),
@@ -561,16 +566,7 @@ construct_dbusmenu_for_widget (GtkWidget * widget)
GtkWidget *submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(widget));
if (submenu)
{
- pdata->shell = submenu;
- g_signal_connect (G_OBJECT (submenu),
- "child-added",
- G_CALLBACK (child_added_cb),
- mi);
- g_signal_connect (G_OBJECT (submenu),
- "child-removed",
- G_CALLBACK (child_removed_cb),
- mi);
- g_object_add_weak_pointer(G_OBJECT(submenu), (gpointer*)&pdata->shell);
+ watch_submenu(mi, submenu);
}
if (!g_object_get_data (G_OBJECT (widget), "gtk-empty-menu-item") && !GTK_IS_TEAROFF_MENU_ITEM (widget))
@@ -1077,6 +1073,7 @@ widget_notify_cb (GtkWidget *widget,
if (item != NULL) {
GtkWidget * menu = GTK_WIDGET (g_value_get_object (&prop_value));
parse_menu_structure_helper(menu, &recurse);
+ watch_submenu(item, menu);
} else {
/* Note: it would be really odd that we wouldn't have a cached
item, but we should handle that appropriately. */