[gnome-maps/wip/mlundblad/show-native-names] placeView: Show native name of the place




commit d3624d995bfe02ae19da110d3f0a807c4bc432e4
Author: Marcus Lundblad <ml update uu se>
Date:   Wed Feb 10 22:38:23 2021 +0100

    placeView: Show native name of the place
    
    Show a place' native when it differs from
    the one shown at the top (the localized one
    when available) and the user's system has
    fonts capable of displaying it.

 data/ui/place-view.ui | 17 ++++++++++++++++-
 src/placeView.js      | 17 +++++++++++++++++
 2 files changed, 33 insertions(+), 1 deletion(-)
---
diff --git a/data/ui/place-view.ui b/data/ui/place-view.ui
index cbfbd531..7897d5f0 100644
--- a/data/ui/place-view.ui
+++ b/data/ui/place-view.ui
@@ -30,7 +30,7 @@
             <property name="can_focus">False</property>
             <property name="orientation">vertical</property>
             <property name="margin">18</property>
-            <property name="spacing">12</property>
+            <property name="spacing">6</property>
             <child>
               <object class="GtkBox">
                 <property name="visible">True</property>
@@ -77,6 +77,20 @@
                 </child>
               </object>
             </child>
+            <child>
+              <object class="GtkLabel" id="native-name">
+                <property name="visible">False</property>
+                <property name="can_focus">False</property>
+                <property name="halign">start</property>
+                <property name="expand">True</property>
+                <property name="wrap">True</property>
+                <property name="max_width_chars">30</property>
+                <property name="xalign">0</property>
+                <style>
+                  <class name="dim-label"/>
+                </style>
+              </object>
+            </child>
             <child>
               <object class="GtkLabel" id="address-label">
                 <property name="visible">True</property>
@@ -85,6 +99,7 @@
                 <property name="xalign">0</property>
                 <property name="use_markup">True</property>
                 <property name="wrap">True</property>
+                <property name="margin-top">6</property>
               </object>
             </child>
             <child>
diff --git a/src/placeView.js b/src/placeView.js
index faa96a10..4bb266df 100644
--- a/src/placeView.js
+++ b/src/placeView.js
@@ -75,6 +75,7 @@ var PlaceView = GObject.registerClass({
                                                    'bubble-thumbnail',
                                                    'thumbnail-separator',
                                                    'label-title',
+                                                   'native-name',
                                                    'contact-avatar',
                                                    'address-label',
                                                    'bubble-main-stack',
@@ -83,6 +84,7 @@ var PlaceView = GObject.registerClass({
                                                    'send-to-button-alt',
                                                    'title-box' ]);
         this._title = ui.labelTitle;
+        this._nativeName = ui.nativeName;
         this._thumbnail = ui.bubbleThumbnail;
         this._thumbnailSeparator = ui.thumbnailSeparator;
         this._content = ui.bubbleContentArea;
@@ -214,6 +216,21 @@ var PlaceView = GObject.registerClass({
 
         this._title.label = formatter.title;
         this._contactAvatar.text = formatter.title;
+
+        /* show native name unless it's equal to the localized name, or
+         * if the localized name is a substring of the native name, as can
+         * be the case in e.g. duo-lingual native names, such as is used in
+         * Brussels of the form "French name - Dutch name"
+         */
+        if (place.nativeName && !place.nativeName.includes(place.name)) {
+            this._nativeName.label = place.nativeName;
+
+            /* only show native name if there's installed fonts capable of
+             * showing it
+             */
+            if (this._nativeName.get_layout().get_unknown_glyphs_count() === 0)
+                this._nativeName.visible = true;
+        }
     }
 
     _onInfoAdded() {


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