[gnome-maps] mainWindow: Automatically deactivate 'track me' toggle



commit 783bf3fb5b26e419c39a56b911fe57a0b194a9ed
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed Apr 17 17:06:51 2013 +0300

    mainWindow: Automatically deactivate 'track me' toggle
    
    If map view moves so that user location is not visible, deactivate the
    'track me' toggle button for the user.

 src/mainWindow.js | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index a3b0bcd..cb75fec 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -104,10 +104,31 @@ const MainWindow = new Lang.Class({
 
         let toggle = new Gd.HeaderToggleButton({ symbolic_icon_name: 'find-location-symbolic',
                                                  active: trackUserLocation });
+
+        let onViewMoved = Lang.bind(this,
+            function () {
+                if (!this.mapView.userLocationVisible())
+                    toggle.active = false;
+            });
+        if (trackUserLocation)
+            this._onViewMovedId = this.mapView.connect('view-moved', onViewMoved);
+
         toggle.connect('toggled', Lang.bind(this,
             function() {
-                if (toggle.active)
+                if (this._onViewMovedId > 0) {
+                    this.mapView.disconnect(this._onViewMovedId);
+                    this._onViewMovedId = 0;
+                }
+
+                if (toggle.active) {
+                    let goneToUserLocationId = this.mapView.connect('gone-to-user-location', Lang.bind(this,
+                        function () {
+                            this.mapView.disconnect(goneToUserLocationId);
+                            this._onViewMovedId = this.mapView.connect('view-moved', onViewMoved);
+                        }));
                     this.mapView.gotoUserLocation(true);
+                }
+
                 Application.settings.set_boolean('track-user-location', toggle.active);
             }));
         headerBar.pack_start(toggle);


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