[gnome-shell] UnlockDialog: allow typing before the first question from PAM



commit 3d6320295e9937100dfb390b162f7b5ebe676b15
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Mon Aug 13 12:49:04 2012 +0200

    UnlockDialog: allow typing before the first question from PAM
    
    If the user starts typing right away, assume that the entry is
    for a password and don't clear it when the secret request actually
    comes. Then, if the user completes typing, we also stash the answer
    and send it to GDM right away on the first PAM prompt.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=681576

 js/ui/unlockDialog.js |   29 ++++++++++++++++++++++++++---
 1 files changed, 26 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/unlockDialog.js b/js/ui/unlockDialog.js
index 6fcbda7..1ceb35a 100644
--- a/js/ui/unlockDialog.js
+++ b/js/ui/unlockDialog.js
@@ -91,6 +91,7 @@ const UnlockDialog = new Lang.Class({
         this._user = this._userManager.get_user(this._userName);
 
         this._failCounter = 0;
+        this._firstQuestion = true;
 
         this._greeterClient = new Gdm.Client();
         this._userVerifier = new GdmUtil.ShellUserVerifier(this._greeterClient, { reauthenticationOnly: true });
@@ -115,7 +116,8 @@ const UnlockDialog = new Lang.Class({
 
         this._promptEntry = new St.Entry({ style_class: 'login-dialog-prompt-entry',
                                            can_focus: true });
-        ShellEntry.addContextMenu(this._promptEntry);
+        this._promptEntry.clutter_text.set_password_char('\u25cf');
+        ShellEntry.addContextMenu(this._promptEntry, { isPassword: true });
         this.setInitialKeyFocus(this._promptEntry);
         this._promptEntry.clutter_text.connect('activate', Lang.bind(this, this._doUnlock));
 
@@ -140,7 +142,7 @@ const UnlockDialog = new Lang.Class({
                            default: true };
         this.setButtons([cancelButton, this._okButton]);
 
-        this._updateOkButton(false);
+        this._updateOkButton(true);
 
         let otherUserLabel = new St.Label({ text: _("Log in as another user"),
                                             style_class: 'login-dialog-not-listed-label' });
@@ -171,6 +173,7 @@ const UnlockDialog = new Lang.Class({
 
     _updateOkButton: function(sensitive) {
         this._okButton.button.reactive = sensitive;
+        this._okButton.button.can_focus = sensitive;
     },
 
     _showMessage: function(userVerifier, message, styleClass) {
@@ -180,9 +183,20 @@ const UnlockDialog = new Lang.Class({
     },
 
     _onAskQuestion: function(verifier, serviceName, question, passwordChar) {
+        if (this._firstQuestion && this._firstQuestionAnswer) {
+            this._userVerifier.answerQuery(serviceName, this._firstQuestionAnswer);
+            this._firstQuestionAnswer = null;
+            this._firstQuestion = false;
+            return;
+        }
+
         this._promptLabel.text = question;
 
-        this._promptEntry.text = '';
+        if (!this._firstQuestion)
+            this._promptEntry.text = '';
+        else
+            this._firstQuestion = false;
+
         this._promptEntry.clutter_text.set_password_char(passwordChar);
         this._promptEntry.menu.isPassword = passwordChar != '';
 
@@ -200,6 +214,15 @@ const UnlockDialog = new Lang.Class({
     },
 
     _doUnlock: function() {
+        if (this._firstQuestion) {
+            // we haven't received a query yet, so stash the answer
+            // and make ourself non-reactive
+            // the actual reply to GDM will be sent as soon as asked
+            this._firstQuestionAnswer = this._promptEntry.text;
+            this._updateOkButton(false);
+            return;
+        }
+
         if (!this._currentQuery)
             return;
 



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