[gnome-documents/wip/pranavk/lokdocview: 4/7] Let LOKView has its own window mode



commit 7fde9934b4225634b4a0873fb211711d21df5347
Author: Pranav Kant <pranavk gnome org>
Date:   Sun Aug 16 22:23:06 2015 +0530

    Let LOKView has its own window mode
    
    This also helps invoking a separate toolbar for LOKView.

 src/embed.js      |   25 +++++++++++++++++++++++--
 src/lokview.js    |    6 +++---
 src/mainWindow.js |    1 +
 src/windowMode.js |    3 ++-
 4 files changed, 29 insertions(+), 6 deletions(-)
---
diff --git a/src/embed.js b/src/embed.js
index 8ca5521..0b99bd8 100644
--- a/src/embed.js
+++ b/src/embed.js
@@ -298,6 +298,11 @@ const Embed = new Lang.Class({
                 Application.documentManager.reloadActiveItem();
             this._prepareForPreview();
             break;
+        case WindowMode.WindowMode.LOKVIEW:
+            if (oldMode == WindowMode.WindowMode.EDIT)
+                Application.documentManager.reloadActiveItem();
+            this._prepareForLOKView();
+            break;
         case WindowMode.WindowMode.EDIT:
             this._prepareForEdit();
             break;
@@ -354,8 +359,11 @@ const Embed = new Lang.Class({
         }
     },
 
-    _onLoadStarted: function() {
-        Application.modeController.setWindowMode(WindowMode.WindowMode.PREVIEW);
+    _onLoadStarted: function(manager, doc) {
+        if (doc.isOpenDocumentFormat())
+            Application.modeController.setWindowMode(WindowMode.WindowMode.LOKVIEW);
+        else
+            Application.modeController.setWindowMode(WindowMode.WindowMode.PREVIEW);
 
         this._clearLoadTimer();
         this._loadShowId = Mainloop.timeout_add(_PDF_LOADER_TIMEOUT, Lang.bind(this,
@@ -474,6 +482,19 @@ const Embed = new Lang.Class({
         this._stack.set_visible_child_name('edit');
     },
 
+    _prepareForLOKView: function() {
+        if (this._preview)
+            this._preview.setModel(null);
+        if (this._toolbar)
+            this._toolbar.destroy();
+
+        // pack the toolbar
+        this._toolbar = new LOKView.LOKViewToolbar(this._lokview);
+        this._titlebar.add(this._toolbar);
+
+        this._stack.set_visible_child_name('lokview');
+    },
+
     getMainToolbar: function() {
         let windowMode = Application.modeController.getWindowMode();
         let fullscreen = Application.modeController.getFullscreen();
diff --git a/src/lokview.js b/src/lokview.js
index dd11417..d30d416 100644
--- a/src/lokview.js
+++ b/src/lokview.js
@@ -124,16 +124,16 @@ const LOKViewToolbar = new Lang.Class({
         backButton.connect('clicked', Lang.bind(this,
             function() {
                 Application.documentManager.setActiveItem(null);
-                Application.modeController.goBack(2);
+                Application.modeController.goBack();
             }));
 
         let viewButton = new Gtk.Button({ label: _("View"),
                                           action_name: 'app.view-current' });
         viewButton.get_style_context().add_class('suggested-action');
-        this.toolbar.pack_end(viewButton);
+        //this.toolbar.pack_end(viewButton);
 
         this._setToolbarTitle();
-        this.widget.show_all();
+        this.toolbar.show_all();
     },
 
     createSearchbar: function() {
diff --git a/src/mainWindow.js b/src/mainWindow.js
index ad6ae2b..1c08837 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -201,6 +201,7 @@ const MainWindow = new Lang.Class({
         case WindowMode.WindowMode.SEARCH:
             return this._handleKeyOverview(event);
         case WindowMode.WindowMode.EDIT:
+        case WindowMode.WindowMode.LOKVIEW:
             return false;
         default:
             throw(new Error('Not handled'));
diff --git a/src/windowMode.js b/src/windowMode.js
index ce63d9f..108608f 100644
--- a/src/windowMode.js
+++ b/src/windowMode.js
@@ -32,7 +32,8 @@ const WindowMode = {
     PREVIEW: 2,
     EDIT: 3,
     COLLECTIONS: 4,
-    SEARCH: 5
+    SEARCH: 5,
+    LOKVIEW: 6
 };
 
 const ModeController = new Lang.Class({


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