[gnome-boxes] wizard: Add Esc shortcut for cancelling



commit 79aabaf51cf2230b5413de714ebfe6f1450b374f
Author: Lasse Schuirmann <lasse schuirmann net>
Date:   Wed Mar 12 07:04:20 2014 +0100

    wizard: Add Esc shortcut for cancelling
    
    https://bugzilla.gnome.org/show_bug.cgi?id=726153

 src/app-window.vala |    5 ++---
 src/topbar.vala     |   13 +++++++++++++
 2 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/src/app-window.vala b/src/app-window.vala
index 05a7150..95a13d8 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -162,9 +162,6 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
         if (event.keyval == Gdk.Key.F11) {
             fullscreened = !fullscreened;
             return true;
-        } else if (event.keyval == Gdk.Key.Escape) {
-            if (App.app.selection_mode && ui_state == UIState.COLLECTION)
-               App.app.selection_mode = false;
         } else if (event.keyval == Gdk.Key.q &&
                    (event.state & default_modifiers) == Gdk.ModifierType.CONTROL_MASK) {
             App.app.quit_app ();
@@ -181,6 +178,8 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
                    (event.state & default_modifiers) == Gdk.ModifierType.MOD1_MASK) {
             App.window.topbar.click_forward_button ();
             return true;
+        } else if (event.keyval == Gdk.Key.Escape) { // ESC -> cancel
+            App.window.topbar.click_cancel_button ();
         }
 
         return false;
diff --git a/src/topbar.vala b/src/topbar.vala
index 7d344c8..08e75f2 100644
--- a/src/topbar.vala
+++ b/src/topbar.vala
@@ -76,6 +76,19 @@ private class Boxes.Topbar: Gtk.Stack, Boxes.UI {
             wizard_continue_btn.clicked ();
     }
 
+    // Clicks the appropriate cancel button dependent on the ui state.
+    public void click_cancel_button () {
+        switch (App.app.ui_state) {
+        case UIState.COLLECTION:
+            if (App.app.selection_mode)
+                App.app.selection_mode = false;
+            return;
+        case UIState.WIZARD:
+            wizard_cancel_btn.clicked ();
+            return;
+        }
+    }
+
     public string? _status;
     public string? status {
         get { return _status; }


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