[gnome-maps/wip/mlundblad/transit-service-discovery: 3/4] WIP: sidebar: Update attribution



commit 19746f8680031384847a6ad239c5b1e4e601b1dc
Author: Marcus Lundblad <ml update uu se>
Date:   Sun Sep 1 13:19:45 2019 +0200

    WIP: sidebar: Update attribution

 data/ui/sidebar.ui |  9 ++-------
 src/sidebar.js     | 24 +++++++++++++++++++++++-
 2 files changed, 25 insertions(+), 8 deletions(-)
---
diff --git a/data/ui/sidebar.ui b/data/ui/sidebar.ui
index 015b907..6b6707d 100644
--- a/data/ui/sidebar.ui
+++ b/data/ui/sidebar.ui
@@ -292,16 +292,11 @@
                 <property name="visible">True</property>
                 <property name="halign">GTK_ALIGN_END</property>
                 <child>
-                  <object class="GtkLinkButton">
-                    <property name="label" translatable="yes">Route search by OpenTripPlanner</property>
+                  <object class="GtkLabel" id="transitAttributionLabel">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">True</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="relief">none</property>
-                    <!-- opentripplanner.org uses an SSL cert only valid for github
-                         domains... -->
-                    <property name="uri">http://www.opentripplanner.org</property>
+                    <property name="use_markup">True</property>
                     <style>
                       <class name="small-label"/>
                     </style>
diff --git a/src/sidebar.js b/src/sidebar.js
index 2edc324..3294665 100644
--- a/src/sidebar.js
+++ b/src/sidebar.js
@@ -64,7 +64,8 @@ var Sidebar = GObject.registerClass({
                         'transitItineraryListBox',
                         'transitItineraryBackButton',
                         'transitItineraryTimeLabel',
-                        'transitItineraryDurationLabel']
+                        'transitItineraryDurationLabel',
+                        'transitAttributionLabel']
 }, class Sidebar extends Gtk.Revealer {
 
     _init(mapView) {
@@ -232,6 +233,7 @@ var Sidebar = GObject.registerClass({
             /* don't remove query points as with the turn-based routing,
              * since we might get "no route" because of the time selected
              * and so on */
+            this._transitAttributionLabel.label = '';
         });
 
         transitPlan.connect('no-more-results', () => {
@@ -248,6 +250,7 @@ var Sidebar = GObject.registerClass({
                 if (this._query.transportation === RouteQuery.Transportation.TRANSIT) {
                     this._clearTransitOverview();
                     this._showTransitOverview();
+                    this._transitAttributionLabel.label = '';
                 } else {
                     this._clearInstructions();
                 }
@@ -300,6 +303,7 @@ var Sidebar = GObject.registerClass({
         });
 
         transitPlan.connect('update', () => {
+            this._updateTransitAttribution();
             this._clearTransitOverview();
             this._showTransitOverview();
             this._populateTransitItineraryOverview();
@@ -340,6 +344,24 @@ var Sidebar = GObject.registerClass({
         listBox.forall(listBox.remove.bind(listBox));
     }
 
+    _updateTransitAttribution() {
+        let plan = Application.routingDelegator.transitRouter.plan;
+
+        if (plan.attribution) {
+            let attributionLabel =
+                _("Itineraries provided by %s").format(plan.attribution);
+            if (plan.attributionUrl) {
+                this._transitAttributionLabel.label =
+                    '<a href="%s">%s</a>'.format([plan.attributionUrl],
+                                                 attributionLabel);
+            } else {
+                this._transitAttributionLabel.label = attributionLabel;
+            }
+        } else {
+            this._transitAttributionLabel.label = '';
+        }
+    }
+
     _showTransitOverview() {
         let plan = Application.routingDelegator.transitRouter.plan;
 


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