aboutsummaryrefslogtreecommitdiff
path: root/src/app-indicator.c
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-01-25 09:35:55 -0600
committerTed Gould <ted@gould.cx>2011-01-25 09:35:55 -0600
commit331794c5e1cfc98fa522535bad47a7f77c02a073 (patch)
tree4bc5d704aa6dc9a38b1ed04c350e311ebf63eb05 /src/app-indicator.c
parent8cf0c2e5d59a905f6137a00610b298615b871573 (diff)
downloadlibayatana-appindicator-331794c5e1cfc98fa522535bad47a7f77c02a073.tar.gz
libayatana-appindicator-331794c5e1cfc98fa522535bad47a7f77c02a073.tar.bz2
libayatana-appindicator-331794c5e1cfc98fa522535bad47a7f77c02a073.zip
Rework the setup_dbusmenu function to use the dbusmenu parser.
Diffstat (limited to 'src/app-indicator.c')
-rw-r--r--src/app-indicator.c40
1 files changed, 22 insertions, 18 deletions
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 <libdbusmenu-glib/menuitem.h>
#include <libdbusmenu-glib/server.h>
#include <libdbusmenu-gtk/client.h>
+#include <libdbusmenu-gtk/parser.h>
#include <libindicator/indicator-desktop-shortcuts.h>
@@ -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