[gtk/gtk-3-24: 7/13] Emoji: Drop the shortname field from emoji.data




commit 100ee4ce16c428880efcb55b27ebd7b04fbdf287
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  |  18 ++++++++++--------
 4 files changed, 17 insertions(+), 21 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 23edf88445..7abaf744ee 100644
--- a/gtk/gtkemojichooser.c
+++ b/gtk/gtkemojichooser.c
@@ -184,8 +184,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 = gtk_container_get_children (GTK_CONTAINER (chooser->recent.box));
   for (l = children, i = 1; l; l = l->next, i++)
@@ -205,7 +205,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);
 
@@ -476,7 +476,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);
     }
 
@@ -632,7 +632,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 41c0a87a67..2cb150c031 100644
--- a/gtk/gtkemojicompletion.c
+++ b/gtk/gtkemojicompletion.c
@@ -116,7 +116,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);
@@ -521,7 +521,7 @@ add_emoji (GtkWidget          *list,
   GtkWidget *box;
   PangoAttrList *attrs;
   char text[64];
-  const char *shortname;
+  const char *name;
   GtkWidget *stack;
   gunichar modifier;
 
@@ -551,8 +551,8 @@ add_emoji (GtkWidget          *list,
   gtk_box_pack_start (GTK_BOX (box), stack, FALSE, FALSE, 0);
   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_widget_show (label);
   gtk_label_set_xalign (GTK_LABEL (label), 0);
 
@@ -610,10 +610,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++;
 
@@ -664,7 +665,8 @@ 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);
 
   completion->long_press = gtk_gesture_long_press_new (completion->list);


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