diff options
author | Ted Gould <ted@canonical.com> | 2009-04-03 10:22:20 -0500 |
---|---|---|
committer | Ted Gould <ted@canonical.com> | 2009-04-03 10:22:20 -0500 |
commit | 96c188390cec3abfbaf078cd4bf69f18e8c2bc27 (patch) | |
tree | 363ece1275e6a11aaba54ce10cee2037f3c82d9a /libindicate | |
parent | 68fb067b6dc1a2153205ec8b210813a610d66d24 (diff) | |
download | libayatana-indicator-96c188390cec3abfbaf078cd4bf69f18e8c2bc27.tar.gz libayatana-indicator-96c188390cec3abfbaf078cd4bf69f18e8c2bc27.tar.bz2 libayatana-indicator-96c188390cec3abfbaf078cd4bf69f18e8c2bc27.zip |
Fleshing out the functions in the listener to set interests.
Diffstat (limited to 'libindicate')
-rw-r--r-- | libindicate/listener.c | 58 | ||||
-rw-r--r-- | libindicate/listener.h | 4 |
2 files changed, 60 insertions, 2 deletions
diff --git a/libindicate/listener.c b/libindicate/listener.c index f8ce32e..858c63b 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -55,6 +55,7 @@ struct _IndicateListenerServer { gchar * name; DBusGProxy * proxy; DBusGConnection * connection; + gboolean interests[INDICATE_INTEREST_LAST]; }; struct _IndicateListenerIndicator { @@ -462,7 +463,7 @@ todo_idle (gpointer data) proxy_todo_t * todo = &g_array_index(priv->proxy_todo, proxy_todo_t, priv->proxy_todo->len - 1); - proxy_t * proxyt = g_new(proxy_t, 1); + proxy_t * proxyt = g_new0(proxy_t, 1); proxyt->name = todo->name; proxyt->type = NULL; proxyt->proxy = dbus_g_proxy_new_for_name(todo->bus, @@ -961,3 +962,58 @@ indicate_listener_indicator_get_id (IndicateListenerIndicator * indicator) return GPOINTER_TO_UINT(indicator); } +static const gchar * +interest_to_string (IndicateInterests interest) +{ + switch (interest) { + case INDICATE_INTEREST_SERVER_DISPLAY: + return INDICATE_INTEREST_STRING_SERVER_DISPLAY; + case INDICATE_INTEREST_SERVER_SIGNAL: + return INDICATE_INTEREST_STRING_SERVER_SIGNAL; + case INDICATE_INTEREST_INDICATOR_DISPLAY: + return INDICATE_INTEREST_STRING_INDICATOR_DISPLAY; + case INDICATE_INTEREST_INDICATOR_SIGNAL: + return INDICATE_INTEREST_STRING_INDICATOR_SIGNAL; + case INDICATE_INTEREST_INDICATOR_COUNT: + return INDICATE_INTEREST_STRING_INDICATOR_COUNT; + default: + return ""; + } +} + +static void +interest_cb (DBusGProxy *proxy, GError *error, gpointer userdata) +{ + if (error != NULL) { + g_warning("Unable to configure interest on server %s because: %s", ((IndicateListenerServer *)userdata)->name, error->message); + } + + return; +} + +void +indicate_listener_server_show_interest (IndicateListener * listener, IndicateListenerServer * server, IndicateInterests interest) +{ + if (!server->interests[interest]) { + org_freedesktop_indicator_show_interest_async (server->proxy, interest_to_string(interest), interest_cb, server); + server->interests[interest] = TRUE; + } + return; +} + +void +indicate_listener_server_remove_interest (IndicateListener * listener, IndicateListenerServer * server, IndicateInterests interest) +{ + if (server->interests[interest]) { + org_freedesktop_indicator_remove_interest_async (server->proxy, interest_to_string(interest), interest_cb, server); + server->interests[interest] = FALSE; + } + return; +} + +gboolean +indicate_listener_server_check_interest (IndicateListener * listener, IndicateListenerServer * server, IndicateInterests interest) +{ + return server->interests[interest]; +} + diff --git a/libindicate/listener.h b/libindicate/listener.h index 9b20070..f9bb6bb 100644 --- a/libindicate/listener.h +++ b/libindicate/listener.h @@ -127,7 +127,9 @@ void indicate_listener_server_show_interest (IndicateListen void indicate_listener_server_remove_interest (IndicateListener * listener, IndicateListenerServer * server, IndicateInterests interest); - +gboolean indicate_listener_server_check_interest (IndicateListener * listener, + IndicateListenerServer * server, + IndicateInterests interest); G_END_DECLS |