[gnome-maps/wip/fix-geoloc: 11/11] Fix map not panning to new user location



commit e5bf308628a10c0dc3144c57946d7f4921a07288
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date:   Thu Jul 18 06:40:50 2013 +0200

    Fix map not panning to new user location
    
    Fix a bug where when a new user location is found the map wouldn't pan
    to it even if the track-user-location setting is enabled.
    This patch doesn't make the map not animate if the new location was
    found on start of the program.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=704537

 src/mainWindow.js |   15 ++++++++++-----
 src/mapView.js    |   27 ++++++++++++---------------
 2 files changed, 22 insertions(+), 20 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 0db2d93..d962482 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -110,11 +110,10 @@ const MainWindow = new Lang.Class({
         this.mapView.connect('gone-to-user-location',
                              this._connectMapMove.bind(this));
 
-        Application.settings.connect('changed::track-user-location', (function() {
-            if(Application.settings.get_boolean('track-user-location')) {
-                this.mapView.gotoUserLocation(true);
-            }
-        }).bind(this));
+        this.mapView.connect('user-location-changed',
+                             this._onUserLocationChange.bind(this));
+        Application.settings.connect('changed::track-user-location',
+                                     this._onUserLocationChange.bind(this));
     },
 
     _connectMapMove: function() {
@@ -133,6 +132,12 @@ const MainWindow = new Lang.Class({
         }
     },
 
+    _onUserLocationChange: function() {
+        if(Application.settings.get_boolean('track-user-location')) {
+            this.mapView.gotoUserLocation(true);
+        }
+    },
+
     _saveWindowGeometry: function() {
         let window = this.window.get_window();
         let state = window.get_state();
diff --git a/src/mapView.js b/src/mapView.js
index b39d4b4..2162b8f 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -77,7 +77,10 @@ const MapView = new Lang.Class({
         this._factory = Champlain.MapSourceFactory.dup_default();
         this.setMapType(MapType.STREET);
 
-        this._showUserLocation();
+        this._geoclue = new Geoclue.Geoclue();
+        this._updateUserLocation();
+        this._geoclue.connect("location-changed",
+                              this._updateUserLocation.bind(this));
     },
 
     setMapType: function(mapType) {
@@ -139,21 +142,15 @@ const MapView = new Lang.Class({
                     this._userLocation.longitude);
     },
 
-    _showUserLocation: function() {
-        this._geoclue = new Geoclue.Geoclue();
+    _updateUserLocation: function() {
+        if (!this._geoclue.location)
+            return;
 
-        let onLocationChanged = Lang.bind(this,
-            function() {
-                if (this._geoclue.location == null)
-                    return;
-
-                this._userLocation =
-                    new UserLocation.UserLocation(this._geoclue.location,
-                                                  this);
-                this._userLocation.show(this._userLocationLayer);
-            });
-        this._geoclue.connect("location-changed", onLocationChanged);
-        onLocationChanged();
+        this._userLocation =
+            new UserLocation.UserLocation(this._geoclue.location,
+                                          this);
+        this._userLocation.show(this._userLocationLayer);
+        this.emit('user-location-changed');
     },
 
     _showLocations: function(locations) {


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