Blob Blame History Raw
From f3f5643134c317546c88ff11b974f1a04ad780ff Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Tue, 19 Apr 2016 13:12:46 -0400
Subject: [PATCH] loginDialog: allow timed login with disabled user list

---
 data/theme/gnome-shell-high-contrast.css |  3 +++
 data/theme/gnome-shell.css               |  3 +++
 js/gdm/authPrompt.js                     | 41 ++++++++++++++++++++++++++++++++
 js/gdm/loginDialog.js                    | 29 +++++++++++++++++++---
 4 files changed, 73 insertions(+), 3 deletions(-)

diff --git a/data/theme/gnome-shell-high-contrast.css b/data/theme/gnome-shell-high-contrast.css
index 3ce5278e1..0325fea87 100644
--- a/data/theme/gnome-shell-high-contrast.css
+++ b/data/theme/gnome-shell-high-contrast.css
@@ -1691,6 +1691,9 @@ StScrollBar {
   padding-bottom: 12px;
   spacing: 8px;
   width: 23em; }
+  .login-dialog-prompt-layout .login-dialog-timed-login-indicator {
+    height: 2px;
+    background-color: #8b8b8b; }
 
 .login-dialog-prompt-label {
   color: #bebeb6;
diff --git a/data/theme/gnome-shell.css b/data/theme/gnome-shell.css
index 342bebe9d..e2a442ecb 100644
--- a/data/theme/gnome-shell.css
+++ b/data/theme/gnome-shell.css
@@ -1691,6 +1691,9 @@ StScrollBar {
   padding-bottom: 12px;
   spacing: 8px;
   width: 23em; }
+  .login-dialog-prompt-layout .login-dialog-timed-login-indicator {
+    height: 2px;
+    background-color: #8b8b8b; }
 
 .login-dialog-prompt-label {
   color: #bebeb6;
diff --git a/js/gdm/authPrompt.js b/js/gdm/authPrompt.js
index 6327633d9..ae03a5b49 100644
--- a/js/gdm/authPrompt.js
+++ b/js/gdm/authPrompt.js
@@ -2,6 +2,7 @@
 
 const Clutter = imports.gi.Clutter;
 const Gio = imports.gi.Gio;
+const GLib = imports.gi.GLib;
 const Lang = imports.lang;
 const Signals = imports.signals;
 const St = imports.gi.St;
@@ -118,6 +119,11 @@ const AuthPrompt = new Lang.Class({
 
         this._entry.grab_key_focus();
 
+        this._timedLoginIndicator = new St.Bin({ style_class: 'login-dialog-timed-login-indicator',
+                                                 scale_x: 0 });
+
+        this.actor.add(this._timedLoginIndicator);
+
         this._message = new St.Label({ opacity: 0,
                                        styleClass: 'login-dialog-message' });
         this._message.clutter_text.line_wrap = true;
@@ -142,6 +148,41 @@ const AuthPrompt = new Lang.Class({
         this._defaultButtonWell.add_child(this._spinner.actor);
     },
 
+    showTimedLoginIndicator: function(time) {
+        let hold = new Batch.Hold();
+
+        this.hideTimedLoginIndicator();
+
+        let startTime = GLib.get_monotonic_time();
+
+        this._timedLoginTimeoutId = GLib.timeout_add (GLib.PRIORITY_DEFAULT,
+                                                      33,
+                                                      Lang.bind(this, function() {
+                                                          let currentTime = GLib.get_monotonic_time();
+                                                          let elapsedTime = (currentTime - startTime) / GLib.USEC_PER_SEC;
+                                                          this._timedLoginIndicator.scale_x = elapsedTime / time;
+                                                          if (elapsedTime >= time) {
+                                                              this._timedLoginTimeoutId = 0;
+                                                              hold.release();
+                                                              return GLib.SOURCE_REMOVE;
+                                                          }
+
+                                                          return GLib.SOURCE_CONTINUE;
+                                                      }));
+
+        GLib.Source.set_name_by_id(this._timedLoginTimeoutId, '[gnome-shell] this._timedLoginTimeoutId');
+
+        return hold;
+    },
+
+    hideTimedLoginIndicator: function() {
+        if (this._timedLoginTimeoutId) {
+            GLib.source_remove(this._timedLoginTimeoutId);
+            this._timedLoginTimeoutId = 0;
+        }
+        this._timedLoginIndicator.scale_x = 0.;
+    },
+
     _onDestroy: function() {
         if (this._preemptiveAnswerWatchId) {
             this._idleMonitor.remove_watch(this._preemptiveAnswerWatchId);
diff --git a/js/gdm/loginDialog.js b/js/gdm/loginDialog.js
index 45eca18f7..9034d732e 100644
--- a/js/gdm/loginDialog.js
+++ b/js/gdm/loginDialog.js
@@ -729,6 +729,9 @@ const LoginDialog = new Lang.Class({
 
             if (this._authPrompt.verificationStatus == AuthPrompt.AuthPromptStatus.NOT_VERIFYING)
                 this._authPrompt.reset();
+
+            if (this._disableUserList && this._timedLoginUserListHold)
+                this._timedLoginUserListHold.release();
         }
     },
 
@@ -984,6 +987,9 @@ const LoginDialog = new Lang.Class({
     },
 
     _showTimedLoginAnimation: function() {
+        if (this._disableUserList) {
+                return this._authPrompt.showTimedLoginIndicator(this._timedLoginAnimationTime);
+        }
         this._timedLoginItem.actor.grab_key_focus();
         return this._timedLoginItem.showTimedLoginIndicator(this._timedLoginAnimationTime);
     },
@@ -1011,19 +1017,31 @@ const LoginDialog = new Lang.Class({
     },
 
     _startTimedLogin: function(userName, delay) {
+        this._timedLoginUserName = userName;
         this._timedLoginItem = null;
         this._timedLoginDelay = delay;
         this._timedLoginAnimationTime = delay;
-
         let tasks = [function() {
-                         return this._waitForItemForUser(userName);
+                         if (this._disableUserList)
+                             return;
+
+                         this._timedLoginUserListHold = this._waitForItemForUser(userName);
+
+                         return this._timedLoginUserListHold;
                      },
 
                      function() {
+                         this._timedLoginUserListHold = null;
+
+                         if (this._disableUserList)
+                             return;
                          this._timedLoginItem = this._userList.getItemFromUserName(userName);
                      },
 
                      function() {
+                         if (this._disableUserList)
+                             return;
+
                          // If we're just starting out, start on the right
                          // item.
                          if (!this._userManager.is_loaded) {
@@ -1034,6 +1052,9 @@ const LoginDialog = new Lang.Class({
                      this._blockTimedLoginUntilIdle,
 
                      function() {
+                         if (this._disableUserList)
+                             return;
+
                          this._userList.scrollToItem(this._timedLoginItem);
                      },
 
@@ -1058,7 +1079,9 @@ const LoginDialog = new Lang.Class({
         if (this._timedLoginItem)
             this._timedLoginItem.hideTimedLoginIndicator();
 
-        let userName = this._timedLoginItem.user.get_user_name();
+        this._authPrompt.hideTimedLoginIndicator();
+
+        let userName = this._timedLoginUserName;
 
         if (userName)
             this._startTimedLogin(userName, this._timedLoginDelay);
-- 
2.12.0