aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Arne Petersen <jpetersen@openismus.com>2010-02-22 14:47:03 -0600
committerTed Gould <ted@gould.cx>2010-02-22 14:47:03 -0600
commit75ccac53fc05f24633c76ac5d956b91a9a6640fb (patch)
treeb27c26d1ef0db316166eb7ee201057f88b8b64f5 /src
parent225f2911ff99822cdb77c4e74f75c0e21f63b943 (diff)
downloadlibayatana-appindicator-75ccac53fc05f24633c76ac5d956b91a9a6640fb.tar.gz
libayatana-appindicator-75ccac53fc05f24633c76ac5d956b91a9a6640fb.tar.bz2
libayatana-appindicator-75ccac53fc05f24633c76ac5d956b91a9a6640fb.zip
Creates and event handler for the add and remove signals to recreate the menu
Diffstat (limited to 'src')
-rw-r--r--src/libappindicator/app-indicator.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c
index 62e8905..361875d 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);
@@ -1242,6 +1243,16 @@ container_iterate (GtkWidget *widget,
gtk_container_forall (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);
}
}
@@ -1259,6 +1270,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_forall (GTK_CONTAINER (widget),
+ container_iterate,
+ root);
+}
+
+static void
setup_dbusmenu (AppIndicator *self)
{
AppIndicatorPrivate *priv;