[gnome-documents/wip/lokdocview-rebase: 2/9] Move LO supported mime-types to the backend
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents/wip/lokdocview-rebase: 2/9] Move LO supported mime-types to the backend
- Date: Fri, 8 Jan 2016 13:02:46 +0000 (UTC)
commit 691e996804efcb08d5d14358dda645fab8308eab
Author: Bastien Nocera <hadess hadess net>
Date: Fri Dec 4 18:17:39 2015 +0100
Move LO supported mime-types to the backend
We'll need to keep it so that it's available when LOK isn't.
src/documents.js | 37 +------------------------------------
src/embed.js | 2 +-
src/lokview.js | 36 +++++++++++++++++++++++++++++++++++-
3 files changed, 37 insertions(+), 38 deletions(-)
---
diff --git a/src/documents.js b/src/documents.js
index 0553c6c..16712c2 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -45,29 +45,6 @@ const Search = imports.search;
const TrackerUtils = imports.trackerUtils;
const Utils = imports.utils;
-const openDocumentFormats = ['application/vnd.oasis.opendocument.text',
- 'application/vnd.oasis.opendocument.text-template',
- 'application/vnd.oasis.opendocument.text-web',
- 'application/vnd.oasis.opendocument.text-master',
- 'application/vnd.oasis.opendocument.graphics',
- 'application/vnd.oasis.opendocument.graphics-template',
- 'application/vnd.oasis.opendocument.presentation',
- 'application/vnd.oasis.opendocument.presentation-template',
- 'application/vnd.oasis.opendocument.spreadsheet',
- 'application/vnd.oasis.opendocument.spreadsheet-template',
- 'application/vnd.oasis.opendocument.chart',
- 'application/vnd.oasis.opendocument.formula',
- 'application/vnd.oasis.opendocument.database',
- 'application/vnd.oasis.opendocument.image',
- 'application/vnd.openofficeorg.extension'];
-
-// These are the documents consisting of document parts.
-const openDocumentPartFormats = ['application/vnd.oasis.opendocument.presentation',
- 'application/vnd.oasis.opendocument.presentation-template',
- 'application/vnd.oasis.opendocument.spreadsheet',
- 'application/vnd.oasis.opendocument.spreadsheet-template',];
-
-
const DeleteItemJob = new Lang.Class({
Name: 'DeleteItemJob',
// deletes the given resource
@@ -690,18 +667,6 @@ const DocCommon = new Lang.Class({
return retval;
},
-
- isOpenDocumentPartDocument: function() {
- if (openDocumentPartFormats.indexOf(this.mimeType) != -1)
- return true;
- return false;
- },
-
- isOpenDocumentFormat: function() {
- if (openDocumentFormats.indexOf(this.mimeType) != -1)
- return true;
- return false;
- }
});
Signals.addSignalMethods(DocCommon.prototype);
@@ -789,7 +754,7 @@ const LocalDocument = new Lang.Class({
return;
}
- if (this.isOpenDocumentFormat() && !Application.application.isBooks) {
+ if (LOKView.isOpenDocumentFormat(this.mimeType) && !Application.application.isBooks) {
let exception = null;
if (!LOKView.isAvailable()) {
exception = new GLib.Error(Gio.IOErrorEnum,
diff --git a/src/embed.js b/src/embed.js
index 822c046..62f12bb 100644
--- a/src/embed.js
+++ b/src/embed.js
@@ -338,7 +338,7 @@ const Embed = new Lang.Class({
},
_onLoadStarted: function(manager, doc) {
- if (doc.isOpenDocumentFormat())
+ if (LOKView.isOpenDocumentFormat(doc.mimeType))
Application.modeController.setWindowMode(WindowMode.WindowMode.PREVIEW_LOK);
else
Application.modeController.setWindowMode(WindowMode.WindowMode.PREVIEW);
diff --git a/src/lokview.js b/src/lokview.js
index f5b0ffc..44ce731 100644
--- a/src/lokview.js
+++ b/src/lokview.js
@@ -49,10 +49,44 @@ const View = imports.view;
const WindowMode = imports.windowMode;
const Documents = imports.documents;
+const openDocumentFormats = ['application/vnd.oasis.opendocument.text',
+ 'application/vnd.oasis.opendocument.text-template',
+ 'application/vnd.oasis.opendocument.text-web',
+ 'application/vnd.oasis.opendocument.text-master',
+ 'application/vnd.oasis.opendocument.graphics',
+ 'application/vnd.oasis.opendocument.graphics-template',
+ 'application/vnd.oasis.opendocument.presentation',
+ 'application/vnd.oasis.opendocument.presentation-template',
+ 'application/vnd.oasis.opendocument.spreadsheet',
+ 'application/vnd.oasis.opendocument.spreadsheet-template',
+ 'application/vnd.oasis.opendocument.chart',
+ 'application/vnd.oasis.opendocument.formula',
+ 'application/vnd.oasis.opendocument.database',
+ 'application/vnd.oasis.opendocument.image',
+ 'application/vnd.openofficeorg.extension'];
+
+// These are the documents consisting of document parts.
+const openDocumentPartFormats = ['application/vnd.oasis.opendocument.presentation',
+ 'application/vnd.oasis.opendocument.presentation-template',
+ 'application/vnd.oasis.opendocument.spreadsheet',
+ 'application/vnd.oasis.opendocument.spreadsheet-template',];
+
function isAvailable() {
return (LOKDocView != undefined);
}
+function isOpenDocumentPartDocument(mimeType) {
+ if (openDocumentPartFormats.indexOf(mimeType) != -1)
+ return true;
+ return false;
+}
+
+function isOpenDocumentFormat(mimeType) {
+ if (openDocumentFormats.indexOf(mimeType) != -1)
+ return true;
+ return false;
+}
+
const LOKView = new Lang.Class({
Name: 'LOKView',
Extends: Gtk.Stack,
@@ -119,7 +153,7 @@ const LOKView = new Lang.Class({
open_document_cb: function(res, doc) {
// TODO: Call _finish and check failure
- if (this._doc.isOpenDocumentPartDocument()) {
+ if (isOpenDocumentPartDocument(this._doc.mimeType)) {
this.hasParts = true;
this.totalParts = this.view.get_parts();
this.currentPart = this.view.get_part();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]