[gnome-maps/wip/mlundblad/transit-routing: 25/28] mapView: Add a view property to indicate showing a route



commit 8a1085b24fd190ae6aff032e2f55e3ac5547e9ca
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".

 src/mapView.js |   30 ++++++++++++++++++++++++++++--
 1 files changed, 28 insertions(+), 2 deletions(-)
---
diff --git a/src/mapView.js b/src/mapView.js
index 1c92528..f3912ab 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -71,12 +71,20 @@ const MapView = new Lang.Class({
     Name: 'MapView',
     Extends: GtkChamplain.Embed,
     Properties: {
+        /* this property is true when the routing sidebar is active */
         'routeVisible': GObject.ParamSpec.boolean('routeVisible',
                                                   'Route visible',
                                                   'Visibility of route layers',
                                                   GObject.ParamFlags.READABLE |
                                                   GObject.ParamFlags.WRITABLE,
-                                                  false)
+                                                  false),
+        /* this property is true when a route is being shown on the map */
+        'routeActive': GObject.ParamSpec.boolean('routeActive',
+                                                 'Route active',
+                                                 'Showing a route on the map',
+                                                 GObject.ParamFlags.READABLE |
+                                                 GObject.ParamFlags.WRITABLE,
+                                                 false)
     },
     Signals: {
         'user-location-changed': {},
@@ -99,9 +107,20 @@ const MapView = new Lang.Class({
             routeLayer.visible = value && isValid;
         }).bind(this));
         this._instructionMarkerLayer.visible = value && isValid;
+        if (!value)
+            this.routeActive = false;
         this.notify('routeVisible');
     },
 
+    get routeActive() {
+        return this._routeActive;
+    },
+
+    set routeActive(value) {
+        this._routeActive = value;
+        this.notify('routeActive');
+    },
+
     _init: function(params) {
         this.parent();
 
@@ -229,22 +248,29 @@ const MapView = new Lang.Class({
         let transitPlan = Application.openTripPlanner.plan;
         let query = Application.routeQuery;
 
-        route.connect('update', this.showRoute.bind(this, route));
+        route.connect('update', (function() {
+            this.showRoute(route);
+            this.routeActive = true;
+        }).bind(this));
         route.connect('reset', (function() {
             this._clearRouteLayers();
             this._instructionMarkerLayer.remove_all();
+            this.routeActive = false;
         }).bind(this));
         transitPlan.connect('update', this._showTransitPlan.bind(this, transitPlan));
         transitPlan.connect('reset', (function() {
             this._clearRouteLayers();
             this._instructionMarkerLayer.remove_all();
+            this.routeActive = false;
         }).bind(this));
         transitPlan.connect('itinerary-selected', (function(obj, itinerary) {
             this._showTransitItinerary(itinerary);
+            this.routeActive = true;
         }).bind(this));
         transitPlan.connect('itinerary-deselected', (function() {
             this._clearRouteLayers();
             this._instructionMarkerLayer.remove_all();
+            this.routeActive = false;
         }).bind(this));
 
         query.connect('notify', (function() {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]