[gnome-maps/wip/mlundblad/headerbar-zoom] WIP: mainWindow: Show zoom control buttons in headerbar



commit 1ee96b49a2601d9947fcad97ee429ebdc506f6a0
Author: Marcus Lundblad <ml update uu se>
Date:   Tue Dec 12 23:07:41 2017 +0100

    WIP: mainWindow: Show zoom control buttons in headerbar
    
    Since overlaying GTK widgets on the Champlain view
    doesn't work on Wayland.

 data/org.gnome.Maps.data.gresource.xml |    1 -
 data/ui/main-window.ui                 |   40 +++++++++++++++++++
 data/ui/zoom-control.ui                |   63 ------------------------------
 src/mainWindow.js                      |   29 ++++++++++++-
 src/org.gnome.Maps.src.gresource.xml   |    1 -
 src/zoomControl.js                     |   66 --------------------------------
 6 files changed, 66 insertions(+), 134 deletions(-)
---
diff --git a/data/org.gnome.Maps.data.gresource.xml b/data/org.gnome.Maps.data.gresource.xml
index a1b638a..004a56a 100644
--- a/data/org.gnome.Maps.data.gresource.xml
+++ b/data/org.gnome.Maps.data.gresource.xml
@@ -39,7 +39,6 @@
     <file preprocess="xml-stripblanks">ui/transit-route-label.ui</file>
     <file preprocess="xml-stripblanks">ui/transit-stop-row.ui</file>
     <file preprocess="xml-stripblanks">ui/user-location-bubble.ui</file>
-    <file preprocess="xml-stripblanks">ui/zoom-control.ui</file>
     <file preprocess="xml-stripblanks">ui/zoom-in-notification.ui</file>
     <file alias="application.css">gnome-maps.css</file>
     <file alias="ui/maptype-aerial.png">media/maptype-aerial.png</file>
diff --git a/data/ui/main-window.ui b/data/ui/main-window.ui
index 411ee21..fe0cb0c 100644
--- a/data/ui/main-window.ui
+++ b/data/ui/main-window.ui
@@ -55,6 +55,46 @@
           </object>
         </child>
         <child>
+          <object class="GtkBox">
+            <property name="visible">True</property>
+            <style>
+              <class name="linked"/>
+            </style>
+            <child>
+              <object class="GtkButton" id="zoomOutButton">
+                <property name="visible">True</property>
+                <property name="can-focus">True</property>
+                <property name="valign">center</property>
+                <property name="action-name">win.zoom-out</property>
+                <property name="tooltip-text" translatable="yes" comments="Translators: This is a 
tooltip">Zoom out</property>
+                <child>
+                  <object class="GtkImage">
+                    <property name="visible">True</property>
+                    <property name="icon-size">1</property>
+                    <property name="icon-name">zoom-out-symbolic</property>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child>
+              <object class="GtkButton" id="zoomInButton">
+                <property name="visible">True</property>
+                <property name="can-focus">True</property>
+                <property name="valign">center</property>
+                <property name="action-name">win.zoom-in</property>
+                <property name="tooltip-text" translatable="yes" comments="Translators: This is a 
tooltip">Zoom in</property>
+                <child>
+                  <object class="GtkImage">
+                    <property name="visible">True</property>
+                    <property name="icon-size">1</property>
+                    <property name="icon-name">zoom-in-symbolic</property>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child>
           <object class="GtkToggleButton" id="toggleSidebarButton">
             <property name="visible">True</property>
             <property name="can-focus">True</property>
diff --git a/src/mainWindow.js b/src/mainWindow.js
index cb9ca58..b6b0bf8 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -43,7 +43,6 @@ const Service = imports.service;
 const ShapeLayer = imports.shapeLayer;
 const Sidebar = imports.sidebar;
 const Utils = imports.utils;
-const ZoomControl = imports.zoomControl;
 
 const _CONFIGURE_ID_TIMEOUT = 100; // msecs
 const _WINDOW_MIN_WIDTH = 600;
@@ -86,7 +85,9 @@ var MainWindow = new Lang.Class({
                         'toggleSidebarButton',
                         'layersButton',
                         'favoritesButton',
-                        'printRouteButton' ],
+                        'printRouteButton',
+                        'zoomInButton',
+                        'zoomOutButton' ],
 
     get mapView() {
         return this._mapView;
@@ -118,7 +119,6 @@ var MainWindow = new Lang.Class({
         });
         this._layersButton.popover = this.layersPopover;
         this._favoritesButton.popover = new FavoritesPopover.FavoritesPopover({ mapView: this._mapView });
-        this._overlay.add_overlay(new ZoomControl.ZoomControl(this._mapView));
 
         this._mainStack.add(this._overlay);
         this._busy = new BusyMarker.BusyMarker();
@@ -305,6 +305,29 @@ var MainWindow = new Lang.Class({
 
             return false;
         }).bind(this));
+
+        this._mapView.view.connect('notify::zoom-level',
+                                   this._updateZoomButtonsSensitivity.bind(this));
+        this._mapView.view.connect('notify::max-zoom-level',
+                                   this._updateZoomButtonsSensitivity.bind(this));
+        this._mapView.view.connect('notify::min-zoom-level',
+                                   this._updateZoomButtonsSensitivity.bind(this));
+    },
+
+    _updateZoomButtonsSensitivity: function() {
+        let zoomLevel = this._mapView.view.zoom_level;
+        let maxZoomLevel = this._mapView.view.max_zoom_level;
+        let minZoomLevel = this._mapView.view.min_zoom_level;
+
+        if (zoomLevel >= maxZoomLevel)
+            this._zoomInButton.set_sensitive(false);
+        else
+            this._zoomInButton.set_sensitive(true);
+
+        if (zoomLevel <= minZoomLevel)
+            this._zoomOutButton.set_sensitive(false);
+        else
+            this._zoomOutButton.set_sensitive(true);
     },
 
     _updateLocationSensitivity: function() {
diff --git a/src/org.gnome.Maps.src.gresource.xml b/src/org.gnome.Maps.src.gresource.xml
index f91a0bd..1cf4a31 100644
--- a/src/org.gnome.Maps.src.gresource.xml
+++ b/src/org.gnome.Maps.src.gresource.xml
@@ -99,7 +99,6 @@
     <file>xmldom/dom.js</file>
     <file>xmldom/domparser.js</file>
     <file>xmldom/sax.js</file>
-    <file>zoomControl.js</file>
     <file>zoomInNotification.js</file>
     <file alias="geojsonvt/clip.js">clip.js</file>
     <file alias="geojsonvt/convert.js">convert.js</file>


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