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



commit 5ce8bf4778157f914e0d9a760ddfb415835cd2a6
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 9b61c96..cd59564 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -75,12 +75,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': {},
@@ -103,9 +111,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();
 
@@ -233,22 +252,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]