[gnome-documents/wip/pranavk/lokdocview: 4/5] Let LOKView has its own window mode
- From: Pranav Kant <pranavk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents/wip/pranavk/lokdocview: 4/5] Let LOKView has its own window mode
- Date: Sun, 16 Aug 2015 17:23:39 +0000 (UTC)
commit d7371fe4bcb4eb76a363ed767d52ac0b884ae0f9
Author: Pranav Kant <pranavk gnome org>
Date: Sun Aug 16 22:23:06 2015 +0530
Let LOKView has its own window mode
This also helps invoking a separate toolbar for LOKView.
src/embed.js | 25 +++++++++++++++++++++++--
src/lokview.js | 6 +++---
src/windowMode.js | 3 ++-
3 files changed, 28 insertions(+), 6 deletions(-)
---
diff --git a/src/embed.js b/src/embed.js
index 8ca5521..0b99bd8 100644
--- a/src/embed.js
+++ b/src/embed.js
@@ -298,6 +298,11 @@ const Embed = new Lang.Class({
Application.documentManager.reloadActiveItem();
this._prepareForPreview();
break;
+ case WindowMode.WindowMode.LOKVIEW:
+ if (oldMode == WindowMode.WindowMode.EDIT)
+ Application.documentManager.reloadActiveItem();
+ this._prepareForLOKView();
+ break;
case WindowMode.WindowMode.EDIT:
this._prepareForEdit();
break;
@@ -354,8 +359,11 @@ const Embed = new Lang.Class({
}
},
- _onLoadStarted: function() {
- Application.modeController.setWindowMode(WindowMode.WindowMode.PREVIEW);
+ _onLoadStarted: function(manager, doc) {
+ if (doc.isOpenDocumentFormat())
+ Application.modeController.setWindowMode(WindowMode.WindowMode.LOKVIEW);
+ else
+ Application.modeController.setWindowMode(WindowMode.WindowMode.PREVIEW);
this._clearLoadTimer();
this._loadShowId = Mainloop.timeout_add(_PDF_LOADER_TIMEOUT, Lang.bind(this,
@@ -474,6 +482,19 @@ const Embed = new Lang.Class({
this._stack.set_visible_child_name('edit');
},
+ _prepareForLOKView: function() {
+ if (this._preview)
+ this._preview.setModel(null);
+ if (this._toolbar)
+ this._toolbar.destroy();
+
+ // pack the toolbar
+ this._toolbar = new LOKView.LOKViewToolbar(this._lokview);
+ this._titlebar.add(this._toolbar);
+
+ this._stack.set_visible_child_name('lokview');
+ },
+
getMainToolbar: function() {
let windowMode = Application.modeController.getWindowMode();
let fullscreen = Application.modeController.getFullscreen();
diff --git a/src/lokview.js b/src/lokview.js
index e126c6c..dab1a01 100644
--- a/src/lokview.js
+++ b/src/lokview.js
@@ -124,16 +124,16 @@ const LOKViewToolbar = new Lang.Class({
backButton.connect('clicked', Lang.bind(this,
function() {
Application.documentManager.setActiveItem(null);
- Application.modeController.goBack(2);
+ Application.modeController.goBack();
}));
let viewButton = new Gtk.Button({ label: _("View"),
action_name: 'app.view-current' });
viewButton.get_style_context().add_class('suggested-action');
- this.toolbar.pack_end(viewButton);
+ //this.toolbar.pack_end(viewButton);
this._setToolbarTitle();
- this.widget.show_all();
+ this.toolbar.show_all();
},
createSearchbar: function() {
diff --git a/src/windowMode.js b/src/windowMode.js
index ce63d9f..108608f 100644
--- a/src/windowMode.js
+++ b/src/windowMode.js
@@ -32,7 +32,8 @@ const WindowMode = {
PREVIEW: 2,
EDIT: 3,
COLLECTIONS: 4,
- SEARCH: 5
+ SEARCH: 5,
+ LOKVIEW: 6
};
const ModeController = new Lang.Class({
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]