[gnome-documents/wip/epub-colors: 2/3] epub: use zoom-in/zoom-out actions for text size



commit 0cf3c2974e2a0c2b59950101ae2c30b107ce91eb
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Thu Jun 30 08:24:38 2016 -0700

    epub: use zoom-in/zoom-out actions for text size
    
    So that it works out of the box in the existing menu.

 src/epubview.js |   43 +++++++++++++------------------------------
 1 files changed, 13 insertions(+), 30 deletions(-)
---
diff --git a/src/epubview.js b/src/epubview.js
index 70d8120..ba6f865 100644
--- a/src/epubview.js
+++ b/src/epubview.js
@@ -36,16 +36,12 @@ function isEpub(mimeType) {
     return (mimeType == 'application/epub+zip');
 }
 
+const _ZOOM_STEP = 0.2;
+
 const EPUBView = new Lang.Class({
     Name: 'EPUBView',
     Extends: Preview.Preview,
 
-    _init: function(preview) {
-        this.invertedColors = false;
-
-        this.parent(preview);
-    },
-
     createActions: function() {
         return [
             { name: 'find-prev',
@@ -54,18 +50,12 @@ const EPUBView = new Lang.Class({
             { name: 'find-next',
               callback: Lang.bind(this, this.findNext),
               accels: ['<Primary>g'] },
-            { name: 'font-increase',
-              callback: Lang.bind(this, function() {
-                this.increaseFontSize();
-              }) },
-            { name: 'font-decrease',
-              callback: Lang.bind(this, function() {
-                this.decreaseFontSize();
-              }) },
-            { name: 'font-normal',
-              callback: Lang.bind(this, function() {
-                this.defaultFontSize();
-              }) },
+            { name: 'zoom-in',
+              callback: Lang.bind(this, this._zoomIn),
+              accels: ['<Primary>plus', '<Primary>equal'] },
+            { name: 'zoom-out',
+              callback: Lang.bind(this, this._zoomOut),
+              accels: ['<Primary>minus'] },
             { name: 'font-invert-colors',
               callback: Lang.bind(this, function() {
                 this.invertColors();
@@ -80,7 +70,7 @@ const EPUBView = new Lang.Class({
     createView: function() {
         let view = new Gepub.Widget();
         let settings = view.get_settings();
-        settings.set_zoom_text_only(true);
+        settings.zoom_text_only = true;
 
         view.connect('load-changed', Lang.bind(this, function(wview, ev, data) {
             if (ev == WebKit2.LoadEvent.FINISHED) {
@@ -112,9 +102,6 @@ const EPUBView = new Lang.Class({
 
         this.set_visible_child_name('view');
 
-        this.getAction('font-increase').enabled = true;
-        this.getAction('font-decrease').enabled = true;
-        this.getAction('font-normal').enabled = true;
         this.getAction('font-invert-colors').enabled = true;
     },
 
@@ -180,18 +167,14 @@ const EPUBView = new Lang.Class({
         fc.search_previous();
     },
 
-    increaseFontSize: function() {
+    _zoomIn: function() {
         var zoom = this.view.get_zoom_level();
-        this.view.set_zoom_level(zoom + 0.2);
+        this.view.set_zoom_level(zoom + _ZOOM_STEP);
     },
 
-    decreaseFontSize: function() {
+    _zoomOut: function() {
         var zoom = this.view.get_zoom_level();
-        this.view.set_zoom_level(zoom - 0.2);
-    },
-
-    defaultFontSize: function() {
-        this.view.set_zoom_level(1);
+        this.view.set_zoom_level(zoom - _ZOOM_STEP);
     },
 
     setInvertedColors: function() {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]