[gnome-maps] MapView: pan to new user locations
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] MapView: pan to new user locations
- Date: Wed, 31 Jul 2013 00:36:04 +0000 (UTC)
commit 411618a200b3c0822e7e150ed80e1dd95956f42e
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date: Thu Jul 18 06:40:50 2013 +0200
MapView: pan to new user locations
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.
https://bugzilla.gnome.org/show_bug.cgi?id=704537
src/mainWindow.js | 15 ++++++++++-----
src/mapView.js | 25 +++++++++++--------------
2 files changed, 21 insertions(+), 19 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index b0c1a0f..d847029 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._onUserLocationChanged.bind(this));
+ Application.settings.connect('changed::track-user-location',
+ this._onUserLocationChanged.bind(this));
},
_connectMapMove: function() {
@@ -132,6 +131,12 @@ const MainWindow = new Lang.Class({
}
},
+ _onUserLocationChanged: 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 60c8619..22f19e4 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) {
@@ -136,19 +139,13 @@ const MapView = new Lang.Class({
return box.covers(this._userLocation.latitude, this._userLocation.longitude);
},
- _showUserLocation: function() {
- this._geoclue = new Geoclue.Geoclue();
-
- let onLocationChanged = (function() {
- if (this._geoclue.location == null)
- return;
-
- this._userLocation = new UserLocation.UserLocation(this._geoclue.location, this);
- this._userLocation.show(this._userLocationLayer);
- }).bind(this);
+ _updateUserLocation: function() {
+ if (!this._geoclue.location)
+ return;
- 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) {
@@ -170,4 +167,4 @@ const MapView = new Lang.Class({
this.emit('view-moved');
}
});
-Signals.addSignalMethods(MapView.prototype);
+Utils.addSignalMethods(MapView.prototype);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]