[gnome-maps/wip/mlundblad/transit-routing: 9/11] Add a list box row to show the arrival of a transit itinerary



commit daa53dbef5464ba7536b5b655156d771cfd8147a
Author: Marcus Lundblad <ml update uu se>
Date:   Tue Jun 7 23:59:03 2016 +0200

    Add a list box row to show the arrival of a transit itinerary

 data/org.gnome.Maps.data.gresource.xml |    1 +
 data/ui/transit-arrival-row.ui         |   53 ++++++++++++++++++++++++++++++
 po/POTFILES.in                         |    1 +
 src/org.gnome.Maps.src.gresource.xml   |    1 +
 src/transitArrivalRow.js               |   55 ++++++++++++++++++++++++++++++++
 5 files changed, 111 insertions(+), 0 deletions(-)
---
diff --git a/data/org.gnome.Maps.data.gresource.xml b/data/org.gnome.Maps.data.gresource.xml
index ebf23a5..f596942 100644
--- a/data/org.gnome.Maps.data.gresource.xml
+++ b/data/org.gnome.Maps.data.gresource.xml
@@ -31,6 +31,7 @@
     <file preprocess="xml-stripblanks">ui/sidebar.ui</file>
     <file preprocess="xml-stripblanks">ui/social-place-more-results-row.ui</file>
     <file preprocess="xml-stripblanks">ui/social-place-row.ui</file>
+    <file preprocess="xml-stripblanks">ui/transit-arrival-row.ui</file>
     <file preprocess="xml-stripblanks">ui/transit-itinerary-row.ui</file>
     <file preprocess="xml-stripblanks">ui/transit-leg-row.ui</file>
     <file preprocess="xml-stripblanks">ui/transit-route-label.ui</file>
diff --git a/data/ui/transit-arrival-row.ui b/data/ui/transit-arrival-row.ui
new file mode 100644
index 0000000..ed5c7dc
--- /dev/null
+++ b/data/ui/transit-arrival-row.ui
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<interface>
+  <requires lib="gtk+" version="3.14"/>
+  <template class="Gjs_TransitArrivalRow" parent="GtkListBoxRow">
+    <property name="visible">True</property>
+    <property name="can-focus">False</property>
+    <child>
+      <object class="GtkGrid" id="grid">
+        <property name="visible">True</property>
+        <property name="margin-top">6</property>
+        <property name="margin-bottom">6</property>
+        <property name="row-spacing">3</property>
+        <child>
+          <object class="GtkImage">
+            <property name="visible">True</property>
+            <property name="can-focus">False</property>
+            <property name="margin-left">12</property>
+            <property name="margin-right">12</property>
+            <property name="icon-name">maps-point-end-symbolic</property>
+          </object>
+          <packing>
+            <property name="left-attach">0</property>
+            <property name="top-attach">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="arrivalLabel">
+            <property name="visible">True</property>
+            <property name="can-focus">False</property>
+            <property name="hexpand">True</property>
+            <property name="halign">GTK_ALIGN_START</property>
+          </object>
+          <packing>
+            <property name="left-attach">1</property>
+            <property name="top-attach">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="timeLabel">
+            <property name="visible">True</property>
+            <property name="can-focus">False</property>
+            <property name="halign">GTK_ALIGN_END</property>
+            <property name="margin-end">12</property>
+          </object>
+          <packing>
+            <property name="left-attach">2</property>
+            <property name="top-attach">0</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 7267ca4..273b29d 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -49,6 +49,7 @@ src/routeService.js
 src/sendToDialog.js
 src/shapeLayer.js
 src/sidebar.js
+src/transitArrivalRow.js
 src/transitLegRow.js
 src/transitPlan.js
 src/translations.js
diff --git a/src/org.gnome.Maps.src.gresource.xml b/src/org.gnome.Maps.src.gresource.xml
index 66b5f7b..2f5a80f 100644
--- a/src/org.gnome.Maps.src.gresource.xml
+++ b/src/org.gnome.Maps.src.gresource.xml
@@ -72,6 +72,7 @@
     <file>socialPlaceMatcher.js</file>
     <file>storedRoute.js</file>
     <file>togeojson/togeojson.js</file>
+    <file>transitArrivalRow.js</file>
     <file>transitItineraryRow.js</file>
     <file>transitLegRow.js</file>
     <file>transitOptions.js</file>
diff --git a/src/transitArrivalRow.js b/src/transitArrivalRow.js
new file mode 100644
index 0000000..4bbc6e5
--- /dev/null
+++ b/src/transitArrivalRow.js
@@ -0,0 +1,55 @@
+/* -*- Mode: JS2; indent-tabs-mode: nil; js2-basic-offset: 4 -*- */
+/* vim: set et ts=4 sw=4: */
+/*
+ * Copyright (c) 2016 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, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: Marcus Lundblad <ml update uu se>
+ */
+
+const Lang = imports.lang;
+
+const _ = imports.gettext.gettext;
+
+const Gtk = imports.gi.Gtk;
+
+const TransitArrivalRow = new Lang.Class({
+   Name: 'TransitArrivalRow',
+   Extends: Gtk.ListBoxRow,
+   Template: 'resource:///org/gnome/Maps/ui/transit-arrival-row.ui',
+   InternalChildren: ['arrivalLabel',
+                      'timeLabel'],
+
+   _init: function(params) {
+       this._itinerary = params.itinerary;
+       delete params.itinerary;
+
+       this.parent(params);
+
+       let lastLeg = this._itinerary.legs[this._itinerary.legs.length - 1];
+
+       if (lastLeg.to) {
+           /* Translators: this a format string indicating arriving at the
+            * destination of journey with the arrival address and transit
+            * stop as the format parameter */
+           this._arrivalLabel.label = _("Arrive at %s").format(lastLeg.to);
+       } else {
+           this._arrivalLabel.label = _("Arrive");
+       }
+
+       this._timeLabel.label = lastLeg.prettyPrintArrivalTime();
+   }
+});


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