aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2012-03-06 16:54:21 -0600
committerTed Gould <ted@gould.cx>2012-03-06 16:54:21 -0600
commit865583222d8d7394c1a0597f0dd6b47e20896894 (patch)
treee90c6d4d58a5ac1a6af82d2734043114f2bd871f
parentbd4dbb3c1b266daf27511e62397abd4fa6256e85 (diff)
parentbe2eef52dad67332388bb47b75b2918d58025211 (diff)
downloadlibayatana-appindicator-865583222d8d7394c1a0597f0dd6b47e20896894.tar.gz
libayatana-appindicator-865583222d8d7394c1a0597f0dd6b47e20896894.tar.bz2
libayatana-appindicator-865583222d8d7394c1a0597f0dd6b47e20896894.zip
Look for files and don't use those as icon names in the fallback
-rw-r--r--src/app-indicator.c82
1 files changed, 40 insertions, 42 deletions
diff --git a/src/app-indicator.c b/src/app-indicator.c
index 2a49586..8c78529 100644
--- a/src/app-indicator.c
+++ b/src/app-indicator.c
@@ -1582,60 +1582,58 @@ static void
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);
- }
+ /* 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);
+ }
+
+ const gchar * icon_name = NULL;
switch (app_indicator_get_status(self)) {
case APP_INDICATOR_STATUS_PASSIVE:
- /* 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));
+ /* hide first to avoid that the change is visible to the user */
+ gtk_status_icon_set_visible(icon, FALSE);
+ icon_name = app_indicator_get_icon(self);
break;
case APP_INDICATOR_STATUS_ACTIVE:
- 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));
+ icon_name = app_indicator_get_icon(self);
gtk_status_icon_set_visible(icon, TRUE);
break;
case APP_INDICATOR_STATUS_ATTENTION:
- /* 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));
+ /* get the _attention_ icon here */
+ icon_name = app_indicator_get_attention_icon(self);
gtk_status_icon_set_visible(icon, TRUE);
break;
};
- if (longname) {
- g_free(longname);
+ if (icon_name != NULL) {
+ if (g_file_test(icon_name, G_FILE_TEST_EXISTS)) {
+ gtk_status_icon_set_from_file(icon, icon_name);
+ } else {
+ gchar *longname = append_panel_icon_suffix(icon_name);
+
+ if (longname != NULL && 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, icon_name);
+ }
+
+ g_free(longname);
+ }
}
return;