From c7398986a6a83033bcb2f90ab37fb30622160d6c Mon Sep 17 00:00:00 2001 From: Xiao-Long Chen Date: Thu, 13 Sep 2012 09:27:06 +0200 Subject: Add fallback to "system-shutdown" icon Thanks Xiao-Long! --- src/indicator-session.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src') diff --git a/src/indicator-session.c b/src/indicator-session.c index aa328dd..de58a20 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -64,6 +64,7 @@ struct _IndicatorSession GDBusProxy * service_proxy; GSettings * settings; DbusmenuClient * menu_client; + GtkIconTheme * icon_theme; }; static gboolean greeter_mode; @@ -84,6 +85,7 @@ static gboolean build_restart_item (DbusmenuMenuitem * newitem, DbusmenuClient * client, gpointer user_data); static void on_menu_layout_updated (DbusmenuClient * client, IndicatorSession * session); +static void indicator_session_update_icon_callback (GtkWidget * widget, gpointer callback_data); static void indicator_session_update_icon_and_a11y (IndicatorSession * self); static void indicator_session_update_users_label (IndicatorSession* self, const gchar* name); @@ -135,6 +137,13 @@ indicator_session_init (IndicatorSession *self) self->entry.image = GTK_IMAGE (gtk_image_new()); self->entry.menu = GTK_MENU (dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT)); + /* We need to check if the current icon theme has the hard coded icons. + * If not, we'll fall back to a standard icon */ + self->icon_theme = gtk_icon_theme_get_default(); + g_signal_connect(G_OBJECT(self->icon_theme), + "changed", + G_CALLBACK(indicator_session_update_icon_callback), self); + indicator_session_update_icon_and_a11y (self); g_settings_bind (self->settings, "show-real-name-on-panel", self->entry.label, "visible", @@ -478,6 +487,9 @@ indicator_session_update_icon_from_disposition (IndicatorSession * indicator, icon = ICON_ALERT; } + if (gtk_icon_theme_has_icon (indicator->icon_theme, icon) == FALSE) + icon = "system-shutdown"; // or some other fallback icon + g_debug (G_STRLOC" setting icon to \"%s\"", icon); gtk_image_set_from_icon_name (GTK_IMAGE(indicator->entry.image), icon, @@ -514,6 +526,12 @@ calculate_disposition (IndicatorSession * indicator) return ret; } +static void +indicator_session_update_icon_callback (GtkWidget * widget, gpointer callback_data) +{ + indicator_session_update_icon_and_a11y ((IndicatorSession *)callback_data); +} + static void indicator_session_update_icon_and_a11y (IndicatorSession * indicator) { -- cgit v1.2.3 From c6d485032398a1d29889d996ef793f0aeca5d3c3 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Thu, 13 Sep 2012 15:27:35 +0200 Subject: Change fallback icon to "gtk-missing-image" --- src/indicator-session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/indicator-session.c b/src/indicator-session.c index de58a20..71b05a3 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -488,7 +488,7 @@ indicator_session_update_icon_from_disposition (IndicatorSession * indicator, } if (gtk_icon_theme_has_icon (indicator->icon_theme, icon) == FALSE) - icon = "system-shutdown"; // or some other fallback icon + icon = "gtk-missing-image"; g_debug (G_STRLOC" setting icon to \"%s\"", icon); gtk_image_set_from_icon_name (GTK_IMAGE(indicator->entry.image), -- cgit v1.2.3