From 6ecd10fbb57cea400d59ad68da1d0fc602264c4e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 30 Sep 2011 11:26:17 +0200 Subject: src/app-indicator.c: when using the fallback icon, first check if there is a "-panel" version of the icon available and if not fallback to the indicator one --- src/app-indicator.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/app-indicator.c b/src/app-indicator.c index c2f0f69..c9e7ab9 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -1523,20 +1523,21 @@ status_icon_changes (AppIndicator * self, gpointer data) GtkStatusIcon * icon = GTK_STATUS_ICON(data); gchar *longname = NULL; + /* set longname only if its actually in the icon theme */ + longname = append_panel_icon_suffix(app_indicator_get_icon(self)); + if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default(), longname)) + gtk_status_icon_set_from_icon_name(icon, longname); + else + gtk_status_icon_set_from_icon_name(icon, app_indicator_get_icon(self)); + 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); 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); 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); gtk_status_icon_set_visible(icon, TRUE); break; }; -- cgit v1.2.3 From f476076f2bc74a408f135895c9a6d7f96329bac0 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 30 Sep 2011 16:38:11 +0200 Subject: unbreak attention_icon --- src/app-indicator.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/app-indicator.c b/src/app-indicator.c index c9e7ab9..21276c6 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -1523,21 +1523,30 @@ status_icon_changes (AppIndicator * self, gpointer data) GtkStatusIcon * icon = GTK_STATUS_ICON(data); gchar *longname = NULL; - /* set longname only if its actually in the icon theme */ - longname = append_panel_icon_suffix(app_indicator_get_icon(self)); - if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default(), longname)) - gtk_status_icon_set_from_icon_name(icon, longname); - else - gtk_status_icon_set_from_icon_name(icon, app_indicator_get_icon(self)); - switch (app_indicator_get_status(self)) { case APP_INDICATOR_STATUS_PASSIVE: + longname = append_panel_icon_suffix(app_indicator_get_icon(self)); + if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default(), 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, FALSE); break; case APP_INDICATOR_STATUS_ACTIVE: + longname = append_panel_icon_suffix(app_indicator_get_icon(self)); + if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default(), 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: + /* get the _attention_ icon here */ + longname = append_panel_icon_suffix(app_indicator_get_attention_icon(self)); + if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default(), 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; }; -- cgit v1.2.3 From 4aca6f60949a7c707f33fa6f39257613b7d6d5d5 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 30 Sep 2011 16:44:39 +0200 Subject: src/app-indicator.c: honor icon_theme_path in the fallback --- src/app-indicator.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/app-indicator.c b/src/app-indicator.c index 21276c6..7b5e0f2 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -1523,10 +1523,19 @@ status_icon_changes (AppIndicator * self, gpointer data) GtkStatusIcon * icon = GTK_STATUS_ICON(data); gchar *longname = NULL; + GtkIconTheme *icon_theme; + if (self->priv->icon_theme_path != NULL) + { + icon_theme = gtk_icon_theme_new(); + gtk_icon_theme_prepend_search_path(icon_theme, self->priv->icon_theme_path); + } else { + icon_theme = gtk_icon_theme_get_default(); + } + switch (app_indicator_get_status(self)) { case APP_INDICATOR_STATUS_PASSIVE: longname = append_panel_icon_suffix(app_indicator_get_icon(self)); - if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default(), longname)) + 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)); @@ -1534,7 +1543,7 @@ status_icon_changes (AppIndicator * self, gpointer data) break; case APP_INDICATOR_STATUS_ACTIVE: longname = append_panel_icon_suffix(app_indicator_get_icon(self)); - if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default(), longname)) + 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)); @@ -1543,7 +1552,7 @@ status_icon_changes (AppIndicator * self, gpointer data) 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 (gtk_icon_theme_get_default(), longname)) + 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)); @@ -1554,6 +1563,9 @@ status_icon_changes (AppIndicator * self, gpointer data) if (longname) { g_free(longname); } + if (icon_theme != gtk_icon_theme_get_default()) { + g_object_unref(icon_theme); + } return; } -- cgit v1.2.3 From 5819385d28106fd7f511fc4e8eb4960b46a5fc37 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 30 Sep 2011 17:54:29 +0200 Subject: simplify --- src/app-indicator.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/app-indicator.c b/src/app-indicator.c index 7b5e0f2..13c7ce4 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -1523,13 +1523,10 @@ status_icon_changes (AppIndicator * self, gpointer data) GtkStatusIcon * icon = GTK_STATUS_ICON(data); gchar *longname = NULL; - GtkIconTheme *icon_theme; + GtkIconTheme *icon_theme = gtk_icon_theme_get_default(); if (self->priv->icon_theme_path != NULL) { - icon_theme = gtk_icon_theme_new(); - gtk_icon_theme_prepend_search_path(icon_theme, self->priv->icon_theme_path); - } else { - icon_theme = gtk_icon_theme_get_default(); + gtk_icon_theme_append_search_path(icon_theme, self->priv->icon_theme_path); } switch (app_indicator_get_status(self)) { @@ -1563,9 +1560,6 @@ status_icon_changes (AppIndicator * self, gpointer data) if (longname) { g_free(longname); } - if (icon_theme != gtk_icon_theme_get_default()) { - g_object_unref(icon_theme); - } return; } -- cgit v1.2.3 From ff65f9f759bad5b929e1057a3ca482ef0107649c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 30 Sep 2011 18:04:27 +0200 Subject: src/app-indicator.c: do not add the same icon_theme_path again, gtk3 apparently does not check this --- src/app-indicator.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/app-indicator.c b/src/app-indicator.c index 13c7ce4..285abd6 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -1523,10 +1523,25 @@ 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) { - gtk_icon_theme_append_search_path(icon_theme, self->priv->icon_theme_path); + 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)) { -- cgit v1.2.3 From d1788f9e65073e31af39d638d72fcd2e0854ecf7 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 30 Sep 2011 18:14:52 +0200 Subject: src/app-indicator.c: hide first in passive mode and add comment about it --- src/app-indicator.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app-indicator.c b/src/app-indicator.c index 285abd6..f885cc7 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -1546,12 +1546,13 @@ status_icon_changes (AppIndicator * self, gpointer data) 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)); - gtk_status_icon_set_visible(icon, FALSE); break; case APP_INDICATOR_STATUS_ACTIVE: longname = append_panel_icon_suffix(app_indicator_get_icon(self)); -- cgit v1.2.3