[gnome-maps/wip/mlundblad/transit-routing: 5/11] Add list box row class for transit stops



commit 801b7d013755332098a713f45c3f4f60e542c7fd
Author: Marcus Lundblad <ml update uu se>
Date:   Wed Jun 29 22:59:13 2016 +0200

    Add list box row class for transit stops
    
    List box row showing intermediate stops.

 data/org.gnome.Maps.data.gresource.xml |    1 +
 data/ui/transit-stop-row.ui            |   52 ++++++++++++++++++++++++++++++++
 src/org.gnome.Maps.src.gresource.xml   |    1 +
 src/transitLegRow.js                   |    3 ++
 src/transitStopRow.js                  |   52 ++++++++++++++++++++++++++++++++
 5 files changed, 109 insertions(+), 0 deletions(-)
---
diff --git a/data/org.gnome.Maps.data.gresource.xml b/data/org.gnome.Maps.data.gresource.xml
index d8cac68..a313ce8 100644
--- a/data/org.gnome.Maps.data.gresource.xml
+++ b/data/org.gnome.Maps.data.gresource.xml
@@ -36,6 +36,7 @@
     <file preprocess="xml-stripblanks">ui/transit-leg-row.ui</file>
     <file preprocess="xml-stripblanks">ui/transit-more-row.ui</file>
     <file preprocess="xml-stripblanks">ui/transit-route-label.ui</file>
+    <file preprocess="xml-stripblanks">ui/transit-stop-row.ui</file>
     <file preprocess="xml-stripblanks">ui/user-location-bubble.ui</file>
     <file preprocess="xml-stripblanks">ui/zoom-control.ui</file>
     <file preprocess="xml-stripblanks">ui/zoom-in-notification.ui</file>
diff --git a/data/ui/transit-stop-row.ui b/data/ui/transit-stop-row.ui
new file mode 100644
index 0000000..6557ab7
--- /dev/null
+++ b/data/ui/transit-stop-row.ui
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<interface>
+  <template class="Gjs_TransitStopRow" parent="GtkListBoxRow">
+    <property name="visible">True</property>
+    <property name="can-focus">False</property>
+    <child>
+      <object class="GtkGrid" id="grid">
+        <property name="visible">True</property>
+        <child>
+          <object class="GtkImage">
+            <property name="visible">True</property>
+            <property name="can-focus">False</property>
+            <property name="margin-left">0</property>
+            <property name="margin-right">6</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="nameLabel">
+            <property name="visible">True</property>
+            <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>
+            <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">0</property>
+          </object>
+          <packing>
+            <property name="left-attach">2</property>
+            <property name="top-attach">0</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/src/org.gnome.Maps.src.gresource.xml b/src/org.gnome.Maps.src.gresource.xml
index 6612de5..fa1b45d 100644
--- a/src/org.gnome.Maps.src.gresource.xml
+++ b/src/org.gnome.Maps.src.gresource.xml
@@ -83,6 +83,7 @@
     <file>transitOptions.js</file>
     <file>transitPlan.js</file>
     <file>transitRouteLabel.js</file>
+    <file>transitStopRow.js</file>
     <file>transitWalkMarker.js</file>
     <file>translations.js</file>
     <file>turnPointMarker.js</file>
diff --git a/src/transitLegRow.js b/src/transitLegRow.js
index 962f527..a6caad3 100644
--- a/src/transitLegRow.js
+++ b/src/transitLegRow.js
@@ -27,6 +27,7 @@ const _ = imports.gettext.gettext;
 const Gdk = imports.gi.Gdk;
 const GLib = imports.gi.GLib;
 const Gtk = imports.gi.Gtk;
+const Pango = imports.gi.Pango;
 
 const InstructionRow = imports.instructionRow;
 const TransitRouteLabel = imports.transitRouteLabel;
@@ -90,6 +91,8 @@ const TransitLegRow = new Lang.Class({
 
         let headsignLabel = new Gtk.Label({ visible: true, can_focus: false,
                                             use_markup: true, hexpand: true,
+                                            max_width_chars: 20,
+                                            ellipsize: Pango.EllipsizeMode.END,
                                             halign: Gtk.Align.START });
         if (this._leg.transit) {
             headsignLabel.label =
diff --git a/src/transitStopRow.js b/src/transitStopRow.js
new file mode 100644
index 0000000..f7c2f58
--- /dev/null
+++ b/src/transitStopRow.js
@@ -0,0 +1,52 @@
+/* -*- 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 TransitStopRow = new Lang.Class({
+    Name: 'TransitStopRow',
+    Extends: Gtk.ListBoxRow,
+    Template: 'resource:///org/gnome/Maps/ui/transit-stop-row.ui',
+    InternalChildren: [ 'nameLabel',
+                        'timeLabel' ],
+
+    _init: function(params) {
+        this.stop = params.stop;
+        delete params.stop;
+
+        this._final = params.final;
+        delete params.final;
+
+        this.parent();
+
+        this._nameLabel.label = this.stop.name;
+
+        if (this._final)
+            this._timeLabel.label = this.stop.prettyPrintArrivalTime();
+        else
+            this._timeLabel.label = this.stop.prettyPrintDepartureTime();
+    }
+});


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