[gnome-maps/wip/user-location-toggle] wip Make 'track me' toggle automatically inactivate
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/user-location-toggle] wip Make 'track me' toggle automatically inactivate
- Date: Wed, 17 Apr 2013 01:51:49 +0000 (UTC)
commit 4c09ea4231fdc22ee30c4d7ea56757d68e0b3cab
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Wed Apr 17 04:49:02 2013 +0300
wip Make 'track me' toggle automatically inactivate
This toggle should automatically become inactive when user location is
no longer in the view.
src/mainWindow.js | 25 ++++++++++++++++++++++++-
src/mapView.js | 23 +++++++++++++++++++++++
2 files changed, 47 insertions(+), 1 deletion(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index a3b0bcd..6fcde5f 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -104,10 +104,33 @@ const MainWindow = new Lang.Class({
let toggle = new Gd.HeaderToggleButton({ symbolic_icon_name: 'find-location-symbolic',
active: trackUserLocation });
+
+ let onViewMoved = Lang.bind(this,
+ function () {
+ log ('view moved');
+ 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 () {
+ log ('gone');
+ this._onViewMovedId = this.mapView.connect('view-moved', onViewMoved);
+ this.mapView.disconnect(goneToUserLocationId);
+ }));
this.mapView.gotoUserLocation(true);
+ }
+
Application.settings.set_boolean('track-user-location', toggle.active);
}));
headerBar.pack_start(toggle);
diff --git a/src/mapView.js b/src/mapView.js
index f2c939f..5a8b998 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -30,6 +30,7 @@ const Geocode = imports.gi.GeocodeGlib;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
+const Signals = imports.signals;
const Application = imports.application;
const Properties = imports.properties;
@@ -57,6 +58,9 @@ const MapView = new Lang.Class({
this.view = this.actor;
this.view.set_zoom_level(3);
+ this.view.connect('notify::latitude', Lang.bind(this, this._onViewMoved));
+ this.view.connect('notify::longitude', Lang.bind(this, this._onViewMoved));
+
this._properties = new Properties.Properties(this);
this.view.bin_layout_add(this._properties.actor,
Clutter.BinAlignment.FILL,
@@ -130,9 +134,22 @@ const MapView = new Lang.Class({
},
gotoUserLocation: function(animate) {
+ let anim_completed_id = this.view.connect("animation-completed::go-to", Lang.bind(this,
+ function() {
+ log(this.view.latitude + "," + this.view.longitude);
+ this.emit('gone-to-user-location');
+ this.view.disconnect(anim_completed_id);
+ }));
this._userLocation.goTo(animate);
},
+ userLocationVisible: function() {
+ let box = this.view.get_bounding_box();
+ log("Checking for " + this._userLocation.latitude + "," + this._userLocation.longitude);
+
+ return box.covers(this._userLocation.latitude, this._userLocation.longitude);
+ },
+
_showUserLocation: function() {
let lastLocation = Application.settings.get_value('last-location');
if (lastLocation.n_children() >= 3) {
@@ -185,4 +202,10 @@ const MapView = new Lang.Class({
else
this.ensureVisible(locations);
},
+
+ _onViewMoved: function() {
+ log(this.view.latitude + "," + this.view.longitude);
+ this.emit('view-moved');
+ },
});
+Signals.addSignalMethods(MapView.prototype);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]