[gnome-maps] contextMenu: Allow routing from right click
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] contextMenu: Allow routing from right click
- Date: Sat, 30 Jan 2016 14:08:54 +0000 (UTC)
commit 3d6efe1053b4d35785f03e0668a6e4c6601645c4
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Mon Sep 7 20:41:30 2015 +0200
contextMenu: Allow routing from right click
Add item to context menu to allow routing to/from/via the
right clicked location.
https://bugzilla.gnome.org/show_bug.cgi?id=737322
data/ui/context-menu.ui | 6 ++++++
src/contextMenu.js | 42 +++++++++++++++++++++++++++++++++++++++++-
2 files changed, 47 insertions(+), 1 deletions(-)
---
diff --git a/data/ui/context-menu.ui b/data/ui/context-menu.ui
index b968616..eb2c7c8 100644
--- a/data/ui/context-menu.ui
+++ b/data/ui/context-menu.ui
@@ -24,5 +24,11 @@
<property name="visible">True</property>
</object>
</child>
+ <child>
+ <object class="GtkMenuItem" id="routeItem">
+ <property name="name">route-item</property>
+ <property name="visible">True</property>
+ </object>
+ </child>
</template>
</interface>
diff --git a/src/contextMenu.js b/src/contextMenu.js
index 87f0832..7560adc 100644
--- a/src/contextMenu.js
+++ b/src/contextMenu.js
@@ -30,6 +30,7 @@ const Application = imports.application;
const ExportViewDialog = imports.exportViewDialog;
const Lang = imports.lang;
const Location = imports.location;
+const Place = imports.place;
const Utils = imports.utils;
const ContextMenu = new Lang.Class({
@@ -38,7 +39,8 @@ const ContextMenu = new Lang.Class({
Template: 'resource:///org/gnome/Maps/ui/context-menu.ui',
InternalChildren: [ 'whatsHereItem',
'geoURIItem',
- 'exportItem' ],
+ 'exportItem',
+ 'routeItem' ],
_init: function(params) {
this._mapView = params.mapView;
@@ -55,6 +57,12 @@ const ContextMenu = new Lang.Class({
this._onGeoURIActivated.bind(this));
this._exportItem.connect('activate',
this._onExportActivated.bind(this));
+ this._routeItem.connect('activate',
+ this._onRouteActivated.bind(this));
+ Application.routeService.query.connect('notify::points',
+ this._routingUpdate.bind(this));
+ this._routeItem.visible = false;
+ this._routingUpdate();
},
_onButtonReleaseEvent: function(actor, event) {
@@ -71,6 +79,38 @@ const ContextMenu = new Lang.Class({
}
},
+ _routingUpdate: function() {
+ let query = Application.routeService.query;
+
+ if (query.points.length === 0)
+ return;
+
+ this._routeItem.visible = true;
+ if (!query.points[0].place) {
+ this._routeItem.label = _("Route from here");
+ } else if (query.filledPoints.length > 1) {
+ this._routeItem.label = _("Add destination");
+ } else {
+ this._routeItem.label = _("Route to here");
+ }
+ },
+
+ _onRouteActivated: function() {
+ let query = Application.routeService.query;
+ let location = new Location.Location({ latitude: this._latitude,
+ longitude: this._longitude,
+ accuracy: 0 });
+ let place = new Place.Place({ location: location });
+
+ if (!query.points[0].place) {
+ query.points[0].place = place;
+ } else if (query.filledPoints.length > 1) {
+ query.addPoint(-1).place = place;
+ } else {
+ query.points[query.points.length - 1].place = place;
+ }
+ },
+
_onWhatsHereActivated: function() {
let location = new Location.Location({ latitude: this._latitude,
longitude: this._longitude,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]