[gnome-maps/gnome-40] mainWindow: Only enable map type shortcuts when useful



commit ca9b4a986ab520d6cadc74c38faacc3a5d710276
Author: Marcus Lundblad <ml update uu se>
Date:   Tue Jun 1 22:28:07 2021 +0200

    mainWindow: Only enable map type shortcuts when useful
    
    Only enable the shortcuts to switch b/w street and aerial
    map types when aerial tiles are available.

 src/mainWindow.js | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 853a4386..560d40a1 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -192,7 +192,7 @@ var MainWindow = GObject.registerClass({
     }
 
     _initActions() {
-        Utils.addActions(this, {
+        let actions = {
             'about': {
                 onActivate: () => this._onAboutActivate()
             },
@@ -200,14 +200,6 @@ var MainWindow = GObject.registerClass({
                 state: ['b', false],
                 onActivate: () => this._onMapTypeMenuActivate()
             },
-            'switch-to-street-view': {
-                accels: ['<Primary>1', '<Primary>KP_1'],
-                onActivate: () => this._onStreetViewActivate()
-            },
-            'switch-to-aearial-view': {
-                accels: ['<Primary>2', '<Primary>KP_2'],
-                onActivate: () => this._onAerialViewActivate()
-            },
             'hybrid-aerial': {
                 paramType:     'b',
                 setting:       'hybrid-aerial'
@@ -252,7 +244,22 @@ var MainWindow = GObject.registerClass({
             'export-as-image': {
                 onActivate: () => this._onExportActivated()
             }
-        }, Application.settings);
+        };
+
+        // when aerial tiles are available, add shortcuts to switch
+        if (Service.getService().tiles.aerial) {
+            actions['switch-to-street-view'] = {
+                accels: ['<Primary>1', '<Primary>KP_1'],
+                onActivate: () => this._onStreetViewActivate()
+            };
+
+            actions['switch-to-aearial-view'] = {
+                accels: ['<Primary>2', '<Primary>KP_2'],
+                onActivate: () => this._onAerialViewActivate()
+            };
+        }
+
+        Utils.addActions(this, actions, Application.settings);
     }
 
     _initSignals() {


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