diff options
Diffstat (limited to 'libempathy-gtk')
-rw-r--r-- | libempathy-gtk/empathy-presence-chooser.c | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/libempathy-gtk/empathy-presence-chooser.c b/libempathy-gtk/empathy-presence-chooser.c index f8c4212dd..7c4aae9ba 100644 --- a/libempathy-gtk/empathy-presence-chooser.c +++ b/libempathy-gtk/empathy-presence-chooser.c @@ -111,6 +111,7 @@ typedef struct { PresenceChooserEntryType previous_type; TpAccountManager *account_manager; + GdkPixbuf *not_favorite_pixbuf; } EmpathyPresenceChooserPriv; /* States to be listed in the menu. @@ -327,6 +328,7 @@ presence_chooser_is_preset (EmpathyPresenceChooser *self) static void presence_chooser_set_favorite_icon (EmpathyPresenceChooser *self) { + EmpathyPresenceChooserPriv *priv = GET_PRIV (self); GtkWidget *entry; PresenceChooserEntryType type; @@ -338,16 +340,16 @@ presence_chooser_set_favorite_icon (EmpathyPresenceChooser *self) /* saved entries can be removed from the list */ gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY, - "empathy-starred"); + "emblem-favorite"); gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY, _("Click to remove this status as a favorite")); } else { /* custom entries can be favorited */ - gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry), + gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY, - "empathy-unstarred"); + priv->not_favorite_pixbuf); gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY, _("Click to make this status a favorite")); @@ -807,6 +809,36 @@ presence_chooser_connectivity_state_change (EmpathyConnectivity *connectivity, presence_chooser_update_sensitivity (chooser); } +/* Create a greyed version of the 'favorite' icon */ +static GdkPixbuf * +create_not_favorite_pixbuf (void) +{ + GdkPixbuf *favorite, *result; + + favorite = empathy_pixbuf_from_icon_name ("emblem-favorite", + GTK_ICON_SIZE_MENU); + + result = gdk_pixbuf_copy (favorite); + gdk_pixbuf_saturate_and_pixelate (favorite, result, 1.0, TRUE); + + g_object_unref (favorite); + return result; +} + +static void +icon_theme_changed_cb (GtkIconTheme *icon_theme, + EmpathyPresenceChooser *self) +{ + EmpathyPresenceChooserPriv *priv = GET_PRIV (self); + + /* Theme has changed, recreate the not-favorite icon */ + g_object_unref (priv->not_favorite_pixbuf); + priv->not_favorite_pixbuf = create_not_favorite_pixbuf (); + + /* Update the icon */ + presence_chooser_set_favorite_icon (self); +} + static void empathy_presence_chooser_init (EmpathyPresenceChooser *chooser) { @@ -817,6 +849,14 @@ empathy_presence_chooser_init (EmpathyPresenceChooser *chooser) chooser->priv = priv; + /* Create the not-favorite icon */ + priv->not_favorite_pixbuf = create_not_favorite_pixbuf (); + g_assert (priv->not_favorite_pixbuf != NULL); + + empathy_signal_connect_weak (gtk_icon_theme_get_default (), "changed", + G_CALLBACK (icon_theme_changed_cb), + G_OBJECT (chooser)); + presence_chooser_create_model (chooser); gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (chooser), @@ -924,6 +964,7 @@ presence_chooser_finalize (GObject *object) g_object_unref (priv->idle); g_object_unref (priv->connectivity); + g_object_unref (priv->not_favorite_pixbuf); G_OBJECT_CLASS (empathy_presence_chooser_parent_class)->finalize (object); } |