[gnome-shell] UnlockDialog: allow going back to the lock screen by pressing escape



commit 413ace2eb1a5890a7ff4ece0e0701aafc1548090
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Fri Aug 3 19:26:30 2012 +0200

    UnlockDialog: allow going back to the lock screen by pressing escape
    
    https://bugzilla.gnome.org/show_bug.cgi?id=681143

 js/ui/modalDialog.js  |   16 ++++++++++++----
 js/ui/unlockDialog.js |    5 +++++
 2 files changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/modalDialog.js b/js/ui/modalDialog.js
index 84fca17..60f08e2 100644
--- a/js/ui/modalDialog.js
+++ b/js/ui/modalDialog.js
@@ -56,7 +56,7 @@ const ModalDialog = new Lang.Class({
         this._group.connect('destroy', Lang.bind(this, this._onGroupDestroy));
 
         this._actionKeys = {};
-        this._group.connect('key-press-event', Lang.bind(this, this._onKeyPressEvent));
+        this._group.connect('key-release-event', Lang.bind(this, this._onKeyReleaseEvent));
 
         this._backgroundBin = new St.Bin();
         this._group.add_actor(this._backgroundBin);
@@ -108,6 +108,10 @@ const ModalDialog = new Lang.Class({
         this._group.destroy();
     },
 
+    setActionKey: function(key, action) {
+        this._actionKeys[key] = action;
+    },
+
     setButtons: function(buttons) {
         let hadChildren = this._buttonLayout.get_children() > 0;
 
@@ -175,12 +179,16 @@ const ModalDialog = new Lang.Class({
 
     },
 
-    _onKeyPressEvent: function(object, keyPressEvent) {
-        let symbol = keyPressEvent.get_key_symbol();
+    _onKeyReleaseEvent: function(object, event) {
+        let symbol = event.get_key_symbol();
         let action = this._actionKeys[symbol];
 
-        if (action)
+        if (action) {
             action();
+            return true;
+        }
+
+        return false;
     },
 
     _onGroupDestroy: function() {
diff --git a/js/ui/unlockDialog.js b/js/ui/unlockDialog.js
index af07a72..5cbe2e5 100644
--- a/js/ui/unlockDialog.js
+++ b/js/ui/unlockDialog.js
@@ -143,6 +143,7 @@ const UnlockDialog = new Lang.Class({
                            action: Lang.bind(this, this._doUnlock),
                            default: true };
         this.setButtons([this._okButton]);
+        this.setActionKey(Clutter.KEY_Escape, Lang.bind(this, this._escape));
 
         this._updateOkButton(false);
         this._reset();
@@ -202,6 +203,10 @@ const UnlockDialog = new Lang.Class({
         this.emit('failed');
     },
 
+    _escape: function() {
+        this._onVerificationFailed();
+    },
+
     _otherUserClicked: function(button, event) {
         this._userManager.goto_login_session();
 



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