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



commit 6ef402ddfbc948a37204a2602e35eb915c557b80
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".
    
    https://bugzilla.gnome.org/show_bug.cgi?id=755808

 src/mapView.js |   30 ++++++++++++++++++++++++++++--
 1 files changed, 28 insertions(+), 2 deletions(-)
---
diff --git a/src/mapView.js b/src/mapView.js
index a1e65b4..02365da 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -76,12 +76,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': {},
@@ -104,9 +112,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();
 
@@ -231,22 +250,29 @@ 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.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]