[gnome-documents/wip/pranavk/lokdocview: 6/7] Add zoom feature
- From: Pranav Kant <pranavk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents/wip/pranavk/lokdocview: 6/7] Add zoom feature
- Date: Wed, 19 Aug 2015 18:58:40 +0000 (UTC)
commit 2cab4986de9aaee3a096bb3eda72cc4083551e3a
Author: Pranav Kant <pranavk gnome org>
Date: Tue Aug 18 09:45:49 2015 +0530
Add zoom feature
src/application.js | 6 ++++--
src/embed.js | 2 ++
src/lokview.js | 22 ++++++++++++++++++++++
src/preview.js | 4 ++++
4 files changed, 32 insertions(+), 2 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 9a02527..d09ad7d 100644
--- a/src/application.js
+++ b/src/application.js
@@ -572,9 +572,11 @@ const Application = new Lang.Class({
{ name: 'find-prev', accel: '<Shift><Primary>g',
window_mode: WindowMode.WindowMode.PREVIEW },
{ name: 'zoom-in', accels: ['<Primary>plus', '<Primary>equal'],
- window_mode: WindowMode.WindowMode.PREVIEW },
+ window_mode: [WindowMode.WindowMode.PREVIEW,
+ WindowMode.WindowMode.LOKVIEW] },
{ name: 'zoom-out', accel: '<Primary>minus',
- window_mode: WindowMode.WindowMode.PREVIEW },
+ window_mode: [WindowMode.WindowMode.PREVIEW,
+ WindowMode.WindowMode.LOKVIEW] },
{ name: 'rotate-left', accel: '<Primary>Left',
window_mode: WindowMode.WindowMode.PREVIEW },
{ name: 'rotate-right', accel: '<Primary>Right',
diff --git a/src/embed.js b/src/embed.js
index 0b99bd8..9141bd1 100644
--- a/src/embed.js
+++ b/src/embed.js
@@ -485,6 +485,8 @@ const Embed = new Lang.Class({
_prepareForLOKView: function() {
if (this._preview)
this._preview.setModel(null);
+ if (this._edit)
+ this._edit.setUri(null);
if (this._toolbar)
this._toolbar.destroy();
diff --git a/src/lokview.js b/src/lokview.js
index c2c4386..c94cc09 100644
--- a/src/lokview.js
+++ b/src/lokview.js
@@ -68,11 +68,30 @@ const LOKView = new Lang.Class({
this.show_all();
+ this._zoomIn = Application.application.lookup_action('zoom-in');
+ let zoomInId = this._zoomIn.connect('activate', Lang.bind(this,
+ function() {
+ let zoomLevel = this.view.get_zoom();
+ this.view.set_zoom(zoomLevel * 2);
+ }));
+
+ this._zoomOut = Application.application.lookup_action('zoom-out');
+ let zoomOutId = this._zoomOut.connect('activate', Lang.bind(this,
+ function() {
+ let zoomLevel = this.view.get_zoom();
+ this.view.set_zoom(zoomLevel / 2);
+ }));
+
Application.documentManager.connect('load-started',
Lang.bind(this, this._onLoadStarted));
Application.documentManager.connect('load-finished',
Lang.bind(this, this._onLoadFinished));
+ this.connect('destroy', Lang.bind(this,
+ function() {
+ this._zoomIn.disconnect(zoomInId);
+ this._zoomOut.disconnect(zoomOutId);
+ }));
},
_onLoadStarted: function() {
@@ -122,6 +141,9 @@ const LOKViewToolbar = new Lang.Class({
this._gearMenu = Application.application.lookup_action('gear-menu');
this._gearMenu.enabled = true;
+ this._lokView._zoomIn.enabled = true;
+ this._lokView._zoomOut.enabled = true;
+
// back button, on the left of the toolbar
let backButton = this.addBackButton();
backButton.connect('clicked', Lang.bind(this,
diff --git a/src/preview.js b/src/preview.js
index 1e78b86..52d8f50 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -100,6 +100,8 @@ const PreviewView = new Lang.Class({
this._zoomIn = Application.application.lookup_action('zoom-in');
let zoomInId = this._zoomIn.connect('activate', Lang.bind(this,
function() {
+ if (!this._model)
+ return;
this._model.set_sizing_mode(EvView.SizingMode.FREE);
this.view.zoom_in();
}));
@@ -107,6 +109,8 @@ const PreviewView = new Lang.Class({
this._zoomOut = Application.application.lookup_action('zoom-out');
let zoomOutId = this._zoomOut.connect('activate', Lang.bind(this,
function() {
+ if (!this._model)
+ return;
this._model.set_sizing_mode(EvView.SizingMode.FREE);
this.view.zoom_out();
}));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]