[gnome-maps] mapView: Save map type between runs



commit cd99ef6ce4a4ecc6b06977c51b2fd213e73a8841
Author: James Westman <flyingpimonster flyingpimonster net>
Date:   Thu Aug 1 14:06:55 2019 -0500

    mapView: Save map type between runs

 data/org.gnome.Maps.gschema.xml |  5 +++++
 src/layersPopover.js            |  2 ++
 src/mainWindow.js               |  2 +-
 src/mapView.js                  | 21 ++++++++++++++++++++-
 4 files changed, 28 insertions(+), 2 deletions(-)
---
diff --git a/data/org.gnome.Maps.gschema.xml b/data/org.gnome.Maps.gschema.xml
index dae9ad9..133478d 100644
--- a/data/org.gnome.Maps.gschema.xml
+++ b/data/org.gnome.Maps.gschema.xml
@@ -16,6 +16,11 @@
       <summary>zoom</summary>
       <description>Zoom level</description>
     </key>
+    <key name="map-type" type="s">
+      <default>"MapsStreetSource"</default>
+      <summary>Map type</summary>
+      <description>The type of map to display (street, aerial, etc.)</description>
+    </key>
     <key name="window-size" type="ai">
       <default>[768, 600]</default>
       <summary>Window size</summary>
diff --git a/src/layersPopover.js b/src/layersPopover.js
index 0d79748..4566482 100644
--- a/src/layersPopover.js
+++ b/src/layersPopover.js
@@ -125,6 +125,8 @@ var LayersPopover = GObject.registerClass({
             this._streetLayerButton.visible = false;
             this._aerialLayerButton.visible = false;
         }
+
+        this.setMapType(this._mapView.getMapType());
     }
 
     _setLayerPreviews() {
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 5b0b6e9..0d8b138 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -101,7 +101,7 @@ var MainWindow = GObject.registerClass({
 
         this._mapView = new MapView.MapView({
             mapType: this.application.local_tile_path ?
-                MapView.MapType.LOCAL : MapView.MapType.STREET,
+                MapView.MapType.LOCAL : undefined,
             mainWindow: this });
 
         this._mainGrid.add(this._mapView);
diff --git a/src/mapView.js b/src/mapView.js
index fc9388f..d447c70 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -140,7 +140,7 @@ var MapView = GObject.registerClass({
     _init(params) {
         super._init();
 
-        let mapType = params.mapType || MapType.STREET;
+        let mapType = params.mapType || this._getStoredMapType();
         delete params.mapType;
 
         this._mainWindow = params.mainWindow;
@@ -296,6 +296,23 @@ var MapView = GObject.registerClass({
         query.connect('notify', () => this.routingOpen = query.isValid());
     }
 
+    _getStoredMapType() {
+        let mapType = Application.settings.get('map-type');
+
+        // make sure it's a valid map type
+        for (let type in MapType) {
+            if (mapType === MapType[type]) {
+                return mapType;
+            }
+        }
+
+        return MapType.STREET;
+    }
+
+    getMapType() {
+        return this._mapType;
+    }
+
     setMapType(mapType) {
         if (this._mapType && this._mapType === mapType)
             return;
@@ -314,6 +331,8 @@ var MapView = GObject.registerClass({
                 this._attribution = new MapSource.AttributionLogo(this.view);
                 this.view.add_child(this._attribution);
             }
+
+            Application.settings.set('map-type', mapType);
         } else {
             let renderer = new Champlain.ImageRenderer();
             let source = new Maps.FileTileSource({


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