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. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1809>
This commit is contained in:
@ -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,13 @@ 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.add_child(this._timedLoginIndicator);
|
||||
|
||||
[this._textEntry, this._passwordEntry].forEach(entry => {
|
||||
entry.clutter_text.connect('text-changed', () => {
|
||||
if (!this._userVerifier.hasPendingMessages)
|
||||
@ -198,6 +205,40 @@ var AuthPrompt = GObject.registerClass({
|
||||
this._defaultButtonWell.add_child(this._spinner);
|
||||
}
|
||||
|
||||
showTimedLoginIndicator(time) {
|
||||
let hold = new Batch.Hold();
|
||||
|
||||
this.hideTimedLoginIndicator();
|
||||
|
||||
const startTime = GLib.get_monotonic_time();
|
||||
|
||||
this._timedLoginTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 33,
|
||||
() => {
|
||||
const currentTime = GLib.get_monotonic_time();
|
||||
const 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);
|
||||
|
Reference in New Issue
Block a user