~kvalo/indicator-application/dont-unfallback-after-timer-expired

« back to all changes in this revision

Viewing changes to src/libappindicator/app-indicator.c

Fixing icon changing with fallbacks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
144
144
static void client_menu_changed (GtkWidget *widget, GtkWidget *child, AppIndicator *indicator);
145
145
static void submenu_changed (GtkWidget *widget, GtkWidget *child, gpointer data);
146
146
 
 
147
static void theme_changed_cb (GtkIconTheme * theme, gpointer user_data);
 
148
 
147
149
/* GObject type */
148
150
G_DEFINE_TYPE (AppIndicator, app_indicator, G_TYPE_OBJECT);
149
151
 
335
337
        }
336
338
        dbus_g_connection_ref(priv->connection);
337
339
 
 
340
        g_signal_connect(G_OBJECT(gtk_icon_theme_get_default()),
 
341
                "changed", G_CALLBACK(theme_changed_cb), self);
 
342
 
338
343
        self->priv = priv;
339
344
 
340
345
        return;
812
817
        return FALSE;
813
818
}
814
819
 
 
820
/* emit a NEW_ICON signal in response for the theme change */
 
821
static void
 
822
theme_changed_cb (GtkIconTheme * theme, gpointer user_data)
 
823
{
 
824
        g_signal_emit (user_data, signals[NEW_ICON], 0, TRUE);
 
825
}
 
826
 
815
827
/* Creates a StatusIcon that can be used when the application
816
828
   indicator area isn't available. */
817
829
static GtkStatusIcon *
849
861
status_icon_changes (AppIndicator * self, gpointer data)
850
862
{
851
863
        GtkStatusIcon * icon = GTK_STATUS_ICON(data);
 
864
        GIcon *themed_icon = NULL;
852
865
 
853
866
        switch (app_indicator_get_status(self)) {
854
867
        case APP_INDICATOR_STATUS_PASSIVE:
 
868
                themed_icon =
 
869
                    g_themed_icon_new_with_default_fallbacks (app_indicator_get_icon (self));
855
870
                gtk_status_icon_set_visible(icon, FALSE);
856
 
                gtk_status_icon_set_from_icon_name(icon, app_indicator_get_icon(self));
 
871
                gtk_status_icon_set_from_gicon(icon, themed_icon);
857
872
                break;
858
873
        case APP_INDICATOR_STATUS_ACTIVE:
859
 
                gtk_status_icon_set_from_icon_name(icon, app_indicator_get_icon(self));
 
874
                themed_icon =
 
875
                    g_themed_icon_new_with_default_fallbacks (app_indicator_get_icon (self));
 
876
                gtk_status_icon_set_from_gicon(icon, themed_icon);
860
877
                gtk_status_icon_set_visible(icon, TRUE);
861
878
                break;
862
879
        case APP_INDICATOR_STATUS_ATTENTION:
863
 
                gtk_status_icon_set_from_icon_name(icon, app_indicator_get_attention_icon(self));
 
880
                themed_icon =
 
881
                    g_themed_icon_new_with_default_fallbacks (app_indicator_get_attention_icon (self));
 
882
                gtk_status_icon_set_from_gicon(icon, themed_icon);
864
883
                gtk_status_icon_set_visible(icon, TRUE);
865
884
                break;
866
885
        };
867
886
 
 
887
        if (themed_icon)
 
888
                g_object_unref (themed_icon);
 
889
 
868
890
        return;
869
891
}
870
892