[gnome-shell/wip/login-unlock-merge: 8/9] loginDialog: add unlock-dialog code paths



commit faffddfa53a03798d3b8c5947f8325e285e603e0
Author: Ray Strode <rstrode redhat com>
Date:   Mon Jul 8 23:24:54 2013 -0400

    loginDialog: add unlock-dialog code paths
    
    Now that we've conditionalized out the gdm bits, we can conditionalize
    in the unlock-dialog bits.

 js/gdm/loginDialog.js |  114 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 110 insertions(+), 4 deletions(-)
---
diff --git a/js/gdm/loginDialog.js b/js/gdm/loginDialog.js
index 2e90d48..6305985 100644
--- a/js/gdm/loginDialog.js
+++ b/js/gdm/loginDialog.js
@@ -52,6 +52,9 @@ const _DEFAULT_BUTTON_WELL_ANIMATION_TIME = 0.3;
 const _TIMED_LOGIN_IDLE_THRESHOLD = 5.0;
 const _LOGO_ICON_HEIGHT = 48;
 
+const _SCREENSAVER_SCHEMA = 'org.gnome.desktop.screensaver';
+const _USER_SWITCH_ENABLED_KEY = 'user-switch-enabled';
+
 let _loginDialog = null;
 
 const DefaultButtonWellMode = {
@@ -426,10 +429,16 @@ const LoginDialog = new Lang.Class({
                                   Lang.bind(this, this._onTimedLoginRequested));
         }
 
-        this._userVerifier = new GdmUtil.ShellUserVerifier(this._greeterClient);
+        let reauthenticationOnly;
+
+        if (this._mode == 'lock-screen')
+            reauthenticationOnly = true;
+
+        this._userVerifier = new GdmUtil.ShellUserVerifier(this._greeterClient, { reauthenticationOnly: 
reauthenticationOnly });
         this._userVerifier.connect('ask-question', Lang.bind(this, this._askQuestion));
         this._userVerifier.connect('show-message', Lang.bind(this, this._showMessage));
         this._userVerifier.connect('verification-failed', Lang.bind(this, this._verificationFailed));
+        this._userVerifier.connect('verification-complete', Lang.bind(this, this._verificationComplete));
         this._userVerifier.connect('reset', Lang.bind(this, this._reset));
         this._userVerifier.connect('show-login-hint', Lang.bind(this, this._showLoginHint));
         this._userVerifier.connect('hide-login-hint', Lang.bind(this, this._hideLoginHint));
@@ -468,6 +477,8 @@ const LoginDialog = new Lang.Class({
                                        { expand: true,
                                          x_fill: true,
                                          y_fill: true });
+        } else if (this._mode == 'lock-screen') {
+            this._settings = new Gio.Settings({ schema: _SCREENSAVER_SCHEMA });
         }
 
         this._promptBox = new St.BoxLayout({ style_class: 'login-dialog-prompt-layout',
@@ -554,6 +565,30 @@ const LoginDialog = new Lang.Class({
                                          x_align: St.Align.START,
                                          x_fill: true });
 
+        } else if (this._mode == 'lock-screen') {
+            // translators: this message is shown below the password entry on the
+            // unlock screen. It can be activated to switch VTs to a login screen
+            // to log in as another user.
+            let otherUserLabel = new St.Label({ text: _("Log in as another user"),
+                                                style_class: 'login-dialog-not-listed-label' });
+            this._otherUserButton = new St.Button({ style_class: 'login-dialog-not-listed-button',
+                                                    button_mask: St.ButtonMask.ONE | St.ButtonMask.THREE,
+                                                    can_focus: true,
+                                                    child: otherUserLabel,
+                                                    reactive: true,
+                                                    x_align: St.Align.START,
+                                                    x_fill: true });
+            this._otherUserButton.connect('clicked', Lang.bind(this, this._cancelAndUserSwitch));
+
+            this._promptBox.add(this._otherUserButton,
+                                { expand: false,
+                                  x_align: St.Align.START,
+                                  x_fill: true });
+
+            this._settings.connect('changed::' + _USER_SWITCH_ENABLED_KEY,
+                                   Lang.bind(this, this._updateUserSwitching));
+
+            this._updateUserSwitching();
         }
 
         this._defaultButtonWell = new St.Widget();
@@ -610,6 +645,9 @@ const LoginDialog = new Lang.Class({
                                                                                        align_axis: 
Clutter.AlignAxis.BOTH,
                                                                                        factor: 0.5 }));
         }
+
+        if (this._mode == 'lock-screen')
+            this._verifyCurrentUser();
    },
 
     _updateDisableUserList: function() {
@@ -653,6 +691,35 @@ const LoginDialog = new Lang.Class({
         this._updateLogoTexture(this._textureCache, this._logoFileUri);
     },
 
+    _updateUserSwitching: function() {
+        let userSwitchEnabled = this._settings.get_boolean('user-switch-enabled');
+
+        let opacity;
+        if (userSwitchEnabled) {
+            opacity = 255;
+            this._otherUserButton.reactive = true;
+        } else {
+            opacity = 0;
+            this._otherUserButton.reactive = false;
+        }
+
+        Tweener.addTween(this._otherUserButton,
+                         { opacity: opacity,
+                           time: _FADE_ANIMATION_TIME,
+                           transition: 'easeOutQuad' });
+    },
+
+    _verifyCurrentUser: function() {
+        this._promptEntry.reactive = false;
+
+        let user = this._userManager.get_user(GLib.get_user_name());
+
+        let userWidget = new UserWidget.UserWidget(user);
+        this._promptUser.set_child(userWidget.actor);
+
+        return this._beginVerificationForUser(GLib.get_user_name());
+    },
+
     _reset: function() {
         this._userVerifier.clear();
 
@@ -666,6 +733,8 @@ const LoginDialog = new Lang.Class({
                 this._hideUserListAndLogIn();
             else
                 this._showUserList();
+        } else if (this._mode == 'lock-screen') {
+            this._verifyCurrentUser();
         }
     },
 
@@ -738,6 +807,26 @@ const LoginDialog = new Lang.Class({
         this._setDefaultButtonWellMode(DefaultButtonWellMode.NONE, true);
     },
 
+    _finishUnlock: function() {
+        this._userVerifier.clear();
+        this.emit('unlocked');
+    },
+
+    _verificationComplete: function() {
+        if (this._mode != 'lock-screen')
+            return;
+
+        if (!this._userVerifier.hasPendingMessages) {
+            this._finishUnlock();
+        } else {
+            let signalId = this._userVerifier.connect('no-more-messages',
+                                                      Lang.bind(this, function() {
+                                                          this._userVerifier.disconnect(signalId);
+                                                          this._finishUnlock();
+                                                      }));
+        }
+    },
+
     _onDefaultSessionChanged: function(client, sessionId) {
         this._sessionMenuButton.setActiveSession(sessionId);
     },
@@ -763,10 +852,18 @@ const LoginDialog = new Lang.Class({
     },
 
     cancel: function() {
-        if (this._verifyingUser)
+        if (this._verifyingUser) {
             this._userVerifier.cancel();
-        else
+            this.emit('failed');
+        } else {
             this._reset();
+        }
+    },
+
+    _cancelAndUserSwitch: function() {
+        Gdm.goto_login_session_sync(null);
+
+        this.cancel();
     },
 
     _shouldShowSessionMenuButton: function() {
@@ -847,11 +944,20 @@ const LoginDialog = new Lang.Class({
                               y_fill: false,
                               x_align: St.Align.END,
                               y_align: St.Align.MIDDLE });
+        let signInText;
+
+        if (!forSecret)
+            signInText = _("Next");
+        else if (this._mode == 'gdm')
+            signInText = C_("button", "Sign In");
+        else if (this._mode == 'lock-screen')
+            signInText = C_("button", "Unlock");
+
         this._signInButton = new St.Button({ style_class: 'modal-dialog-button',
                                              button_mask: St.ButtonMask.ONE | St.ButtonMask.THREE,
                                              reactive: true,
                                              can_focus: true,
-                                             label: forSecret ? C_("button", "Sign In") : _("Next") });
+                                             label: signInText });
         this._signInButton.connect('clicked',
                                    Lang.bind(this, function() {
                                        hold.release();


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