[gnome-documents] documents: factor out a common function



commit 1b1346ff677de96f119eb9a6f78a93125b1de45e
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Thu Mar 30 18:49:40 2017 -0700

    documents: factor out a common function

 src/documents.js |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)
---
diff --git a/src/documents.js b/src/documents.js
index cb56c70..eae3071 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -1388,6 +1388,15 @@ const DocumentManager = new Lang.Class({
         Application.modeController.setWindowMode(windowMode);
     },
 
+    _loadActiveItem: function(passwd) {
+        let doc = this.getActiveItem();
+
+        this._loaderCancellable = new Gio.Cancellable();
+        this._requestPreview(doc);
+        this.emit('load-started', doc);
+        doc.load(passwd, this._loaderCancellable, Lang.bind(this, this._onDocumentLoaded));
+    },
+
     reloadActiveItem: function(passwd) {
         let doc = this.getActiveItem();
 
@@ -1400,10 +1409,7 @@ const DocumentManager = new Lang.Class({
         // cleanup any state we have for previously loaded model
         this._clearActiveDocModel();
 
-        this._loaderCancellable = new Gio.Cancellable();
-        this._requestPreview(doc);
-        this.emit('load-started', doc);
-        doc.load(passwd, this._loaderCancellable, Lang.bind(this, this._onDocumentLoaded));
+        this._loadActiveItem(passwd);
     },
 
     removeItemById: function(id) {
@@ -1459,10 +1465,7 @@ const DocumentManager = new Lang.Class({
             let recentManager = Gtk.RecentManager.get_default();
             recentManager.add_item(doc.uri);
 
-            this._loaderCancellable = new Gio.Cancellable();
-            this._requestPreview(doc);
-            this.emit('load-started', doc);
-            doc.load(null, this._loaderCancellable, Lang.bind(this, this._onDocumentLoaded));
+            this._loadActiveItem(null);
         }
 
         return retval;


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