[gtk/emoji-data-cldr: 4/5] Emoji: Drop the shortname field from emoji.data




commit 7ef5921022b568ea2cb5c7d98f4d742e89560b70
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Apr 15 01:19:09 2020 -0400

    Emoji: Drop the shortname field from emoji.data
    
    Match the name for Emoji completion, and display
    it too. 'man worker' looks a lot more natural in
    the UI than ':man_worker:'.

 gtk/emoji/convert-emoji.c                          |  10 ++--------
 gtk/emoji/emoji.data                               | Bin 152041 -> 135259 bytes
 gtk/gtkemojichooser.c                              |  10 +++++-----
 gtk/gtkemojicompletion.c                           |  17 +++++++++--------
 gtk/org.gtk.gtk4.Settings.EmojiChooser.gschema.xml |   4 ++--
 5 files changed, 18 insertions(+), 23 deletions(-)
---
diff --git a/gtk/emoji/convert-emoji.c b/gtk/emoji/convert-emoji.c
index 2e89f5a3d6..5226fcdd35 100644
--- a/gtk/emoji/convert-emoji.c
+++ b/gtk/emoji/convert-emoji.c
@@ -24,8 +24,6 @@
  *      sequence contains a 0, it marks the point
  *      where skin tone modifiers should be inserted
  * s  - name, e.g. "man worker"
- * s  - shortname, for completion. This includes
- *      colons to mark the ends, e.g. ":guardsman:"
  * as - keywords, e.g. "man", "worker"
  */
 #include <json-glib/json-glib.h>
@@ -127,7 +125,7 @@ main (int argc, char *argv[])
   array = json_node_get_array (root);
   length = json_array_get_length (array);
 
-  g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(aussas)"));
+  g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(ausas)"));
   i = 0;
   while (i < length)
     {
@@ -136,7 +134,6 @@ main (int argc, char *argv[])
       GVariantBuilder b1;
       GVariantBuilder b2;
       const char *name;
-      const char *shortname;
       char *code;
       int j, k;
       gboolean skip;
@@ -187,7 +184,6 @@ main (int argc, char *argv[])
       obj2 = g_hash_table_lookup (names, name_key->str);
       if (obj2)
         {
-          shortname = json_object_get_string_member (obj2, "shortname");
           kw = json_object_get_array_member (obj2, "keywords");
           for (k = 0; k < json_array_get_length (kw); k++)
             {
@@ -209,12 +205,10 @@ main (int argc, char *argv[])
               g_strfreev (ascii);
             }
         }
-      else
-        shortname = "";
 
       g_strfreev (name_tokens);
 
-      g_variant_builder_add (&builder, "(aussas)", &b1, name, shortname, &b2);
+      g_variant_builder_add (&builder, "(ausas)", &b1, name, &b2);
     }
 
   v = g_variant_builder_end (&builder);
diff --git a/gtk/emoji/emoji.data b/gtk/emoji/emoji.data
index 5b9298db16..944fe0f7da 100644
Binary files a/gtk/emoji/emoji.data and b/gtk/emoji/emoji.data differ
diff --git a/gtk/gtkemojichooser.c b/gtk/gtkemojichooser.c
index c58fe51bb2..997a832dd5 100644
--- a/gtk/gtkemojichooser.c
+++ b/gtk/gtkemojichooser.c
@@ -337,8 +337,8 @@ add_recent_item (GtkEmojiChooser *chooser,
 
   g_variant_ref (item);
 
-  g_variant_builder_init (&builder, G_VARIANT_TYPE ("a((aussas)u)"));
-  g_variant_builder_add (&builder, "(@(aussas)u)", item, modifier);
+  g_variant_builder_init (&builder, G_VARIANT_TYPE ("a((ausas)u)"));
+  g_variant_builder_add (&builder, "(@(ausas)u)", item, modifier);
 
   children = NULL;
   for (child = gtk_widget_get_last_child (chooser->recent.box);
@@ -363,7 +363,7 @@ add_recent_item (GtkEmojiChooser *chooser,
           continue;
         }
 
-      g_variant_builder_add (&builder, "(@(aussas)u)", item2, modifier2);
+      g_variant_builder_add (&builder, "(@(ausas)u)", item2, modifier2);
     }
   g_list_free (children);
 
@@ -603,7 +603,7 @@ populate_emoji_chooser (gpointer data)
   if (!chooser->data)
     {
       GBytes *bytes = g_resources_lookup_data ("/org/gtk/libgtk/emoji/emoji.data", 0, NULL);
-      chooser->data = g_variant_ref_sink (g_variant_new_from_bytes (G_VARIANT_TYPE ("a(aussas)"), bytes, 
TRUE));
+      chooser->data = g_variant_ref_sink (g_variant_new_from_bytes (G_VARIANT_TYPE ("a(ausas)"), bytes, 
TRUE));
       g_bytes_unref (bytes);
     }
 
@@ -765,7 +765,7 @@ filter_func (GtkFlowBoxChild *child,
   
   g_variant_get_child (emoji_data, 1, "&s", &name);
   name_tokens = g_str_tokenize_and_fold (name, "en", NULL);
-  g_variant_get_child (emoji_data, 3, "^a&s", &keywords);
+  g_variant_get_child (emoji_data, 2, "^a&s", &keywords);
 
   res = match_tokens ((const char **)term_tokens, (const char **)name_tokens) ||
         match_tokens ((const char **)term_tokens, keywords);
diff --git a/gtk/gtkemojicompletion.c b/gtk/gtkemojicompletion.c
index a59a4322a0..19d9703360 100644
--- a/gtk/gtkemojicompletion.c
+++ b/gtk/gtkemojicompletion.c
@@ -115,7 +115,7 @@ next:
               break;
             }
         }
-      while (g_unichar_isalnum (g_utf8_get_char (p)) || *p == '_');
+      while (g_unichar_isalnum (g_utf8_get_char (p)) || *p == '_' || *p == ' ');
 
       if (found_candidate)
         n_matches = populate_completion (completion, p, 0);
@@ -488,7 +488,7 @@ add_emoji (GtkWidget          *list,
   GtkWidget *box;
   PangoAttrList *attrs;
   char text[64];
-  const char *shortname;
+  const char *name;
   GtkWidget *stack;
   gunichar modifier;
 
@@ -515,8 +515,8 @@ add_emoji (GtkWidget          *list,
   gtk_box_append (GTK_BOX (box), stack);
   g_object_set_data (G_OBJECT (child), "stack", stack);
 
-  g_variant_get_child (emoji_data, 2, "&s", &shortname);
-  label = gtk_label_new (shortname);
+  g_variant_get_child (emoji_data, 1, "&s", &name);
+  label = gtk_label_new (name);
   gtk_label_set_xalign (GTK_LABEL (label), 0);
 
   gtk_stack_add_named (GTK_STACK (stack), label, "text");
@@ -572,10 +572,11 @@ populate_completion (GtkEmojiCompletion *completion,
   g_variant_iter_init (&iter, completion->data);
   while ((item = g_variant_iter_next_value (&iter)))
     {
-      const char *shortname;
+      const char *name;
 
-      g_variant_get_child (item, 2, "&s", &shortname);
-      if (g_str_has_prefix (shortname, text))
+      g_variant_get_child (item, 1, "&s", &name);
+
+      if (g_str_has_prefix (name, text + 1))
         {
           n_matches++;
 
@@ -623,7 +624,7 @@ gtk_emoji_completion_init (GtkEmojiCompletion *completion)
   gtk_widget_init_template (GTK_WIDGET (completion));
 
   bytes = g_resources_lookup_data ("/org/gtk/libgtk/emoji/emoji.data", 0, NULL);
-  completion->data = g_variant_ref_sink (g_variant_new_from_bytes (G_VARIANT_TYPE ("a(auss)"), bytes, TRUE));
+  completion->data = g_variant_ref_sink (g_variant_new_from_bytes (G_VARIANT_TYPE ("a(ausas)"), bytes, 
TRUE));
 
   g_bytes_unref (bytes);
 
diff --git a/gtk/org.gtk.gtk4.Settings.EmojiChooser.gschema.xml 
b/gtk/org.gtk.gtk4.Settings.EmojiChooser.gschema.xml
index 6085c0e901..298d3bf4ba 100644
--- a/gtk/org.gtk.gtk4.Settings.EmojiChooser.gschema.xml
+++ b/gtk/org.gtk.gtk4.Settings.EmojiChooser.gschema.xml
@@ -2,12 +2,12 @@
 <schemalist>
 
   <schema id='org.gtk.gtk4.Settings.EmojiChooser' path='/org/gtk/gtk4/settings/emoji-chooser/'>
-    <key name='recent-emoji' type='a((aussas)u)'>
+    <key name='recent-emoji' type='a((ausas)u)'>
       <default>[]</default>
       <summary>Recently used Emoji</summary>
       <description>
         An array of Emoji definitions to show in the Emoji chooser. Each Emoji is
-        specified as an array of codepoints, name, shortname and keywords. The extra
+        specified as an array of codepoints, name and keywords. The extra
         integer after this pair is the code of the Fitzpatrick modifier to use in
         place of a 0 in the codepoint array.
       </description>


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