aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-03-29 12:41:18 -0500
committerTed Gould <ted@gould.cx>2010-03-29 12:41:18 -0500
commit9fddbf6ce595b5c113b2e22187f5ae8eb563761a (patch)
treea0ced2fe72de47c4799eb8ddb2e2929b62628a07
parent9919c5e4bcbbcb1ea533b45e5e1aa12e03dae41a (diff)
parent1d034522d1f19b089f3d326d18551b4a978323ba (diff)
downloadlibayatana-appindicator-9fddbf6ce595b5c113b2e22187f5ae8eb563761a.tar.gz
libayatana-appindicator-9fddbf6ce595b5c113b2e22187f5ae8eb563761a.tar.bz2
libayatana-appindicator-9fddbf6ce595b5c113b2e22187f5ae8eb563761a.zip
Tracking the icon name and included the panel suffix for fallback usage.
-rw-r--r--src/indicator-application.c7
-rw-r--r--src/libappindicator/app-indicator.c34
2 files changed, 37 insertions, 4 deletions
diff --git a/src/indicator-application.c b/src/indicator-application.c
index b681a24..16c3a9f 100644
--- a/src/indicator-application.c
+++ b/src/indicator-application.c
@@ -447,7 +447,12 @@ application_added (DBusGProxy * proxy, const gchar * iconname, gint position, co
/* We make a long name using the suffix, and if that
icon is available we want to use it. Otherwise we'll
just use the name we were given. */
- gchar * longname = g_strdup_printf("%s-%s", iconname, PANEL_ICON_SUFFIX);
+ gchar * longname = NULL;
+ if (!g_str_has_suffix(iconname, PANEL_ICON_SUFFIX)) {
+ longname = g_strdup_printf("%s-%s", iconname, PANEL_ICON_SUFFIX);
+ } else {
+ longname = g_strdup(iconname);
+ }
app->entry.image = indicator_image_helper(longname);
g_free(longname);
diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c
index 6cb49b9..4076334 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.
@@ -140,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 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);
@@ -455,6 +458,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;
@@ -505,7 +509,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);
}
@@ -922,6 +927,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 gchar *
+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 */
@@ -1023,6 +1045,8 @@ 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);
@@ -1031,7 +1055,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);
}
@@ -1049,6 +1074,8 @@ 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);
@@ -1057,7 +1084,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);
}