aboutsummaryrefslogtreecommitdiff
path: root/libindicate/server.c
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-01-12 17:15:43 -0600
committerTed Gould <ted@canonical.com>2009-01-12 17:15:43 -0600
commit514837a37737b049827008f7685de9d49c4034ba (patch)
treeeb759002aa8dd891a2846c22c600ee1dd4461571 /libindicate/server.c
parent2dc2f266359d30841fa2970dba0265cb22556b89 (diff)
downloadlibayatana-indicator-514837a37737b049827008f7685de9d49c4034ba.tar.gz
libayatana-indicator-514837a37737b049827008f7685de9d49c4034ba.tar.bz2
libayatana-indicator-514837a37737b049827008f7685de9d49c4034ba.zip
Fleshing out the whole show and hide thing. We should also be signalling when indicators are added or removed from the server.
Diffstat (limited to 'libindicate/server.c')
-rw-r--r--libindicate/server.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/libindicate/server.c b/libindicate/server.c
index 95c0a2c..17db3dc 100644
--- a/libindicate/server.c
+++ b/libindicate/server.c
@@ -95,6 +95,7 @@ indicate_server_init (IndicateServer * server)
server->path = g_strdup("/org/freedesktop/indicate");
server->indicators = NULL;
+ server->num_hidden = 0;
return;
}
@@ -136,11 +137,37 @@ indicate_server_show (IndicateServer * server)
return;
}
+static void
+indicator_show_cb (IndicateIndicator * indicator, IndicateServer * server)
+{
+ server->num_hidden--;
+ g_signal_emit(server, signals[INDICATOR_ADDED], 0, indicate_indicator_get_id(indicator), indicate_indicator_get_indicator_type(indicator), TRUE);
+ return;
+}
+
+static void
+indicator_hide_cb (IndicateIndicator * indicator, IndicateServer * server)
+{
+ server->num_hidden++;
+ g_signal_emit(server, signals[INDICATOR_REMOVED], 0, indicate_indicator_get_id(indicator), indicate_indicator_get_indicator_type(indicator), TRUE);
+ return;
+}
+
void
indicate_server_add_indicator (IndicateServer * server, IndicateIndicator * indicator)
{
g_object_ref(indicator);
server->indicators = g_slist_prepend(server->indicators, indicator);
+
+ if (!indicate_indicator_is_visible(indicator)) {
+ server->num_hidden++;
+ } else {
+ g_signal_emit(server, signals[INDICATOR_ADDED], 0, indicate_indicator_get_id(indicator), indicate_indicator_get_indicator_type(indicator), TRUE);
+ }
+
+ g_signal_connect(indicator, INDICATE_INDICATOR_SIGNAL_SHOW, indicator_show_cb, server);
+ g_signal_connect(indicator, INDICATE_INDICATOR_SIGNAL_HIDE, indicator_hide_cb, server);
+
return;
}
@@ -148,6 +175,15 @@ void
indicate_server_remove_indicator (IndicateServer * server, IndicateIndicator * indicator)
{
server->indicators = g_slist_remove(server->indicators, indicator);
+ if (indicate_indicator_is_visible(indicator)) {
+ g_signal_emit(server, signals[INDICATOR_REMOVED], 0, indicate_indicator_get_id(indicator), indicate_indicator_get_indicator_type(indicator), TRUE);
+ } else {
+ server->num_hidden--;
+ }
+
+ g_signal_handlers_disconnect_by_func(indicator, indicator_show_cb, server);
+ g_signal_handlers_disconnect_by_func(indicator, indicator_hide_cb, server);
+
g_object_unref(indicator);
return;
}