[gnome-maps/wip/mlundblad/dont-use-offscreen-window: 4/11] Add module with utility functions for transit
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/dont-use-offscreen-window: 4/11] Add module with utility functions for transit
- Date: Mon, 25 Mar 2019 21:43:01 +0000 (UTC)
commit 7ff7a3d961fba4244ab94645d9ef059d534dbb93
Author: Marcus Lundblad <ml update uu se>
Date: Sun Mar 17 22:07:35 2019 +0100
Add module with utility functions for transit
Utility module with functions related to presenting
public transit itineraries.
Fixes #78
po/POTFILES.in | 1 +
src/org.gnome.Maps.src.gresource.xml | 1 +
src/transit.js | 79 ++++++++++++++++++++++++++++++++++++
3 files changed, 81 insertions(+)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index a538f71..f49ebcf 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -51,6 +51,7 @@ src/routeEntry.js
src/sendToDialog.js
src/shapeLayer.js
src/sidebar.js
+src/transit.js
src/transitArrivalRow.js
src/transitLegRow.js
src/transitMoreRow.js
diff --git a/src/org.gnome.Maps.src.gresource.xml b/src/org.gnome.Maps.src.gresource.xml
index 16d777f..4abd878 100644
--- a/src/org.gnome.Maps.src.gresource.xml
+++ b/src/org.gnome.Maps.src.gresource.xml
@@ -76,6 +76,7 @@
<file>storedRoute.js</file>
<file>time.js</file>
<file>togeojson/togeojson.js</file>
+ <file>transit.js</file>
<file>transitArrivalMarker.js</file>
<file>transitArrivalRow.js</file>
<file>transitBoardMarker.js</file>
diff --git a/src/transit.js b/src/transit.js
new file mode 100644
index 0000000..936847e
--- /dev/null
+++ b/src/transit.js
@@ -0,0 +1,79 @@
+/* -*- Mode: JS2; indent-tabs-mode: nil; js2-basic-offset: 4 -*- */
+/* vim: set et ts=4 sw=4: */
+/*
+ * Copyright (c) 2019, 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 _ = imports.gettext.gettext;
+
+const Utils = imports.utils;
+
+/**
+ * Get the label to display for the starting point of an itinerary leg.
+ * leg: the itinerary leg
+ * isFirstLeg: true if this is the first leg of the itinerary.
+ */
+function getFromLabel(leg, isFirstLeg) {
+ if (isFirstLeg) {
+ if (leg.from) {
+ /* Translators: this is a format string indicating instructions
+ * starting a journey at the address given as the parameter
+ */
+ return _("Start at %s").format(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)
+ */
+ return _("Start");
+ }
+ } else {
+ return leg.from;
+ }
+}
+
+/**
+ * Get the label to display for the destination headsign.
+ * leg: the itinerary leg
+ */
+function getHeadsignLabel(leg) {
+ if (leg.transit && leg.headsign) {
+ return leg.headsign;
+ } else if (!leg.transit) {
+ /* Translators: this is a format string indicating walking a certain
+ * distance, with the distance expression being the %s placeholder
+ */
+ return _("Walk %s").format(Utils.prettyDistance(leg.distance));
+ } else {
+ return null;
+ }
+}
+
+/**
+ * Get the label to display for arrival of the final leg of an itinerary.
+ */
+function getArrivalLabel(lastLeg) {
+ 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 */
+ return _("Arrive at %s").format(lastLeg.to);
+ } else {
+ return _("Arrive");
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]