From 1967b9c58fd2727733fb38c10d610eb80e365ae3 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 13 Jul 2011 13:12:00 +0100 Subject: tidied up signals and methods for the session service so as the users real name should be available and not the icon, icon should not change on the panel --- src/session-dbus.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'src/session-dbus.c') diff --git a/src/session-dbus.c b/src/session-dbus.c index fa9ea54..07cebf7 100644 --- a/src/session-dbus.c +++ b/src/session-dbus.c @@ -5,6 +5,7 @@ Copyright 2010 Canonical Ltd. Authors: Ted Gould + Conor Curran This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3, as published @@ -28,7 +29,7 @@ with this program. If not, see . #include "session-dbus.h" #include "dbus-shared-names.h" -static GVariant * get_icon (SessionDbus * service); +static GVariant * get_users_real_name (SessionDbus * service); static void bus_get_cb (GObject * object, GAsyncResult * res, gpointer user_data); static void bus_method_call (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * method, GVariant * params, GDBusMethodInvocation * invocation, gpointer user_data); @@ -98,7 +99,7 @@ session_dbus_init (SessionDbus *self) { SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(self); - priv->name = g_strdup(ICON_DEFAULT); + priv->name = NULL; priv->bus = NULL; priv->bus_cancel = NULL; priv->dbus_registration = 0; @@ -163,8 +164,8 @@ bus_method_call (GDBusConnection * connection, const gchar * sender, SessionDbus * service = SESSION_DBUS(user_data); GVariant * retval = NULL; - if (g_strcmp0(method, "GetIcon") == 0) { - retval = get_icon(service); + if (g_strcmp0(method, "GetUserRealName") == 0) { + retval = get_users_real_name (service); } else { g_warning("Calling method '%s' on the indicator service and it's unknown", method); } @@ -214,10 +215,11 @@ session_dbus_finalize (GObject *object) } static GVariant * -get_icon (SessionDbus * service) +get_users_real_name (SessionDbus * service) { SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(service); - return g_variant_new("(s)", priv->name); + g_debug ("Get users real name: %s", priv->name); + return g_variant_new ("(s)", priv->name); } SessionDbus * @@ -239,19 +241,18 @@ session_dbus_set_name (SessionDbus * session, const gchar * name) if (priv->bus != NULL) { g_dbus_connection_emit_signal (priv->bus, - NULL, - INDICATOR_SESSION_SERVICE_DBUS_OBJECT, - INDICATOR_SESSION_SERVICE_DBUS_IFACE, - "IconUpdated", - g_variant_new ("(s)", priv->name, NULL), - &error); + NULL, + INDICATOR_SESSION_SERVICE_DBUS_OBJECT, + INDICATOR_SESSION_SERVICE_DBUS_IFACE, + "UserRealNameUpdated", + g_variant_new ("(s)", priv->name, NULL), + &error); if (error != NULL) { - g_warning("Unable to send IconUpdated signal: %s", error->message); + g_warning("Unable to send UserRealNameUpdated signal: %s", error->message); g_error_free(error); return; } } - return; } -- cgit v1.2.3 From ee23d617b4f66ddeddaa355faef5760d62314823 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 13 Jul 2011 17:34:03 +0100 Subject: user label fixed for now --- src/indicator-session.c | 152 ++++++++++++++++++++++++++---------------------- src/session-dbus.c | 8 +++ src/session-dbus.h | 3 +- src/session-service.c | 4 +- 4 files changed, 94 insertions(+), 73 deletions(-) (limited to 'src/session-dbus.c') diff --git a/src/indicator-session.c b/src/indicator-session.c index 1de33d9..ab3e87a 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -89,10 +89,11 @@ static gboolean build_restart_item (DbusmenuMenuitem * newitem, DbusmenuClient * client, gpointer user_data); static void indicator_session_update_users_label (IndicatorSession* self, - GVariant * variant); + const gchar* name); static void service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data); 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 indicator_session_class_init (IndicatorSessionClass *klass); static void indicator_session_init (IndicatorSession *self); @@ -128,6 +129,8 @@ indicator_session_init (IndicatorSession *self) g_signal_connect(G_OBJECT(self->service), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(service_connection_cb), self); + + GtkWidget* avatar_icon = NULL; // users self->users.menu = GTK_MENU (dbusmenu_gtkmenu_new (INDICATOR_USERS_DBUS_NAME, INDICATOR_USERS_DBUS_OBJECT)); @@ -140,8 +143,6 @@ indicator_session_init (IndicatorSession *self) GTK_ICON_LOOKUP_FORCE_SIZE, &error); - GtkWidget* avatar_icon = NULL; - // I think the avatar image is available always but just in case have a fallback if (error != NULL) { g_warning ("Could not load the default avatar image for some reason"); @@ -192,19 +193,6 @@ indicator_session_init (IndicatorSession *self) GtkAccelGroup * agroup = gtk_accel_group_new(); dbusmenu_gtkclient_set_accel_group(DBUSMENU_GTKCLIENT(devices_client), agroup); - - self->service_proxy_cancel = g_cancellable_new(); - - g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION, - G_DBUS_PROXY_FLAGS_NONE, - NULL, - INDICATOR_SESSION_DBUS_NAME, - INDICATOR_SESSION_SERVICE_DBUS_OBJECT, - INDICATOR_SESSION_SERVICE_DBUS_IFACE, - self->service_proxy_cancel, - service_proxy_cb, - self); - return; } @@ -249,9 +237,59 @@ indicator_session_finalize (GObject *object) return; } -/* Callback from trying to create the proxy for the service, this - could include starting the service. Sometime it'll fail and - we'll try to start that dang service again! */ +static GList* +indicator_session_get_entries (IndicatorObject* obj) +{ + g_return_val_if_fail(IS_INDICATOR_SESSION(obj), NULL); + IndicatorSession* self = INDICATOR_SESSION (obj); + + GList * retval = NULL; + + retval = g_list_prepend (retval, &self->users); + retval = g_list_prepend (retval, &self->devices); + + if (retval != NULL) { + retval = g_list_reverse(retval); + } + return retval; +} + +/* callback for the service manager state of being */ +static void +service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data) +{ + IndicatorSession * self = INDICATOR_SESSION (user_data); + + if (connected) { + if (self->service_proxy != NULL){ + // Its a reconnect ! + // fetch the users's real name and return + g_dbus_proxy_call (self->service_proxy, + "GetUserRealName", + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + user_real_name_get_cb, + user_data); + return; + } + + self->service_proxy_cancel = g_cancellable_new(); + g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + INDICATOR_SESSION_DBUS_NAME, + INDICATOR_SESSION_SERVICE_DBUS_OBJECT, + INDICATOR_SESSION_SERVICE_DBUS_IFACE, + self->service_proxy_cancel, + service_proxy_cb, + self); + } + return; +} + + static void service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data) { @@ -278,29 +316,20 @@ service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data) self->service_proxy = proxy; g_signal_connect(proxy, "g-signal", G_CALLBACK(receive_signal), self); - + + // Fetch the user's real name for the user entry label + g_dbus_proxy_call (self->service_proxy, + "GetUserRealName", + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + user_real_name_get_cb, + user_data); return; } -static GList* -indicator_session_get_entries (IndicatorObject* obj) -{ - g_return_val_if_fail(IS_INDICATOR_SESSION(obj), NULL); - IndicatorSession* self = INDICATOR_SESSION (obj); - - GList * retval = NULL; - - retval = g_list_prepend (retval, &self->users); - retval = g_list_prepend (retval, &self->devices); - - if (retval != NULL) { - retval = g_list_reverse(retval); - } - return retval; -} - -/* Builds an item with a hip little logged in icon. */ static gboolean new_user_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, @@ -346,20 +375,10 @@ user_real_name_get_cb (GObject * obj, GAsyncResult * res, gpointer user_data) g_error_free (error); return; } - indicator_session_update_users_label (self, result); - return; -} - -static void -service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data) -{ - IndicatorSession * self = INDICATOR_SESSION (user_data); - - if (connected) { - g_dbus_proxy_call(self->service_proxy, "GetUserRealName", NULL, - G_DBUS_CALL_FLAGS_NONE, -1, NULL, - user_real_name_get_cb, user_data); - } + + const gchar* username = NULL; + g_variant_get (result, "(s)", &username); + indicator_session_update_users_label (self, username); return; } @@ -375,7 +394,9 @@ receive_signal (GDBusProxy * proxy, IndicatorSession * self = INDICATOR_SESSION(user_data); if (g_strcmp0(signal_name, "UserRealNameUpdated") == 0) { - indicator_session_update_users_label (self, parameters); + const gchar* username = NULL; + g_variant_get (parameters, "(s)", &username); + indicator_session_update_users_label (self, username); } return; } @@ -559,25 +580,14 @@ build_menu_switch (DbusmenuMenuitem * newitem, static void indicator_session_update_users_label (IndicatorSession* self, - GVariant * variant) + const gchar* name) { - const gchar* username = NULL; - if (variant == NULL || g_variant_get_string(variant, NULL) == NULL || - g_variant_get_string(variant, NULL)[0] == '\0'){ - gtk_widget_hide(GTK_WIDGET(self->users.label)); - return; - } + g_debug ("update users label"); - username = g_strdup (g_variant_get_string(variant, NULL)); - - // Just in case protect again. - if (username != NULL) { - g_debug ("!!!!!!!!!!!!update users label: %s", username); - gtk_label_set_text (self->users.label, username); - gtk_widget_show(GTK_WIDGET(self->users.label)); - } - else { + if (name == NULL){ gtk_widget_hide(GTK_WIDGET(self->users.label)); - } + return; + } + gtk_label_set_text (self->users.label, g_strdup(name)); + gtk_widget_show(GTK_WIDGET(self->users.label)); } - diff --git a/src/session-dbus.c b/src/session-dbus.c index 07cebf7..d28629b 100644 --- a/src/session-dbus.c +++ b/src/session-dbus.c @@ -230,6 +230,11 @@ session_dbus_new (void) void session_dbus_set_name (SessionDbus * session, const gchar * name) +{ +} + +void +session_dbus_set_users_real_name (SessionDbus * session, const gchar * name) { SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(session); GError * error = NULL; @@ -237,6 +242,9 @@ session_dbus_set_name (SessionDbus * session, const gchar * name) g_free(priv->name); priv->name = NULL; } + + g_debug ("sesssion dbus set name with %s", name); + priv->name = g_strdup(name); if (priv->bus != NULL) { diff --git a/src/session-dbus.h b/src/session-dbus.h index 792917b..377212b 100644 --- a/src/session-dbus.h +++ b/src/session-dbus.h @@ -48,7 +48,8 @@ struct _SessionDbus { GType session_dbus_get_type (void); SessionDbus * session_dbus_new (void); -void session_dbus_set_name (SessionDbus * session, const gchar * name); +void session_dbus_set_name (SessionDbus * session, const gchar * name); +void session_dbus_set_users_real_name (SessionDbus * session, const gchar * name); G_END_DECLS diff --git a/src/session-service.c b/src/session-service.c index d213b6d..2110241 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -541,7 +541,9 @@ rebuild_user_items (DbusmenuMenuitem *root, USER_ITEM_PROP_IS_CURRENT_USER, logged_in); if (logged_in == TRUE){ - session_dbus_set_name (session_dbus, user->real_name); + g_debug ("about to set the users real name to %s for user %s", + user->real_name, user->user_name); + session_dbus_set_users_real_name (session_dbus, user->real_name); } dbusmenu_menuitem_child_append (root, mi); -- cgit v1.2.3 From d8eae0b9560084bc68781d73c14fcb54cd53fd02 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 14 Jul 2011 13:06:38 +0100 Subject: dynamic user menu hiding on the way# --- src/indicator-session.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++--- src/session-dbus.c | 42 +++++++++++++++++++++++++++++++---- src/session-dbus.h | 1 + src/session-dbus.xml | 9 +++++--- src/session-service.c | 4 ++++ 5 files changed, 104 insertions(+), 10 deletions(-) (limited to 'src/session-dbus.c') 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 @@ -397,6 +445,10 @@ receive_signal (GDBusProxy * proxy, const gchar* username = NULL; 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; } diff --git a/src/session-dbus.c b/src/session-dbus.c index d28629b..9e24141 100644 --- a/src/session-dbus.c +++ b/src/session-dbus.c @@ -38,6 +38,7 @@ static void bus_method_call (GDBusConnection * connection, const gchar * sender, typedef struct _SessionDbusPrivate SessionDbusPrivate; struct _SessionDbusPrivate { gchar * name; + gboolean user_menu_is_visible; GDBusConnection * bus; GCancellable * bus_cancel; guint dbus_registration; @@ -103,6 +104,7 @@ session_dbus_init (SessionDbus *self) priv->bus = NULL; priv->bus_cancel = NULL; priv->dbus_registration = 0; + priv->user_menu_is_visible = FALSE; priv->bus_cancel = g_cancellable_new(); g_bus_get(G_BUS_TYPE_SESSION, @@ -161,15 +163,20 @@ bus_method_call (GDBusConnection * connection, const gchar * sender, const gchar * method, GVariant * params, GDBusMethodInvocation * invocation, gpointer user_data) { - SessionDbus * service = SESSION_DBUS(user_data); + SessionDbus * service = SESSION_DBUS (user_data); + SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE (service); + GVariant * retval = NULL; if (g_strcmp0(method, "GetUserRealName") == 0) { retval = get_users_real_name (service); - } else { - g_warning("Calling method '%s' on the indicator service and it's unknown", method); } - + else if (g_strcmp0 (method, "GetUserMenuVisibility") == 0){ + retval = g_variant_new ("(b)", priv->user_menu_is_visible); + } + else { + g_warning("Calling method '%s' on the indicator service and it's unknown", method); + } g_dbus_method_invocation_return_value(invocation, retval); return; } @@ -264,3 +271,30 @@ session_dbus_set_users_real_name (SessionDbus * session, const gchar * name) } return; } + +void +session_dbus_set_user_menu_visibility (SessionDbus* session, + gboolean visible) +{ + SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(session); + GError * error = NULL; + + g_debug ("sesssion dbus set user visibility - %i", visible); + + priv->user_menu_is_visible = visible; + + if (priv->bus != NULL) { + g_dbus_connection_emit_signal (priv->bus, + NULL, + INDICATOR_SESSION_SERVICE_DBUS_OBJECT, + INDICATOR_SESSION_SERVICE_DBUS_IFACE, + "UserMenuIsVisible", + g_variant_new ("(b)", priv->user_menu_is_visible), + &error); + + if (error != NULL) { + g_warning("Unable to send UserMenuIsVisible signal: %s", error->message); + g_error_free(error); + } + } +} diff --git a/src/session-dbus.h b/src/session-dbus.h index 377212b..45ebae2 100644 --- a/src/session-dbus.h +++ b/src/session-dbus.h @@ -50,6 +50,7 @@ GType session_dbus_get_type (void); SessionDbus * session_dbus_new (void); void session_dbus_set_name (SessionDbus * session, const gchar * name); void session_dbus_set_users_real_name (SessionDbus * session, const gchar * name); +void session_dbus_set_user_menu_visibility (SessionDbus* session, gboolean visible); G_END_DECLS diff --git a/src/session-dbus.xml b/src/session-dbus.xml index 82c8dc8..f496ff1 100644 --- a/src/session-dbus.xml +++ b/src/session-dbus.xml @@ -2,14 +2,17 @@ - - + + + - + + + diff --git a/src/session-service.c b/src/session-service.c index 2110241..812769e 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -490,6 +490,10 @@ rebuild_user_items (DbusmenuMenuitem *root, GList * users = NULL; users = users_service_dbus_get_user_list (service); guint user_count = g_list_length(users); + g_debug ("USER COUNT = %i", user_count); + // We only want to show this menu when we have more than one registered + // user + session_dbus_set_user_menu_visibility (session_dbus, user_count > 1); if (user_count > MINIMUM_USERS && user_count < MAXIMUM_USERS) { users = g_list_sort (users, (GCompareFunc)compare_users_by_username); -- cgit v1.2.3 From f2d458b0addfe408835366939b49f4a38c0a14cb Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 14 Jul 2011 16:35:57 +0100 Subject: get location overridden and debugs tidied up --- src/indicator-session.c | 74 +++++++++++++++++++++++++++++++++++++++++-------- src/session-dbus.c | 9 ++---- src/session-service.c | 2 +- 3 files changed, 66 insertions(+), 19 deletions(-) (limited to 'src/session-dbus.c') diff --git a/src/indicator-session.c b/src/indicator-session.c index 704e959..5a5e26c 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -102,7 +102,9 @@ static void indicator_session_init (IndicatorSession *self); static void indicator_session_dispose (GObject *object); static void indicator_session_finalize (GObject *object); static GList* indicator_session_get_entries (IndicatorObject* obj); - +static guint indicator_session_get_location (IndicatorObject * io, + IndicatorObjectEntry * entry); + G_DEFINE_TYPE (IndicatorSession, indicator_session, INDICATOR_OBJECT_TYPE); static void @@ -115,6 +117,7 @@ indicator_session_class_init (IndicatorSessionClass *klass) IndicatorObjectClass * io_class = INDICATOR_OBJECT_CLASS(klass); io_class->get_entries = indicator_session_get_entries; + io_class->get_location = indicator_session_get_location; return; } @@ -246,6 +249,7 @@ indicator_session_get_entries (IndicatorObject* obj) g_return_val_if_fail(IS_INDICATOR_SESSION(obj), NULL); IndicatorSession* self = INDICATOR_SESSION (obj); + g_debug ("get entries"); GList * retval = NULL; // Only show the users menu if we have more than one if (self->show_users_entry == TRUE){ @@ -259,6 +263,21 @@ indicator_session_get_entries (IndicatorObject* obj) return retval; } +static guint +indicator_session_get_location (IndicatorObject * io, + IndicatorObjectEntry * entry) +{ + IndicatorSession * self = INDICATOR_SESSION (io); + if (entry == &self->users){ + return 1; + } + else if (entry == &self->devices){ + return 0; + } + g_warning ("IOEntry handed to us to position but we don't own it!"); + return -1; +} + /* callback for the service manager state of being */ static void service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data) @@ -421,15 +440,28 @@ user_menu_visibility_get_cb (GObject* obj, GAsyncResult* res, gpointer user_data } gboolean update; g_variant_get (result, "(b)", &update); - g_debug ("GET VISIBILITY CB: NEW VALUE = %i", update); + + // If it is what we had before no need to do anything... + if (self->show_users_entry == update){ + return; + } + + //Otherwise self->show_users_entry = update; - g_signal_emit_by_name (user_data, - "entry-added", - self->parent, - self->users); - return; -} + IndicatorObjectEntry user_entry = self->users; + + if (self->show_users_entry == TRUE){ + g_signal_emit_by_name ((gpointer)self, + "entry-added", + &user_entry); + } + else{ + g_signal_emit_by_name ((gpointer)self, + "entry-removed", + &user_entry); + } +} /* Receives all signals from the service, routed to the appropriate functions */ static void @@ -447,10 +479,30 @@ receive_signal (GDBusProxy * proxy, 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); + gboolean update; + g_variant_get (parameters, "(b)", &update); + + // If it is what we had before no need to do anything... + if (self->show_users_entry == update){ + return; + } + + //Otherwise + self->show_users_entry = update; + + IndicatorObjectEntry user_entry = self->users; + + if (self->show_users_entry == TRUE){ + g_signal_emit_by_name ((gpointer)self, + "entry-added", + &user_entry); + } + else{ + g_signal_emit_by_name ((gpointer)self, + "entry-removed", + &user_entry); + } } - return; } diff --git a/src/session-dbus.c b/src/session-dbus.c index 9e24141..9aa75ef 100644 --- a/src/session-dbus.c +++ b/src/session-dbus.c @@ -225,7 +225,6 @@ static GVariant * get_users_real_name (SessionDbus * service) { SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(service); - g_debug ("Get users real name: %s", priv->name); return g_variant_new ("(s)", priv->name); } @@ -249,9 +248,7 @@ session_dbus_set_users_real_name (SessionDbus * session, const gchar * name) g_free(priv->name); priv->name = NULL; } - - g_debug ("sesssion dbus set name with %s", name); - + priv->name = g_strdup(name); if (priv->bus != NULL) { @@ -278,9 +275,7 @@ session_dbus_set_user_menu_visibility (SessionDbus* session, { SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(session); GError * error = NULL; - - g_debug ("sesssion dbus set user visibility - %i", visible); - + priv->user_menu_is_visible = visible; if (priv->bus != NULL) { diff --git a/src/session-service.c b/src/session-service.c index 812769e..fb6ce37 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -490,7 +490,7 @@ rebuild_user_items (DbusmenuMenuitem *root, GList * users = NULL; users = users_service_dbus_get_user_list (service); guint user_count = g_list_length(users); - g_debug ("USER COUNT = %i", user_count); + // g_debug ("USER COUNT = %i", user_count); // We only want to show this menu when we have more than one registered // user session_dbus_set_user_menu_visibility (session_dbus, user_count > 1); -- cgit v1.2.3