[gnome-documents] mainWindow: further consolidate back key handling



commit 32ea604226fd0fa044bc93d2db970f8c9f0e776b
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Fri Feb 22 17:39:31 2013 -0500

    mainWindow: further consolidate back key handling
    
    This also ensures it works from Edit mode.

 src/mainWindow.js |   39 ++++++++++++++++++++++++---------------
 1 files changed, 24 insertions(+), 15 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 56693dd..e3f35a4 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -147,6 +147,9 @@ const MainWindow = new Lang.Class({
         if (toolbar.handleEvent(event))
             return true;
 
+        if (this._handleBackKey(event))
+            return true;
+
         switch (Application.modeController.getWindowMode()) {
         case WindowMode.WindowMode.NONE:
             return false;
@@ -177,6 +180,27 @@ const MainWindow = new Lang.Class({
         return isBack;
     },
 
+    _handleBackKey: function(event) {
+        let isBack = this._isBackKey(event);
+        if (!isBack)
+            return false;
+
+        let windowMode = Application.modeController.getWindowMode();
+        let activeCollection = Application.collectionManager.getActiveItem();
+        let handled = true;
+
+        if (windowMode == WindowMode.WindowMode.PREVIEW ||
+            windowMode == WindowMode.WindowMode.EDIT) {
+            Application.documentManager.setActiveItem(null);
+        } else if (windowMode == WindowMode.WindowMode.OVERVIEW && activeCollection) {
+            Application.documentManager.activatePreviousCollection();
+        } else {
+            handled = false;
+        }
+
+        return handled;
+    },
+
     _handleKeyPreview: function(event) {
         let keyval = event.get_keyval()[1];
         let fullscreen = Application.modeController.getFullscreen();
@@ -189,14 +213,6 @@ const MainWindow = new Lang.Class({
                 preview.controlsVisible = false;
             else if (fullscreen)
                 Application.documentManager.setActiveItem(null);
-
-            return false;
-        }
-
-        let isBack = this._isBackKey(event);
-        if (isBack) {
-            Application.documentManager.setActiveItem(null);
-            return true;
         }
 
         return false;
@@ -211,13 +227,6 @@ 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]