[gnome-maps] Make stored route store transportation



commit f212ed395a8149dc8ba0b55bdcc695c0f99d4ef2
Author: Jonas Danielsson <jonas threetimestwo org>
Date:   Fri Aug 21 20:42:00 2015 +0200

    Make stored route store transportation

 src/mapView.js      |    1 +
 src/placeListRow.js |    3 ++-
 src/sidebar.js      |    1 +
 src/storedRoute.js  |   38 +++++++++++++++++++++++++++++++++-----
 4 files changed, 37 insertions(+), 6 deletions(-)
---
diff --git a/src/mapView.js b/src/mapView.js
index 53146f1..c4f4675 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -251,6 +251,7 @@ const MapView = new Lang.Class({
             let storedLast = stored.places.length - 1;
             query.points[0].place = stored.places[0];
             query.points[1].place = stored.places[storedLast];
+            query.transportation = stored.transportation;
 
             for (let i = 1; i < storedLast; i++) {
                 let point = query.addPoint(i);
diff --git a/src/placeListRow.js b/src/placeListRow.js
index a0e1143..df7b3fa 100644
--- a/src/placeListRow.js
+++ b/src/placeListRow.js
@@ -60,7 +60,8 @@ const PlaceListRow = new Lang.Class({
         this._details.label = formatter.getDetailsString();
         this._icon.gicon = this.place.icon;
 
-        if (type === PlaceStore.PlaceType.RECENT)
+        if (type === PlaceStore.PlaceType.RECENT ||
+            type === PlaceStore.PlaceType.RECENT_ROUTE)
             this._typeIcon.icon_name = 'document-open-recent-symbolic';
         else if (type === PlaceStore.PlaceType.FAVORITE)
             this._typeIcon.icon_name = 'emblem-favorite-symbolic';
diff --git a/src/sidebar.js b/src/sidebar.js
index 4ad6d65..7496b22 100644
--- a/src/sidebar.js
+++ b/src/sidebar.js
@@ -208,6 +208,7 @@ const Sidebar = new Lang.Class({
                     return point.place;
                 });
                 let storedRoute = new StoredRoute.StoredRoute({
+                    transportation: query.transportation,
                     route: route,
                     places: places
                 });
diff --git a/src/storedRoute.js b/src/storedRoute.js
index c4f73e4..5556691 100644
--- a/src/storedRoute.js
+++ b/src/storedRoute.js
@@ -27,6 +27,7 @@ const Lang = imports.lang;
 const Application = imports.application;
 const Place = imports.place;
 const Route = imports.route;
+const RouteQuery = imports.routeQuery;
 
 const StoredRoute = new Lang.Class({
     Name: 'StoredRoute',
@@ -36,6 +37,9 @@ const StoredRoute = new Lang.Class({
         let route = params.route;
         delete params.route;
 
+        this._transportation = params.transportation || null;
+        delete params.transportation;
+
         this.route = new Route.Route();
         this.route.update({ path: route.path,
                             turnPoints: route.turnPoints,
@@ -56,8 +60,6 @@ const StoredRoute = new Lang.Class({
             this.places.push(new Place.Place({ place: place }));
         }).bind(this));
 
-        this._icon = Gio.Icon.new_for_string('route-button-symbolic');
-
         this.parent(params);
     },
 
@@ -67,12 +69,31 @@ const StoredRoute = new Lang.Class({
         }).join(' → ');
     },
 
+    get transportation() {
+        return this._transportation;
+    },
+
     get icon() {
-        return this._icon;
+        let transport = RouteQuery.Transportation;
+        let icon = Gio.Icon.new_for_string('route-button-symbolic');
+
+        switch(this._transportation) {
+        case transport.PEDESTRIAN:
+            icon = Gio.Icon.new_for_string('route-pedestrian-symbolic');
+            break;
+        case transport.CAR:
+            icon = Gio.Icon.new_for_string('route-car-symbolic');
+            break;
+        case transport.BIKE:
+            icon = Gio.Icon.new_for_string('route-bike-symbolic');
+            break;
+        }
+
+        return icon;
     },
 
     get uniqueID() {
-        return this.places.map(function(place) {
+        return this._transportation + '-' + this.places.map(function(place) {
             return [place.osm_type, place.osm_id].join('-');
         }).join('-');
     },
@@ -110,6 +131,7 @@ const StoredRoute = new Lang.Class({
         });
 
         return { id: -1,
+                 transportation: this._transportation,
                  route: route,
                  places: places };
     }
@@ -119,11 +141,16 @@ StoredRoute.fromJSON = function(obj) {
     let props;
     let places = [];
     let route;
+    let transportation = null;
 
     for (let key in obj) {
         let prop = obj[key];
 
         switch(key) {
+        case 'transportation':
+            transportation = prop;
+            break;
+
         case 'route':
             route = new Route.Route();
             prop.path = prop.path.map(function(coordinate) {
@@ -156,6 +183,7 @@ StoredRoute.fromJSON = function(obj) {
             break;
         }
     }
-    return new StoredRoute({ route: route,
+    return new StoredRoute({ transportation: transportation,
+                             route: route,
                              places: places });
 };


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