diff options
author | Marcus Lundblad <ml@update.uu.se> | 2020-06-21 12:15:43 +0200 |
---|---|---|
committer | Marcus Lundblad <ml@update.uu.se> | 2020-06-24 08:12:52 +0200 |
commit | 4927d9134d457c5f427161c9661b714aaafd56c4 (patch) | |
tree | beb17a9472316b020411520e1a6506ab9f102912 | |
parent | 47d56d51c0a41fb64a7956871c3aa0a6db727c84 (diff) | |
download | gnome-maps-wip/mlundblad/aerial-hybrid.tar.gz |
layersPopover: Add checkbox to toggle hybrid aerialwip/mlundblad/aerial-hybrid
Also update the thumbnail to reflect the style.
-rw-r--r-- | data/ui/layers-popover.ui | 37 | ||||
-rw-r--r-- | src/layersPopover.js | 34 |
2 files changed, 66 insertions, 5 deletions
diff --git a/data/ui/layers-popover.ui b/data/ui/layers-popover.ui index 22ec9c81..423c4a86 100644 --- a/data/ui/layers-popover.ui +++ b/data/ui/layers-popover.ui @@ -48,6 +48,39 @@ </packing> </child> <child> + <object class="GtkRevealer" id="hybridAerialRevealer"> + <property name="can-focus">False</property> + <property name="visible">True</property> + <child> + <object class="GtkBox"> + <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property> + <property name="visible">True</property> + <property name="can-focus">False</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="hexpand">True</property> + <property name="halign">GTK_ALIGN_START</property> + <property name="label" translatable="yes">Show Labels</property> + </object> + </child> + <child> + <object class="GtkCheckButton"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="action-name">win.hybrid-aerial</property> + </object> + </child> + </object> + </child> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">2</property> + </packing> + </child> + <child> <object class="GtkListBox" id="layersListBox"> <property name="name">layers-list-box</property> <property name="visible">false</property> @@ -59,7 +92,7 @@ </object> <packing> <property name="left-attach">0</property> - <property name="top-attach">2</property> + <property name="top-attach">3</property> </packing> </child> <child> @@ -71,7 +104,7 @@ </object> <packing> <property name="left-attach">0</property> - <property name="top-attach">3</property> + <property name="top-attach">4</property> </packing> </child> </object> diff --git a/src/layersPopover.js b/src/layersPopover.js index 0526e684..3f80f93c 100644 --- a/src/layersPopover.js +++ b/src/layersPopover.js @@ -65,6 +65,7 @@ var LayersPopover = GObject.registerClass({ 'aerialLayerButton', 'streetLayerImage', 'aerialLayerImage', + 'hybridAerialRevealer', 'layersListBox', 'loadLayerButton' ] }, class LayersPopover extends Gtk.Popover { @@ -115,6 +116,13 @@ var LayersPopover = GObject.registerClass({ lastLocation: { x: -1, y: -1, z: -1 } }; } + if (Service.getService().tiles.hybridAerial) { + this._layerPreviews.hybridAerial = { + source: MapSource.createHybridAerialSource(), + widget: this._aerialLayerImage, + lastLocation: { x: -1, y: -1, z: -1 } + }; + } // disable the map type switch buttons if aerial is unavailable if (Service.getService().tiles.aerial) { @@ -138,6 +146,8 @@ var LayersPopover = GObject.registerClass({ this._setLayerPreviews.bind(this)); Application.settings.connect("changed::night-mode", this._onNightModeChanged.bind(this)); + Application.settings.connect("changed::hybrid-aerial", + this._onHybridAerialChanged.bind(this)); } else { this._streetLayerButton.visible = false; @@ -159,6 +169,15 @@ var LayersPopover = GObject.registerClass({ } } + _onHybridAerialChanged() { + if (Service.getService().tiles.hybridAerial && + Application.settings.get('hybrid-aerial')) { + this._setLayerPreviewImage('hybridAerial', true); + } else { + this._setLayerPreviewImage('aerial', true); + } + } + _setLayerPreviews() { if (Service.getService().tiles.streetDark && Application.settings.get('night-mode')) { @@ -166,7 +185,12 @@ var LayersPopover = GObject.registerClass({ } else { this._setLayerPreviewImage('street'); } - this._setLayerPreviewImage('aerial'); + if (Service.getService().tiles.hybridAerial && + Application.settings.get('hybrid-aerial')) { + this._setLayerPreviewImage('hybridAerial'); + } else { + this._setLayerPreviewImage('aerial'); + } } _setLayerPreviewImage(layer, forceUpdate = false) { @@ -216,10 +240,14 @@ var LayersPopover = GObject.registerClass({ } setMapType(mapType) { - if (mapType === MapView.MapType.STREET) + if (mapType === MapView.MapType.STREET) { this._streetLayerButton.active = true; - else if (mapType === MapView.MapType.AERIAL) + this._hybridAerialRevealer.reveal_child = false; + } else if (mapType === MapView.MapType.AERIAL) { this._aerialLayerButton.active = true; + if (Service.getService().tiles.hybridAerial) + this._hybridAerialRevealer.reveal_child = true; + } } _onRemoveClicked(row) { |