[gnome-maps/wip/mlundblad/transit-routing: 1/7] WIP: Add list box row to display a leg of a transit itinerary



commit ba046c999ff849ca06637f03f766821ebe557106
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/gnome-maps.css                    |   10 ++
 data/org.gnome.Maps.data.gresource.xml |    1 +
 data/ui/transit-leg-row.ui             |  144 ++++++++++++++++++++++++++++++++
 po/POTFILES.in                         |    1 +
 src/org.gnome.Maps.src.gresource.xml   |    1 +
 src/transitLegRow.js                   |  114 +++++++++++++++++++++++++
 6 files changed, 271 insertions(+), 0 deletions(-)
---
diff --git a/data/gnome-maps.css b/data/gnome-maps.css
index 5ff11b5..5f500fe 100644
--- a/data/gnome-maps.css
+++ b/data/gnome-maps.css
@@ -95,3 +95,13 @@
     min-height: 16px;
     font-size: smaller;
 }
+
+.small-circular {
+  border-radius: 14px;
+  min-width: 14px;
+  min-height: 14px;
+  padding: 0px 0px;
+  background-color: transparent;
+  -gtk-outline-radius: 14px;
+}
+
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..d81a411
--- /dev/null
+++ b/data/ui/transit-leg-row.ui
@@ -0,0 +1,144 @@
+<?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">0</property>
+        <property name="margin-bottom">0</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>
+        <child>
+          <object class="GtkStack" id="footerStack">
+            <property name="visible">True</property>
+            <property name="can-focus">False</property>
+            <child>
+              <object class="GtkGrid">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+                <child>
+                  <object class="GtkSeparator">
+                    <property name="visible">True</property>
+                    <property name="can-focus">False</property>
+                    <property name="hexpand">True</property>
+                    <property name="valign">GTK_ALIGN_CENTER</property>
+                  </object>
+                  <packing>
+                    <property name="top-attach">0</property>
+                    <property name="left-attach">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkButton" id="expandButton">
+                    <property name="visible">True</property>
+                    <property name="can-focus">True</property>
+                    <property name="tooltip-text" translatable="yes">Show intermediate stops and 
information</property>
+                    <!--<property name="width-request">10</property>
+                    <property name="height-request">10</property>-->
+                    <style>
+                      <class name="small-circular"/>
+                    </style>
+                    <child>
+                      <object class="GtkImage">
+                        <property name="visible">True</property>
+                        <property name="can-focus">False</property>
+                        <property name="icon-name">go-down-symbolic</property>
+                        <property name="pixel-size">8</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="top-attach">0</property>
+                    <property name="left-attach">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkSeparator">
+                    <property name="visible">True</property>
+                    <property name="can-focus">False</property>
+                    <property name="hexpand">True</property>
+                    <property name="valign">GTK_ALIGN_CENTER</property>
+                  </object>
+                  <packing>
+                    <property name="top-attach">0</property>
+                    <property name="left-attach">2</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="name">expander</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkSeparator">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+                <property name="hexpand">True</property>
+                <property name="valign">GTK_ALIGN_CENTER</property>
+              </object>
+              <packing>
+                <property name="name">separator</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="top-attach">3</property>
+            <property name="left-attach">0</property>
+            <property name="width">3</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..6c329ff
--- /dev/null
+++ b/src/transitLegRow.js
@@ -0,0 +1,114 @@
+/* -*- 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',
+                       'footerStack',
+                       'expandButton'],
+
+    _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();
+
+        this._expandButton.connect('clicked', (function() {
+            this._expand();
+        }).bind(this));
+    },
+
+    _expand: function() {
+        this._footerStack.visible_child_name = 'separator';
+    },
+
+    _collaps: function() {
+        this._footerStack.visible_child_name = 'expander';
+    }
+});


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