[gnome-documents] preview: Simplify the load-finished logic



commit 4a7d0c7610061ce6d287a597c002c64b05480514
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Mar 3 10:53:03 2015 +0100

    preview: Simplify the load-finished logic
    
    Instead of having PreviewView react to load-finished in two different
    steps - once in its own handler, and then from Embed's handler, let's
    consolidate everything in one place.
    
    It is hard to know the order in which these handlers are getting
    called. If it changed, the logic for showing or hiding the places and
    bookmarks controls will break.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=745507

 src/preview.js |   19 +++++--------------
 1 files changed, 5 insertions(+), 14 deletions(-)
---
diff --git a/src/preview.js b/src/preview.js
index db3d6d9..2deac71 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -138,8 +138,6 @@ const PreviewView = new Lang.Class({
 
         Application.documentManager.connect('load-started',
                                             Lang.bind(this, this._onLoadStarted));
-        Application.documentManager.connect('load-finished',
-                                            Lang.bind(this, this._onLoadFinished));
         Application.documentManager.connect('load-error',
                                             Lang.bind(this, this._onLoadError));
     },
@@ -150,18 +148,6 @@ const PreviewView = new Lang.Class({
         this._copy.enabled = false;
     },
 
-    _onLoadFinished: function(manager, doc, docModel) {
-        this._showPlaces.enabled = true;
-        this._togglePresentation.enabled = true;
-        this._navControls.show();
-
-        if (!Application.documentManager.metadata)
-            return;
-
-        this._bookmarks = new GdPrivate.Bookmarks({ metadata: Application.documentManager.metadata });
-        this._bookmarkPage.enabled = true;
-    },
-
     _onLoadError: function(manager, doc, message, exception) {
         this._controlsVisible = true;
 
@@ -537,6 +523,11 @@ const PreviewView = new Lang.Class({
         if (this._model) {
             this.view.set_model(this._model);
             this._navControls.setModel(model);
+            this._navControls.show();
+            this._togglePresentation.enabled = true;
+
+            if (Application.documentManager.metadata)
+                this._bookmarks = new GdPrivate.Bookmarks({ metadata: Application.documentManager.metadata 
});
 
             let hasMultiplePages = (this._model.document.get_n_pages() > 1);
             this._bookmarkPage.enabled = hasMultiplePages && this._bookmarks;


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