From 64c02739926fa0559c0ad528ab8f41cd2f2522a4 Mon Sep 17 00:00:00 2001 From: Krzysztof Klimonda Date: Thu, 25 Mar 2010 19:23:57 +0100 Subject: Make GtkStatusIcon use icons with the panel suffix if available. Rhythmbox uses two icons: rhythmbox-notplaying for the not playing state and the rhythmbox for playing. The rhythmbox-notplaying has a monochromatic icon but the rhythmbox not - instead a rhythmbox-panel is used. This patch makes AppIndicator prefer an icon with panel suffix just as the indicator-application does. --- src/libappindicator/app-indicator.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index 32fb2ff..84c39b3 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -43,6 +43,8 @@ License version 3 and version 2.1 along with this program. If not, see #include "dbus-shared.h" +#define PANEL_ICON_SUFFIX "panel" + /** AppIndicatorPrivate: @id: The ID of the indicator. Maps to AppIndicator::id. @@ -900,6 +902,23 @@ unfallback (AppIndicator * self, GtkStatusIcon * status_icon) return; } +/* A helper function that appends PANEL_ICON_SUFFIX to the given icon name + if it's missing. */ +static char * +append_panel_icon_suffix (const gchar *icon_name) +{ + gchar * long_name = NULL; + + if (!g_str_has_suffix (icon_name, PANEL_ICON_SUFFIX)) { + long_name = + g_strdup_printf("%s-%s", icon_name, PANEL_ICON_SUFFIX); + } else { + long_name = g_strdup (icon_name); + } + + return long_name; +} + /* ************************* */ /* Public Functions */ @@ -1001,6 +1020,8 @@ app_indicator_set_status (AppIndicator *self, AppIndicatorStatus status) void app_indicator_set_attention_icon (AppIndicator *self, const gchar *icon_name) { + char *long_name; + g_return_if_fail (IS_APP_INDICATOR (self)); g_return_if_fail (icon_name != NULL); @@ -1009,7 +1030,8 @@ app_indicator_set_attention_icon (AppIndicator *self, const gchar *icon_name) if (self->priv->attention_icon_name) g_free (self->priv->attention_icon_name); - self->priv->attention_icon_name = g_strdup (icon_name); + long_name = append_panel_icon_suffix (icon_name); + self->priv->attention_icon_name = long_name; g_signal_emit (self, signals[NEW_ATTENTION_ICON], 0, TRUE); } @@ -1027,6 +1049,8 @@ app_indicator_set_attention_icon (AppIndicator *self, const gchar *icon_name) void app_indicator_set_icon (AppIndicator *self, const gchar *icon_name) { + char *long_name; + g_return_if_fail (IS_APP_INDICATOR (self)); g_return_if_fail (icon_name != NULL); @@ -1035,7 +1059,8 @@ app_indicator_set_icon (AppIndicator *self, const gchar *icon_name) if (self->priv->icon_name) g_free (self->priv->icon_name); - self->priv->icon_name = g_strdup (icon_name); + long_name = append_panel_icon_suffix (icon_name); + self->priv->icon_name = long_name; g_signal_emit (self, signals[NEW_ICON], 0, TRUE); } -- cgit v1.2.3 From 5bf0d10c5c87aca4ea853ef11eab7ed4ca206830 Mon Sep 17 00:00:00 2001 From: Krzysztof Klimonda Date: Thu, 25 Mar 2010 19:43:52 +0100 Subject: Make app_indicator_set_property also set the suffixed icon_name. --- src/libappindicator/app-indicator.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index 84c39b3..3a4522e 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -142,6 +142,7 @@ static void status_icon_status_wrapper (AppIndicator * self, const gchar * statu static void status_icon_changes (AppIndicator * self, gpointer data); static void status_icon_activate (GtkStatusIcon * icon, gpointer data); static void unfallback (AppIndicator * self, GtkStatusIcon * status_icon); +static char * append_panel_icon_suffix (const char * icon_name); static void watcher_proxy_destroyed (GObject * object, gpointer data); static void client_menu_changed (GtkWidget *widget, GtkWidget *child, AppIndicator *indicator); static void submenu_changed (GtkWidget *widget, GtkWidget *child, gpointer data); @@ -452,6 +453,7 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu { AppIndicator *self = APP_INDICATOR (object); AppIndicatorPrivate *priv = self->priv; + gchar *long_name; const gchar *instr; GEnumValue *enum_val; @@ -502,7 +504,8 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu if (priv->icon_name) g_free (priv->icon_name); - priv->icon_name = g_strdup (instr); + long_name = append_panel_icon_suffix (instr); + priv->icon_name = long_name; g_signal_emit (self, signals[NEW_ICON], 0, TRUE); } -- cgit v1.2.3 From 1d034522d1f19b089f3d326d18551b4a978323ba Mon Sep 17 00:00:00 2001 From: Krzysztof Klimonda Date: Thu, 25 Mar 2010 19:45:11 +0100 Subject: use gchar instead of for the clarity --- src/libappindicator/app-indicator.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index 3a4522e..c3a2d7f 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -142,7 +142,7 @@ static void status_icon_status_wrapper (AppIndicator * self, const gchar * statu static void status_icon_changes (AppIndicator * self, gpointer data); static void status_icon_activate (GtkStatusIcon * icon, gpointer data); static void unfallback (AppIndicator * self, GtkStatusIcon * status_icon); -static char * append_panel_icon_suffix (const char * icon_name); +static gchar * append_panel_icon_suffix (const gchar * icon_name); static void watcher_proxy_destroyed (GObject * object, gpointer data); static void client_menu_changed (GtkWidget *widget, GtkWidget *child, AppIndicator *indicator); static void submenu_changed (GtkWidget *widget, GtkWidget *child, gpointer data); @@ -907,7 +907,7 @@ unfallback (AppIndicator * self, GtkStatusIcon * status_icon) /* A helper function that appends PANEL_ICON_SUFFIX to the given icon name if it's missing. */ -static char * +static gchar * append_panel_icon_suffix (const gchar *icon_name) { gchar * long_name = NULL; @@ -1023,7 +1023,7 @@ app_indicator_set_status (AppIndicator *self, AppIndicatorStatus status) void app_indicator_set_attention_icon (AppIndicator *self, const gchar *icon_name) { - char *long_name; + gchar *long_name; g_return_if_fail (IS_APP_INDICATOR (self)); g_return_if_fail (icon_name != NULL); @@ -1052,7 +1052,7 @@ app_indicator_set_attention_icon (AppIndicator *self, const gchar *icon_name) void app_indicator_set_icon (AppIndicator *self, const gchar *icon_name) { - char *long_name; + gchar *long_name; g_return_if_fail (IS_APP_INDICATOR (self)); g_return_if_fail (icon_name != NULL); -- cgit v1.2.3 From 4bbf4c09be5cae94cab39b0cd3518671d9b7435a Mon Sep 17 00:00:00 2001 From: C10uD Date: Tue, 30 Mar 2010 14:09:04 -0500 Subject: Patch 001 from bug 527061 --- bindings/python/appindicator.defs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bindings/python/appindicator.defs b/bindings/python/appindicator.defs index 4498465..98abe4c 100644 --- a/bindings/python/appindicator.defs +++ b/bindings/python/appindicator.defs @@ -41,14 +41,15 @@ (return-type "GType") ) -(define-function app_indicator_new - (c-name "app_indicator_new") +(define-function app_indicator_new_with_path + (c-name "app_indicator_new_with_path") (is-constructor-of "AppIndicator") (return-type "AppIndicator*") (parameters '("const-gchar*" "id") '("const-gchar*" "icon_name") '("AppIndicatorCategory" "category") + '("const-gchar*" "icon_path" (null-ok) (default "NULL")) ) ) -- cgit v1.2.3 From d6bb68c1ba7e9c0d3cfe1f7f4aeeacd01f3af55b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 1 Apr 2010 11:26:22 -0500 Subject: No timer if we're already in fallback. --- src/libappindicator/app-indicator.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index 4076334..d7c8a8d 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -781,6 +781,11 @@ start_fallback_timer (AppIndicator * self, gboolean disable_timeout) return; } + if (priv->status_icon != NULL) { + /* We're already fallen back. Let's not do it again. */ + return; + } + if (priv->dbus_proxy == NULL) { /* NOTE: Read the comment on setup_name_owner_proxy */ g_idle_add(setup_name_owner_proxy, self); -- cgit v1.2.3 From 5aa064c48d946062b84ea4fe70572cee087766ec Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 1 Apr 2010 13:26:53 -0500 Subject: Make it so that we don't store the panel-suffix icons but we do use them with the status icon. --- src/libappindicator/app-indicator.c | 53 +++++++++++++++---------------------- 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index 4076334..11a9b1c 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -458,8 +458,6 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu { AppIndicator *self = APP_INDICATOR (object); AppIndicatorPrivate *priv = self->priv; - gchar *long_name; - const gchar *instr; GEnumValue *enum_val; switch (prop_id) { @@ -502,26 +500,15 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu break; case PROP_ICON_NAME: - instr = g_value_get_string (value); - - if (g_strcmp0 (priv->icon_name, instr) != 0) - { - if (priv->icon_name) - g_free (priv->icon_name); - - long_name = append_panel_icon_suffix (instr); - priv->icon_name = long_name; - - g_signal_emit (self, signals[NEW_ICON], 0, TRUE); - } - + app_indicator_set_icon (APP_INDICATOR (object), + g_value_get_string (value)); check_connect (self); break; case PROP_ATTENTION_ICON_NAME: app_indicator_set_attention_icon (APP_INDICATOR (object), g_value_get_string (value)); - break; + break; case PROP_ICON_THEME_PATH: if (priv->icon_path != NULL) { @@ -867,30 +854,36 @@ status_icon_changes (AppIndicator * self, gpointer data) { GtkStatusIcon * icon = GTK_STATUS_ICON(data); GIcon *themed_icon = NULL; + gchar *longname = NULL; switch (app_indicator_get_status(self)) { case APP_INDICATOR_STATUS_PASSIVE: - themed_icon = - g_themed_icon_new_with_default_fallbacks (app_indicator_get_icon (self)); + longname = append_panel_icon_suffix(app_indicator_get_icon(self)); + themed_icon = g_themed_icon_new_with_default_fallbacks (longname); gtk_status_icon_set_visible(icon, FALSE); gtk_status_icon_set_from_gicon(icon, themed_icon); break; case APP_INDICATOR_STATUS_ACTIVE: - themed_icon = - g_themed_icon_new_with_default_fallbacks (app_indicator_get_icon (self)); + longname = append_panel_icon_suffix(app_indicator_get_icon(self)); + themed_icon = g_themed_icon_new_with_default_fallbacks (longname); gtk_status_icon_set_from_gicon(icon, themed_icon); gtk_status_icon_set_visible(icon, TRUE); break; case APP_INDICATOR_STATUS_ATTENTION: - themed_icon = - g_themed_icon_new_with_default_fallbacks (app_indicator_get_attention_icon (self)); + longname = append_panel_icon_suffix(app_indicator_get_attention_icon(self)); + themed_icon = g_themed_icon_new_with_default_fallbacks (longname); gtk_status_icon_set_from_gicon(icon, themed_icon); gtk_status_icon_set_visible(icon, TRUE); break; }; - if (themed_icon) + if (themed_icon) { g_object_unref (themed_icon); + } + + if (longname) { + g_free(longname); + } return; } @@ -1045,8 +1038,6 @@ app_indicator_set_status (AppIndicator *self, AppIndicatorStatus status) void app_indicator_set_attention_icon (AppIndicator *self, const gchar *icon_name) { - gchar *long_name; - g_return_if_fail (IS_APP_INDICATOR (self)); g_return_if_fail (icon_name != NULL); @@ -1055,11 +1046,12 @@ app_indicator_set_attention_icon (AppIndicator *self, const gchar *icon_name) if (self->priv->attention_icon_name) g_free (self->priv->attention_icon_name); - long_name = append_panel_icon_suffix (icon_name); - self->priv->attention_icon_name = long_name; + self->priv->attention_icon_name = g_strdup(icon_name); g_signal_emit (self, signals[NEW_ATTENTION_ICON], 0, TRUE); } + + return; } /** @@ -1074,8 +1066,6 @@ app_indicator_set_attention_icon (AppIndicator *self, const gchar *icon_name) void app_indicator_set_icon (AppIndicator *self, const gchar *icon_name) { - gchar *long_name; - g_return_if_fail (IS_APP_INDICATOR (self)); g_return_if_fail (icon_name != NULL); @@ -1084,11 +1074,12 @@ app_indicator_set_icon (AppIndicator *self, const gchar *icon_name) if (self->priv->icon_name) g_free (self->priv->icon_name); - long_name = append_panel_icon_suffix (icon_name); - self->priv->icon_name = long_name; + self->priv->icon_name = g_strdup(icon_name); g_signal_emit (self, signals[NEW_ICON], 0, TRUE); } + + return; } static void -- cgit v1.2.3 From 14aebe465a014d42381f73b8dea3386357d14098 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 1 Apr 2010 13:32:42 -0500 Subject: Adding in documentation for the private structure. --- src/libappindicator/app-indicator.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libappindicator/app-indicator.h b/src/libappindicator/app-indicator.h index 03656ce..d490c8c 100644 --- a/src/libappindicator/app-indicator.h +++ b/src/libappindicator/app-indicator.h @@ -189,6 +189,7 @@ struct _AppIndicatorClass { /** AppIndicator: @parent: Parent object. + @priv: Internal data. A application indicator represents the values that are needed to show a unique status in the panel for an application. In general, applications @@ -198,7 +199,7 @@ struct _AppIndicatorClass { struct _AppIndicator { GObject parent; - AppIndicatorPrivate *priv; + AppIndicatorPrivate *priv; }; /* GObject Stuff */ -- cgit v1.2.3 From ba28468540c9e9b45d66ad0fbba59c5e86ce2fd5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 1 Apr 2010 15:23:36 -0500 Subject: Moving field documentation into a different comment block so that they're private --- src/libappindicator/app-indicator.c | 9 ++++++--- src/libappindicator/app-indicator.h | 8 ++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index f82587e..132e279 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -47,6 +47,11 @@ License version 3 and version 2.1 along with this program. If not, see /** AppIndicatorPrivate: + + All of the private data in an instance of a + application indicator. +*/ +/* Private Fields @id: The ID of the indicator. Maps to AppIndicator::id. @category: Which category the indicator is. Maps to AppIndicator::category. @status: The status of the indicator. Maps to AppIndicator::status. @@ -54,11 +59,9 @@ License version 3 and version 2.1 along with this program. If not, see @attention_icon_name: The name of the attention icon to use. Maps to AppIndicator::attention-icon-name. @menu: The menu for this indicator. Maps to AppIndicator::menu @watcher_proxy: The proxy connection to the watcher we're connected to. If we're not connected to one this will be #NULL. - - All of the private data in an instance of a - application indicator. */ struct _AppIndicatorPrivate { + /*< Private >*/ /* Properties */ gchar *id; gchar *clean_id; diff --git a/src/libappindicator/app-indicator.h b/src/libappindicator/app-indicator.h index d490c8c..549ab35 100644 --- a/src/libappindicator/app-indicator.h +++ b/src/libappindicator/app-indicator.h @@ -188,17 +188,21 @@ struct _AppIndicatorClass { /** AppIndicator: - @parent: Parent object. - @priv: Internal data. A application indicator represents the values that are needed to show a unique status in the panel for an application. In general, applications should try to fit in the other indicators that are available on the panel before using this. But, sometimes it is necissary. */ +/* Private fields + @parent: Parent object. + @priv: Internal data. +*/ struct _AppIndicator { + /*< Private >*/ GObject parent; + /*< Private >*/ AppIndicatorPrivate *priv; }; -- cgit v1.2.3 From 1fbc5af0037617432ad4cb1e6a668b91ec1105e4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 1 Apr 2010 15:46:22 -0500 Subject: 0.0.19 --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index dc1b787..c34bed2 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(indicator-application, 0.0.18, ted@canonical.com) +AC_INIT(indicator-application, 0.0.19, ted@canonical.com) AC_COPYRIGHT([Copyright 2009, 2010 Canonical]) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-application, 0.0.18) +AM_INIT_AUTOMAKE(indicator-application, 0.0.19) AM_MAINTAINER_MODE -- cgit v1.2.3