diff options
author | Conor Curran <conor.curran@canonical.com> | 2011-07-14 13:06:38 +0100 |
---|---|---|
committer | Conor Curran <conor.curran@canonical.com> | 2011-07-14 13:06:38 +0100 |
commit | d8eae0b9560084bc68781d73c14fcb54cd53fd02 (patch) | |
tree | 5154306e3838d7617fa1c6dc8270317461e5b68b /src/indicator-session.c | |
parent | ee23d617b4f66ddeddaa355faef5760d62314823 (diff) | |
download | ayatana-indicator-session-d8eae0b9560084bc68781d73c14fcb54cd53fd02.tar.gz ayatana-indicator-session-d8eae0b9560084bc68781d73c14fcb54cd53fd02.tar.bz2 ayatana-indicator-session-d8eae0b9560084bc68781d73c14fcb54cd53fd02.zip |
dynamic user menu hiding on the way#
Diffstat (limited to 'src/indicator-session.c')
-rw-r--r-- | src/indicator-session.c | 58 |
1 files changed, 55 insertions, 3 deletions
diff --git a/src/indicator-session.c b/src/indicator-session.c index ab3e87a..704e959 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -65,6 +65,7 @@ struct _IndicatorSession { IndicatorServiceManager * service; IndicatorObjectEntry users; IndicatorObjectEntry devices; + gboolean show_users_entry; GCancellable * service_proxy_cancel; GDBusProxy * service_proxy; }; @@ -94,6 +95,7 @@ static void service_connection_cb (IndicatorServiceManager * sm, gboolean connec static void receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, GVariant * parameters, gpointer user_data); static void service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data); static void user_real_name_get_cb (GObject * obj, GAsyncResult * res, gpointer user_data); +static void user_menu_visibility_get_cb (GObject* obj, GAsyncResult* res, gpointer user_data); static void indicator_session_class_init (IndicatorSessionClass *klass); static void indicator_session_init (IndicatorSession *self); @@ -122,6 +124,7 @@ indicator_session_init (IndicatorSession *self) self->service = NULL; self->service_proxy_cancel = NULL; self->service_proxy = NULL; + self->show_users_entry = FALSE; /* Now let's fire these guys up. */ self->service = indicator_service_manager_new_version(INDICATOR_SESSION_DBUS_NAME, @@ -244,8 +247,10 @@ indicator_session_get_entries (IndicatorObject* obj) IndicatorSession* self = INDICATOR_SESSION (obj); GList * retval = NULL; - - retval = g_list_prepend (retval, &self->users); + // Only show the users menu if we have more than one + if (self->show_users_entry == TRUE){ + retval = g_list_prepend (retval, &self->users); + } retval = g_list_prepend (retval, &self->devices); if (retval != NULL) { @@ -263,7 +268,15 @@ service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointe if (connected) { if (self->service_proxy != NULL){ // Its a reconnect ! - // fetch the users's real name and return + // Fetch synchronisation data and return (proxy is still legit) + g_dbus_proxy_call (self->service_proxy, + "GetUserMenuVisibility", + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + user_menu_visibility_get_cb, + user_data); g_dbus_proxy_call (self->service_proxy, "GetUserRealName", NULL, @@ -317,6 +330,16 @@ service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data) g_signal_connect(proxy, "g-signal", G_CALLBACK(receive_signal), self); + // Figure out whether we should show the user menu at all. + g_dbus_proxy_call (self->service_proxy, + "GetUserMenuVisibility", + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + user_menu_visibility_get_cb, + user_data); + // Fetch the user's real name for the user entry label g_dbus_proxy_call (self->service_proxy, "GetUserRealName", @@ -382,6 +405,31 @@ user_real_name_get_cb (GObject * obj, GAsyncResult * res, gpointer user_data) return; } +static void +user_menu_visibility_get_cb (GObject* obj, GAsyncResult* res, gpointer user_data) +{ + IndicatorSession * self = INDICATOR_SESSION(user_data); + GError * error = NULL; + GVariant * result; + + result = g_dbus_proxy_call_finish(self->service_proxy, res, &error); + + if (error != NULL) { + g_warning ("unable to complete real name dbus query"); + g_error_free (error); + return; + } + gboolean update; + g_variant_get (result, "(b)", &update); + g_debug ("GET VISIBILITY CB: NEW VALUE = %i", update); + self->show_users_entry = update; + g_signal_emit_by_name (user_data, + "entry-added", + self->parent, + self->users); + return; +} + /* Receives all signals from the service, routed to the appropriate functions */ static void @@ -398,6 +446,10 @@ receive_signal (GDBusProxy * proxy, g_variant_get (parameters, "(s)", &username); indicator_session_update_users_label (self, username); } + else if (g_strcmp0(signal_name, "UserMenuIsVisible") == 0) { + gboolean result = g_variant_get_boolean (parameters); + g_debug ("GET VISIBILITY signal: NEW VALUE = %i", result); + } return; } |