[gnome-books] epubview: Remember zoom level across runs



commit e33f3a985b6a25bcde4c6a9b71a24ba9fbf3d569
Author: IBBoard <dev ibboard co uk>
Date:   Fri Apr 19 18:54:57 2019 +0100

    epubview: Remember zoom level across runs
    
    This helps make books readable without having to zoom to the
    right level each time you open them.

 src/epubview.js | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/src/epubview.js b/src/epubview.js
index 84ae32d7..eb6cf898 100644
--- a/src/epubview.js
+++ b/src/epubview.js
@@ -138,6 +138,12 @@ var EPUBView = new Lang.Class({
         if (res)
             this._epubdoc.chapter = val;
 
+        [res, val] = metadata.get_double('zoom');
+        if (res) {
+            this._setZoomLevel(val);
+            this._updateZoomActions();
+        }
+
         return metadata;
     },
 
@@ -246,7 +252,7 @@ var EPUBView = new Lang.Class({
         let level = this.view.get_zoom_level();
         if (level <= ZOOM_LEVEL_MIN)
             return;
-        this.view.set_zoom_level(Math.max(level - ZOOM_LEVEL_STEP, ZOOM_LEVEL_MIN));
+        this._setZoomLevel(Math.max(level - ZOOM_LEVEL_STEP, ZOOM_LEVEL_MIN));
         this._updateZoomActions();
     },
 
@@ -254,13 +260,19 @@ var EPUBView = new Lang.Class({
         let level = this.view.get_zoom_level();
         if (level >= ZOOM_LEVEL_MAX)
             return;
-        this.view.set_zoom_level(Math.min(level + ZOOM_LEVEL_STEP, ZOOM_LEVEL_MAX));
+        this._setZoomLevel(Math.min(level + ZOOM_LEVEL_STEP, ZOOM_LEVEL_MAX));
         this._updateZoomActions();
     },
 
     _resetZoom: function() {
-        this.view.set_zoom_level(ZOOM_LEVEL_DEFAULT);
+        this._setZoomLevel(ZOOM_LEVEL_DEFAULT);
         this._updateZoomActions();
+    },
+
+    _setZoomLevel: function(val) {
+        this.view.set_zoom_level(val);
+        if (this._metadata)
+            this._metadata.set_double('zoom', val);
     }
 });
 


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