aboutsummaryrefslogtreecommitdiff
path: root/src/indicator-sus.c
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-06-30 15:27:38 -0500
committerTed Gould <ted@canonical.com>2009-06-30 15:27:38 -0500
commita6afde93e447dc090d0ec245bedc3295441a391c (patch)
treea57b3140937d02b22d3d7e8b17be302a54ca5e5e /src/indicator-sus.c
parent23bead1b2a7c60dc8380b7cc7acf30eecf973f45 (diff)
downloadayatana-indicator-session-a6afde93e447dc090d0ec245bedc3295441a391c.tar.gz
ayatana-indicator-session-a6afde93e447dc090d0ec245bedc3295441a391c.tar.bz2
ayatana-indicator-session-a6afde93e447dc090d0ec245bedc3295441a391c.zip
Switching over the status menu too. Woot!
Diffstat (limited to 'src/indicator-sus.c')
-rw-r--r--src/indicator-sus.c51
1 files changed, 46 insertions, 5 deletions
diff --git a/src/indicator-sus.c b/src/indicator-sus.c
index 75030b3..4e7d4b2 100644
--- a/src/indicator-sus.c
+++ b/src/indicator-sus.c
@@ -59,7 +59,7 @@ menu_add (GtkContainer * source, GtkWidget * addee, GtkMenu * addto, guint posit
static void
child_added (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint position, guint (*posfunc) (void))
{
-
+ menu_add(NULL, NULL, NULL, 0);
}
@@ -72,11 +72,52 @@ child_moved (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint newpos,
/* Status Menu */
+static guint
+status_menu_pos_offset (void)
+{
+ return 0;
+}
+
+static void
+status_menu_added (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint position, gpointer user_data)
+{
+ gtk_widget_show(GTK_WIDGET(status_separator));
+ return;
+}
+
static void
-status_menu_add (GtkContainer * container, GtkWidget * widget, gpointer userdata)
+status_menu_removed (DbusmenuMenuitem * root, DbusmenuMenuitem * child, gpointer user_data)
{
- menu_add(container, widget, GTK_MENU(userdata), 0);
- gtk_widget_show(status_separator);
+ if (g_list_length(dbusmenu_menuitem_get_children(root)) == 0) {
+ gtk_widget_hide(GTK_WIDGET(status_separator));
+ }
+
+ return;
+}
+
+static void
+status_menu_root_changed(DbusmenuGtkClient * client, DbusmenuMenuitem * newroot, GtkMenu * main)
+{
+ if (newroot == NULL) {
+ gtk_widget_hide(GTK_WIDGET(status_separator));
+ return;
+ }
+
+ g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_ADDED, G_CALLBACK(child_added), status_menu_pos_offset);
+ g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_REMOVED, G_CALLBACK(status_menu_added), NULL);
+ g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_REMOVED, G_CALLBACK(status_menu_removed), NULL);
+ g_signal_connect(G_OBJECT(newroot), DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED, G_CALLBACK(child_moved), status_menu_pos_offset);
+
+ GList * child = NULL;
+ guint count = 0;
+ for (child = dbusmenu_menuitem_get_children(newroot); child != NULL; child = g_list_next(child), count++) {
+ child_added(newroot, DBUSMENU_MENUITEM(child->data), count, status_menu_pos_offset);
+ }
+
+ if (count > 0) {
+ gtk_widget_show(GTK_WIDGET(status_separator));
+ }
+
return;
}
@@ -103,7 +144,7 @@ build_status_menu (gpointer userdata)
}
status_client = dbusmenu_gtkclient_new(INDICATOR_STATUS_DBUS_NAME, INDICATOR_STATUS_DBUS_OBJECT);
- g_signal_connect(G_OBJECT(status_client), DBUSMENU_GTKCLIENT_SIGNAL_ROOT_CHANGED, G_CALLBACK(status_menu_add), main_menu);
+ g_signal_connect(G_OBJECT(status_client), DBUSMENU_GTKCLIENT_SIGNAL_ROOT_CHANGED, G_CALLBACK(status_menu_root_changed), main_menu);
status_separator = gtk_separator_menu_item_new();
gtk_menu_shell_append(GTK_MENU_SHELL(main_menu), status_separator);