[gnome-maps/wip/mlundblad/additional-place-icons: 6/6] storedRoute: Implement icon name method




commit 044d5310a8cd1fbf4365e0c14a9b2b3db94a67ad
Author: Marcus Lundblad <ml update uu se>
Date:   Tue Apr 6 22:20:58 2021 +0200

    storedRoute: Implement icon name method
    
    Instead of creating the Gio.Icon, just implement
    the _getIconName() method from Place and let
    the icon() getter in Place handle the task
    of creating the icon instance.

 src/storedRoute.js | 31 +++++++++++--------------------
 1 file changed, 11 insertions(+), 20 deletions(-)
---
diff --git a/src/storedRoute.js b/src/storedRoute.js
index 784c6693..04763097 100644
--- a/src/storedRoute.js
+++ b/src/storedRoute.js
@@ -21,7 +21,6 @@
  */
 
 const Champlain = imports.gi.Champlain;
-const Gio = imports.gi.Gio;
 const GObject = imports.gi.GObject;
 const Gtk = imports.gi.Gtk;
 
@@ -89,25 +88,6 @@ class StoredRoute extends Place.Place {
         return this._transportation;
     }
 
-    get 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._transportation + '-' + this.places.map(function(place) {
             return [place.osm_type, place.osm_id].join('-');
@@ -130,6 +110,17 @@ class StoredRoute extends Place.Place {
         return hasNull;
     }
 
+    _getIconName() {
+        let transport = RouteQuery.Transportation;
+
+        switch (this._transportation) {
+            case transport.PEDESTRIAN: return 'route-pedestrian-symbolic';
+            case transport.BIKE:       return 'route-bike-symbolic';
+            case transport.CAR:        return 'route-car-symbolic';
+            default:                   return 'route-button-symbolic';
+        }
+    }
+
     toJSON() {
         let turnPoints = this.route.turnPoints.map(function(turnPoint) {
             let coordinate = { latitude: turnPoint.coordinate.latitude,


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