[gnome-maps/wip/mlundblad/restructure-routing-items] WIP: contextMenu: Allow setting route start/end directly
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/restructure-routing-items] WIP: contextMenu: Allow setting route start/end directly
- Date: Wed, 29 Jan 2020 21:14:01 +0000 (UTC)
commit 3fab335487a3d7224e39da36130a768764b2eb02
Author: Marcus Lundblad <ml update uu se>
Date: Wed Jan 29 21:02:32 2020 +0100
WIP: contextMenu: Allow setting route start/end directly
Add individual menu options for setting start and
end points, and adding intermediate destinations,
allowing modifying query without clearing and
starting over.
data/ui/context-menu.ui | 34 +++++++++++++++++++++++------
src/contextMenu.js | 57 +++++++++++++++++++++++++++++--------------------
2 files changed, 62 insertions(+), 29 deletions(-)
---
diff --git a/data/ui/context-menu.ui b/data/ui/context-menu.ui
index 6f3e54ca..7fcb6734 100644
--- a/data/ui/context-menu.ui
+++ b/data/ui/context-menu.ui
@@ -3,6 +3,33 @@
<!-- interface-requires gtk+ 3.0 -->
<template class="Gjs_ContextMenu" parent="GtkMenu">
<property name="visible">False</property>
+ <child>
+ <object class="GtkMenuItem" id="routeFromHereItem">
+ <property name="name">route-from-here-item</property>
+ <property name="label" translatable="yes">Route from here</property>
+ <property name="visible">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="addIntermediateDestinationItem">
+ <property name="name">add-itermediate-destination-item</property>
+ <property name="label" translatable="yes">Add intermediate destination</property>
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="routeToHereItem">
+ <property name="name">route-to-here-item</property>
+ <property name="label" translatable="yes">Route to here</property>
+ <property name="visible">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSeparatorMenuItem">
+ <property name="visible">True</property>
+ </object>
+ </child>
<child>
<object class="GtkMenuItem" id="whatsHereItem">
<property name="name">whats-here-item</property>
@@ -17,12 +44,7 @@
<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>
diff --git a/src/contextMenu.js b/src/contextMenu.js
index 699025de..6a4727a2 100644
--- a/src/contextMenu.js
+++ b/src/contextMenu.js
@@ -41,7 +41,9 @@ var ContextMenu = GObject.registerClass({
InternalChildren: [ 'whatsHereItem',
'geoURIItem',
'addOSMLocationItem',
- 'routeItem' ],
+ 'routeFromHereItem',
+ 'addIntermediateDestinationItem',
+ 'routeToHereItem' ],
}, class ContextMenu extends Gtk.Menu {
_init(params) {
this._mapView = params.mapView;
@@ -61,11 +63,14 @@ var ContextMenu = GObject.registerClass({
this._onGeoURIActivated.bind(this));
this._addOSMLocationItem.connect('activate',
this._onAddOSMLocationActivated.bind(this));
- this._routeItem.connect('activate',
- this._onRouteActivated.bind(this));
+ this._routeFromHereItem.connect('activate',
+ this._onRouteFromHereActivated.bind(this));
+ this._addIntermediateDestinationItem.connect('activate',
+ this._onAddIntermediateDestinationActivated.bind(this));
+ this._routeToHereItem.connect('activate',
+ this._onRouteToHereActivated.bind(this));
Application.routeQuery.connect('notify::points',
this._routingUpdate.bind(this));
- this._routeItem.visible = false;
this._routingUpdate();
}
@@ -83,36 +88,42 @@ var ContextMenu = GObject.registerClass({
_routingUpdate() {
let query = Application.routeQuery;
+ let numPoints = query.points.length;
- this._routeItem.sensitive = query.points.length < RouteQuery.MAX_QUERY_POINTS;
+ this._routeFromHereItem.sensitive = numPoints < RouteQuery.MAX_QUERY_POINTS;
+ this._routeToHereItem.sensitive = numPoints < RouteQuery.MAX_QUERY_POINTS;
+ this._addIntermediateDestinationItem.sensitive =
+ query.filledPoints.length >= 2 && numPoints < RouteQuery.MAX_QUERY_POINTS;
+ }
- if (query.points.length === 0)
- return;
+ _onRouteFromHereActivated() {
+ let query = Application.routeQuery;
+ let location = new Location.Location({ latitude: this._latitude,
+ longitude: this._longitude,
+ accuracy: 0 });
+ let place = new Place.Place({ location: location });
- 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");
- }
+ query.points[0].place = place;
}
- _onRouteActivated() {
+ _onRouteToHereActivated() {
let query = Application.routeQuery;
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;
- }
+ query.points.last().place = place;
+ }
+
+ _onAddIntermediateDestinationActivated() {
+ let query = Application.routeQuery;
+ let location = new Location.Location({ latitude: this._latitude,
+ longitude: this._longitude,
+ accuracy: 0 });
+ let place = new Place.Place({ location: location });
+
+ query.addPoint(-1).place = place;
}
_onWhatsHereActivated() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]