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




commit 60b4feda96f018aaf4973287896377390af536f9
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 | 15 +++++++++++++++
 src/placeView.js      | 17 +++++++++++++++++
 2 files changed, 32 insertions(+)
---
diff --git a/data/ui/place-view.ui b/data/ui/place-view.ui
index cbfbd531..06f2dcce 100644
--- a/data/ui/place-view.ui
+++ b/data/ui/place-view.ui
@@ -77,6 +77,21 @@
                 </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="caption"/>
+                  <class name="dim-label"/>
+                </style>
+              </object>
+            </child>
             <child>
               <object class="GtkLabel" id="address-label">
                 <property name="visible">True</property>
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]