[gnome-documents] Don't show a glimpse of the older item when going back to the preview



commit 71a559aae60e17ed791532d0a018b318330abf6e
Author: Debarshi Ray <debarshir gnome org>
Date:   Mon Oct 6 18:13:44 2014 +0200

    Don't show a glimpse of the older item when going back to the preview
    
    Now that we switch to the preview as soon as an item starts loading, we
    should take care to clear any older item that might have been previewed
    earlier.
    
    Since EvView does not allow unsetting the model (by passing NULL), we
    destroy the old widget and create a new one. We do the same for the
    NavControls because of GdNavBar.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=720516

 src/embed.js   |    2 +-
 src/preview.js |   18 +++++++++++++++---
 2 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/src/embed.js b/src/embed.js
index 13312cb..82c3fea 100644
--- a/src/embed.js
+++ b/src/embed.js
@@ -431,7 +431,7 @@ const Embed = new Lang.Class({
 
     _prepareForOverview: function() {
         if (this._preview)
-            this._preview.setModel(null);
+            this._preview.reset();
         if (this._edit)
             this._edit.setUri(null);
         if (this._toolbar)
diff --git a/src/preview.js b/src/preview.js
index 9431b8b..878925c 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -80,9 +80,6 @@ const PreviewView = new Lang.Class({
         this._previewContextMenu = Gtk.Menu.new_from_model(model);
         this._previewContextMenu.attach_to_widget(this.widget, null);
 
-        // create page nav controls
-        this._navControls = new PreviewNavControls(this, this._overlay);
-
         this.widget.show_all();
 
         this._bookmarkPage = Application.application.lookup_action('bookmark-page');
@@ -339,6 +336,8 @@ const PreviewView = new Lang.Class({
             this._onViewSelectionChanged));
         this.view.connect('external-link', Lang.bind(this,
             this._handleExternalLink));
+
+        this._navControls = new PreviewNavControls(this, this._overlay);
     },
 
     _getPreviewContextMenu: function() {
@@ -504,6 +503,13 @@ const PreviewView = new Lang.Class({
         this.emit('search-changed', job.has_results());
     },
 
+    reset: function() {
+        this.setModel(null);
+        this.view.destroy();
+        this._navControls.destroy();
+        this._createView();
+    },
+
     setModel: function(model) {
         if (this._model == model)
             return;
@@ -740,6 +746,12 @@ const PreviewNavControls = new Lang.Class({
     hide: function() {
         this._visible = false;
         this._updateVisibility();
+    },
+
+    destroy: function() {
+        this.bar_widget.destroy();
+        this.prev_widget.destroy();
+        this.next_widget.destroy();
     }
 });
 


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