aboutsummaryrefslogtreecommitdiff
path: root/libindicate
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-01-09 16:24:57 -0600
committerTed Gould <ted@canonical.com>2009-01-09 16:24:57 -0600
commit57b3f5814a7059fb382b377610b58703af6359b0 (patch)
tree9688d5592bb15bd57702dc04aae6b2d68edb17c3 /libindicate
parentf8ca55562f8b06ac5358cc54ffd1b272db7110de (diff)
downloadlibayatana-indicator-57b3f5814a7059fb382b377610b58703af6359b0.tar.gz
libayatana-indicator-57b3f5814a7059fb382b377610b58703af6359b0.tar.bz2
libayatana-indicator-57b3f5814a7059fb382b377610b58703af6359b0.zip
Setting up the singleton nature of the server, and allow setting it.
Diffstat (limited to 'libindicate')
-rw-r--r--libindicate/server.c36
-rw-r--r--libindicate/server.h3
2 files changed, 38 insertions, 1 deletions
diff --git a/libindicate/server.c b/libindicate/server.c
index d166bb0..b6edcbf 100644
--- a/libindicate/server.c
+++ b/libindicate/server.c
@@ -105,15 +105,49 @@ indicate_server_show (IndicateServer * server)
void
indicator_server_add_indicator (IndicateServer * server, IndicateIndicator * indicator)
{
+ g_object_ref(indicator);
+ server->indicators = g_slist_prepend(server->indicators, indicator);
+ return;
+}
+
+void
+indicator_server_remove_indicator (IndicateServer * server, IndicateIndicator * indicator)
+{
+ server->indicators = g_slist_remove(server->indicators, indicator);
+ g_object_unref(indicator);
+ return;
+}
+static IndicateServer * default_indicate_server = NULL;
+IndicateServer *
+indicate_server_ref_default (void)
+{
+ if (default_indicate_server != NULL) {
+ g_object_ref(default_indicate_server);
+ } else {
+ default_indicate_server = g_object_new(INDICATE_TYPE_SERVER, NULL);
+ g_object_add_weak_pointer(G_OBJECT(default_indicate_server),
+ (gpointer *)&default_indicate_server);
+ }
+
+ return default_indicate_server;
}
void
-indicator_server_remove_indicator (IndicateServer * server, IndicateIndicator * indicator)
+indicate_server_set_default (IndicateServer * server)
{
+ if (default_indicate_server != NULL) {
+ g_warning("Setting a default Indicator Server when one has already been created. I'm not going to destroy that one, but let it live. This may create some odd results if you don't know what you're doing.");
+ }
+ if (server != NULL) {
+ default_indicate_server = server;
+ g_object_add_weak_pointer(G_OBJECT(default_indicate_server),
+ (gpointer *)&default_indicate_server);
+ }
+ return;
}
/* Virtual Functions */
diff --git a/libindicate/server.h b/libindicate/server.h
index 19a92a4..159bcd7 100644
--- a/libindicate/server.h
+++ b/libindicate/server.h
@@ -58,6 +58,9 @@ void indicate_server_hide (IndicateServer * server);
void indicator_server_add_indicator (IndicateServer * server, IndicateIndicator * indicator);
void indicator_server_remove_indicator (IndicateServer * server, IndicateIndicator * indicator);
+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);