aboutsummaryrefslogtreecommitdiff
path: root/src/libappindicator
diff options
context:
space:
mode:
Diffstat (limited to 'src/libappindicator')
-rw-r--r--src/libappindicator/app-indicator.c41
-rw-r--r--src/libappindicator/app-indicator.h13
2 files changed, 47 insertions, 7 deletions
diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c
index 84d9ebd..e3de406 100644
--- a/src/libappindicator/app-indicator.c
+++ b/src/libappindicator/app-indicator.c
@@ -64,8 +64,9 @@ struct _AppIndicatorPrivate {
gchar *icon_name;
gchar *attention_icon_name;
gchar * icon_path;
- DbusmenuServer *menuservice;
- GtkWidget *menu;
+ DbusmenuServer *menuservice;
+ GtkWidget *menu;
+ GtkStatusIcon * status_icon;
/* Fun stuff */
DBusGProxy *watcher_proxy;
@@ -126,6 +127,8 @@ static void app_indicator_get_property (GObject * object, guint prop_id, GValue
/* Other stuff */
static void check_connect (AppIndicator * self);
static void register_service_cb (DBusGProxy * proxy, GError * error, gpointer data);
+static GtkStatusIcon * fallback (AppIndicator * self);
+static void unfallback (AppIndicator * self, GtkStatusIcon * status_icon);
/* GObject type */
G_DEFINE_TYPE (AppIndicator, app_indicator, G_TYPE_OBJECT);
@@ -145,6 +148,10 @@ app_indicator_class_init (AppIndicatorClass *klass)
object_class->set_property = app_indicator_set_property;
object_class->get_property = app_indicator_get_property;
+ /* Our own funcs */
+ klass->fallback = fallback;
+ klass->unfallback = unfallback;
+
/* Properties */
g_object_class_install_property (object_class,
PROP_ID,
@@ -299,6 +306,8 @@ app_indicator_init (AppIndicator *self)
priv->watcher_proxy = NULL;
priv->connection = NULL;
+ priv->status_icon = NULL;
+
/* Put the object on DBus */
GError * error = NULL;
priv->connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
@@ -322,13 +331,21 @@ app_indicator_init (AppIndicator *self)
static void
app_indicator_dispose (GObject *object)
{
- AppIndicator *self = APP_INDICATOR (object);
+ AppIndicator *self = APP_INDICATOR (object);
AppIndicatorPrivate *priv = self->priv;
if (priv->status != APP_INDICATOR_STATUS_PASSIVE) {
app_indicator_set_status(self, APP_INDICATOR_STATUS_PASSIVE);
}
+ if (priv->status_icon != NULL) {
+ AppIndicatorClass * class = APP_INDICATOR_CLASS(object);
+ if (class->unfallback != NULL) {
+ class->unfallback(self, priv->status_icon);
+ }
+ priv->status_icon = NULL;
+ }
+
if (priv->menu != NULL) {
g_object_unref(G_OBJECT(priv->menu));
priv->menu = NULL;
@@ -572,6 +589,24 @@ category_from_enum (AppIndicatorCategory category)
return value->value_nick;
}
+/* Creates a StatusIcon that can be used when the application
+ indicator area isn't available. */
+static GtkStatusIcon *
+fallback (AppIndicator * self)
+{
+
+ return NULL;
+}
+
+/* Removes the status icon as the application indicator area
+ is now up and running again. */
+static void
+unfallback (AppIndicator * self, GtkStatusIcon * status_icon)
+{
+
+ return;
+}
+
/* ************************* */
/* Public Functions */
diff --git a/src/libappindicator/app-indicator.h b/src/libappindicator/app-indicator.h
index a680c33..a8d82ab 100644
--- a/src/libappindicator/app-indicator.h
+++ b/src/libappindicator/app-indicator.h
@@ -148,10 +148,12 @@ typedef struct _AppIndicatorPrivate AppIndicatorPrivate;
@new_attention_icon: Slot for #AppIndicator::new-attention-icon.
@new_status: Slot for #AppIndicator::new-status.
@connection_changed: Slot for #AppIndicator::connection-changed.
+ @fallback: Function that gets called to make a #GtkStatusIcon when
+ there is no Application Indicator area available.
+ @unfallback: The function that gets called if an Application
+ Indicator area appears after the fallback has been created.
@app_indicator_reserved_1: Reserved for future use.
@app_indicator_reserved_2: Reserved for future use.
- @app_indicator_reserved_3: Reserved for future use.
- @app_indicator_reserved_4: Reserved for future use.
The signals and external functions that make up the #AppIndicator
class object.
@@ -174,11 +176,14 @@ struct _AppIndicatorClass {
gboolean connected,
gpointer user_data);
+ /* Overridable Functions */
+ GtkStatusIcon * (*fallback) (AppIndicator * indicator);
+ void (*unfallback) (AppIndicator * indicator,
+ GtkStatusIcon * status_icon);
+
/* Reserved */
void (*app_indicator_reserved_1)(void);
void (*app_indicator_reserved_2)(void);
- void (*app_indicator_reserved_3)(void);
- void (*app_indicator_reserved_4)(void);
};
/**