[gnome-documents: 18/22] embed: move handling of activate-result out of here



commit 57732d67a4a3ccdef8b4cdefb5e65036cc329f56
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Sun Aug 7 16:56:49 2016 -0700

    embed: move handling of activate-result out of here
    
    And into each class of views.

 src/embed.js   |   13 +------------
 src/preview.js |    9 ++++-----
 src/view.js    |   10 +++++++++-
 3 files changed, 14 insertions(+), 18 deletions(-)
---
diff --git a/src/embed.js b/src/embed.js
index 988eee9..94b46a2 100644
--- a/src/embed.js
+++ b/src/embed.js
@@ -23,13 +23,11 @@ const Lang = imports.lang;
 const Mainloop = imports.mainloop;
 
 const Application = imports.application;
-const MainToolbar = imports.mainToolbar;
 const Edit = imports.edit;
 const Search = imports.search;
 const Selections = imports.selections;
 const View = imports.view;
 const WindowMode = imports.windowMode;
-const Documents = imports.documents;
 
 const EvView = imports.gi.EvinceView;
 const EvinceView = imports.evinceview;
@@ -104,11 +102,6 @@ const Embed = new Lang.Class({
             this._onWindowModeChanged(Application.modeController, windowMode, WindowMode.WindowMode.NONE);
     },
 
-    _onActivateResult: function() {
-        if (this._currentView)
-            this._currentView.activateResult();
-    },
-
     _restoreLastPage: function() {
         let windowMode = Application.modeController.getWindowMode();
         if (windowMode == WindowMode.WindowMode.NONE)
@@ -224,10 +217,6 @@ const Embed = new Lang.Class({
             throw(new Error('Not handled'));
             break;
         }
-
-        if (this._toolbar.searchbar)
-            this._toolbar.searchbar.connectJS('activate-result',
-                                              Lang.bind(this, this._onActivateResult));
     },
 
     _restoreSearch: function() {
@@ -304,7 +293,7 @@ const Embed = new Lang.Class({
                 this._toolbar.destroy();
 
             // pack the toolbar
-            this._toolbar = new MainToolbar.OverviewToolbar(this._stack);
+            this._toolbar = visibleChild.createToolbar(this._stack);
             this._titlebar.add(this._toolbar);
         }
 
diff --git a/src/preview.js b/src/preview.js
index ef8f6cc..31e0b29 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -132,7 +132,10 @@ const Preview = new Lang.Class({
     },
 
     createToolbar: function() {
-        return new PreviewToolbar(this);
+        let toolbar = new PreviewToolbar(this);
+        toolbar.searchbar.connectJS('activate-result',
+                                    Lang.bind(this, this.findNext));
+        return toolbar;
     },
 
     createView: function() {
@@ -238,10 +241,6 @@ const Preview = new Lang.Class({
 
     scroll: function(direction) {
         throw (new Error('Not implemented'));
-    },
-
-    activateResult: function() {
-        this.findNext();
     }
 });
 
diff --git a/src/view.js b/src/view.js
index c85ce67..ac1fa4f 100644
--- a/src/view.js
+++ b/src/view.js
@@ -34,6 +34,7 @@ const Mainloop = imports.mainloop;
 
 const Application = imports.application;
 const ErrorBox = imports.errorBox;
+const MainToolbar = imports.mainToolbar;
 const WindowMode = imports.windowMode;
 const Utils = imports.utils;
 
@@ -458,7 +459,7 @@ const ViewContainer = new Lang.Class({
         this._model.set_sort_column_id(sortBy, sortType);
     },
 
-    activateResult: function() {
+    _activateResult: function() {
         let doc = this._getFirstDocument();
         if (doc)
             Application.documentManager.setActiveItem(doc)
@@ -662,5 +663,12 @@ const ViewContainer = new Lang.Class({
             this.view.disconnect(this._edgeHitId);
             this._edgeHitId = 0;
         }
+    },
+
+    createToolbar: function(stack) {
+        let toolbar = new MainToolbar.OverviewToolbar(stack);
+        toolbar.searchbar.connectJS('activate-result',
+                                    Lang.bind(this, this._activateResult));
+        return toolbar;
     }
 });


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