diff options
author | Krzysztof Klimonda <kklimonda@laptop> | 2010-03-20 00:55:03 +0100 |
---|---|---|
committer | Krzysztof Klimonda <kklimonda@laptop> | 2010-03-20 00:55:03 +0100 |
commit | b531c560bb046c359598a07a08cfaeaa973090c2 (patch) | |
tree | 73569c47d0b989c5ad1da500e301a33bc3800aa5 /src | |
parent | 65febbd636ebe580a34a7e59b083e6210fbadee5 (diff) | |
download | libayatana-appindicator-b531c560bb046c359598a07a08cfaeaa973090c2.tar.gz libayatana-appindicator-b531c560bb046c359598a07a08cfaeaa973090c2.tar.bz2 libayatana-appindicator-b531c560bb046c359598a07a08cfaeaa973090c2.zip |
Fix the missing icon on theme change if old icon has different name
Some applications (like Transmission) use different icon name for
Notification Area to display monochrome icon. To make sure that
the icon we display exists after user changes theme use
indicator_image_helper () from libindicator to keep track of the icon.
Diffstat (limited to 'src')
-rw-r--r-- | src/libappindicator/app-indicator.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index 1dce0a0..2e6d8d1 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -35,6 +35,8 @@ License version 3 and version 2.1 along with this program. If not, see #include <libdbusmenu-glib/server.h> #include <libdbusmenu-gtk/client.h> +#include <libindicator/indicator-image-helper.h> + #include "libappindicator/app-indicator.h" #include "libappindicator/app-indicator-enum-types.h" @@ -812,6 +814,13 @@ fallback_timer_expire (gpointer data) return FALSE; } +/* emit a NEW_ICON signal in response for the theme change */ +static void +theme_changed_cb (GtkIconTheme * theme, gpointer user_data) +{ + g_signal_emit (user_data, signals[NEW_ICON], 0, TRUE); +} + /* Creates a StatusIcon that can be used when the application indicator area isn't available. */ static GtkStatusIcon * @@ -827,6 +836,8 @@ fallback (AppIndicator * self) G_CALLBACK(status_icon_changes), icon); g_signal_connect(G_OBJECT(self), APP_INDICATOR_SIGNAL_NEW_ATTENTION_ICON, G_CALLBACK(status_icon_changes), icon); + g_signal_connect(G_OBJECT(gtk_icon_theme_get_default()), + "changed", G_CALLBACK(theme_changed_cb), self); status_icon_changes(self, icon); @@ -849,22 +860,26 @@ static void status_icon_changes (AppIndicator * self, gpointer data) { GtkStatusIcon * icon = GTK_STATUS_ICON(data); + GtkImage *image = indicator_image_helper (self->priv->icon_name); switch (app_indicator_get_status(self)) { case APP_INDICATOR_STATUS_PASSIVE: gtk_status_icon_set_visible(icon, FALSE); - gtk_status_icon_set_from_icon_name(icon, app_indicator_get_icon(self)); + gtk_status_icon_set_from_pixbuf(icon, gtk_image_get_pixbuf (image)); break; case APP_INDICATOR_STATUS_ACTIVE: - gtk_status_icon_set_from_icon_name(icon, app_indicator_get_icon(self)); + gtk_status_icon_set_from_pixbuf(icon, gtk_image_get_pixbuf (image)); gtk_status_icon_set_visible(icon, TRUE); break; case APP_INDICATOR_STATUS_ATTENTION: - gtk_status_icon_set_from_icon_name(icon, app_indicator_get_attention_icon(self)); + gtk_status_icon_set_from_pixbuf(icon, gtk_image_get_pixbuf (image)); gtk_status_icon_set_visible(icon, TRUE); break; }; + g_object_ref_sink (image); + g_object_unref (image); + return; } |