[gnome-documents] lokview: Clamp zoom levels the same way as the Evince view
- From: Pranav Kant <pranavk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] lokview: Clamp zoom levels the same way as the Evince view
- Date: Wed, 20 Jan 2016 13:43:48 +0000 (UTC)
commit a7c3fd5c0ff5e9bd17521e656e44e347ef702ce7
Author: Bastien Nocera <hadess hadess net>
Date: Tue Dec 15 17:44:22 2015 +0100
lokview: Clamp zoom levels the same way as the Evince view
https://bugzilla.gnome.org/show_bug.cgi?id=753686
src/lokview.js | 23 +++++++++++++++++++----
1 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/src/lokview.js b/src/lokview.js
index 4cc8eab..c23add9 100644
--- a/src/lokview.js
+++ b/src/lokview.js
@@ -49,6 +49,9 @@ const View = imports.view;
const WindowMode = imports.windowMode;
const Documents = imports.documents;
+const ZOOM_IN_FACTOR = 1.2;
+const ZOOM_OUT_FACTOR = (1.0/ZOOM_IN_FACTOR);
+
const openDocumentFormats = ['application/vnd.oasis.opendocument.text',
'application/vnd.oasis.opendocument.text-template',
'application/vnd.oasis.opendocument.text-web',
@@ -121,17 +124,21 @@ const LOKView = new Lang.Class({
this.show_all();
this._zoomIn = Application.application.lookup_action('zoom-in');
+ this.view.connect('notify::can-zoom-in', Lang.bind(this,
+ this._onCanZoomInChanged));
let zoomInId = this._zoomIn.connect('activate', Lang.bind(this,
function() {
- let zoomLevel = this.view.get_zoom();
- this.view.set_zoom(zoomLevel * 2);
+ let zoomLevel = this.view.get_zoom() * ZOOM_IN_FACTOR;
+ this.view.set_zoom(zoomLevel);
}));
this._zoomOut = Application.application.lookup_action('zoom-out');
+ this.view.connect('notify::can-zoom-out', Lang.bind(this,
+ this._onCanZoomOutChanged));
let zoomOutId = this._zoomOut.connect('activate', Lang.bind(this,
function() {
- let zoomLevel = this.view.get_zoom();
- this.view.set_zoom(zoomLevel / 2);
+ let zoomLevel = this.view.get_zoom() * ZOOM_OUT_FACTOR;
+ this.view.set_zoom(zoomLevel);
}));
this._copy = Application.application.lookup_action('copy');
@@ -150,6 +157,14 @@ const LOKView = new Lang.Class({
}));
},
+ _onCanZoomInChanged: function() {
+ this._zoomIn.enabled = this.view.can_zoom_in;
+ },
+
+ _onCanZoomOutChanged: function() {
+ this._zoomOut.enabled = this.view.can_zoom_out;
+ },
+
_onCopyActivated: function() {
let [selectedText, mimeType] = this.view.copy_selection('text/plain;charset=utf-8');
let display = Gdk.Display.get_default();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]