From 331794c5e1cfc98fa522535bad47a7f77c02a073 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 25 Jan 2011 09:35:55 -0600 Subject: Rework the setup_dbusmenu function to use the dbusmenu parser. --- src/app-indicator.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 40959bf..35ac818 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -34,6 +34,7 @@ License version 3 and version 2.1 along with this program. If not, see #include #include #include +#include #include @@ -2032,32 +2033,35 @@ submenu_changed (GtkWidget *widget, root); } +/* Does the dbusmenu related work. If there isn't a server, it builds + one and if there are menus it runs the parse to put those menus into + the server. */ static void setup_dbusmenu (AppIndicator *self) { - AppIndicatorPrivate *priv; - DbusmenuMenuitem *root; + AppIndicatorPrivate *priv; + DbusmenuMenuitem *root = NULL; - priv = self->priv; - root = dbusmenu_menuitem_new (); + priv = self->priv; - if (priv->menu) - { - gtk_container_foreach (GTK_CONTAINER (priv->menu), - container_iterate, - root); - } + if (priv->menu) { + root = dbusmenu_gtk_parse_menu_structure(priv->menu); + } - if (priv->menuservice == NULL) - { - gchar * path = g_strdup_printf(DEFAULT_ITEM_PATH "/%s/Menu", priv->clean_id); - priv->menuservice = dbusmenu_server_new (path); - g_free(path); - } + if (priv->menuservice == NULL) { + gchar * path = g_strdup_printf(DEFAULT_ITEM_PATH "/%s/Menu", priv->clean_id); + priv->menuservice = dbusmenu_server_new (path); + g_free(path); + } - dbusmenu_server_set_root (priv->menuservice, root); + dbusmenu_server_set_root (priv->menuservice, root); - return; + /* Drop our local ref as set_root should get it's own. */ + if (root != NULL) { + g_object_unref(root); + } + + return; } static void -- cgit v1.2.3