[gnome-shell/wip/rstrode/timed-login-with-disable-user-list] loginDialog: Allow timed login with disabled user list




commit 3aa4ec6dc18a117a0124cae5e2bddfe7cf6ea0b7
Author: Ray Strode <rstrode redhat com>
Date:   Tue Apr 13 10:59:49 2021 -0400

    loginDialog: Allow timed login with disabled user list
    
    At the moment the timed login feature is implemented in the user list.
    If there's no user list, we don't show the indicator anywhere and
    don't proceed with timed login.
    
    This commit allows timed login to work when the user list is disabled.
    It accomplishes this by putting the timed login indicator on the
    auth prompt in that scenario.

 .../gnome-shell-sass/widgets/_login-dialog.scss    |  5 +++
 js/gdm/authPrompt.js                               | 41 +++++++++++++++++++++-
 js/gdm/loginDialog.js                              | 24 +++++++++++--
 subprojects/gvc                                    |  2 +-
 4 files changed, 68 insertions(+), 4 deletions(-)
---
diff --git a/data/theme/gnome-shell-sass/widgets/_login-dialog.scss 
b/data/theme/gnome-shell-sass/widgets/_login-dialog.scss
index d6608fc307..1789beca92 100644
--- a/data/theme/gnome-shell-sass/widgets/_login-dialog.scss
+++ b/data/theme/gnome-shell-sass/widgets/_login-dialog.scss
@@ -151,6 +151,11 @@
   padding-top: 16px;
 }
 
+.login-dialog-timed-login-indicator {
+    height: 2px;
+    background-color: darken($fg_color,40%);
+}
+
 .login-dialog-prompt-layout {
   padding-top: 24px;
   padding-bottom: 12px;
diff --git a/js/gdm/authPrompt.js b/js/gdm/authPrompt.js
index d2c9a16594..07de0f8d27 100644
--- a/js/gdm/authPrompt.js
+++ b/js/gdm/authPrompt.js
@@ -1,7 +1,7 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 /* exported AuthPrompt */
 
-const { Clutter, GObject, Pango, Shell, St } = imports.gi;
+const { Clutter, GLib, GObject, Pango, Shell, St } = imports.gi;
 
 const Animation = imports.ui.animation;
 const Batch = imports.gdm.batch;
@@ -170,6 +170,11 @@ var AuthPrompt = GObject.registerClass({
         this._mainBox.add_child(this._entry);
         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._textEntry, this._passwordEntry].forEach(entry => {
             entry.clutter_text.connect('text-changed', () => {
                 if (!this._userVerifier.hasPendingMessages)
@@ -198,6 +203,40 @@ var AuthPrompt = GObject.registerClass({
         this._defaultButtonWell.add_child(this._spinner);
     }
 
+    showTimedLoginIndicator(time) {
+        let hold = new Batch.Hold();
+
+        this.hideTimedLoginIndicator();
+
+        let startTime = GLib.get_monotonic_time();
+
+        this._timedLoginTimeoutId = GLib.timeout_add (GLib.PRIORITY_DEFAULT, 33,
+            () => {
+                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() {
+        if (this._timedLoginTimeoutId) {
+            GLib.source_remove(this._timedLoginTimeoutId);
+            this._timedLoginTimeoutId = 0;
+        }
+        this._timedLoginIndicator.scale_x = 0.;
+    }
+
     _activateNext(shouldSpin) {
         this.verificationStatus = AuthPromptStatus.VERIFICATION_IN_PROGRESS;
         this.updateSensitivity(false);
diff --git a/js/gdm/loginDialog.js b/js/gdm/loginDialog.js
index 6f66a27592..72d3322db1 100644
--- a/js/gdm/loginDialog.js
+++ b/js/gdm/loginDialog.js
@@ -762,6 +762,9 @@ var LoginDialog = GObject.registerClass({
 
             if (this._authPrompt.verificationStatus == AuthPrompt.AuthPromptStatus.NOT_VERIFYING)
                 this._authPrompt.reset();
+
+            if (this._disableUserList && this._timedLoginUserListHold)
+                this._timedLoginUserListHold.release();
         }
     }
 
@@ -1048,16 +1051,30 @@ var LoginDialog = GObject.registerClass({
         let loginItem = null;
         let animationTime;
 
-        let tasks = [() => this._waitForItemForUser(userName),
+        let tasks = [() => {
+                         if (this._disableUserList)
+                             return;
+
+                         this._timedLoginUserListHold = this._waitForItemForUser(userName);
+
+                         return this._timedLoginUserListHold;
+                     },
 
                      () => {
-                         loginItem = this._userList.getItemFromUserName(userName);
+                         this._timedLoginUserListHold = null;
+
+                         loginItem = this._disableUserList
+                            ? this._authPrompt
+                            : this._userList.getItemFromUserName(userName);
 
                          // If there is an animation running on the item, reset it.
                          loginItem.hideTimedLoginIndicator();
                      },
 
                      () => {
+                         if (this._disableUserList)
+                             return;
+
                          // If we're just starting out, start on the right item.
                          if (!this._userManager.is_loaded)
                              this._userList.jumpToItem(loginItem);
@@ -1079,6 +1096,9 @@ var LoginDialog = GObject.registerClass({
                      },
 
                      () => {
+                         if (this._disableUserList)
+                             return;
+
                          // If idle timeout is done, make sure the timed login indicator is shown
                          if (delay > _TIMED_LOGIN_IDLE_THRESHOLD &&
                              this._authPrompt.visible)
diff --git a/subprojects/gvc b/subprojects/gvc
index 7a621180b4..0e1b4bdafc 160000
--- a/subprojects/gvc
+++ b/subprojects/gvc
@@ -1 +1 @@
-Subproject commit 7a621180b46421e356b33972e3446775a504139c
+Subproject commit 0e1b4bdafc364d5b62ffd14847e9e6ecfefbf2c9


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