[gnome-maps] mainWindow: Disable actions rather than buttons



commit 9b8e1c22d17aaf005547c9c25285fc9cddb89a1e
Author: James Westman <flyingpimonster gmail com>
Date:   Wed Jan 1 22:23:41 2020 -0600

    mainWindow: Disable actions rather than buttons
    
    This makes it easier to move some of the headerbar buttons around, since
    they aren't tied to the code in mainWindow.js.
    
    This will be useful when implementing adaptive UI modes.

 data/ui/main-window.ui |  4 ++--
 src/mainWindow.js      | 17 ++++++++---------
 2 files changed, 10 insertions(+), 11 deletions(-)
---
diff --git a/data/ui/main-window.ui b/data/ui/main-window.ui
index ace2a6e2..6abf9807 100644
--- a/data/ui/main-window.ui
+++ b/data/ui/main-window.ui
@@ -83,7 +83,7 @@
               <class name="linked"/>
             </style>
             <child>
-              <object class="GtkButton" id="zoomOutButton">
+              <object class="GtkButton">
                 <property name="visible">True</property>
                 <property name="can-focus">True</property>
                 <property name="valign">center</property>
@@ -99,7 +99,7 @@
               </object>
             </child>
             <child>
-              <object class="GtkButton" id="zoomInButton">
+              <object class="GtkButton">
                 <property name="visible">True</property>
                 <property name="can-focus">True</property>
                 <property name="valign">center</property>
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 8525245e..3536b17a 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -83,13 +83,10 @@ var MainWindow = GObject.registerClass({
                         'mainStack',
                         'mainGrid',
                         'noNetworkView',
-                        'gotoUserLocationButton',
                         'toggleSidebarButton',
                         'layersButton',
                         'favoritesButton',
-                        'printRouteButton',
-                        'zoomInButton',
-                        'zoomOutButton' ]
+                        'printRouteButton' ]
 }, class MainWindow extends Gtk.ApplicationWindow {
 
     get mapView() {
@@ -319,16 +316,18 @@ var MainWindow = GObject.registerClass({
         let zoomLevel = this._mapView.view.zoom_level;
         let maxZoomLevel = this._mapView.view.max_zoom_level;
         let minZoomLevel = this._mapView.view.min_zoom_level;
+        let zoomInAction = this.lookup_action("zoom-in");
+        let zoomOutAction = this.lookup_action("zoom-out");
 
         if (zoomLevel >= maxZoomLevel)
-            this._zoomInButton.set_sensitive(false);
+            zoomInAction.set_enabled(false);
         else
-            this._zoomInButton.set_sensitive(true);
+            zoomInAction.set_enabled(true);
 
         if (zoomLevel <= minZoomLevel)
-            this._zoomOutButton.set_sensitive(false);
+            zoomOutAction.set_enabled(false);
         else
-            this._zoomOutButton.set_sensitive(true);
+            zoomOutAction.set_enabled(true);
     }
 
     _updateLocationSensitivity() {
@@ -336,7 +335,7 @@ var MainWindow = GObject.registerClass({
                          (this.application.connected ||
                           this.application.local_tile_path));
 
-        this._gotoUserLocationButton.sensitive = sensitive;
+        this.lookup_action("goto-user-location").set_enabled(sensitive);
     }
 
     _initHeaderbar() {


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