From a08995020936b425a98970b686ff5f9169d8968b Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Tue, 19 Apr 2016 13:12:46 -0400 Subject: [PATCH] loginDialog: allow timed login with disabled user list --- data/theme/gnome-shell.css | 5 +++++ js/gdm/authPrompt.js | 41 +++++++++++++++++++++++++++++++++++++++++ js/gdm/loginDialog.js | 29 ++++++++++++++++++++++++++--- 3 files changed, 72 insertions(+), 3 deletions(-) diff --git a/data/theme/gnome-shell.css b/data/theme/gnome-shell.css index f1e9a23..97f8b0a 100644 --- a/data/theme/gnome-shell.css +++ b/data/theme/gnome-shell.css @@ -2455,6 +2455,11 @@ StScrollBar StButton#vhandle:active { background-size: contain; } +.login-dialog-prompt-layout .login-dialog-timed-login-indicator { + height: 2px; + background-color: #8b8b8b; +} + .login-dialog-user-list-item .login-dialog-timed-login-indicator { background-color: rgba(0,0,0,0.0); height: 2px; diff --git a/js/gdm/authPrompt.js b/js/gdm/authPrompt.js index fe80519..4370721 100644 --- a/js/gdm/authPrompt.js +++ b/js/gdm/authPrompt.js @@ -1,6 +1,7 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- const Clutter = imports.gi.Clutter; +const GLib = imports.gi.GLib; const Lang = imports.lang; const Signals = imports.signals; const St = imports.gi.St; @@ -117,6 +118,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; @@ -141,6 +147,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 b577520..a370e1c 100644 --- a/js/gdm/loginDialog.js +++ b/js/gdm/loginDialog.js @@ -734,6 +734,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(); } }, @@ -971,6 +974,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); }, @@ -998,19 +1004,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) { @@ -1021,6 +1039,9 @@ const LoginDialog = new Lang.Class({ this._blockTimedLoginUntilIdle, function() { + if (this._disableUserList) + return; + this._userList.scrollToItem(this._timedLoginItem); }, @@ -1045,7 +1066,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); -- 1.8.3.1