aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-01-31 12:13:31 -0600
committerTed Gould <ted@gould.cx>2011-01-31 12:13:31 -0600
commit59a719d0198e5f8de25f66f96eb0743c002c1e4c (patch)
tree3967d2050d76bae65fef67327e9153c70f23a3e6
parente87bb23592996b262ee8565e5ed3da90220619ef (diff)
parent74a0afebe8d3c1fa28d969739ea5c718f00e8c0d (diff)
downloadlibdbusmenu-59a719d0198e5f8de25f66f96eb0743c002c1e4c.tar.gz
libdbusmenu-59a719d0198e5f8de25f66f96eb0743c002c1e4c.tar.bz2
libdbusmenu-59a719d0198e5f8de25f66f96eb0743c002c1e4c.zip
Handling changing submenus by watching for the notify event
-rw-r--r--libdbusmenu-gtk/parser.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c
index 5d71585..7e5e7e1 100644
--- a/libdbusmenu-gtk/parser.c
+++ b/libdbusmenu-gtk/parser.c
@@ -649,6 +649,37 @@ widget_notify_cb (GtkWidget *widget,
}
}
}
+ else if (pspec->name == g_intern_static_string ("submenu"))
+ {
+ /* The underlying submenu got swapped out. Let's see what it is now. */
+ /* First, delete any children that may exist currently. */
+ DbusmenuMenuitem * item = DBUSMENU_MENUITEM(g_object_get_data(G_OBJECT(widget), CACHED_MENUITEM));
+ if (item != NULL)
+ {
+ GList * children = dbusmenu_menuitem_take_children (item);
+ GList * child = children;
+ while (child != NULL) {
+ g_object_unref (G_OBJECT(child->data));
+ child = child->next;
+ }
+ g_list_free(children);
+ }
+
+ /* Now parse new submenu. */
+ RecurseContext recurse = {0};
+ recurse.toplevel = gtk_widget_get_toplevel(widget);
+ recurse.parent = item;
+
+ if (item != NULL) {
+ GtkWidget * menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget));
+ parse_menu_structure_helper(menu, &recurse);
+ } else {
+ /* Note: it would be really odd that we wouldn't have a cached
+ item, but we should handle that appropriately. */
+ parse_menu_structure_helper(widget, &recurse);
+ g_object_unref(G_OBJECT(recurse.parent));
+ }
+ }
}
static gboolean