[gnome-documents/wip/pranavk/lokdocview] WIP/working with lokdocview
- From: Pranav Kant <pranavk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents/wip/pranavk/lokdocview] WIP/working with lokdocview
- Date: Sun, 16 Aug 2015 10:16:44 +0000 (UTC)
commit 9ef95d8bd9fa27744d956fa7e44b30fa26feb5f5
Author: Pranav Kant <pranavk gnome org>
Date: Fri Jun 19 21:08:44 2015 +0530
WIP/working with lokdocview
src/documents.js | 27 ++++++++++++++++++++++++++-
src/embed.js | 19 ++++++++++++-------
src/preview.js | 20 +++++++++++++++++++-
3 files changed, 57 insertions(+), 9 deletions(-)
---
diff --git a/src/documents.js b/src/documents.js
index e5e34b7..a87ae9b 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -44,6 +44,22 @@ const Search = imports.search;
const TrackerUtils = imports.trackerUtils;
const Utils = imports.utils;
+const openofficeFormats = ['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'];
+
const DeleteItemJob = new Lang.Class({
Name: 'DeleteItemJob',
// deletes the given resource
@@ -727,6 +743,11 @@ const LocalDocument = new Lang.Class({
return;
}
+ if (openofficeFormats.indexOf(this.mimeType) != -1) {
+ callback (this, null, null);
+ return;
+ }
+
GdPrivate.pdf_loader_load_uri_async(this.uri, passwd, cancellable, Lang.bind(this,
function(source, res) {
try {
@@ -1305,7 +1326,8 @@ const DocumentManager = new Lang.Class({
// save loaded model and signal
this._activeDocModel = docModel;
- this._activeDocModel.set_continuous(false);
+ if (this._activeDocModel)
+ this._activeDocModel.set_continuous(false);
// load metadata
this._connectMetadata(docModel);
@@ -1421,6 +1443,9 @@ const DocumentManager = new Lang.Class({
},
_connectMetadata: function(docModel) {
+ if (!docModel)
+ return;
+
let evDoc = docModel.get_document();
let file = Gio.File.new_for_uri(evDoc.get_uri());
if (!GdPrivate.is_metadata_supported_for_file(file))
diff --git a/src/embed.js b/src/embed.js
index b9d5e8e..b031915 100644
--- a/src/embed.js
+++ b/src/embed.js
@@ -365,13 +365,18 @@ const Embed = new Lang.Class({
},
_onLoadFinished: function(manager, doc, docModel) {
- if (!Application.application.isBooks)
- docModel.set_sizing_mode(EvView.SizingMode.AUTOMATIC);
- else
- docModel.set_sizing_mode(EvView.SizingMode.FIT_PAGE);
- docModel.set_page_layout(EvView.PageLayout.AUTOMATIC);
- this._toolbar.setModel(docModel);
- this._preview.setModel(docModel);
+ if(docModel) {
+ if (!Application.application.isBooks)
+ docModel.set_sizing_mode(EvView.SizingMode.AUTOMATIC);
+ else
+ docModel.set_sizing_mode(EvView.SizingMode.FIT_PAGE);
+ docModel.set_page_layout(EvView.PageLayout.AUTOMATIC);
+ this._toolbar.setModel(docModel);
+ this._preview.setModel(docModel);
+ } else {
+ this._preview.setDoc(doc);
+ }
+
this._preview.grab_focus();
this._clearLoadTimer();
diff --git a/src/preview.js b/src/preview.js
index 1e78b86..993bf98 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -27,6 +27,7 @@ const Gdk = imports.gi.Gdk;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Gtk = imports.gi.Gtk;
+const LOKDocView = imports.gi.LOKDocView;
const _ = imports.gettext.gettext;
const Lang = imports.lang;
@@ -43,7 +44,6 @@ const Utils = imports.utils;
const View = imports.view;
const WindowMode = imports.windowMode;
const Presentation = imports.presentation;
-
const _FULLSCREEN_TOOLBAR_TIMEOUT = 2; // seconds
const PreviewView = new Lang.Class({
@@ -80,8 +80,11 @@ const PreviewView = new Lang.Class({
this._sw.get_vscrollbar().connect('button-press-event', Lang.bind(this, this._onScrollbarClick));
this._sw.get_hadjustment().connect('value-changed', Lang.bind(this, this._onAdjustmentChanged));
this._sw.get_vadjustment().connect('value-changed', Lang.bind(this, this._onAdjustmentChanged));
+
this.add_named(this._sw, 'view');
+ this.LOKView = LOKDocView.View.new ('/opt/libreoffice/instdir/program', null, null);
+
this._createView();
// create context menu
@@ -539,6 +542,21 @@ const PreviewView = new Lang.Class({
this._createView();
},
+ _documentLoaded: function() {
+ log("LOKDocView: document loading finished");
+ // TODO: Call open_document_finish and check for error
+ },
+
+ setDoc: function (doc) {
+ let location = doc.uri.replace ('file://', '');
+ this.setModel(null);
+ this.view.destroy();
+ this._sw.add (this.LOKView);
+ this.LOKView.open_document (location, null, Lang.bind(this, this._documentLoaded),
+ null);
+ this.LOKView.show();
+ },
+
setModel: function(model) {
if (this._model == model)
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]