[gnome-documents/gnome-3-10] preview: The toolbar is created after load-{started, finished}



commit 84eb2f01c3e5ec32c409408b25ea82eec7cd1196
Author: Debarshi Ray <debarshir gnome org>
Date:   Mon Feb 24 10:30:35 2014 +0100

    preview: The toolbar is created after load-{started, finished}
    
    Fallout from cde99212000c2f2b0beb29d66956aad7b791b44e
    
    https://bugzilla.gnome.org/show_bug.cgi?id=700716

 src/preview.js |   34 +++++++++++++++-------------------
 1 files changed, 15 insertions(+), 19 deletions(-)
---
diff --git a/src/preview.js b/src/preview.js
index 2cc40e2..f2daad5 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -817,8 +817,14 @@ const PreviewToolbar = new Lang.Class({
         this.parent();
         this.toolbar.set_show_close_button(true);
 
+        this._handleEvent = false;
+        this._model = null;
+
         this._searchAction = Application.application.lookup_action('search');
+        this._searchAction.enabled = false;
+
         this._gearMenu = Application.application.lookup_action('gear-menu');
+        this._gearMenu.enabled = true;
 
         // back button, on the left of the toolbar
         let backButton = this.addBackButton();
@@ -841,29 +847,17 @@ const PreviewToolbar = new Lang.Class({
         this._setToolbarTitle();
         this.toolbar.show_all();
 
-        let loadStartId =
-            Application.documentManager.connect('load-started',
-                Lang.bind(this, this._onLoadStarted));
-        let loadFinishId =
-            Application.documentManager.connect('load-finished',
-                Lang.bind(this, this._onLoadFinished));
-
-        this.widget.connect('destroy',
+        this.widget.connect('destroy', Lang.bind(this,
             function() {
-                Application.documentManager.disconnect(loadStartId);
-                Application.documentManager.disconnect(loadFinishId);
-            });
-    },
-
-    _onLoadStarted: function() {
-        this._gearMenu.enabled = false;
-        this._searchAction.enabled = false;
+                this._searchAction.enabled = true;
+            }));
     },
 
-    _onLoadFinished: function(manager, doc, docModel) {
-        this._gearMenu.enabled = true;
+    _enableSearch: function() {
+        if (!this._model)
+            return;
 
-        let evDoc = docModel.get_document();
+        let evDoc = this._model.get_document();
         let hasPages = (evDoc.get_n_pages() > 0);
         let isFind = true;
 
@@ -877,6 +871,7 @@ const PreviewToolbar = new Lang.Class({
         } catch (e) {
         }
 
+        this._handleEvent = (hasPages && isFind);
         this._searchAction.enabled = (hasPages && isFind);
     },
 
@@ -914,6 +909,7 @@ const PreviewToolbar = new Lang.Class({
             return;
 
         this._model = model;
+        this._enableSearch();
         this._setToolbarTitle();
     }
 });


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