[gnome-shell/gnome-3-18] loginDialog: Reconsider user for user list when user changes



commit 3001f3376c9ad92c5b5b2b129b001a5d67caaea6
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Mon Nov 23 18:24:19 2015 -0600

    loginDialog: Reconsider user for user list when user changes
    
    Generally a user-changed operation will be uninteresting, but if the
    user is currently in the user list and the account changes to locked, we
    want to remove it from the list, or if the user is not in the list and
    the account changed to unlocked, we want to add it to the list. This
    fixes the case where a new user account created in gnome-control-center
    does not appear in the user list. The password mode is set in the new
    account immediately after it is created, but the operations are not
    atomic, so the login dialog considers the new user account when it is
    still locked and rejects it from being displayed, then immediately
    afterwards the account is unlocked. This commit causes the login dialog
    to show the account when this occurs.
    
    The containsUser() check here is not strictly necessary, but reduces
    spurious calls to addUser() and removeUser(), since there's no easy way
    to check if the locked status of the account has changed (as it's much
    easier to connect to one signal on the UserManager than to
    notify::locked on each User object).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=758568

 js/gdm/loginDialog.js |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/js/gdm/loginDialog.js b/js/gdm/loginDialog.js
index 4150649..46eeb83 100644
--- a/js/gdm/loginDialog.js
+++ b/js/gdm/loginDialog.js
@@ -212,6 +212,10 @@ const UserList = new Lang.Class({
         return item;
     },
 
+    containsUser: function(user) {
+        return this._items[user.get_user_name()] != null;
+    },
+
     addUser: function(user) {
         if (!user.is_loaded)
             return;
@@ -1126,6 +1130,10 @@ const LoginDialog = new Lang.Class({
             this._userManager.disconnect(this._userRemovedId);
             this._userRemovedId = 0;
         }
+        if (this._userChangedId) {
+            this._userManager.disconnect(this._userChangedId);
+            this._userChangedId = 0;
+        }
         this._textureCache.disconnect(this._updateLogoTextureId);
         Main.layoutManager.disconnect(this._startupCompleteId);
         if (this._settings) {
@@ -1172,6 +1180,14 @@ const LoginDialog = new Lang.Class({
                                                             this._userList.removeUser(user);
                                                         }));
 
+        this._userChangedId = this._userManager.connect('user-changed',
+                                                        Lang.bind(this, function(userManager, user) {
+                                                            if (this._userList.containsUser(user) && 
user.locked)
+                                                                this._userList.removeUser(user);
+                                                            else if (!this._userList.containsUser(user) && 
!user.locked)
+                                                                this._userList.addUser(user);
+                                                        }));
+
         return GLib.SOURCE_REMOVE;
     },
 


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