aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libindicate/indicate-interface.xml13
-rw-r--r--libindicate/server.c140
-rw-r--r--libindicate/server.h4
3 files changed, 117 insertions, 40 deletions
diff --git a/libindicate/indicate-interface.xml b/libindicate/indicate-interface.xml
index d1fed7e..f1c7c37 100644
--- a/libindicate/indicate-interface.xml
+++ b/libindicate/indicate-interface.xml
@@ -2,10 +2,11 @@
<node name="/">
<interface name="org.freedesktop.indicator">
+<!-- Properties -->
+ <property name="desktop" type="s" access="read"/>
+ <property name="type" type="s" access="read"/>
+
<!-- Functions -->
- <method name="GetDesktop">
- <arg type="s" name="desktop_file_uri" direction="out" />
- </method>
<method name="GetIndicatorCount">
<arg type="u" name="indicator_count" direction="out" />
</method>
@@ -52,6 +53,12 @@
<arg type="u" name="id" direction="out" />
<arg type="s" name="property" direction="out" />
</signal>
+ <signal name="ServerShow">
+ <arg type="s" name="type" direction="out" />
+ </signal>
+ <signal name="ServerHide">
+ <arg type="s" name="type" direction="out" />
+ </signal>
<!-- End of interesting stuff -->
diff --git a/libindicate/server.c b/libindicate/server.c
index ab64304..6139fd0 100644
--- a/libindicate/server.c
+++ b/libindicate/server.c
@@ -22,9 +22,18 @@ enum {
INDICATOR_ADDED,
INDICATOR_REMOVED,
INDICATOR_MODIFIED,
+ SERVER_SHOW,
+ SERVER_HIDE,
LAST_SIGNAL
};
+/* Properties */
+enum {
+ PROP_0,
+ PROP_DESKTOP,
+ PROP_TYPE
+};
+
static guint signals[LAST_SIGNAL] = { 0 };
/* Private area */
@@ -36,6 +45,9 @@ struct _IndicateServerPrivate
gboolean visible;
guint current_id;
+ gchar * desktop;
+ gchar * type;
+
// TODO: Should have a more robust way to track this, but this'll work for now
guint num_hidden;
};
@@ -49,7 +61,6 @@ G_DEFINE_TYPE (IndicateServer, indicate_server, G_TYPE_OBJECT);
/* Prototypes */
static void indicate_server_finalize (GObject * obj);
-static gboolean get_desktop (IndicateServer * server, gchar ** desktop_path, GError **error);
static gboolean get_indicator_count (IndicateServer * server, guint * count, GError **error);
static gboolean get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error);
static gboolean get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error);
@@ -59,6 +70,8 @@ static gboolean get_indicator_property_group (IndicateServer * server, guint id,
static gboolean get_indicator_properties (IndicateServer * server, guint id, gchar *** properties, GError **error);
static gboolean show_indicator_to_user (IndicateServer * server, guint id, GError ** error);
static guint get_next_id (IndicateServer * server);
+static void set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec);
+static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec);
/* Code */
static void
@@ -71,6 +84,8 @@ indicate_server_class_init (IndicateServerClass * class)
g_type_class_add_private (class, sizeof (IndicateServerPrivate));
gobj->finalize = indicate_server_finalize;
+ gobj->set_property = set_property;
+ gobj->get_property = get_property;
signals[INDICATOR_ADDED] = g_signal_new("indicator-added",
G_TYPE_FROM_CLASS (class),
@@ -93,11 +108,35 @@ indicate_server_class_init (IndicateServerClass * class)
NULL, NULL,
g_cclosure_marshal_VOID__UINT_POINTER,
G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING);
+ signals[SERVER_SHOW] = g_signal_new("server-show",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (IndicateServerClass, server_show),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
+ signals[SERVER_HIDE] = g_signal_new("server-hide",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (IndicateServerClass, server_hide),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
+
+ g_object_class_install_property (gobj, PROP_DESKTOP,
+ g_param_spec_string("desktop", "Desktop File",
+ "The desktop file representing this server",
+ "",
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobj, PROP_TYPE,
+ g_param_spec_string("type", "Server Type",
+ "The type of indicators that this server will provide",
+ "",
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
dbus_g_object_type_install_info(INDICATE_TYPE_SERVER,
&dbus_glib_indicate_server_object_info);
- class->get_desktop = get_desktop;
class->get_indicator_count = get_indicator_count;
class->get_indicator_count_by_type = get_indicator_count_by_type;
class->get_indicator_list = get_indicator_list;
@@ -123,6 +162,8 @@ indicate_server_init (IndicateServer * server)
priv->num_hidden = 0;
priv->visible = FALSE;
priv->current_id = 0;
+ priv->type = NULL;
+ priv->desktop = NULL;
return;
}
@@ -133,9 +174,69 @@ indicate_server_finalize (GObject * obj)
IndicateServer * server = INDICATE_SERVER(obj);
IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
+ /* TODO: This probably shouldn't be as far down as finalize, but it's fine here. */
+ g_signal_emit(server, signals[SERVER_HIDE], 0, "", TRUE);
+
if (priv->path) {
g_free(priv->path);
}
+ if (priv->desktop) {
+ g_free(priv->desktop);
+ }
+ if (priv->type) {
+ g_free(priv->type);
+ }
+
+ return;
+}
+
+static void
+set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec)
+{
+ g_return_if_fail(G_VALUE_HOLDS_STRING(value));
+ g_return_if_fail(id == PROP_DESKTOP || id == PROP_TYPE);
+
+ gchar ** outstr;
+ IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(obj);
+ switch (id) {
+ case PROP_DESKTOP:
+ outstr = &(priv->desktop);
+ break;
+ case PROP_TYPE:
+ outstr = &(priv->type);
+ break;
+ }
+
+ if (*outstr != NULL) {
+ g_free(*outstr);
+ }
+
+ *outstr = g_strdup(g_value_get_string(value));
+
+ return;
+}
+
+static void
+get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec)
+{
+ g_return_if_fail(id == PROP_DESKTOP || id == PROP_TYPE);
+
+ gchar * outstr;
+ IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(obj);
+ switch (id) {
+ case PROP_DESKTOP:
+ outstr = priv->desktop;
+ break;
+ case PROP_TYPE:
+ outstr = priv->type;
+ break;
+ }
+
+ if (outstr != NULL) {
+ g_value_set_string(value, outstr);
+ } else {
+ g_value_set_static_string(value, "");
+ }
return;
}
@@ -168,6 +269,8 @@ indicate_server_show (IndicateServer * server)
priv->path,
G_OBJECT(server));
priv->visible = TRUE;
+
+ g_signal_emit(server, signals[SERVER_SHOW], 0, "", TRUE);
return;
}
@@ -278,18 +381,6 @@ indicate_server_set_default (IndicateServer * server)
}
static gboolean
-get_desktop (IndicateServer * server, gchar ** desktop_path, GError **error)
-{
- IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
-
- if (priv->path != NULL) {
- // TODO: This might be a memory leak, check into that.
- *desktop_path = g_strdup(priv->path);
- }
- return TRUE;
-}
-
-static gboolean
get_indicator_count (IndicateServer * server, guint * count, GError **error)
{
IndicateServerPrivate * priv = INDICATE_SERVER_GET_PRIVATE(server);
@@ -505,27 +596,6 @@ show_indicator_to_user (IndicateServer * server, guint id, GError ** error)
/* Virtual Functions */
gboolean
-indicate_server_get_desktop (IndicateServer * server, gchar ** desktop_path, GError **error)
-{
- IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
-
- if (class != NULL) {
- return class->get_desktop (server, desktop_path, error);
- }
-
- if (error) {
- g_set_error(error,
- indicate_server_error_quark(),
- NO_GET_DESKTOP,
- "get_desktop function doesn't exist for this server class: %s",
- G_OBJECT_TYPE_NAME(server));
- return FALSE;
- }
-
- return TRUE;
-}
-
-gboolean
indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error)
{
IndicateServerClass * class = INDICATE_SERVER_GET_CLASS(server);
diff --git a/libindicate/server.h b/libindicate/server.h
index eccf3c6..c2b2191 100644
--- a/libindicate/server.h
+++ b/libindicate/server.h
@@ -30,9 +30,10 @@ struct _IndicateServerClass {
void (* indicator_added) (IndicateServer * server, guint id, gchar * type);
void (* indicator_removed) (IndicateServer * server, guint id, gchar * type);
void (* indicator_modified) (IndicateServer * server, guint id, gchar * property);
+ void (* server_show) (IndicateServer * server, gchar * type);
+ void (* server_hide) (IndicateServer * server, gchar * type);
/* Virtual Functions */
- gboolean (*get_desktop) (IndicateServer * server, gchar ** desktop_path, GError **error);
gboolean (*get_indicator_count) (IndicateServer * server, guint * count, GError **error);
gboolean (*get_indicator_count_by_type) (IndicateServer * server, gchar * type, guint * count, GError **error);
gboolean (*get_indicator_list) (IndicateServer * server, GArray ** indicators, GError ** error);
@@ -71,7 +72,6 @@ IndicateServer * indicate_server_ref_default (void);
void indicate_server_set_default (IndicateServer * server);
/* DBus API */
-gboolean indicate_server_get_desktop (IndicateServer * server, gchar ** desktop_path, GError **error);
gboolean indicate_server_get_indicator_count (IndicateServer * server, guint * count, GError **error);
gboolean indicate_server_get_indicator_count_by_type (IndicateServer * server, gchar * type, guint * count, GError **error);
gboolean indicate_server_get_indicator_list (IndicateServer * server, GArray ** indicators, GError ** error);