[gnome-maps/wip/mlundblad/transit-routing: 17/29] Add a list box row to show the arrival of a transit itinerary
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/transit-routing: 17/29] Add a list box row to show the arrival of a transit itinerary
- Date: Thu, 13 Oct 2016 19:32:24 +0000 (UTC)
commit dda9d7165b83f0ea4d96703e2f6c6f0671ba3061
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 | 72 ++++++++++++++++++++++++++++++
po/POTFILES.in | 1 +
src/org.gnome.Maps.src.gresource.xml | 1 +
src/transitArrivalRow.js | 75 ++++++++++++++++++++++++++++++++
5 files changed, 150 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..2be414c
--- /dev/null
+++ b/data/ui/transit-arrival-row.ui
@@ -0,0 +1,72 @@
+<?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="GtkEventBox" id="eventBox">
+ <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">0</property>
+ <property name="row-spacing">12</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-start">6</property>
+ <property name="margin-end">18</property>
+ </object>
+ <packing>
+ <property name="left-attach">2</property>
+ <property name="top-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSeparator">
+ <property name="visible">True</property>
+ <property name="can-focus">False</property>
+ <property name="valign">GTK_ALIGN_CENTER</property>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">1</property>
+ <property name="width">3</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 5eaa2c9..4e5d75a 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -50,6 +50,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 8272afd..817bb75 100644
--- a/src/org.gnome.Maps.src.gresource.xml
+++ b/src/org.gnome.Maps.src.gresource.xml
@@ -74,6 +74,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..8fa64e2
--- /dev/null
+++ b/src/transitArrivalRow.js
@@ -0,0 +1,75 @@
+/* -*- 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 Gdk = imports.gi.Gdk;
+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',
+ 'eventBox'],
+
+ _init: function(params) {
+ this._itinerary = params.itinerary;
+ delete params.itinerary;
+
+ this._mapView = params.mapView;
+ delete params.mapView;
+
+ 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();
+
+ this._eventBox.connect('event', (function(widget, event) {
+ this._onEvent(event, lastLeg.toCoordinate);
+ return true;
+ }).bind(this));
+ },
+
+ _onEvent: function(event, coord) {
+ let [isButton, button] = event.get_button();
+ let type = event.get_event_type();
+
+ if (isButton && button === 1 && type === Gdk.EventType.BUTTON_PRESS) {
+ this._mapView.view.zoom_level = 16;
+ this._mapView.view.center_on(coord[0], coord[1]);
+ }
+ }
+});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]