aboutsummaryrefslogtreecommitdiff
path: root/libindicate/server.c
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/server.c
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/server.c')
-rw-r--r--libindicate/server.c36
1 files changed, 35 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 */