diff options
Diffstat (limited to 'libindicate/server.c')
-rw-r--r-- | libindicate/server.c | 36 |
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; } |