unlockDialog: Use GdmUtil.AuthPrompt instead of ModalDialog
commit ea02380c15
made the login
screen stop using ModalDialog. It makes sense for the unlock
code to also stop using ModalDialog, too (for similar reasons).
Now that the login screen's auth prompt code has been separated
out, the unlock dialog can use it to get the buttons and spinners
etc, that it was previously getting from ModalDialog.
This commit drops the ModalDialog usage in the unlock dialog, and
makes the unlock dialog use GdmUtil.AuthPrompt instead.
https://bugzilla.gnome.org/show_bug.cgi?id=702308
This commit is contained in:
parent
953f44bcc5
commit
b4567acc6b
@ -1,6 +1,7 @@
|
|||||||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||||
|
|
||||||
const AccountsService = imports.gi.AccountsService;
|
const AccountsService = imports.gi.AccountsService;
|
||||||
|
const Atk = imports.gi.Atk;
|
||||||
const Clutter = imports.gi.Clutter;
|
const Clutter = imports.gi.Clutter;
|
||||||
const Gdm = imports.gi.Gdm;
|
const Gdm = imports.gi.Gdm;
|
||||||
const Gio = imports.gi.Gio;
|
const Gio = imports.gi.Gio;
|
||||||
@ -12,10 +13,9 @@ const Signals = imports.signals;
|
|||||||
const Shell = imports.gi.Shell;
|
const Shell = imports.gi.Shell;
|
||||||
const St = imports.gi.St;
|
const St = imports.gi.St;
|
||||||
|
|
||||||
|
const Layout = imports.ui.layout;
|
||||||
const Main = imports.ui.main;
|
const Main = imports.ui.main;
|
||||||
const ModalDialog = imports.ui.modalDialog;
|
|
||||||
const Panel = imports.ui.panel;
|
const Panel = imports.ui.panel;
|
||||||
const ShellEntry = imports.ui.shellEntry;
|
|
||||||
const Tweener = imports.ui.tweener;
|
const Tweener = imports.ui.tweener;
|
||||||
const UserWidget = imports.ui.userWidget;
|
const UserWidget = imports.ui.userWidget;
|
||||||
|
|
||||||
@ -28,14 +28,14 @@ const IDLE_TIMEOUT = 2 * 60;
|
|||||||
|
|
||||||
const UnlockDialog = new Lang.Class({
|
const UnlockDialog = new Lang.Class({
|
||||||
Name: 'UnlockDialog',
|
Name: 'UnlockDialog',
|
||||||
Extends: ModalDialog.ModalDialog,
|
|
||||||
|
|
||||||
_init: function(parentActor) {
|
_init: function(parentActor) {
|
||||||
this.parent({ shellReactive: true,
|
this.actor = new St.Widget({ accessible_role: Atk.Role.WINDOW,
|
||||||
styleClass: 'login-dialog',
|
style_class: 'login-dialog',
|
||||||
keybindingMode: Shell.KeyBindingMode.UNLOCK_SCREEN,
|
visible: false });
|
||||||
parentActor: parentActor
|
|
||||||
});
|
this.actor.add_constraint(new Layout.MonitorConstraint({ primary: true }));
|
||||||
|
parentActor.add_child(this.actor);
|
||||||
|
|
||||||
this._userManager = AccountsService.UserManager.get_default();
|
this._userManager = AccountsService.UserManager.get_default();
|
||||||
this._userName = GLib.get_user_name();
|
this._userName = GLib.get_user_name();
|
||||||
@ -56,62 +56,22 @@ const UnlockDialog = new Lang.Class({
|
|||||||
this._userVerifier.connect('show-login-hint', Lang.bind(this, this._showLoginHint));
|
this._userVerifier.connect('show-login-hint', Lang.bind(this, this._showLoginHint));
|
||||||
this._userVerifier.connect('hide-login-hint', Lang.bind(this, this._hideLoginHint));
|
this._userVerifier.connect('hide-login-hint', Lang.bind(this, this._hideLoginHint));
|
||||||
|
|
||||||
this._userWidget = new UserWidget.UserWidget(this._user);
|
this._promptBox = new St.BoxLayout({ vertical: true });
|
||||||
this.contentLayout.add_actor(this._userWidget.actor);
|
this.actor.add_child(this._promptBox);
|
||||||
|
this._promptBox.add_constraint(new Clutter.AlignConstraint({ source: this.actor,
|
||||||
|
align_axis: Clutter.AlignAxis.BOTH,
|
||||||
|
factor: 0.5 }));
|
||||||
|
|
||||||
this._promptLayout = new St.BoxLayout({ style_class: 'login-dialog-prompt-layout',
|
this._authPrompt = new GdmUtil.AuthPrompt();
|
||||||
vertical: true });
|
this._authPrompt.setUser(this._user);
|
||||||
|
this._authPrompt.setPasswordChar('\u25cf');
|
||||||
|
this._authPrompt.nextButton.label = _("Unlock");
|
||||||
|
this._authPrompt.connect('cancel', Lang.bind(this, this._escape));
|
||||||
|
this._authPrompt.connect('next', Lang.bind(this, this._doUnlock));
|
||||||
|
|
||||||
this._promptLabel = new St.Label({ style_class: 'login-dialog-prompt-label' });
|
this._promptBox.add_child(this._authPrompt.actor);
|
||||||
this._promptLayout.add(this._promptLabel,
|
|
||||||
{ x_align: St.Align.START });
|
|
||||||
|
|
||||||
this._promptEntry = new St.Entry({ style_class: 'login-dialog-prompt-entry',
|
|
||||||
can_focus: true });
|
|
||||||
this._promptEntry.clutter_text.connect('activate', Lang.bind(this, this._doUnlock));
|
|
||||||
this._promptEntry.clutter_text.set_password_char('\u25cf');
|
|
||||||
ShellEntry.addContextMenu(this._promptEntry, { isPassword: true });
|
|
||||||
this.setInitialKeyFocus(this._promptEntry);
|
|
||||||
this._promptEntry.clutter_text.connect('text-changed', Lang.bind(this, function() {
|
|
||||||
this._updateOkButtonSensitivity(this._promptEntry.text.length > 0);
|
|
||||||
}));
|
|
||||||
|
|
||||||
this._promptLayout.add(this._promptEntry,
|
|
||||||
{ expand: true,
|
|
||||||
x_fill: true });
|
|
||||||
|
|
||||||
this.contentLayout.add_actor(this._promptLayout);
|
|
||||||
|
|
||||||
this._promptMessage = new St.Label({ visible: false });
|
|
||||||
this.contentLayout.add(this._promptMessage, { x_fill: true });
|
|
||||||
|
|
||||||
this._promptLoginHint = new St.Label({ style_class: 'login-dialog-prompt-login-hint' });
|
|
||||||
this._promptLoginHint.hide();
|
|
||||||
this.contentLayout.add_actor(this._promptLoginHint);
|
|
||||||
|
|
||||||
this.allowCancel = false;
|
this.allowCancel = false;
|
||||||
this.buttonLayout.visible = true;
|
|
||||||
this.addButton({ label: _("Cancel"),
|
|
||||||
action: Lang.bind(this, this._escape),
|
|
||||||
key: Clutter.KEY_Escape },
|
|
||||||
{ expand: true,
|
|
||||||
x_fill: false,
|
|
||||||
y_fill: false,
|
|
||||||
x_align: St.Align.START,
|
|
||||||
y_align: St.Align.MIDDLE });
|
|
||||||
this.placeSpinner({ expand: false,
|
|
||||||
x_fill: false,
|
|
||||||
y_fill: false,
|
|
||||||
x_align: St.Align.END,
|
|
||||||
y_align: St.Align.MIDDLE });
|
|
||||||
this._okButton = this.addButton({ label: _("Unlock"),
|
|
||||||
action: Lang.bind(this, this._doUnlock),
|
|
||||||
default: true },
|
|
||||||
{ expand: false,
|
|
||||||
x_fill: false,
|
|
||||||
y_fill: false,
|
|
||||||
x_align: St.Align.END,
|
|
||||||
y_align: St.Align.MIDDLE });
|
|
||||||
|
|
||||||
let screenSaverSettings = new Gio.Settings({ schema: 'org.gnome.desktop.screensaver' });
|
let screenSaverSettings = new Gio.Settings({ schema: 'org.gnome.desktop.screensaver' });
|
||||||
if (screenSaverSettings.get_boolean('user-switch-enabled')) {
|
if (screenSaverSettings.get_boolean('user-switch-enabled')) {
|
||||||
@ -124,9 +84,7 @@ const UnlockDialog = new Lang.Class({
|
|||||||
x_align: St.Align.START,
|
x_align: St.Align.START,
|
||||||
x_fill: true });
|
x_fill: true });
|
||||||
this._otherUserButton.connect('clicked', Lang.bind(this, this._otherUserClicked));
|
this._otherUserButton.connect('clicked', Lang.bind(this, this._otherUserClicked));
|
||||||
this.dialogLayout.add(this._otherUserButton,
|
this._promptBox.add_child(this._otherUserButton);
|
||||||
{ x_align: St.Align.START,
|
|
||||||
x_fill: false });
|
|
||||||
} else {
|
} else {
|
||||||
this._otherUserButton = null;
|
this._otherUserButton = null;
|
||||||
}
|
}
|
||||||
@ -136,35 +94,23 @@ const UnlockDialog = new Lang.Class({
|
|||||||
let batch = new Batch.Hold();
|
let batch = new Batch.Hold();
|
||||||
this._userVerifier.begin(this._userName, batch);
|
this._userVerifier.begin(this._userName, batch);
|
||||||
|
|
||||||
Main.ctrlAltTabManager.addGroup(this.dialogLayout, _("Unlock Window"), 'dialog-password-symbolic');
|
Main.ctrlAltTabManager.addGroup(this.actor, _("Unlock Window"), 'dialog-password-symbolic');
|
||||||
|
|
||||||
this._idleMonitor = new GnomeDesktop.IdleMonitor();
|
this._idleMonitor = new GnomeDesktop.IdleMonitor();
|
||||||
this._idleWatchId = this._idleMonitor.add_idle_watch(IDLE_TIMEOUT * 1000, Lang.bind(this, this._escape));
|
this._idleWatchId = this._idleMonitor.add_idle_watch(IDLE_TIMEOUT * 1000, Lang.bind(this, this._escape));
|
||||||
},
|
},
|
||||||
|
|
||||||
_updateSensitivity: function(sensitive) {
|
_updateSensitivity: function(sensitive) {
|
||||||
this._promptEntry.reactive = sensitive;
|
this._authPrompt.updateSensitivity(sensitive);
|
||||||
this._promptEntry.clutter_text.editable = sensitive;
|
|
||||||
this._updateOkButtonSensitivity(sensitive && this._promptEntry.text.length > 0);
|
|
||||||
if (this._otherUserButton) {
|
if (this._otherUserButton) {
|
||||||
this._otherUserButton.reactive = sensitive;
|
this._otherUserButton.reactive = sensitive;
|
||||||
this._otherUserButton.can_focus = sensitive;
|
this._otherUserButton.can_focus = sensitive;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_updateOkButtonSensitivity: function(sensitive) {
|
|
||||||
this._okButton.reactive = sensitive;
|
|
||||||
this._okButton.can_focus = sensitive;
|
|
||||||
},
|
|
||||||
|
|
||||||
_showMessage: function(userVerifier, message, styleClass) {
|
_showMessage: function(userVerifier, message, styleClass) {
|
||||||
if (message) {
|
this._authPrompt.setMessage(message, styleClass);
|
||||||
this._promptMessage.text = message;
|
|
||||||
this._promptMessage.styleClass = styleClass;
|
|
||||||
GdmUtil.fadeInActor(this._promptMessage);
|
|
||||||
} else {
|
|
||||||
GdmUtil.fadeOutActor(this._promptMessage);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_onAskQuestion: function(verifier, serviceName, question, passwordChar) {
|
_onAskQuestion: function(verifier, serviceName, question, passwordChar) {
|
||||||
@ -175,28 +121,26 @@ const UnlockDialog = new Lang.Class({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._promptLabel.text = question;
|
|
||||||
|
|
||||||
if (!this._firstQuestion)
|
if (!this._firstQuestion)
|
||||||
this._promptEntry.text = '';
|
this._promptEntry.text = '';
|
||||||
else
|
else
|
||||||
this._firstQuestion = false;
|
this._firstQuestion = false;
|
||||||
|
|
||||||
this._promptEntry.clutter_text.set_password_char(passwordChar);
|
this._authPrompt.setPasswordChar(passwordChar);
|
||||||
this._promptEntry.menu.isPassword = passwordChar != '';
|
this._authPrompt.setQuestion(question);
|
||||||
|
|
||||||
this._currentQuery = serviceName;
|
this._currentQuery = serviceName;
|
||||||
|
|
||||||
this._updateSensitivity(true);
|
this._updateSensitivity(true);
|
||||||
this.setWorking(false);
|
this._authPrompt.stopSpinning();
|
||||||
},
|
},
|
||||||
|
|
||||||
_showLoginHint: function(verifier, message) {
|
_showLoginHint: function(verifier, message) {
|
||||||
this._promptLoginHint.set_text(message)
|
this._authPrompt.setHint(message);
|
||||||
GdmUtil.fadeInActor(this._promptLoginHint);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_hideLoginHint: function() {
|
_hideLoginHint: function() {
|
||||||
GdmUtil.fadeOutActor(this._promptLoginHint);
|
this._authPrompt.setHint(null);
|
||||||
},
|
},
|
||||||
|
|
||||||
_doUnlock: function() {
|
_doUnlock: function() {
|
||||||
@ -206,7 +150,7 @@ const UnlockDialog = new Lang.Class({
|
|||||||
// the actual reply to GDM will be sent as soon as asked
|
// the actual reply to GDM will be sent as soon as asked
|
||||||
this._firstQuestionAnswer = this._promptEntry.text;
|
this._firstQuestionAnswer = this._promptEntry.text;
|
||||||
this._updateSensitivity(false);
|
this._updateSensitivity(false);
|
||||||
this.setWorking(true);
|
this._authPrompt.startSpinning();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,9 +161,9 @@ const UnlockDialog = new Lang.Class({
|
|||||||
this._currentQuery = null;
|
this._currentQuery = null;
|
||||||
|
|
||||||
this._updateSensitivity(false);
|
this._updateSensitivity(false);
|
||||||
this.setWorking(true);
|
this._authPrompt.startSpinning();
|
||||||
|
|
||||||
this._userVerifier.answerQuery(query, this._promptEntry.text);
|
this._userVerifier.answerQuery(query, this._authPrompt.getAnswer());
|
||||||
},
|
},
|
||||||
|
|
||||||
_onVerificationComplete: function() {
|
_onVerificationComplete: function() {
|
||||||
@ -238,12 +182,10 @@ const UnlockDialog = new Lang.Class({
|
|||||||
this._firstQuestion = true;
|
this._firstQuestion = true;
|
||||||
this._userVerified = false;
|
this._userVerified = false;
|
||||||
|
|
||||||
this._promptEntry.text = '';
|
this._authPrompt.clear();
|
||||||
this._promptEntry.clutter_text.set_password_char('\u25cf');
|
|
||||||
this._promptEntry.menu.isPassword = true;
|
|
||||||
|
|
||||||
this._updateSensitivity(false);
|
this._updateSensitivity(false);
|
||||||
this.setWorking(false);
|
this._authPrompt.stopSpinning();
|
||||||
},
|
},
|
||||||
|
|
||||||
_escape: function() {
|
_escape: function() {
|
||||||
@ -262,13 +204,12 @@ const UnlockDialog = new Lang.Class({
|
|||||||
|
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
this._userVerifier.clear();
|
this._userVerifier.clear();
|
||||||
|
this.actor.destroy();
|
||||||
|
|
||||||
if (this._idleWatchId) {
|
if (this._idleWatchId) {
|
||||||
this._idleMonitor.remove_watch(this._idleWatchId);
|
this._idleMonitor.remove_watch(this._idleWatchId);
|
||||||
this._idleWatchId = 0;
|
this._idleWatchId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.parent();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
cancel: function() {
|
cancel: function() {
|
||||||
@ -278,7 +219,7 @@ const UnlockDialog = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
addCharacter: function(unichar) {
|
addCharacter: function(unichar) {
|
||||||
this._promptEntry.clutter_text.insert_unichar(unichar);
|
this._authPrompt.addCharacter(unichar);
|
||||||
},
|
},
|
||||||
|
|
||||||
finish: function(onComplete) {
|
finish: function(onComplete) {
|
||||||
@ -292,6 +233,28 @@ const UnlockDialog = new Lang.Class({
|
|||||||
this._userVerifier.disconnect(signalId);
|
this._userVerifier.disconnect(signalId);
|
||||||
onComplete();
|
onComplete();
|
||||||
}));
|
}));
|
||||||
|
},
|
||||||
|
|
||||||
|
open: function(timestamp) {
|
||||||
|
this.actor.show();
|
||||||
|
|
||||||
|
if (this._isModal)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (!Main.pushModal(this.actor, { timestamp: timestamp,
|
||||||
|
keybindingMode: Shell.KeyBindingMode.UNLOCK_SCREEN }))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
this._isModal = true;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
|
popModal: function(timestamp) {
|
||||||
|
if (this._isModal) {
|
||||||
|
Main.popModal(this.actor, timestamp);
|
||||||
|
this._isModal = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Signals.addSignalMethods(UnlockDialog.prototype);
|
||||||
|
Loading…
Reference in New Issue
Block a user