aboutsummaryrefslogtreecommitdiff
path: root/src/libappindicator
diff options
context:
space:
mode:
authorSebastien Bacher <seb128@ubuntu.com>2010-04-01 23:41:58 +0200
committerSebastien Bacher <seb128@ubuntu.com>2010-04-01 23:41:58 +0200
commit40b74a14850bacbef753ed1e697de51f68a7ee62 (patch)
tree0bd17cc965406feb51b5f463a351526408cc9950 /src/libappindicator
parentfd1ec3c4cf17a488d072c63660bc818562cd9448 (diff)
parent734b874a2c463115e69d40fa48db8ebbc5996289 (diff)
downloadlibayatana-appindicator-40b74a14850bacbef753ed1e697de51f68a7ee62.tar.gz
libayatana-appindicator-40b74a14850bacbef753ed1e697de51f68a7ee62.tar.bz2
libayatana-appindicator-40b74a14850bacbef753ed1e697de51f68a7ee62.zip
releasing version 0.0.19-0ubuntu10.0.19-0ubuntu1
Diffstat (limited to 'src/libappindicator')
-rw-r--r--src/libappindicator/app-indicator-enum-types.c75
-rw-r--r--src/libappindicator/app-indicator-enum-types.h66
-rw-r--r--src/libappindicator/app-indicator.c79
-rw-r--r--src/libappindicator/app-indicator.h9
4 files changed, 201 insertions, 28 deletions
diff --git a/src/libappindicator/app-indicator-enum-types.c b/src/libappindicator/app-indicator-enum-types.c
new file mode 100644
index 0000000..e53575c
--- /dev/null
+++ b/src/libappindicator/app-indicator-enum-types.c
@@ -0,0 +1,75 @@
+
+/* Generated data (by glib-mkenums) */
+
+/*
+An object to represent the application as an application indicator
+in the system panel.
+
+Copyright 2009 Canonical Ltd.
+
+Authors:
+ Ted Gould <ted@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of either or both of the following licenses:
+
+1) the GNU Lesser General Public License version 3, as published by the
+ Free Software Foundation; and/or
+2) the GNU Lesser General Public License version 2.1, as published by
+ the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
+PURPOSE. See the applicable version of the GNU Lesser General Public
+License for more details.
+
+You should have received a copy of both the GNU Lesser General Public
+License version 3 and version 2.1 along with this program. If not, see
+<http://www.gnu.org/licenses/>
+*/
+
+#include "libappindicator/app-indicator-enum-types.h"
+
+#include "./libappindicator/app-indicator.h"
+GType
+app_indicator_category_get_type (void)
+{
+ static GType etype = 0;
+ if (G_UNLIKELY(etype == 0)) {
+ static const GEnumValue values[] = {
+ { APP_INDICATOR_CATEGORY_APPLICATION_STATUS, "APP_INDICATOR_CATEGORY_APPLICATION_STATUS", "ApplicationStatus" },
+ { APP_INDICATOR_CATEGORY_COMMUNICATIONS, "APP_INDICATOR_CATEGORY_COMMUNICATIONS", "Communications" },
+ { APP_INDICATOR_CATEGORY_SYSTEM_SERVICES, "APP_INDICATOR_CATEGORY_SYSTEM_SERVICES", "SystemServices" },
+ { APP_INDICATOR_CATEGORY_HARDWARE, "APP_INDICATOR_CATEGORY_HARDWARE", "Hardware" },
+ { APP_INDICATOR_CATEGORY_OTHER, "APP_INDICATOR_CATEGORY_OTHER", "Other" },
+ { 0, NULL, NULL}
+ };
+
+ etype = g_enum_register_static (g_intern_static_string("AppIndicatorCategory"), values);
+ }
+
+ return etype;
+}
+
+GType
+app_indicator_status_get_type (void)
+{
+ static GType etype = 0;
+ if (G_UNLIKELY(etype == 0)) {
+ static const GEnumValue values[] = {
+ { APP_INDICATOR_STATUS_PASSIVE, "APP_INDICATOR_STATUS_PASSIVE", "Passive" },
+ { APP_INDICATOR_STATUS_ACTIVE, "APP_INDICATOR_STATUS_ACTIVE", "Active" },
+ { APP_INDICATOR_STATUS_ATTENTION, "APP_INDICATOR_STATUS_ATTENTION", "NeedsAttention" },
+ { 0, NULL, NULL}
+ };
+
+ etype = g_enum_register_static (g_intern_static_string("AppIndicatorStatus"), values);
+ }
+
+ return etype;
+}
+
+
+/* Generated data ends here */
+
diff --git a/src/libappindicator/app-indicator-enum-types.h b/src/libappindicator/app-indicator-enum-types.h
new file mode 100644
index 0000000..515a7f6
--- /dev/null
+++ b/src/libappindicator/app-indicator-enum-types.h
@@ -0,0 +1,66 @@
+
+/* Generated data (by glib-mkenums) */
+
+/*
+An object to represent the application as an application indicator
+in the system panel.
+
+Copyright 2009 Canonical Ltd.
+
+Authors:
+ Ted Gould <ted@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of either or both of the following licenses:
+
+1) the GNU Lesser General Public License version 3, as published by the
+ Free Software Foundation; and/or
+2) the GNU Lesser General Public License version 2.1, as published by
+ the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
+PURPOSE. See the applicable version of the GNU Lesser General Public
+License for more details.
+
+You should have received a copy of both the GNU Lesser General Public
+License version 3 and version 2.1 along with this program. If not, see
+<http://www.gnu.org/licenses/>
+*/
+
+#ifndef __APP_INDICATOR_ENUM_TYPES_H__
+#define __APP_INDICATOR_ENUM_TYPES_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/* Enumerations from file: "./libappindicator/app-indicator.h" */
+/**
+ app_indicator_category_get_type:
+
+ Builds a glib type for the AppIndicatorCategory enumeration.
+
+ Return value: A registered type for the enum
+*/
+GType app_indicator_category_get_type (void) G_GNUC_CONST;
+#define APP_INDICATOR_TYPE_INDICATOR_CATEGORY (app_indicator_category_get_type())
+
+/**
+ app_indicator_status_get_type:
+
+ Builds a glib type for the AppIndicatorStatus enumeration.
+
+ Return value: A registered type for the enum
+*/
+GType app_indicator_status_get_type (void) G_GNUC_CONST;
+#define APP_INDICATOR_TYPE_INDICATOR_STATUS (app_indicator_status_get_type())
+
+
+G_END_DECLS
+
+#endif /* __APP_INDICATOR_ENUM_TYPES_H__ */
+
+/* Generated data ends here */
+
diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c
index 6cb49b9..132e279 100644
--- a/src/libappindicator/app-indicator.c
+++ b/src/libappindicator/app-indicator.c
@@ -43,8 +43,15 @@ License version 3 and version 2.1 along with this program. If not, see
#include "dbus-shared.h"
+#define PANEL_ICON_SUFFIX "panel"
+
/**
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.
@@ -52,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;
@@ -140,6 +145,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,7 +461,6 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu
{
AppIndicator *self = APP_INDICATOR (object);
AppIndicatorPrivate *priv = self->priv;
- const gchar *instr;
GEnumValue *enum_val;
switch (prop_id) {
@@ -498,25 +503,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);
-
- priv->icon_name = g_strdup (instr);
-
- 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) {
@@ -776,6 +771,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);
@@ -862,30 +862,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;
}
@@ -922,6 +928,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 */
@@ -1031,10 +1054,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);
- self->priv->attention_icon_name = g_strdup (icon_name);
+ self->priv->attention_icon_name = g_strdup(icon_name);
g_signal_emit (self, signals[NEW_ATTENTION_ICON], 0, TRUE);
}
+
+ return;
}
/**
@@ -1057,10 +1082,12 @@ 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);
+ self->priv->icon_name = g_strdup(icon_name);
g_signal_emit (self, signals[NEW_ICON], 0, TRUE);
}
+
+ return;
}
static void
diff --git a/src/libappindicator/app-indicator.h b/src/libappindicator/app-indicator.h
index 03656ce..549ab35 100644
--- a/src/libappindicator/app-indicator.h
+++ b/src/libappindicator/app-indicator.h
@@ -188,17 +188,22 @@ struct _AppIndicatorClass {
/**
AppIndicator:
- @parent: Parent object.
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;
- AppIndicatorPrivate *priv;
+ /*< Private >*/
+ AppIndicatorPrivate *priv;
};
/* GObject Stuff */