aboutsummaryrefslogtreecommitdiff
path: root/libindicate/server.c
diff options
context:
space:
mode:
authorRobert Carr <racarr@ender>2009-01-13 06:32:44 -0500
committerRobert Carr <racarr@ender>2009-01-13 06:32:44 -0500
commit544dec8a4c8c8689530bf5eefcc81500812ad73a (patch)
tree768b905cd41c4818f9d7965d70122d9cb42c8216 /libindicate/server.c
parent35c50459f5f93afcb6fbb3a5a6c158b7f15656eb (diff)
parentcd4f548dd5427b48706b29c17a8ea67d6360afd8 (diff)
downloadlibayatana-indicator-544dec8a4c8c8689530bf5eefcc81500812ad73a.tar.gz
libayatana-indicator-544dec8a4c8c8689530bf5eefcc81500812ad73a.tar.bz2
libayatana-indicator-544dec8a4c8c8689530bf5eefcc81500812ad73a.zip
Merge Ted's changes. I should have used bzr bind.
Diffstat (limited to 'libindicate/server.c')
-rw-r--r--libindicate/server.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/libindicate/server.c b/libindicate/server.c
index dd4513a..48f1c71 100644
--- a/libindicate/server.c
+++ b/libindicate/server.c
@@ -44,6 +44,7 @@ static gboolean show_indicator_to_user (IndicateServer * server, guint id, GErro
static void
indicate_server_class_init (IndicateServerClass * class)
{
+ g_debug("Server Class Initialized");
GObjectClass * gobj;
gobj = G_OBJECT_CLASS(class);
@@ -90,8 +91,11 @@ indicate_server_class_init (IndicateServerClass * class)
static void
indicate_server_init (IndicateServer * server)
{
+ g_debug("Server Object Initialized");
+
server->path = g_strdup("/org/freedesktop/indicate");
server->indicators = NULL;
+ server->num_hidden = 0;
return;
}
@@ -133,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;
}
@@ -145,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;
}
@@ -191,6 +230,11 @@ get_desktop (IndicateServer * server, gchar ** desktop_path, GError **error)
static gboolean
get_indicator_count (IndicateServer * server, guint * count, GError **error)
{
+ guint lstcnt = g_slist_length(server->indicators);
+
+ g_return_val_if_fail(server->num_hidden < lstcnt, TRUE);
+
+ *count = lstcnt - server->num_hidden;
return TRUE;
}