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



commit 2cc15706c6f1c0c73d3a4445c7af2dd9d191763c
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 6fe5628..4a8e182 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]