Blame SOURCES/allow-timed-login-with-no-user-list.patch

c7fac9
From ca59b5fa9e089177676c0590924e734910377102 Mon Sep 17 00:00:00 2001
c7fac9
From: Ray Strode <rstrode@redhat.com>
c7fac9
Date: Tue, 19 Apr 2016 13:12:46 -0400
c7fac9
Subject: [PATCH] loginDialog: allow timed login with disabled user list
c7fac9
c7fac9
At the moment the timed login feature is implemented in the user list.
c7fac9
If there's no user list, we don't show the indicator anywhere and
c7fac9
don't proceed with timed login.
c7fac9
c7fac9
This commit allows timed login to work when the user list is disabled.
c7fac9
It accomplishes this by putting the timed login indicator on the
c7fac9
auth prompt, in that scenario.
c7fac9
---
c7fac9
 data/theme/gnome-shell-sass/_common.scss |  4 +++
c7fac9
 js/gdm/authPrompt.js                     | 40 ++++++++++++++++++++++++
c7fac9
 js/gdm/loginDialog.js                    | 28 +++++++++++++++--
c7fac9
 3 files changed, 70 insertions(+), 2 deletions(-)
c7fac9
c7fac9
diff --git a/data/theme/gnome-shell-sass/_common.scss b/data/theme/gnome-shell-sass/_common.scss
c7fac9
index 2f05098df..4e82ef58b 100644
c7fac9
--- a/data/theme/gnome-shell-sass/_common.scss
c7fac9
+++ b/data/theme/gnome-shell-sass/_common.scss
c7fac9
@@ -1825,6 +1825,10 @@ StScrollBar {
c7fac9
       padding-bottom: 12px;
c7fac9
       spacing: 8px;
c7fac9
       width: 23em;
c7fac9
+      .login-dialog-timed-login-indicator {
c7fac9
+          height: 2px;
c7fac9
+          background-color: darken($fg_color,40%);
c7fac9
+      }
c7fac9
   }
c7fac9
 
c7fac9
   .login-dialog-prompt-label {
c7fac9
diff --git a/js/gdm/authPrompt.js b/js/gdm/authPrompt.js
c7fac9
index 89cef4d5d..e44281117 100644
c7fac9
--- a/js/gdm/authPrompt.js
c7fac9
+++ b/js/gdm/authPrompt.js
c7fac9
@@ -2,6 +2,7 @@
c7fac9
 
c7fac9
 const Clutter = imports.gi.Clutter;
c7fac9
 const Gio = imports.gi.Gio;
c7fac9
+const GLib = imports.gi.GLib;
c7fac9
 const Lang = imports.lang;
c7fac9
 const Pango = imports.gi.Pango;
c7fac9
 const Signals = imports.signals;
c7fac9
@@ -117,6 +118,11 @@ var AuthPrompt = new Lang.Class({
c7fac9
 
c7fac9
         this._entry.grab_key_focus();
c7fac9
 
c7fac9
+        this._timedLoginIndicator = new St.Bin({ style_class: 'login-dialog-timed-login-indicator',
c7fac9
+                                                 scale_x: 0 });
c7fac9
+
c7fac9
+        this.actor.add(this._timedLoginIndicator);
c7fac9
+
c7fac9
         this._message = new St.Label({ opacity: 0,
c7fac9
                                        styleClass: 'login-dialog-message' });
c7fac9
         this._message.clutter_text.line_wrap = true;
c7fac9
@@ -142,6 +148,40 @@ var AuthPrompt = new Lang.Class({
c7fac9
         this._defaultButtonWell.add_child(this._spinner.actor);
c7fac9
     },
c7fac9
 
c7fac9
+    showTimedLoginIndicator(time) {
c7fac9
+        let hold = new Batch.Hold();
c7fac9
+
c7fac9
+        this.hideTimedLoginIndicator();
c7fac9
+
c7fac9
+        let startTime = GLib.get_monotonic_time();
c7fac9
+
c7fac9
+        this._timedLoginTimeoutId = GLib.timeout_add (GLib.PRIORITY_DEFAULT, 33,
c7fac9
+            () => {
c7fac9
+                let currentTime = GLib.get_monotonic_time();
c7fac9
+                let elapsedTime = (currentTime - startTime) / GLib.USEC_PER_SEC;
c7fac9
+                this._timedLoginIndicator.scale_x = elapsedTime / time;
c7fac9
+                if (elapsedTime >= time) {
c7fac9
+                    this._timedLoginTimeoutId = 0;
c7fac9
+                    hold.release();
c7fac9
+                    return GLib.SOURCE_REMOVE;
c7fac9
+                }
c7fac9
+
c7fac9
+                return GLib.SOURCE_CONTINUE;
c7fac9
+            });
c7fac9
+
c7fac9
+        GLib.Source.set_name_by_id(this._timedLoginTimeoutId, '[gnome-shell] this._timedLoginTimeoutId');
c7fac9
+
c7fac9
+        return hold;
c7fac9
+    },
c7fac9
+
c7fac9
+    hideTimedLoginIndicator() {
c7fac9
+        if (this._timedLoginTimeoutId) {
c7fac9
+            GLib.source_remove(this._timedLoginTimeoutId);
c7fac9
+            this._timedLoginTimeoutId = 0;
c7fac9
+        }
c7fac9
+        this._timedLoginIndicator.scale_x = 0.;
c7fac9
+    },
c7fac9
+
c7fac9
     _onDestroy() {
c7fac9
         if (this._preemptiveAnswerWatchId) {
c7fac9
             this._idleMonitor.remove_watch(this._preemptiveAnswerWatchId);
c7fac9
diff --git a/js/gdm/loginDialog.js b/js/gdm/loginDialog.js
c7fac9
index 4a93545af..65d9edf1a 100644
c7fac9
--- a/js/gdm/loginDialog.js
c7fac9
+++ b/js/gdm/loginDialog.js
c7fac9
@@ -738,6 +738,9 @@ var LoginDialog = new Lang.Class({
c7fac9
 
c7fac9
             if (this._authPrompt.verificationStatus == AuthPrompt.AuthPromptStatus.NOT_VERIFYING)
c7fac9
                 this._authPrompt.reset();
c7fac9
+
c7fac9
+            if (this._disableUserList && this._timedLoginUserListHold)
c7fac9
+                this._timedLoginUserListHold.release();
c7fac9
         }
c7fac9
     },
c7fac9
 
c7fac9
@@ -1019,17 +1022,33 @@ var LoginDialog = new Lang.Class({
c7fac9
     },
c7fac9
 
c7fac9
     _startTimedLogin(userName, delay) {
c7fac9
+        this._timedLoginUserName = userName;
c7fac9
         this._timedLoginItem = null;
c7fac9
         this._timedLoginDelay = delay;
c7fac9
         this._timedLoginAnimationTime = delay;
c7fac9
 
c7fac9
-        let tasks = [() => this._waitForItemForUser(userName),
c7fac9
+        let tasks = [() => {
c7fac9
+                         if (this._disableUserList)
c7fac9
+                             return;
c7fac9
+
c7fac9
+                         this._timedLoginUserListHold = this._waitForItemForUser(userName);
c7fac9
+
c7fac9
+                         return this._timedLoginUserListHold;
c7fac9
+                     },
c7fac9
 
c7fac9
                      () => {
c7fac9
+                         this._timedLoginUserListHold = null;
c7fac9
+
c7fac9
+                         if (this._disableUserList)
c7fac9
+                             return;
c7fac9
+
c7fac9
                          this._timedLoginItem = this._userList.getItemFromUserName(userName);
c7fac9
                      },
c7fac9
 
c7fac9
                      () => {
c7fac9
+                         if (this._disableUserList)
c7fac9
+                             return;
c7fac9
+
c7fac9
                          // If we're just starting out, start on the right
c7fac9
                          // item.
c7fac9
                          if (!this._userManager.is_loaded) {
c7fac9
@@ -1040,6 +1059,9 @@ var LoginDialog = new Lang.Class({
c7fac9
                      this._blockTimedLoginUntilIdle,
c7fac9
 
c7fac9
                      () => {
c7fac9
+                         if (this._disableUserList)
c7fac9
+                             return;
c7fac9
+
c7fac9
                          this._userList.scrollToItem(this._timedLoginItem);
c7fac9
                      },
c7fac9
 
c7fac9
@@ -1064,7 +1086,9 @@ var LoginDialog = new Lang.Class({
c7fac9
         if (this._timedLoginItem)
c7fac9
             this._timedLoginItem.hideTimedLoginIndicator();
c7fac9
 
c7fac9
-        let userName = this._timedLoginItem.user.get_user_name();
c7fac9
+        this._authPrompt.hideTimedLoginIndicator();
c7fac9
+
c7fac9
+        let userName = this._timedLoginUserName;
c7fac9
 
c7fac9
         if (userName)
c7fac9
             this._startTimedLogin(userName, this._timedLoginDelay);
c7fac9
-- 
c7fac9
2.20.1
c7fac9