[gnome-shell] shellMountDialog: Close all dialogs when pressing Escape key



commit 6d2c83469418f49d831e5fd729e0dd36248696af
Author: Jonas Dreßler <verdre v0yd nl>
Date:   Mon Jan 27 18:46:17 2020 +0100

    shellMountDialog: Close all dialogs when pressing Escape key
    
    Since we don't really know what the buttons we're adding to the dialogs
    are about, we can't configure a button to "be clicked" when the escape
    key is pressed. So add a separate escape key handler to fix that, return
    -1 and abort the request.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/961

 js/ui/shellMountOperation.js | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/shellMountOperation.js b/js/ui/shellMountOperation.js
index 59a4e6e0fe..b2aa2ac47a 100644
--- a/js/ui/shellMountOperation.js
+++ b/js/ui/shellMountOperation.js
@@ -236,6 +236,15 @@ var ShellMountQuestionDialog = GObject.registerClass({
         this.contentLayout.add_child(this._content);
     }
 
+    vfunc_key_release_event(event) {
+        if (event.keyval === Clutter.KEY_Escape) {
+            this.emit('response', -1);
+            return Clutter.EVENT_STOP;
+        }
+
+        return Clutter.EVENT_PROPAGATE;
+    }
+
     update(message, choices) {
         _setLabelsForMessage(this._content, message);
         _setButtonsForChoices(this, this._oldChoices, choices);
@@ -481,7 +490,13 @@ var ShellProcessesDialog = GObject.registerClass({
         this.contentLayout.add_child(this._applicationSection);
     }
 
+    vfunc_key_release_event(event) {
+        if (event.keyval === Clutter.KEY_Escape) {
+            this.emit('response', -1);
+            return Clutter.EVENT_STOP;
+        }
 
+        return Clutter.EVENT_PROPAGATE;
     }
 
     _setAppsForPids(pids) {
@@ -662,8 +677,17 @@ var GnomeShellMountOpHandler = class {
 
         this._dialog = new ShellMountQuestionDialog(message);
         this._dialog.connect('response', (object, choice) => {
-            this._clearCurrentRequest(Gio.MountOperationResult.HANDLED,
-                                      { choice: GLib.Variant.new('i', choice) });
+            let response;
+            let details = {};
+
+            if (choice == -1) {
+                response = Gio.MountOperationResult.ABORTED;
+            } else {
+                response = Gio.MountOperationResult.HANDLED;
+                details['choice'] = GLib.Variant.new('i', choice);
+            }
+
+            this._clearCurrentRequest(response, details);
         });
 
         this._dialog.update(message, choices);


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