From c26cab9055e9d909babb509e606b35ec47574c78 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 13 Jan 2010 19:52:02 -0600 Subject: Making it so that the icon will update in the fallback case with changes to the properties of the AppIndicator. --- src/libappindicator/app-indicator.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'src/libappindicator/app-indicator.c') diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index f330870..f66888f 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -136,6 +136,7 @@ static void register_service_cb (DBusGProxy * proxy, GError * error, gpointer da static void start_fallback_timer (AppIndicator * self, gboolean do_it_now); static gboolean fallback_timer_expire (gpointer data); static GtkStatusIcon * fallback (AppIndicator * self); +static void status_icon_changes (GObject * icon, GParamSpec * pspec, gpointer data); 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); @@ -751,6 +752,28 @@ fallback (AppIndicator * self) gtk_status_icon_set_title(icon, app_indicator_get_id(self)); + g_signal_connect(G_OBJECT(self), "notify::" PROP_STATUS_S, + G_CALLBACK(status_icon_changes), icon); + g_signal_connect(G_OBJECT(self), "notify::" PROP_ICON_NAME_S, + G_CALLBACK(status_icon_changes), icon); + g_signal_connect(G_OBJECT(self), "notify::" PROP_ATTENTION_ICON_NAME_S, + G_CALLBACK(status_icon_changes), icon); + + status_icon_changes(G_OBJECT(icon), NULL, self); + + g_signal_connect(G_OBJECT(icon), "activate", G_CALLBACK(status_icon_activate), self); + + return NULL; +} + +/* This tracks changes to either the status or the icons + that are associated with the app indicator */ +static void +status_icon_changes (GObject * oicon, GParamSpec * pspec, gpointer data) +{ + AppIndicator * self = APP_INDICATOR(data); + GtkStatusIcon * icon = GTK_STATUS_ICON(oicon); + switch (app_indicator_get_status(self)) { case APP_INDICATOR_STATUS_PASSIVE: gtk_status_icon_set_visible(icon, FALSE); @@ -766,9 +789,7 @@ fallback (AppIndicator * self) break; }; - g_signal_connect(G_OBJECT(icon), "activate", G_CALLBACK(status_icon_activate), self); - - return NULL; + return; } /* Handles the activate action by the status icon by showing @@ -796,6 +817,7 @@ status_icon_activate (GtkStatusIcon * icon, gpointer data) static void unfallback (AppIndicator * self, GtkStatusIcon * status_icon) { + g_signal_handlers_disconnect_by_func(G_OBJECT(self), status_icon_changes, status_icon); g_object_unref(G_OBJECT(status_icon)); return; } -- cgit v1.2.3