[gnome-documents] embed: fix "activate-result" signal connection



commit ba38badc757a1241b7bb9d423f1e6a4eb4987046
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Oct 10 17:48:00 2016 -0700

    embed: fix "activate-result" signal connection
    
    Since we share a single toolbar instance for all the "view" modes, we
    also have to share the signal connection to "activate-result", or we'll
    potentially activate a result on the wrong model.
    
    This partially reverts commit 57732d67a4a3ccdef8b4cdefb5e65036cc329f56.

 src/embed.js   |    7 +++++++
 src/preview.js |    9 +++++----
 src/view.js    |   21 +++++++++++----------
 3 files changed, 23 insertions(+), 14 deletions(-)
---
diff --git a/src/embed.js b/src/embed.js
index 4c84c0d..5014b38 100644
--- a/src/embed.js
+++ b/src/embed.js
@@ -128,10 +128,17 @@ const Embed = new Lang.Class({
 
             // pack the toolbar
             this._toolbar = this._view.createToolbar();
+            if (this._toolbar.searchbar)
+                this._toolbar.searchbar.connectJS('activate-result',
+                                                  Lang.bind(this, this._onActivateResult));
             this._titlebar.add(this._toolbar);
         }
     },
 
+    _onActivateResult: function() {
+        this._view.activateResult();
+    },
+
     _restoreSearch: function() {
         if (!this._searchState)
             return;
diff --git a/src/preview.js b/src/preview.js
index 31e0b29..6734a22 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -131,11 +131,12 @@ const Preview = new Lang.Class({
         return new PreviewNavControls(this, this.overlay);
     },
 
+    activateResult: function() {
+        this.findNext();
+    },
+
     createToolbar: function() {
-        let toolbar = new PreviewToolbar(this);
-        toolbar.searchbar.connectJS('activate-result',
-                                    Lang.bind(this, this.findNext));
-        return toolbar;
+        return new PreviewToolbar(this);
     },
 
     createView: function() {
diff --git a/src/view.js b/src/view.js
index 99a2fa5..75efa97 100644
--- a/src/view.js
+++ b/src/view.js
@@ -513,12 +513,6 @@ const ViewContainer = new Lang.Class({
         Application.searchMatchManager.setActiveItemById(itemId);
     },
 
-    _activateResult: function() {
-        let doc = this._getFirstDocument();
-        if (doc)
-            Application.documentManager.setActiveItem(doc)
-    },
-
     _getFirstDocument: function() {
         let doc = null;
 
@@ -719,11 +713,14 @@ const ViewContainer = new Lang.Class({
         }
     },
 
+    activateResult: function() {
+        let doc = this._getFirstDocument();
+        if (doc)
+            Application.documentManager.setActiveItem(doc)
+    },
+
     createToolbar: function(stack) {
-        let toolbar = new MainToolbar.OverviewToolbar(stack);
-        toolbar.searchbar.connectJS('activate-result',
-                                    Lang.bind(this, this._activateResult));
-        return toolbar;
+        return new MainToolbar.OverviewToolbar(stack);
     }
 });
 
@@ -807,6 +804,10 @@ const View = new Lang.Class({
         this._stack.add_named(this._preview, 'preview');
     },
 
+    activateResult: function() {
+        this.view.activateResult();
+    },
+
     createToolbar: function() {
         return this.view.createToolbar(this._stack);
     },


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