[gnome-maps/wip/mlundblad/photon-geocode: 2/3] mainWindow: Show geocoder attribution in About



commit 3a0fdb1b6b6ff535952120e60eea6a7e88483d62
Author: Marcus Lundblad <ml update uu se>
Date:   Fri May 3 20:12:53 2019 +0200

    mainWindow: Show geocoder attribution in About
    
    Show attribution for the geocode service provider in
    the About dialog.

 src/mainWindow.js | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index e2bafe7..5b0b6e9 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -33,6 +33,7 @@ const Application = imports.application;
 const ContextMenu = imports.contextMenu;
 const FavoritesPopover = imports.favoritesPopover;
 const Geoclue = imports.geoclue;
+const GeocodeFactory = imports.geocode;
 const LayersPopover = imports.layersPopover;
 const LocationServiceDialog = imports.locationServiceDialog;
 const MapView = imports.mapView;
@@ -536,6 +537,7 @@ var MainWindow = GObject.registerClass({
 
     _getAttribution() {
         let tileProviderInfo = Service.getService().tileProviderInfo;
+        let photonGeocode = Service.getService().photonGeocode;
         let attribution = _("Map data by %s and contributors").format('<a 
href="https://www.openstreetmap.org";>OpenStreetMap</a>');
 
         if (tileProviderInfo) {
@@ -555,6 +557,35 @@ var MainWindow = GObject.registerClass({
             attribution += _("Map tiles provided by %s").format(tileProviderString);
         }
 
+        let provider = GeocodeFactory.getGeocoder().attribution;
+        let providerUrl = GeocodeFactory.getGeocoder().attributionUrl;
+        let geocoderName = GeocodeFactory.getGeocoder().name;
+        let geocoderUrl = GeocodeFactory.getGeocoder().url;
+
+        let providerString;
+        if (providerUrl) {
+            providerString =
+                '<a href="' + providerUrl + '">' + provider + '</a>';
+        } else {
+            providerString = provider;
+        }
+
+        let geocoderLink =
+            '<a href="%s">%s</a>'.format(geocoderUrl, geocoderName);
+
+        attribution += '\n';
+        /* Translators: this is an attribution string giving credit to the
+         * search provider where the first %s placeholder is replaced by either
+         * the bare name of the geocoder provider, or a linkified URL if one
+         * is available, and the second %s placeholder is replaced by the
+         * URL to the geocoder project page. These placeholders
+         * can be swapped, if needed using the %n$s positional syntax
+         * (i.e. "%2$s ... %1$s ..." for positioning the project URL
+         * before the provider).
+         */
+        attribution += _("Search provided by %s using %s").
+            format(providerString, geocoderLink);
+
         return attribution;
     }
 


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