[gnome-characters/wip/exalm/emoji: 5/5] characterDialog: Don't show codepoint for composite emoji




commit 9656c16d0cffa195e5c65a64dafc82f7aea41d6a
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Thu Mar 10 22:22:29 2022 +0400

    characterDialog: Don't show codepoint for composite emoji
    
    There isn't a single codepoint to show here, just hide it.

 data/character_dialog.ui |  2 +-
 src/characterDialog.js   | 25 ++++++++++++++++++-------
 2 files changed, 19 insertions(+), 8 deletions(-)
---
diff --git a/data/character_dialog.ui b/data/character_dialog.ui
index adf2be1..3f26344 100644
--- a/data/character_dialog.ui
+++ b/data/character_dialog.ui
@@ -87,7 +87,7 @@
                               <object class="GtkListBox">
                                 <property name="selection-mode">none</property>
                                 <child>
-                                  <object class="AdwActionRow">
+                                  <object class="AdwActionRow" id="detailRow">
                                     <property name="title" translatable="yes">Unicode</property>
                                     <child>
                                       <object class="GtkLabel" id="detailLabel">
diff --git a/src/characterDialog.js b/src/characterDialog.js
index 6b6c9d7..3118473 100644
--- a/src/characterDialog.js
+++ b/src/characterDialog.js
@@ -28,7 +28,8 @@ var CharacterDialog = GObject.registerClass({
     Template: 'resource:///org/gnome/Characters/character_dialog.ui',
     InternalChildren: [
         'leaflet', 'characterStack',
-        'characterLabel', 'missingLabel', 'detailLabel',
+        'characterLabel', 'missingLabel',
+        'detailRow', 'detailLabel',
         'seeAlsoRow', 'relatedListbox',
         'windowTitle', 'toastOverlay',
     ],
@@ -90,18 +91,28 @@ var CharacterDialog = GObject.registerClass({
     _setCharacter(uc) {
         this._character = uc;
 
-        let codePoint = Util.toCodePoint(this._character);
-        let codePointHex = codePoint.toString(16).toUpperCase();
-
         let name = Gc.character_name(this._character);
         if (name !== null)
             name = Util.capitalize(name);
-        else
-            name = 'U+%04s'.format(codePointHex);
+
+        if (Gc.character_is_composite(uc)) {
+            this._detailRow.hide();
+
+            if (name === null)
+                name = 'Emoji';
+        } else {
+            let codePoint = Util.toCodePoint(this._character);
+            let codePointHex = codePoint.toString(16).toUpperCase();
+
+            this._detailLabel.label = 'U+%04s'.format(codePointHex);
+            this._detailRow.show();
+
+            if (name === null)
+                name = 'U+%04s'.format(codePointHex);
+        }
 
         this._windowTitle.title = name;
         this._characterLabel.label = this._character;
-        this._detailLabel.label = 'U+%04s'.format(codePointHex);
 
         let pangoContext = this._characterLabel.get_pango_context();
         pangoContext.set_font_description(this._fontDescription);


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