aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-gtk/menu.c
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-06-25 16:20:53 -0500
committerTed Gould <ted@canonical.com>2009-06-25 16:20:53 -0500
commita901ed8e2d0f3dd55fb8628766cc1a8194d5b468 (patch)
treec97130fd9a031b398c9c7c1a8b6349590fbfa0ea /libdbusmenu-gtk/menu.c
parent7fde2d3d2d3b1437eea4695d5164d92b0d845b5c (diff)
downloadlibdbusmenu-a901ed8e2d0f3dd55fb8628766cc1a8194d5b468.tar.gz
libdbusmenu-a901ed8e2d0f3dd55fb8628766cc1a8194d5b468.tar.bz2
libdbusmenu-a901ed8e2d0f3dd55fb8628766cc1a8194d5b468.zip
Fleshing out the root changed function, but that's led to another couple that need to get figured out as well.
Diffstat (limited to 'libdbusmenu-gtk/menu.c')
-rw-r--r--libdbusmenu-gtk/menu.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c
index 4b88f67..28a446b 100644
--- a/libdbusmenu-gtk/menu.c
+++ b/libdbusmenu-gtk/menu.c
@@ -185,8 +185,43 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec)
/* Internal Functions */
static void
-root_changed (void) {
- /* stub */
+root_child_added (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint position, DbusmenuGtkMenu * menu)
+{
+
+ return;
+}
+
+static void
+root_child_moved (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint newposition, guint oldposition, DbusmenuGtkMenu * menu)
+{
+
+ return;
+}
+
+static void
+root_changed (DbusmenuGtkClient * client, DbusmenuMenuitem * newroot, DbusmenuGtkMenu * menu) {
+ if (newroot == NULL) {
+ gtk_widget_hide(GTK_WIDGET(menu));
+ return;
+ }
+
+ g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_ADDED, G_CALLBACK(root_child_added), menu);
+ g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED, G_CALLBACK(root_child_moved), menu);
+
+ GList * child = NULL;
+ guint count = 0;
+ for (child = dbusmenu_menuitem_get_children(newroot); child != NULL; child = g_list_next(child)) {
+ gtk_menu_append(menu, GTK_WIDGET(dbusmenu_gtkclient_menuitem_get(client, child->data)));
+ count++;
+ }
+
+ if (count > 0) {
+ gtk_widget_show(GTK_WIDGET(menu));
+ } else {
+ gtk_widget_hide(GTK_WIDGET(menu));
+ }
+
+ return;
}
/* Builds the client and connects all of the signals