[gnome-documents] mainWindow: ensure Back keyboard button goes back from collections



commit 8809a285517d38c6e2c3d3b5c36e9ba7ce4f2eb4
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Fri Feb 22 17:02:53 2013 -0500

    mainWindow: ensure Back keyboard button goes back from collections
    
    https://bugzilla.gnome.org/show_bug.cgi?id=680662

 src/mainWindow.js |   28 ++++++++++++++++++++++------
 1 files changed, 22 insertions(+), 6 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 1fcc9d1..56693dd 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -164,11 +164,22 @@ const MainWindow = new Lang.Class({
         return false;
     },
 
-    _handleKeyPreview: function(event) {
+    _isBackKey: function(event) {
+        let direction = this.window.get_direction();
         let keyval = event.get_keyval()[1];
         let state = event.get_state()[1];
+
+        let isBack = (((state & Gdk.ModifierType.MOD1_MASK) != 0 &&
+                       (direction == Gtk.TextDirection.LTR && keyval == Gdk.KEY_Left) ||
+                       (direction == Gtk.TextDirection.RTL && keyval == Gdk.KEY_Right)) ||
+                      keyval == Gdk.KEY_Back);
+
+        return isBack;
+    },
+
+    _handleKeyPreview: function(event) {
+        let keyval = event.get_keyval()[1];
         let fullscreen = Application.modeController.getFullscreen();
-        let direction = this.window.get_direction();
 
         if (keyval == Gdk.KEY_Escape) {
             let preview = this._embed.getPreview();
@@ -182,10 +193,8 @@ const MainWindow = new Lang.Class({
             return false;
         }
 
-        if (((state & Gdk.ModifierType.MOD1_MASK) != 0 &&
-             (direction == Gtk.TextDirection.LTR && keyval == Gdk.KEY_Left) ||
-             (direction == Gtk.TextDirection.RTL && keyval == Gdk.KEY_Right)) ||
-            keyval == Gdk.KEY_Back) {
+        let isBack = this._isBackKey(event);
+        if (isBack) {
             Application.documentManager.setActiveItem(null);
             return true;
         }
@@ -202,6 +211,13 @@ const MainWindow = new Lang.Class({
             return true;
         }
 
+        let isBack = this._isBackKey(event);
+        let activeCollection = Application.collectionManager.getActiveItem();
+        if (isBack && activeCollection != null) {
+            Application.documentManager.activatePreviousCollection();
+            return true;
+        }
+
         return false;
     },
 


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