From 72ddc78d74a6022c62d1928f6777dc85b3cde28a Mon Sep 17 00:00:00 2001 From: Sebastien Bacher Date: Wed, 29 Feb 2012 19:22:36 +0100 Subject: Set "Since: 0.5" in the inline documentation for the new set_title and get_title functions --- src/app-indicator.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 6c693e8..2a49586 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -2201,6 +2201,9 @@ app_indicator_set_secondary_activate_target (AppIndicator *self, GtkWidget *menu * the title as the first part of the line for the menu items. * * Setting @title to %NULL removes the title. + * + * Since: 0.5 + * */ void app_indicator_set_title (AppIndicator *self, const gchar * title) @@ -2350,6 +2353,9 @@ app_indicator_get_attention_icon_desc (AppIndicator *self) * app_indicator_set_title() for information on the title. * * Return value: The current title. + * + * Since: 0.5 + * */ const gchar * app_indicator_get_title (AppIndicator *self) -- cgit v1.2.3 From 63331bc7d84c4d4cf11b0746293c7264b057de0d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 2 Mar 2012 15:57:24 -0600 Subject: Sets the title of the status icon to the title of the appindicator and the name to the ID --- src/app-indicator.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 6c693e8..1e24bd1 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -1510,7 +1510,8 @@ fallback (AppIndicator * self) { GtkStatusIcon * icon = gtk_status_icon_new(); - gtk_status_icon_set_title(icon, app_indicator_get_id(self)); + gtk_status_icon_set_name(icon, app_indicator_get_id(self)); + gtk_status_icon_set_title(icon, app_indicator_get_title(self)); g_signal_connect(G_OBJECT(self), APP_INDICATOR_SIGNAL_NEW_STATUS, G_CALLBACK(status_icon_status_wrapper), icon); -- cgit v1.2.3 From 002c16bd0b040dfb39468898eb904f035ea2b97c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 2 Mar 2012 16:00:36 -0600 Subject: Handle the title changing at runtime --- src/app-indicator.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 1e24bd1..92aae3b 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -897,6 +897,10 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu if (oldtitle != NULL) { g_free(oldtitle); } + + if (priv->status_icon != NULL) { + gtk_status_icon_set_title(priv->status_icon, priv->title); + } break; } case PROP_LABEL_GUIDE: { -- cgit v1.2.3 From fafea8adaeafdfb79e5a5df29433a9af0b199adc Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 2 Mar 2012 16:03:37 -0600 Subject: Protecting from NULL titles, which apparently status_icon can't take :-/ --- src/app-indicator.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 92aae3b..f3d0b65 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -899,7 +899,7 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu } if (priv->status_icon != NULL) { - gtk_status_icon_set_title(priv->status_icon, priv->title); + gtk_status_icon_set_title(priv->status_icon, priv->title ? priv->title : ""); } break; } @@ -1515,7 +1515,10 @@ fallback (AppIndicator * self) GtkStatusIcon * icon = gtk_status_icon_new(); gtk_status_icon_set_name(icon, app_indicator_get_id(self)); - gtk_status_icon_set_title(icon, app_indicator_get_title(self)); + const gchar * title = app_indicator_get_title(self); + if (title != NULL) { + gtk_status_icon_set_title(icon, title); + } g_signal_connect(G_OBJECT(self), APP_INDICATOR_SIGNAL_NEW_STATUS, G_CALLBACK(status_icon_status_wrapper), icon); -- cgit v1.2.3 From e2ec05db6ca4361bc6423c84edd9e2eab048c764 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 2 Mar 2012 16:30:53 -0600 Subject: Rework the icon setting function so that it can handle images that are file paths by checking to see if the files exist --- src/app-indicator.c | 84 ++++++++++++++++++++++++++--------------------------- 1 file changed, 42 insertions(+), 42 deletions(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index 6c693e8..c2ed7d0 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -1582,60 +1582,60 @@ 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); + } + + if (longname) { + g_free(longname); + } + } } return; -- cgit v1.2.3 From be2eef52dad67332388bb47b75b2918d58025211 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 6 Mar 2012 16:52:50 -0600 Subject: Removing unneeded NULL check --- src/app-indicator.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/app-indicator.c') diff --git a/src/app-indicator.c b/src/app-indicator.c index c2ed7d0..41f0a05 100644 --- a/src/app-indicator.c +++ b/src/app-indicator.c @@ -1632,9 +1632,7 @@ status_icon_changes (AppIndicator * self, gpointer data) gtk_status_icon_set_from_icon_name(icon, icon_name); } - if (longname) { - g_free(longname); - } + g_free(longname); } } -- cgit v1.2.3