diff options
author | Ted Gould <ted@gould.cx> | 2011-09-30 11:26:38 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2011-09-30 11:26:38 -0500 |
commit | bc49dd8e9acfd1069e99999fd573609a404de869 (patch) | |
tree | 19a58d4ea5e6af9485ca330d15b1b8e4a911276c | |
parent | a0119770c6e87433e7b43ec78fe1b17aaf315d71 (diff) | |
parent | d1788f9e65073e31af39d638d72fcd2e0854ecf7 (diff) | |
download | libayatana-appindicator-bc49dd8e9acfd1069e99999fd573609a404de869.tar.gz libayatana-appindicator-bc49dd8e9acfd1069e99999fd573609a404de869.tar.bz2 libayatana-appindicator-bc49dd8e9acfd1069e99999fd573609a404de869.zip |
Work with fallbacks and theme paths
-rw-r--r-- | src/app-indicator.c | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/src/app-indicator.c b/src/app-indicator.c index c2f0f69..f885cc7 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -1523,20 +1523,52 @@ status_icon_changes (AppIndicator * self, gpointer data) GtkStatusIcon * icon = GTK_STATUS_ICON(data); gchar *longname = NULL; + /* add the icon_theme_path once if needed */ + GtkIconTheme *icon_theme = gtk_icon_theme_get_default(); + if (self->priv->icon_theme_path != NULL) + { + gchar **path; + gint n_elements, i; + gboolean found=FALSE; + gtk_icon_theme_get_search_path(icon_theme, &path, &n_elements); + for (i=0; i< n_elements || path[i] == NULL; i++) + { + if(g_strcmp0(path[i], self->priv->icon_theme_path) == 0) + { + found=TRUE; + break; + } + } + if(!found) + gtk_icon_theme_append_search_path(icon_theme, self->priv->icon_theme_path); + g_strfreev (path); + } + switch (app_indicator_get_status(self)) { case APP_INDICATOR_STATUS_PASSIVE: - longname = append_panel_icon_suffix(app_indicator_get_icon(self)); - gtk_status_icon_set_visible(icon, FALSE); - gtk_status_icon_set_from_icon_name(icon, longname); + /* hide first to avoid that the change is visible to the user */ + gtk_status_icon_set_visible(icon, FALSE); + longname = append_panel_icon_suffix(app_indicator_get_icon(self)); + if (gtk_icon_theme_has_icon (icon_theme, longname)) + gtk_status_icon_set_from_icon_name(icon, longname); + else + gtk_status_icon_set_from_icon_name(icon, app_indicator_get_icon(self)); break; case APP_INDICATOR_STATUS_ACTIVE: - longname = append_panel_icon_suffix(app_indicator_get_icon(self)); - gtk_status_icon_set_from_icon_name(icon, longname); + longname = append_panel_icon_suffix(app_indicator_get_icon(self)); + if (gtk_icon_theme_has_icon (icon_theme, longname)) + gtk_status_icon_set_from_icon_name(icon, longname); + else + gtk_status_icon_set_from_icon_name(icon, app_indicator_get_icon(self)); gtk_status_icon_set_visible(icon, TRUE); break; case APP_INDICATOR_STATUS_ATTENTION: - longname = append_panel_icon_suffix(app_indicator_get_attention_icon(self)); - gtk_status_icon_set_from_icon_name(icon, longname); + /* get the _attention_ icon here */ + longname = append_panel_icon_suffix(app_indicator_get_attention_icon(self)); + if (gtk_icon_theme_has_icon (icon_theme, longname)) + gtk_status_icon_set_from_icon_name(icon, longname); + else + gtk_status_icon_set_from_icon_name(icon, app_indicator_get_icon(self)); gtk_status_icon_set_visible(icon, TRUE); break; }; |