[gnome-maps] ContextMenu: Add 'I am here!' menu item
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] ContextMenu: Add 'I am here!' menu item
- Date: Sat, 31 Aug 2013 18:29:55 +0000 (UTC)
commit 69af8b3951d2e7af8ab04ecde050c421a58e72b6
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Mon Aug 26 04:15:57 2013 +0300
ContextMenu: Add 'I am here!' menu item
When launched, it overrides Maps's concept of user location. We also do
a reverse geocoding to set a proper name on the user location pin.
https://bugzilla.gnome.org/show_bug.cgi?id=706726
src/context-menu.ui | 7 +++++++
src/contextMenu.js | 26 ++++++++++++++++++++++++--
2 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/src/context-menu.ui b/src/context-menu.ui
index de9ea6a..cab7f34 100644
--- a/src/context-menu.ui
+++ b/src/context-menu.ui
@@ -10,5 +10,12 @@
<property name="visible">True</property>
</object>
</child>
+ <child>
+ <object class="GtkMenuItem" id="i-am-here-item">
+ <property name="name">i-am-here-item</property>
+ <property name="label" translatable="yes">I'm here!</property>
+ <property name="visible">True</property>
+ </object>
+ </child>
</object>
</interface>
diff --git a/src/contextMenu.js b/src/contextMenu.js
index 617a676..095e438 100644
--- a/src/contextMenu.js
+++ b/src/contextMenu.js
@@ -35,7 +35,8 @@ const ContextMenu = new Lang.Class({
this._mapView = mapView;
let ui = Utils.getUIObject('context-menu', ['context-menu',
- 'whats-here-item']);
+ 'whats-here-item',
+ 'i-am-here-item']);
this._menu = ui.contextMenu;
this._mapView.view.connect('button-release-event',
@@ -43,6 +44,9 @@ const ContextMenu = new Lang.Class({
ui.whatsHereItem.connect('activate',
this._onWhatsHereActivated.bind(this));
+
+ ui.iAmHereItem.connect('activate',
+ this._onIAmHereActivated.bind(this));
},
_onButtonReleaseEvent: function(actor, event) {
@@ -60,6 +64,24 @@ const ContextMenu = new Lang.Class({
let location = new Geocode.Location({ latitude: this._latitude,
longitude: this._longitude,
accuracy: 0 });
+
+ this._reverseGeocode(location, (function(place) {
+ this._mapView.showLocation(place.location);
+ }).bind(this));
+ },
+
+ _onIAmHereActivated: function() {
+ let location = new Geocode.Location({ latitude: this._latitude,
+ longitude: this._longitude,
+ accuracy: 0,
+ description: "" });
+ this._reverseGeocode(location, (function(place) {
+ location.description = place.name;
+ this._mapView.geoclue.overrideLocation(location);
+ }).bind(this));
+ },
+
+ _reverseGeocode: function(location, resultCallback) {
let reverse = Geocode.Reverse.new_for_location(location);
Application.application.mark_busy();
@@ -68,7 +90,7 @@ const ContextMenu = new Lang.Class({
try {
let place = reverse.resolve_finish(res);
- this._mapView.showLocation(place.location);
+ resultCallback(place);
} catch (e) {
log ("Error finding place at " +
this._latitude + ", " +
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]