|
|
7cec7b |
From 777c70d64c13e3a362a7f5516a9c1408a96999a8 Mon Sep 17 00:00:00 2001
|
|
|
7cec7b |
From: Debarshi Ray <debarshir@gnome.org>
|
|
|
7cec7b |
Date: Wed, 6 Jun 2018 13:04:47 +0200
|
|
|
7cec7b |
Subject: [PATCH 1/2] documents: Thumbnail PDF SkydriveDocuments once loaded
|
|
|
7cec7b |
MIME-Version: 1.0
|
|
|
7cec7b |
Content-Type: text/plain; charset=UTF-8
|
|
|
7cec7b |
Content-Transfer-Encoding: 8bit
|
|
|
7cec7b |
|
|
|
7cec7b |
Historically, unlike GoogleDocuments, we were unable to fetch
|
|
|
7cec7b |
server-side thumbnails for SkydriveDocuments due to limitations of
|
|
|
7cec7b |
OneDrive's REST API. Newer versions of the REST API do support it [1],
|
|
|
7cec7b |
but it is not implemented in libzapojit.
|
|
|
7cec7b |
|
|
|
7cec7b |
To work around those limitations, we try to use a cached copy of the
|
|
|
7cec7b |
document as source for the thumbnail. Since a cached copy is likely to
|
|
|
7cec7b |
be present right after a document has been loaded, we retry the
|
|
|
7cec7b |
thumbnailing if we hadn't succeeded before.
|
|
|
7cec7b |
|
|
|
7cec7b |
Even if we can fetch thumbnails from the server in future, these would
|
|
|
7cec7b |
still be nice optimizations to have — reduces network consumption and
|
|
|
7cec7b |
offers a cheap way to jump ahead in the thumbnailing queue.
|
|
|
7cec7b |
|
|
|
7cec7b |
[1] https://dev.onedrive.com/items/thumbnails.htm
|
|
|
7cec7b |
|
|
|
7cec7b |
https://bugzilla.gnome.org/show_bug.cgi?id=780613
|
|
|
7cec7b |
---
|
|
|
7cec7b |
src/documents.js | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
|
|
|
7cec7b |
1 file changed, 102 insertions(+), 2 deletions(-)
|
|
|
7cec7b |
|
|
|
7cec7b |
diff --git a/src/documents.js b/src/documents.js
|
|
|
7cec7b |
index a4a580f39d63..823cfabd74c3 100644
|
|
|
7cec7b |
--- a/src/documents.js
|
|
|
7cec7b |
+++ b/src/documents.js
|
|
|
7cec7b |
@@ -447,7 +447,16 @@ const DocCommon = new Lang.Class({
|
|
|
7cec7b |
return;
|
|
|
7cec7b |
}
|
|
|
7cec7b |
|
|
|
7cec7b |
- this.loadLocal(passwd, cancellable, callback);
|
|
|
7cec7b |
+ this.loadLocal(passwd, cancellable, Lang.bind(this,
|
|
|
7cec7b |
+ function(doc, docModel, error) {
|
|
|
7cec7b |
+ if (error) {
|
|
|
7cec7b |
+ callback(this, null, error);
|
|
|
7cec7b |
+ return;
|
|
|
7cec7b |
+ }
|
|
|
7cec7b |
+
|
|
|
7cec7b |
+ callback(this, docModel, null);
|
|
|
7cec7b |
+ this.postLoad(docModel);
|
|
|
7cec7b |
+ }));
|
|
|
7cec7b |
}));
|
|
|
7cec7b |
} else {
|
|
|
7cec7b |
callback(this, null, error);
|
|
|
7cec7b |
@@ -457,10 +466,14 @@ const DocCommon = new Lang.Class({
|
|
|
7cec7b |
}
|
|
|
7cec7b |
|
|
|
7cec7b |
callback(this, docModel, null);
|
|
|
7cec7b |
+ this.postLoad(docModel);
|
|
|
7cec7b |
}));
|
|
|
7cec7b |
}));
|
|
|
7cec7b |
},
|
|
|
7cec7b |
|
|
|
7cec7b |
+ postLoad: function(docModel) {
|
|
|
7cec7b |
+ },
|
|
|
7cec7b |
+
|
|
|
7cec7b |
canEdit: function() {
|
|
|
7cec7b |
throw(new Error('DocCommon implementations must override canEdit'));
|
|
|
7cec7b |
},
|
|
|
7cec7b |
@@ -1299,7 +1312,7 @@ const SkydriveDocument = new Lang.Class({
|
|
|
7cec7b |
Extends: DocCommon,
|
|
|
7cec7b |
|
|
|
7cec7b |
_init: function(cursor) {
|
|
|
7cec7b |
- this._failedThumbnailing = true;
|
|
|
7cec7b |
+ this._failedThumbnailing = false;
|
|
|
7cec7b |
|
|
|
7cec7b |
this.parent(cursor);
|
|
|
7cec7b |
|
|
|
7cec7b |
@@ -1323,6 +1336,54 @@ const SkydriveDocument = new Lang.Class({
|
|
|
7cec7b |
this.uriToLoad = localFile.get_uri();
|
|
|
7cec7b |
},
|
|
|
7cec7b |
|
|
|
7cec7b |
+ _createThumbnailFromEvDocument: function(evDoc, cancellable, callback) {
|
|
|
7cec7b |
+ let thumbnailPath = GnomeDesktop.desktop_thumbnail_path_for_uri (this.uri,
|
|
|
7cec7b |
+ GnomeDesktop.DesktopThumbnailSize.LARGE);
|
|
|
7cec7b |
+ let thumbnailFile = Gio.File.new_for_path(thumbnailPath);
|
|
|
7cec7b |
+
|
|
|
7cec7b |
+ let thumbnailDir = GLib.path_get_dirname(thumbnailPath);
|
|
|
7cec7b |
+ GLib.mkdir_with_parents(thumbnailDir, 448);
|
|
|
7cec7b |
+
|
|
|
7cec7b |
+ thumbnailFile.replace_async(null,
|
|
|
7cec7b |
+ false,
|
|
|
7cec7b |
+ Gio.FileCreateFlags.PRIVATE,
|
|
|
7cec7b |
+ GLib.PRIORITY_DEFAULT,
|
|
|
7cec7b |
+ cancellable,
|
|
|
7cec7b |
+ Lang.bind(this,
|
|
|
7cec7b |
+ function(source, res) {
|
|
|
7cec7b |
+ let outputStream;
|
|
|
7cec7b |
+
|
|
|
7cec7b |
+ try {
|
|
|
7cec7b |
+ outputStream = thumbnailFile.replace_finish(res);
|
|
|
7cec7b |
+ } catch (e) {
|
|
|
7cec7b |
+ callback(e);
|
|
|
7cec7b |
+ return;
|
|
|
7cec7b |
+ }
|
|
|
7cec7b |
+
|
|
|
7cec7b |
+ let [width, height] = evDoc.get_page_size(0);
|
|
|
7cec7b |
+ let maxDimension = Math.max(width, height);
|
|
|
7cec7b |
+ let scale = Application.application.getScaleFactor();
|
|
|
7cec7b |
+ let size = 128 * scale;
|
|
|
7cec7b |
+ let zoom = size / maxDimension;
|
|
|
7cec7b |
+
|
|
|
7cec7b |
+ let page = evDoc.get_page(0);
|
|
|
7cec7b |
+
|
|
|
7cec7b |
+ let rc = EvDocument.RenderContext.new(page, 0, zoom);
|
|
|
7cec7b |
+ let pixbuf = evDoc.get_thumbnail(rc);
|
|
|
7cec7b |
+ pixbuf.save_to_streamv_async(outputStream, "png", [], [], cancellable, Lang.bind(this,
|
|
|
7cec7b |
+ function(source, res) {
|
|
|
7cec7b |
+ try {
|
|
|
7cec7b |
+ GdkPixbuf.Pixbuf.save_to_stream_finish(res);
|
|
|
7cec7b |
+ } catch (e) {
|
|
|
7cec7b |
+ callback(e);
|
|
|
7cec7b |
+ return;
|
|
|
7cec7b |
+ }
|
|
|
7cec7b |
+
|
|
|
7cec7b |
+ callback(null);
|
|
|
7cec7b |
+ }));
|
|
|
7cec7b |
+ }));
|
|
|
7cec7b |
+ },
|
|
|
7cec7b |
+
|
|
|
7cec7b |
_createZpjEntry: function(cancellable, callback) {
|
|
|
7cec7b |
let source = Application.sourceManager.getItemById(this.resourceUrn);
|
|
|
7cec7b |
|
|
|
7cec7b |
@@ -1405,6 +1466,45 @@ const SkydriveDocument = new Lang.Class({
|
|
|
7cec7b |
}));
|
|
|
7cec7b |
},
|
|
|
7cec7b |
|
|
|
7cec7b |
+ postLoad: function(docModel) {
|
|
|
7cec7b |
+ if (this._thumbPath)
|
|
|
7cec7b |
+ return;
|
|
|
7cec7b |
+
|
|
|
7cec7b |
+ this._failedThumbnailing = false;
|
|
|
7cec7b |
+ this.refreshIcon();
|
|
|
7cec7b |
+ },
|
|
|
7cec7b |
+
|
|
|
7cec7b |
+ createThumbnail: function(callback) {
|
|
|
7cec7b |
+ // try loading from the most recent cache, if any
|
|
|
7cec7b |
+ this.loadLocal(null, null, Lang.bind(this,
|
|
|
7cec7b |
+ function(doc, docModel, error) {
|
|
|
7cec7b |
+ if (error) {
|
|
|
7cec7b |
+ if (!error.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.NOT_FOUND) &&
|
|
|
7cec7b |
+ !error.matches(EvDocument.DocumentError, EvDocument.DocumentError.ENCRYPTED)) {
|
|
|
7cec7b |
+ logError(error, 'Unable to load document from the cache');
|
|
|
7cec7b |
+ callback(false);
|
|
|
7cec7b |
+ return;
|
|
|
7cec7b |
+ }
|
|
|
7cec7b |
+ }
|
|
|
7cec7b |
+
|
|
|
7cec7b |
+ if (!docModel) {
|
|
|
7cec7b |
+ callback(false);
|
|
|
7cec7b |
+ return;
|
|
|
7cec7b |
+ }
|
|
|
7cec7b |
+
|
|
|
7cec7b |
+ this._createThumbnailFromEvDocument(docModel.document, null, Lang.bind(this,
|
|
|
7cec7b |
+ function(error) {
|
|
|
7cec7b |
+ if (error) {
|
|
|
7cec7b |
+ logError(error, 'Unable to create thumbnail from EvDocument');
|
|
|
7cec7b |
+ callback(false);
|
|
|
7cec7b |
+ return;
|
|
|
7cec7b |
+ }
|
|
|
7cec7b |
+
|
|
|
7cec7b |
+ callback(true);
|
|
|
7cec7b |
+ }));
|
|
|
7cec7b |
+ }));
|
|
|
7cec7b |
+ },
|
|
|
7cec7b |
+
|
|
|
7cec7b |
updateTypeDescription: function() {
|
|
|
7cec7b |
let description;
|
|
|
7cec7b |
|
|
|
7cec7b |
--
|
|
|
7cec7b |
2.14.4
|
|
|
7cec7b |
|
|
|
7cec7b |
|
|
|
7cec7b |
From 8591dcde011558c26c789c010f5b78cd806cf34b Mon Sep 17 00:00:00 2001
|
|
|
7cec7b |
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
|
|
|
7cec7b |
Date: Mon, 8 May 2017 16:44:32 +0100
|
|
|
7cec7b |
Subject: [PATCH 2/2] lokview: Fix crash on repeated open of presentations
|
|
|
7cec7b |
|
|
|
7cec7b |
Ensure prompt destruction of the LOKDocView widget when the view is
|
|
|
7cec7b |
destroyed. This gives LOK a chance to shutdown at the right time.
|
|
|
7cec7b |
|
|
|
7cec7b |
https://bugzilla.gnome.org/show_bug.cgi?id=782508
|
|
|
7cec7b |
---
|
|
|
7cec7b |
src/lokview.js | 12 ++++++++++--
|
|
|
7cec7b |
1 file changed, 10 insertions(+), 2 deletions(-)
|
|
|
7cec7b |
|
|
|
7cec7b |
diff --git a/src/lokview.js b/src/lokview.js
|
|
|
7cec7b |
index dfa0b9628735..49bacabd28e7 100644
|
|
|
7cec7b |
--- a/src/lokview.js
|
|
|
7cec7b |
+++ b/src/lokview.js
|
|
|
7cec7b |
@@ -139,11 +139,19 @@ var LOKView = new Lang.Class({
|
|
|
7cec7b |
this._lokview.connect('text-selection', Lang.bind(this, this._onTextSelection));
|
|
|
7cec7b |
this._lokview.connect('notify::can-zoom-in', Lang.bind(this, this._onCanZoomInChanged));
|
|
|
7cec7b |
this._lokview.connect('notify::can-zoom-out', Lang.bind(this, this._onCanZoomOutChanged));
|
|
|
7cec7b |
+ this.connect('destroy', Lang.bind(this, this._destroyView));
|
|
|
7cec7b |
}
|
|
|
7cec7b |
|
|
|
7cec7b |
return sw;
|
|
|
7cec7b |
},
|
|
|
7cec7b |
|
|
|
7cec7b |
+ _destroyView: function() {
|
|
|
7cec7b |
+ if (this._lokview) {
|
|
|
7cec7b |
+ this._lokview.destroy();
|
|
|
7cec7b |
+ this._lokview = null;
|
|
|
7cec7b |
+ }
|
|
|
7cec7b |
+ },
|
|
|
7cec7b |
+
|
|
|
7cec7b |
onLoadFinished: function(manager, doc) {
|
|
|
7cec7b |
this.parent(manager, doc);
|
|
|
7cec7b |
|
|
|
7cec7b |
@@ -239,10 +247,10 @@ var LOKView = new Lang.Class({
|
|
|
7cec7b |
},
|
|
|
7cec7b |
|
|
|
7cec7b |
get page() {
|
|
|
7cec7b |
- return this._lokview.get_part();
|
|
|
7cec7b |
+ return this._lokview ? this._lokview.get_part() : 0;
|
|
|
7cec7b |
},
|
|
|
7cec7b |
|
|
|
7cec7b |
get numPages() {
|
|
|
7cec7b |
- return this._lokview.get_parts();
|
|
|
7cec7b |
+ return this._lokview ? this._lokview.get_parts() : 0;
|
|
|
7cec7b |
}
|
|
|
7cec7b |
});
|
|
|
7cec7b |
--
|
|
|
7cec7b |
2.14.4
|
|
|
7cec7b |
|