diff options
author | Ted Gould <ted@gould.cx> | 2010-02-23 09:43:58 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-02-23 09:43:58 -0600 |
commit | 2fdd555db8dc1844860cec3d414e6e7f38dbde94 (patch) | |
tree | e5cf1248e6da4d3e50f9efd9ff9cfa45c21f52ed /src | |
parent | 225f2911ff99822cdb77c4e74f75c0e21f63b943 (diff) | |
parent | 100dd0956b005f39c897010c48e87d40a167ed03 (diff) | |
download | libayatana-appindicator-2fdd555db8dc1844860cec3d414e6e7f38dbde94.tar.gz libayatana-appindicator-2fdd555db8dc1844860cec3d414e6e7f38dbde94.tar.bz2 libayatana-appindicator-2fdd555db8dc1844860cec3d414e6e7f38dbde94.zip |
Fixes to get the menus updated and visibility all handled nicely.
Diffstat (limited to 'src')
-rw-r--r-- | src/libappindicator/app-indicator.c | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index 62e8905..7c1ac82 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -142,6 +142,7 @@ static void status_icon_activate (GtkStatusIcon * icon, gpointer data); static void unfallback (AppIndicator * self, GtkStatusIcon * status_icon); static void watcher_proxy_destroyed (GObject * object, gpointer data); static void client_menu_changed (GtkWidget *widget, GtkWidget *child, AppIndicator *indicator); +static void submenu_changed (GtkWidget *widget, GtkWidget *child, gpointer data); /* GObject type */ G_DEFINE_TYPE (AppIndicator, app_indicator, G_TYPE_OBJECT); @@ -1157,6 +1158,10 @@ container_iterate (GtkWidget *widget, const gchar *label = NULL; gboolean label_set = FALSE; + if (GTK_IS_TEAROFF_MENU_ITEM(widget)) { + return; + } + child = dbusmenu_menuitem_new (); if (GTK_IS_SEPARATOR_MENU_ITEM (widget)) @@ -1239,15 +1244,28 @@ container_iterate (GtkWidget *widget, submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (widget)); if (submenu != NULL) { - gtk_container_forall (GTK_CONTAINER (submenu), + gtk_container_foreach (GTK_CONTAINER (submenu), container_iterate, child); + g_signal_connect_object (submenu, + "add", + G_CALLBACK (submenu_changed), + child, + 0); + g_signal_connect_object (submenu, + "remove", + G_CALLBACK (submenu_changed), + child, + 0); } } dbusmenu_menuitem_property_set_bool (child, DBUSMENU_MENUITEM_PROP_ENABLED, GTK_WIDGET_IS_SENSITIVE (widget)); + dbusmenu_menuitem_property_set_bool (child, + DBUSMENU_MENUITEM_PROP_VISIBLE, + gtk_widget_get_visible (widget)); g_signal_connect (widget, "notify", G_CALLBACK (widget_notify_cb), child); @@ -1259,6 +1277,27 @@ container_iterate (GtkWidget *widget, } static void +submenu_changed (GtkWidget *widget, + GtkWidget *child, + gpointer data) +{ + DbusmenuMenuitem *root = (DbusmenuMenuitem *)data; + GList *children, *l; + children = dbusmenu_menuitem_get_children (root); + + for (l = children; l;) + { + DbusmenuMenuitem *c = (DbusmenuMenuitem *)l->data; + l = l->next; + dbusmenu_menuitem_child_delete (root, c); + } + + gtk_container_foreach (GTK_CONTAINER (widget), + container_iterate, + root); +} + +static void setup_dbusmenu (AppIndicator *self) { AppIndicatorPrivate *priv; @@ -1269,7 +1308,7 @@ setup_dbusmenu (AppIndicator *self) if (priv->menu) { - gtk_container_forall (GTK_CONTAINER (priv->menu), + gtk_container_foreach (GTK_CONTAINER (priv->menu), container_iterate, root); } |