[gnome-maps/wip/mlundblad/scale-visible-setting: 4/4] mapView: Store scale visibility in gsettings




commit d502d9469c8178c89e9513c02ef9b8200c3badee
Author: Marcus Lundblad <ml dfupdate se>
Date:   Wed Mar 2 23:24:31 2022 +0100

    mapView: Store scale visibility in gsettings
    
    Track visibility of the scale in a setting,
    so that the state is preserved between launches
    rather than always starting as visible.

 src/mapView.js | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/src/mapView.js b/src/mapView.js
index fef736c2..8ead5916 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -175,7 +175,9 @@ var MapView = GObject.registerClass({
     }
 
     _initScale(view) {
-        this._scale = new Champlain.Scale({ visible: true });
+        let showScale = Application.settings.get('show-scale');
+
+        this._scale = new Champlain.Scale({ visible: showScale });
         this._scale.connect_view(view);
 
         if (Utils.getMeasurementSystem() === Utils.METRIC_SYSTEM)
@@ -225,6 +227,9 @@ var MapView = GObject.registerClass({
         this._gtkSettings.connect('notify::gtk-application-prefer-dark-theme',
                             this._onPreferDarkThemeChanged.bind(this));
 
+        Application.settings.connect('changed::show-scale',
+                                     this._onShowScaleChanged.bind(this));
+
         this._initScale(view);
         return view;
     }
@@ -471,7 +476,13 @@ var MapView = GObject.registerClass({
     }
 
     toggleScale() {
-        this._scale.visible = !this._scale.visible;
+        let showScale = Application.settings.get('show-scale');
+
+        Application.settings.set('show-scale', !showScale);
+    }
+
+    _onShowScaleChanged() {
+        this._scale.visible = Application.settings.get('show-scale');
     }
 
     _checkIfFileSizeNeedsConfirmation(files) {


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