[gnome-maps/wip/mlundblad/transit-routing: 24/32] Add map marker to mark end of transit itineraries



commit 7e96276785c4dc6795d05de9bae704f45937c0b2
Author: Marcus Lundblad <ml update uu se>
Date:   Wed Jun 15 00:00:47 2016 +0200

    Add map marker to mark end of transit itineraries
    
    https://bugzilla.gnome.org/show_bug.cgi?id=755808

 data/ui/transit-arrival-row.ui       |    2 +
 src/org.gnome.Maps.src.gresource.xml |    1 +
 src/transitArrivalMarker.js          |   61 ++++++++++++++++++++++++++++++++++
 src/transitWalkMarker.js             |   27 ++++++++-------
 4 files changed, 78 insertions(+), 13 deletions(-)
---
diff --git a/data/ui/transit-arrival-row.ui b/data/ui/transit-arrival-row.ui
index 73f62ab..4688615 100644
--- a/data/ui/transit-arrival-row.ui
+++ b/data/ui/transit-arrival-row.ui
@@ -33,6 +33,8 @@
                 <property name="can-focus">False</property>
                 <property name="hexpand">True</property>
                 <property name="halign">GTK_ALIGN_START</property>
+                <property name="max-width-chars">25</property>
+                <property name="ellipsize">PANGO_ELLIPSIZE_END</property>
               </object>
               <packing>
                 <property name="left-attach">1</property>
diff --git a/src/org.gnome.Maps.src.gresource.xml b/src/org.gnome.Maps.src.gresource.xml
index 0f69d72..0514955 100644
--- a/src/org.gnome.Maps.src.gresource.xml
+++ b/src/org.gnome.Maps.src.gresource.xml
@@ -78,6 +78,7 @@
     <file>storedRoute.js</file>
     <file>time.js</file>
     <file>togeojson/togeojson.js</file>
+    <file>transitArrivalMarker.js</file>
     <file>transitArrivalRow.js</file>
     <file>transitItineraryRow.js</file>
     <file>transitLegRow.js</file>
diff --git a/src/transitArrivalMarker.js b/src/transitArrivalMarker.js
new file mode 100644
index 0000000..b07efaf
--- /dev/null
+++ b/src/transitArrivalMarker.js
@@ -0,0 +1,61 @@
+/* -*- Mode: JS2; indent-tabs-mode: nil; js2-basic-offset: 4 -*- */
+/* vim: set et ts=4 sw=4: */
+/*
+ * Copyright (c) 2017 Marcus Lundblad
+ *
+ * GNOME Maps is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * GNOME Maps is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with GNOME Maps; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Marcus Lundblad <ml update uu se>
+ */
+
+const Lang = imports.lang;
+
+const Gdk = imports.gi.Gdk;
+
+const Location = imports.location;
+const MapMarker = imports.mapMarker;
+const Place = imports.place;
+
+const TransitArrivalMarker = new Lang.Class({
+    Name: 'TransitArrivalMarker',
+    Extends: MapMarker.MapMarker,
+
+    _init: function(params) {
+        let lastPoint = params.leg.polyline[params.leg.polyline.length - 1];
+        let location =
+            new Location.Location({ latitude: lastPoint.latitude,
+                                    longitude: lastPoint.longitude
+                                  });
+
+        delete params.leg;
+        params.place = new Place.Place({ location: location });
+
+        this.parent(params);
+
+        let color = new Gdk.RGBA({ red: 0,
+                                   green: 0,
+                                   blue: 0,
+                                   alpha: 1.0
+                                 });
+        let actor =
+            this._actorFromIconName('maps-point-end-symbolic', 0, color);
+
+        this.add_actor(actor);
+    },
+
+    get anchor() {
+        return { x: Math.floor(this.width / 2) - 1,
+                 y: Math.floor(this.height / 2) - 1 };
+    }
+});
diff --git a/src/transitWalkMarker.js b/src/transitWalkMarker.js
index 22be11a..211e1c4 100644
--- a/src/transitWalkMarker.js
+++ b/src/transitWalkMarker.js
@@ -32,23 +32,23 @@ const TransitWalkMarker = new Lang.Class({
     Extends: MapMarker.MapMarker,
 
     _init: function(params) {
-        this._leg = params.leg;
-        delete params.leg;
-
-        this._previousLeg = params.previousLeg;
-        delete params.previousLeg;
-
         /* if there is a preceeding leg, put the marker at the end of that leg
          * to avoid gaps, since we will "fill out" the walking leg path line
          * since sometimes the walking route might not reach exactly to the
          * transit stop's position
          */
-        let point = this._previousLeg ?
-                    this._previousLeg.polyline[this._previousLeg.polyline.length - 1] :
-                    this._leg.polyline[0];
-        let location =
-            new Location.Location({ latitude: point.get_latitude(),
-                                    longitude: point.get_longitude() });
+        let point;
+        if (params.previousLeg)
+            point = params.previousLeg.polyline[params.previousLeg.polyline.length - 1];
+        else
+            point = params.leg.polyline[0];
+
+        delete params.leg;
+        delete params.previousLeg;
+
+        let location = new Location.Location({ latitude: point.latitude,
+                                               longitude: point.longitude
+                                             });
 
         params.place = new Place.Place({ location: location });
 
@@ -57,7 +57,8 @@ const TransitWalkMarker = new Lang.Class({
         let color = new Gdk.RGBA({ red: 0,
                                    green: 0,
                                    blue: 0,
-                                   alpha: 1.0 });
+                                   alpha: 1.0
+                                 });
         let actor =
             this._actorFromIconName('maps-point-start-symbolic', 0, color);
 


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