diff options
author | Xiao-Long Chen <chillermillerlong@hotmail.com> | 2012-09-13 09:27:06 +0200 |
---|---|---|
committer | Lars Uebernickel <lars.uebernickel@canonical.com> | 2012-09-13 09:27:06 +0200 |
commit | c7398986a6a83033bcb2f90ab37fb30622160d6c (patch) | |
tree | f308a29cebc22444d4f9fa8871d8ba6e473851bf | |
parent | d4df19f0bd39e00aea689aa093f1028a3619e707 (diff) | |
download | ayatana-indicator-session-c7398986a6a83033bcb2f90ab37fb30622160d6c.tar.gz ayatana-indicator-session-c7398986a6a83033bcb2f90ab37fb30622160d6c.tar.bz2 ayatana-indicator-session-c7398986a6a83033bcb2f90ab37fb30622160d6c.zip |
Add fallback to "system-shutdown" icon
Thanks Xiao-Long!
-rw-r--r-- | src/indicator-session.c | 18 |
1 files changed, 18 insertions, 0 deletions
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, @@ -515,6 +527,12 @@ calculate_disposition (IndicatorSession * indicator) } 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) { const int disposition = calculate_disposition (indicator); |