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

1be690
From 3252f05b8745a5d3118986474793fe3ecc2b041c Mon Sep 17 00:00:00 2001
35159f
From: Ray Strode <rstrode@redhat.com>
35159f
Date: Tue, 19 Apr 2016 13:12:46 -0400
35159f
Subject: [PATCH] loginDialog: allow timed login with disabled user list
35159f
35159f
At the moment the timed login feature is implemented in the user list.
35159f
If there's no user list, we don't show the indicator anywhere and
35159f
don't proceed with timed login.
35159f
35159f
This commit allows timed login to work when the user list is disabled.
35159f
It accomplishes this by putting the timed login indicator on the
35159f
auth prompt, in that scenario.
35159f
---
35159f
 data/theme/gnome-shell-sass/_common.scss |  4 +++
35159f
 js/gdm/authPrompt.js                     | 41 +++++++++++++++++++++++-
1be690
 js/gdm/loginDialog.js                    | 25 +++++++++++++--
1be690
 3 files changed, 67 insertions(+), 3 deletions(-)
35159f
35159f
diff --git a/data/theme/gnome-shell-sass/_common.scss b/data/theme/gnome-shell-sass/_common.scss
35159f
index a6357baad..c2df28279 100644
35159f
--- a/data/theme/gnome-shell-sass/_common.scss
35159f
+++ b/data/theme/gnome-shell-sass/_common.scss
35159f
@@ -1856,6 +1856,10 @@ StScrollBar {
35159f
       padding-bottom: 12px;
35159f
       spacing: 8px;
35159f
       width: 23em;
35159f
+      .login-dialog-timed-login-indicator {
35159f
+          height: 2px;
35159f
+          background-color: darken($fg_color,40%);
35159f
+      }
35159f
   }
35159f
 
35159f
   .login-dialog-prompt-label {
35159f
diff --git a/js/gdm/authPrompt.js b/js/gdm/authPrompt.js
35159f
index 27eb31a89..cf77b3f26 100644
35159f
--- a/js/gdm/authPrompt.js
35159f
+++ b/js/gdm/authPrompt.js
35159f
@@ -1,6 +1,6 @@
35159f
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
35159f
 
35159f
-const { Clutter, Pango, Shell, St } = imports.gi;
35159f
+const { Clutter, GLib, Pango, Shell, St } = imports.gi;
35159f
 const Signals = imports.signals;
35159f
 
35159f
 const Animation = imports.ui.animation;
35159f
@@ -111,6 +111,11 @@ var AuthPrompt = class {
35159f
 
35159f
         this._entry.grab_key_focus();
35159f
 
35159f
+        this._timedLoginIndicator = new St.Bin({ style_class: 'login-dialog-timed-login-indicator',
35159f
+                                                 scale_x: 0 });
35159f
+
35159f
+        this.actor.add(this._timedLoginIndicator);
35159f
+
35159f
         this._message = new St.Label({ opacity: 0,
35159f
                                        styleClass: 'login-dialog-message' });
35159f
         this._message.clutter_text.line_wrap = true;
35159f
@@ -135,6 +140,40 @@ var AuthPrompt = class {
35159f
         this._defaultButtonWell.add_child(this._spinner.actor);
35159f
     }
35159f
 
35159f
+    showTimedLoginIndicator(time) {
35159f
+        let hold = new Batch.Hold();
35159f
+
35159f
+        this.hideTimedLoginIndicator();
35159f
+
35159f
+        let startTime = GLib.get_monotonic_time();
35159f
+
35159f
+        this._timedLoginTimeoutId = GLib.timeout_add (GLib.PRIORITY_DEFAULT, 33,
35159f
+            () => {
35159f
+                let currentTime = GLib.get_monotonic_time();
35159f
+                let elapsedTime = (currentTime - startTime) / GLib.USEC_PER_SEC;
35159f
+                this._timedLoginIndicator.scale_x = elapsedTime / time;
35159f
+                if (elapsedTime >= time) {
35159f
+                    this._timedLoginTimeoutId = 0;
35159f
+                    hold.release();
35159f
+                    return GLib.SOURCE_REMOVE;
35159f
+                }
35159f
+
35159f
+                return GLib.SOURCE_CONTINUE;
35159f
+            });
35159f
+
35159f
+        GLib.Source.set_name_by_id(this._timedLoginTimeoutId, '[gnome-shell] this._timedLoginTimeoutId');
35159f
+
35159f
+        return hold;
35159f
+    }
35159f
+
35159f
+    hideTimedLoginIndicator() {
35159f
+        if (this._timedLoginTimeoutId) {
35159f
+            GLib.source_remove(this._timedLoginTimeoutId);
35159f
+            this._timedLoginTimeoutId = 0;
35159f
+        }
35159f
+        this._timedLoginIndicator.scale_x = 0.;
35159f
+    }
35159f
+
35159f
     _onDestroy() {
35159f
         if (this._preemptiveAnswerWatchId) {
35159f
             this._idleMonitor.remove_watch(this._preemptiveAnswerWatchId);
35159f
diff --git a/js/gdm/loginDialog.js b/js/gdm/loginDialog.js
1be690
index 6c4d1357d..b4df6e959 100644
35159f
--- a/js/gdm/loginDialog.js
35159f
+++ b/js/gdm/loginDialog.js
35159f
@@ -734,6 +734,9 @@ var LoginDialog = GObject.registerClass({
35159f
 
35159f
             if (this._authPrompt.verificationStatus == AuthPrompt.AuthPromptStatus.NOT_VERIFYING)
35159f
                 this._authPrompt.reset();
35159f
+
35159f
+            if (this._disableUserList && this._timedLoginUserListHold)
35159f
+                this._timedLoginUserListHold.release();
35159f
         }
35159f
     }
35159f
 
1be690
@@ -1020,16 +1023,31 @@ var LoginDialog = GObject.registerClass({
35159f
         let loginItem = null;
35159f
         let animationTime;
35159f
 
35159f
-        let tasks = [() => this._waitForItemForUser(userName),
35159f
+        let tasks = [() => {
35159f
+                         if (this._disableUserList)
35159f
+                             return;
35159f
+
35159f
+                         this._timedLoginUserListHold = this._waitForItemForUser(userName);
35159f
+
35159f
+                         return this._timedLoginUserListHold;
35159f
+                     },
35159f
 
35159f
                      () => {
1be690
-                         loginItem = this._userList.getItemFromUserName(userName);
35159f
+                         this._timedLoginUserListHold = null;
35159f
+
35159f
+
1be690
+                         loginItem = this._disableUserList
1be690
+                            ? this._authPrompt
1be690
+                            : this._userList.getItemFromUserName(userName);
35159f
 
35159f
                          // If there is an animation running on the item, reset it.
1be690
                          loginItem.hideTimedLoginIndicator();
35159f
                      },
35159f
 
35159f
                      () => {
35159f
+                         if (this._disableUserList)
35159f
+                             return;
35159f
+
35159f
                          // If we're just starting out, start on the right item.
35159f
                          if (!this._userManager.is_loaded) {
35159f
                              this._userList.jumpToItem(loginItem);
35159f
@@ -1051,6 +1069,9 @@ var LoginDialog = GObject.registerClass({
35159f
                      },
35159f
 
35159f
                      () => {
35159f
+                         if (this._disableUserList)
35159f
+                             return;
35159f
+
35159f
                          // If idle timeout is done, make sure the timed login indicator is shown
35159f
                          if (delay > _TIMED_LOGIN_IDLE_THRESHOLD &&
35159f
                              this._authPrompt.actor.visible)
35159f
-- 
1be690
2.26.2
35159f