From fbc5e3709e4a1988aba1acd5c6d9f1f2d126022a Mon Sep 17 00:00:00 2001 From: Xiaoguang Wang Date: Fri, 7 Jul 2017 14:47:23 +0800 Subject: [PATCH] loginDialog: Disable user list when no user https://bugzilla.gnome.org/show_bug.cgi?id=731320 --- js/gdm/loginDialog.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/js/gdm/loginDialog.js b/js/gdm/loginDialog.js index 094a1f96c..5055a0a58 100644 --- a/js/gdm/loginDialog.js +++ b/js/gdm/loginDialog.js @@ -269,6 +269,10 @@ const UserList = new Lang.Class({ item.actor.destroy(); delete this._items[userName]; + }, + + numItems: function() { + return Object.keys(this._items).length; } }); Signals.addSignalMethods(UserList.prototype); @@ -707,6 +711,10 @@ const LoginDialog = new Lang.Class({ _updateDisableUserList: function() { let disableUserList = this._settings.get_boolean(GdmUtil.DISABLE_USER_LIST_KEY); + // Disable user list when there are no users. + if (this._userListLoaded && this._userList.numItems() == 0) + disableUserList = true; + if (disableUserList != this._disableUserList) { this._disableUserList = disableUserList; @@ -1178,14 +1186,18 @@ const LoginDialog = new Lang.Class({ this._userList.addUser(users[i]); } + this._updateDisableUserList(); + this._userAddedId = this._userManager.connect('user-added', Lang.bind(this, function(userManager, user) { this._userList.addUser(user); + this._updateDisableUserList(); })); this._userRemovedId = this._userManager.connect('user-removed', Lang.bind(this, function(userManager, user) { this._userList.removeUser(user); + this._updateDisableUserList(); })); this._userChangedId = this._userManager.connect('user-changed', @@ -1194,6 +1206,7 @@ const LoginDialog = new Lang.Class({ this._userList.removeUser(user); else if (!this._userList.containsUser(user) && !user.locked) this._userList.addUser(user); + this._updateDisableUserList(); })); return GLib.SOURCE_REMOVE;