[gnome-maps/wip/mlundblad/transit-routing: 9/12] WIP: Add list box row to display a leg of a transit itinerary
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/transit-routing: 9/12] WIP: Add list box row to display a leg of a transit itinerary
- Date: Sun, 12 Jun 2016 15:10:02 +0000 (UTC)
commit 379c8f466913b1ba37a59fed5e4701517556cafb
Author: Marcus Lundblad <ml update uu se>
Date: Mon Jun 6 23:19:56 2016 +0200
WIP: Add list box row to display a leg of a transit itinerary
data/org.gnome.Maps.data.gresource.xml | 1 +
data/ui/transit-leg-row.ui | 65 +++++++++++++++++++++
po/POTFILES.in | 1 +
src/org.gnome.Maps.src.gresource.xml | 1 +
src/transitLegRow.js | 100 ++++++++++++++++++++++++++++++++
5 files changed, 168 insertions(+), 0 deletions(-)
---
diff --git a/data/org.gnome.Maps.data.gresource.xml b/data/org.gnome.Maps.data.gresource.xml
index 33cbea1..ebf23a5 100644
--- a/data/org.gnome.Maps.data.gresource.xml
+++ b/data/org.gnome.Maps.data.gresource.xml
@@ -32,6 +32,7 @@
<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-itinerary-row.ui</file>
+ <file preprocess="xml-stripblanks">ui/transit-leg-row.ui</file>
<file preprocess="xml-stripblanks">ui/transit-route-label.ui</file>
<file preprocess="xml-stripblanks">ui/user-location-bubble.ui</file>
<file preprocess="xml-stripblanks">ui/zoom-control.ui</file>
diff --git a/data/ui/transit-leg-row.ui b/data/ui/transit-leg-row.ui
new file mode 100644
index 0000000..a41ed6f
--- /dev/null
+++ b/data/ui/transit-leg-row.ui
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="utf-8"?>
+<interface>
+ <requires lib="gtk+" version="3.14"/>
+ <template class="Gjs_TransitLegRow" 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" id="modeImage">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="margin-start">12</property>
+ <property name="margin-end">12</property>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">0</property>
+ <property name="height">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="fromLabel">
+ <property name="visible">True</property>
+ <property name="can-focus">False</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="GtkGrid" id="routeGrid">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="timeLabel">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="margin-start">6</property>
+ <property name="margin-end">12</property>
+ <property name="hexpand">True</property>
+ <property name="halign">GTK_ALIGN_END</property>
+ </object>
+ <packing>
+ <property name="left-attach">2</property>
+ <property name="top-attach">0</property>
+ <property name="height">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index c79f8f7..7267ca4 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/transitLegRow.js
src/transitPlan.js
src/translations.js
src/utils.js
diff --git a/src/org.gnome.Maps.src.gresource.xml b/src/org.gnome.Maps.src.gresource.xml
index 1475d87..edf362a 100644
--- a/src/org.gnome.Maps.src.gresource.xml
+++ b/src/org.gnome.Maps.src.gresource.xml
@@ -74,6 +74,7 @@
<file>storedRoute.js</file>
<file>togeojson/togeojson.js</file>
<file>transitItineraryRow.js</file>
+ <file>transitLegRow.js</file>
<file>transitOptions.js</file>
<file>transitPlan.js</file>
<file>transitRouteLabel.js</file>
diff --git a/src/transitLegRow.js b/src/transitLegRow.js
new file mode 100644
index 0000000..778cb22
--- /dev/null
+++ b/src/transitLegRow.js
@@ -0,0 +1,100 @@
+/* -*- 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 TransitRouteLabel = imports.transitRouteLabel;
+const Utils = imports.utils;
+
+const TransitLegRow = new Lang.Class({
+ Name: 'TransitLegRow',
+ Extends: Gtk.ListBoxRow,
+ Template: 'resource:///org/gnome/Maps/ui/transit-leg-row.ui',
+ InternalChildren: ['grid',
+ 'modeImage',
+ 'fromLabel',
+ 'routeGrid',
+ 'timeLabel'],
+
+ _init: function(params) {
+ this._leg = params.leg;
+ delete params.leg;
+
+ this._start = params.start;
+ delete params.start;
+
+ this.parent();
+
+ this._modeImage.icon_name = this._leg.iconName;
+ if (this._start) {
+ if (this._leg.from) {
+ /* Translators: this is a format string indicating instructions
+ * starting a journey at the address given as the parameter */
+ this._fromLabel.label = _("Start at %s").format(this._leg.from);
+ } else {
+ /* Translators: this indicates starting a journey at a location
+ * with no set name (such as when the user started routing from
+ * an arbitrary point on the map) */
+ this._fromLabel.label = _("Start");
+ }
+ } else {
+ this._fromLabel.label = this._leg.from;
+ }
+
+ if (this._leg.transit) {
+ let routeLabel =
+ new TransitRouteLabel.TransitRouteLabel({ leg: this._leg });
+
+ routeLabel.margin_end = 3;
+ routeLabel.hexpand = false;
+ routeLabel.halign = Gtk.Align.START;
+ this._routeGrid.add(routeLabel);
+ }
+
+ let headsignLabel = new Gtk.Label({ visible: true, can_focus: false,
+ use_markup: true, hexpand: true,
+ halign: Gtk.Align.START });
+ if (this._leg.transit) {
+ headsignLabel.label =
+ '<span size="small">%s</span>'.format(this._leg.headsign);
+ } else {
+ /* Translators: this is a format string indicating walking a certain
+ * distance, with the distance expression being the %s placeholder */
+ let label =
+ _("Walk %s").format(Utils.prettyDistance(this._leg.distance));
+ headsignLabel.label =
+ '<span size="small">%s</span>'.format(label);
+ }
+
+ headsignLabel.get_style_context().add_class('dim-label');
+ this._routeGrid.add(headsignLabel);
+
+ if (!this._leg.transit && this._start)
+ this._timeLabel.label = this._leg.prettyPrintDepartureTime();
+ else
+ this._timeLabel.label = this._leg.prettyPrintTimeInterval();
+ }
+});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]