[gdm/gnome-2-30] Make applet use has-multiple-users property



commit ca9b9cda23aded9a2e6ff19edfd46f06ff656297
Author: William Jon McCann <jmccann redhat com>
Date:   Wed Jun 9 13:01:29 2010 -0400

    Make applet use has-multiple-users property
    
    https://bugzilla.gnome.org/show_bug.cgi?id=621131

 gui/user-switch-applet/applet.c |   64 ++++++++++++--------------------------
 1 files changed, 20 insertions(+), 44 deletions(-)
---
diff --git a/gui/user-switch-applet/applet.c b/gui/user-switch-applet/applet.c
index 744dda6..e609974 100644
--- a/gui/user-switch-applet/applet.c
+++ b/gui/user-switch-applet/applet.c
@@ -75,8 +75,6 @@ typedef struct _GdmAppletData
         GtkWidget      *login_screen_item;
         GtkWidget      *quit_session_item;
 
-        gboolean        has_other_users;
-
         guint           client_notify_lockdown_id;
 
         guint           current_status;
@@ -701,18 +699,15 @@ do_switch (GdmAppletData *adata,
 static void
 update_switch_user (GdmAppletData *adata)
 {
-        GSList *users;
         gboolean can_switch;
+        gboolean has_other_users;
 
         can_switch = gdm_user_manager_can_switch (adata->manager);
-        users = gdm_user_manager_list_users (adata->manager);
-        adata->has_other_users = FALSE;
-        if (users != NULL) {
-                adata->has_other_users = (g_slist_length (users) > 1);
-        }
-        g_slist_free (users);
+        g_object_get (adata->manager,
+                      "has-multiple-users", &has_other_users,
+                      NULL);
 
-        if (can_switch && adata->has_other_users) {
+        if (can_switch && has_other_users) {
                 gtk_widget_show (adata->login_screen_item);
         } else {
 
@@ -721,25 +716,17 @@ update_switch_user (GdmAppletData *adata)
 }
 
 static void
-on_manager_user_added (GdmUserManager *manager,
-                       GdmUser        *user,
-                       GdmAppletData  *adata)
-{
-        update_switch_user (adata);
-}
-
-static void
-on_manager_user_removed (GdmUserManager *manager,
-                         GdmUser        *user,
-                         GdmAppletData  *adata)
+on_manager_is_loaded_changed (GdmUserManager *manager,
+                              GParamSpec     *pspec,
+                              GdmAppletData  *adata)
 {
         update_switch_user (adata);
 }
 
 static void
-on_manager_is_loaded_changed (GdmUserManager *manager,
-                              GParamSpec     *pspec,
-                              GdmAppletData  *adata)
+on_manager_has_multiple_users_changed (GdmUserManager       *manager,
+                                       GParamSpec           *pspec,
+                                       GdmAppletData        *adata)
 {
         update_switch_user (adata);
 }
@@ -1062,19 +1049,6 @@ create_sub_menu (GdmAppletData *adata)
                           G_CALLBACK (menu_expose_cb), adata);
         gtk_widget_show (adata->menu);
 
-        g_signal_connect (adata->manager,
-                          "notify::is-loaded",
-                          G_CALLBACK (on_manager_is_loaded_changed),
-                          adata);
-        g_signal_connect (adata->manager,
-                          "user-added",
-                          G_CALLBACK (on_manager_user_added),
-                          adata);
-        g_signal_connect (adata->manager,
-                          "user-removed",
-                          G_CALLBACK (on_manager_user_added),
-                          adata);
-
 #ifdef BUILD_PRESENSE_STUFF
         adata->user_item = gdm_entry_menu_item_new ();
         gtk_menu_shell_append (GTK_MENU_SHELL (adata->menu),
@@ -1196,13 +1170,6 @@ static void
 destroy_sub_menu (GdmAppletData *adata)
 {
         gtk_menu_item_set_submenu (GTK_MENU_ITEM (adata->menuitem), NULL);
-
-        g_signal_handlers_disconnect_by_func (adata->manager,
-                                              G_CALLBACK (on_manager_user_added),
-                                              adata);
-        g_signal_handlers_disconnect_by_func (adata->manager,
-                                              G_CALLBACK (on_manager_user_removed),
-                                              adata);
 }
 
 static void
@@ -1503,6 +1470,15 @@ fill_applet (PanelApplet *applet)
         gtk_widget_show (adata->menubar);
 
         adata->manager = gdm_user_manager_ref_default ();
+        g_signal_connect (adata->manager,
+                          "notify::is-loaded",
+                          G_CALLBACK (on_manager_is_loaded_changed),
+                          adata);
+        g_signal_connect (adata->manager,
+                          "notify::has-multiple-users",
+                          G_CALLBACK (on_manager_has_multiple_users_changed),
+                          adata);
+
         gdm_user_manager_queue_load (adata->manager);
         setup_current_user (adata);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]