[gnome-maps/wip/mlundblad/transit-routing: 10/13] mapView: Add a view property to indicate showing a route
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/transit-routing: 10/13] mapView: Add a view property to indicate showing a route
- Date: Sun, 12 Feb 2017 22:04:24 +0000 (UTC)
commit 9e4f3321df5dc0b76a211f4a916c9ddf6512b1fe
Author: Marcus Lundblad <ml update uu se>
Date: Thu Sep 15 21:57:30 2016 +0200
mapView: Add a view property to indicate showing a route
Adds a new boolean property that is set to true when an actual route
is rendered on the map.
This will allow only showing the print button when a transit itinerary
is "dived into".
Also rename the current "routeVisible" property to "routingOpen" to
avoid confusion, since the new property is what's set when a route is
actually rendered on the map, the former property is set when routing
is ongoing (and the routing headerbar button is pressed).
https://bugzilla.gnome.org/show_bug.cgi?id=755808
src/mainWindow.js | 2 +-
src/mapView.js | 54 +++++++++++++++++++++++++++++++++++++++-------------
2 files changed, 41 insertions(+), 15 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 02e4211..d39da81 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -138,7 +138,7 @@ const MainWindow = new Lang.Class({
Application.routeQuery.connect('notify',
this._setRevealSidebar.bind(this, true));
this._toggleSidebarButton.bind_property('active',
- this._mapView, 'routeVisible',
+ this._mapView, 'routingOpen',
GObject.BindingFlags.BIDIRECTIONAL);
this.application.bind_property('connected',
sidebar, 'visible',
diff --git a/src/mapView.js b/src/mapView.js
index 420bb77..d19b6f5 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -90,12 +90,20 @@ const MapView = new Lang.Class({
Name: 'MapView',
Extends: GtkChamplain.Embed,
Properties: {
- 'routeVisible': GObject.ParamSpec.boolean('routeVisible',
- 'Route visible',
- 'Visibility of route layers',
+ // this property is true when the routing sidebar is active
+ 'routingOpen': GObject.ParamSpec.boolean('routingOpen',
+ 'Routing open',
+ 'Routing sidebar open',
GObject.ParamFlags.READABLE |
GObject.ParamFlags.WRITABLE,
- false)
+ false),
+ /* this property is true when a route is being shown on the map */
+ 'routeShowing': GObject.ParamSpec.boolean('routeShowing',
+ 'Route showing',
+ 'Showing a route on the map',
+ GObject.ParamFlags.READABLE |
+ GObject.ParamFlags.WRITABLE,
+ false)
},
Signals: {
'user-location-changed': {},
@@ -106,19 +114,30 @@ const MapView = new Lang.Class({
'marker-selected': { param_types: [Champlain.Marker] }
},
- get routeVisible() {
- return this._routeVisible || this._instructionMarkerLayer.visible;
+ get routingOpen() {
+ return this._routingOpen || this._instructionMarkerLayer.visible;
},
- set routeVisible(value) {
+ set routingOpen(value) {
let isValid = Application.routeQuery.isValid();
- this._routeVisible = value && isValid;
+ this._routingOpen = value && isValid;
this._routeLayers.forEach((function(routeLayer) {
routeLayer.visible = value && isValid;
}).bind(this));
this._instructionMarkerLayer.visible = value && isValid;
- this.notify('routeVisible');
+ if (!value)
+ this.routeShowing = false;
+ this.notify('routingOpen');
+ },
+
+ get routeShowing() {
+ return this._routeShowing;
+ },
+
+ set routeShowing(value) {
+ this._routeShowing = value;
+ this.notify('routeShowing');
},
_init: function(params) {
@@ -246,26 +265,33 @@ const MapView = new Lang.Class({
let transitPlan = Application.routingDelegator.openTripPlanner.plan;
let query = Application.routeQuery;
- route.connect('update', this.showRoute.bind(this, route));
+ route.connect('update', (function() {
+ this.showRoute(route);
+ this.routeShowing = true;
+ }).bind(this));
route.connect('reset', (function() {
this._clearRouteLayers();
this._instructionMarkerLayer.remove_all();
+ this.routeShowing = false;
}).bind(this));
transitPlan.connect('update', this._showTransitPlan.bind(this, transitPlan));
transitPlan.connect('reset', (function() {
this._clearRouteLayers();
this._instructionMarkerLayer.remove_all();
+ this.routeShowing = false;
}).bind(this));
transitPlan.connect('itinerary-selected', (function(obj, itinerary) {
this._showTransitItinerary(itinerary);
+ this.routeShowing = true;
}).bind(this));
transitPlan.connect('itinerary-deselected', (function() {
this._clearRouteLayers();
this._instructionMarkerLayer.remove_all();
+ this.routeShowing = false;
}).bind(this));
query.connect('notify', (function() {
- this.routeVisible = query.isValid();
+ this.routingOpen = query.isValid();
}).bind(this));
},
@@ -528,7 +554,7 @@ const MapView = new Lang.Class({
return;
}
- this.routeVisible = false;
+ this.routingOpen = false;
let placeMarker = new PlaceMarker.PlaceMarker({ place: place,
mapView: this });
@@ -545,7 +571,7 @@ const MapView = new Lang.Class({
routeLayer = this._createRouteLayer(false, TURN_BY_TURN_ROUTE_COLOR,
ROUTE_LINE_WIDTH);
route.path.forEach(routeLayer.add_node.bind(routeLayer));
- this.routeVisible = true;
+ this.routingOpen = true;
this._ensureInstructionLayerAboveRouteLayers();
@@ -643,7 +669,7 @@ const MapView = new Lang.Class({
mapView: this });
this._instructionMarkerLayer.add_marker(arrival);
- this.routeVisible = true;
+ this.routingOpen = true;
},
_showTransitPlan: function(plan) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]