[gnome-documents] preview: hold a reference to the preview toolbar



commit eed973ff29937c208ce0057744e960a1eea6c22d
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Sun Oct 23 17:37:55 2016 -0700

    preview: hold a reference to the preview toolbar
    
    This will be useful in a later commit.

 src/evinceview.js |    9 ++++-----
 src/preview.js    |    2 ++
 src/view.js       |    6 +++++-
 3 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/src/evinceview.js b/src/evinceview.js
index 12b99ee..fc90c78 100644
--- a/src/evinceview.js
+++ b/src/evinceview.js
@@ -203,8 +203,7 @@ const EvinceView = new Lang.Class({
     },
 
     createToolbar: function() {
-        this._toolbar = new EvinceViewToolbar(this);
-        return this._toolbar;
+        return new EvinceViewToolbar(this);
     },
 
     createView: function() {
@@ -280,7 +279,7 @@ const EvinceView = new Lang.Class({
 
         this._evView.set_model(this._model);
         this.navControls.setModel(this._model);
-        this._toolbar.setModel(this._model);
+        this.toolbar.setModel(this._model);
 
         this.set_visible_child_full('view', Gtk.StackTransitionType.NONE);
         this.grab_focus();
@@ -443,8 +442,8 @@ const EvinceView = new Lang.Class({
     _onFullscreenChanged: function(action) {
         let fullscreen = action.state.get_boolean();
 
-        this._toolbar.visible = !fullscreen;
-        this._toolbar.sensitive = !fullscreen;
+        this.toolbar.visible = !fullscreen;
+        this.toolbar.sensitive = !fullscreen;
 
         if (fullscreen) {
             // create fullscreen toolbar (hidden by default)
diff --git a/src/preview.js b/src/preview.js
index 20f2fc6..63ac566 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -50,6 +50,8 @@ const Preview = new Lang.Class({
         this.view.show();
         this.set_visible_child_full('view', Gtk.StackTransitionType.NONE);
 
+        this.toolbar = this.createToolbar();
+
         this.contextMenu = this.createContextMenu();
         if (this.contextMenu)
             this.contextMenu.attach_to_widget(this.view, null);
diff --git a/src/view.js b/src/view.js
index fb99987..dd1f3b0 100644
--- a/src/view.js
+++ b/src/view.js
@@ -845,7 +845,11 @@ const View = new Lang.Class({
             if (this._toolbar)
                 this._toolbar.destroy();
 
-            this._toolbar = this.view.createToolbar(this._stack);
+            if (this._preview)
+                this._toolbar = this._preview.toolbar;
+            else
+                this._toolbar = this.view.createToolbar(this._stack);
+
             if (this._toolbar.searchbar)
                 this._toolbar.searchbar.connectJS('activate-result',
                                                   Lang.bind(this, this._onActivateResult));


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