[gnome-maps/wip/mlundblad/osm-add-location: 11/17] contextMenu: Allow routing from right click
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/osm-add-location: 11/17] contextMenu: Allow routing from right click
- Date: Sat, 30 Jan 2016 15:08:01 +0000 (UTC)
commit 4e507b9864a44a94014e40b8783e02886d285401
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 | 12 +++++++++++
src/contextMenu.js | 49 ++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 60 insertions(+), 1 deletions(-)
---
diff --git a/data/ui/context-menu.ui b/data/ui/context-menu.ui
index b968616..b682885 100644
--- a/data/ui/context-menu.ui
+++ b/data/ui/context-menu.ui
@@ -24,5 +24,17 @@
<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>
+ <child>
+ <object class="GtkMenuItem" id="addOSMLocationItem">
+ <property name="name">add-osm-location-item</property>
+ <property name="label" translatable="yes">Add Location</property>
+ </object>
+ </child>
</template>
</interface>
diff --git a/src/contextMenu.js b/src/contextMenu.js
index 87f0832..e7b377b 100644
--- a/src/contextMenu.js
+++ b/src/contextMenu.js
@@ -30,6 +30,11 @@ const Application = imports.application;
const ExportViewDialog = imports.exportViewDialog;
const Lang = imports.lang;
const Location = imports.location;
+const OSMAccountDialog = imports.osmAccountDialog;
+const OSMEdit = imports.osmEdit;
+const OSMEditDialog = imports.osmEditDialog;
+const OSMUtils = imports.osmUtils;
+const Place = imports.place;
const Utils = imports.utils;
const ContextMenu = new Lang.Class({
@@ -38,7 +43,9 @@ const ContextMenu = new Lang.Class({
Template: 'resource:///org/gnome/Maps/ui/context-menu.ui',
InternalChildren: [ 'whatsHereItem',
'geoURIItem',
- 'exportItem' ],
+ 'exportItem',
+ 'addOSMLocationItem' ],
+ 'routeItem' ],
_init: function(params) {
this._mapView = params.mapView;
@@ -55,6 +62,14 @@ const ContextMenu = new Lang.Class({
this._onGeoURIActivated.bind(this));
this._exportItem.connect('activate',
this._onExportActivated.bind(this));
+ this._addOSMLocationItem.connect('activate',
+ this._onAddOSMLocationActivated.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 +86,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]