diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-04-14 22:29:25 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-10-03 19:46:46 -0400 |
commit | ed724ebc357338de8797884f586b5308243927c7 (patch) | |
tree | 74b177d924a5b9dffcef5764651048b99cb8fe96 /gtk/gtkemojichooser.c | |
parent | 44448016e87349458e358fd2c7762ed280c01647 (diff) | |
download | gtk+-ed724ebc357338de8797884f586b5308243927c7.tar.gz |
emoji: Add keywords to the data
And use them for matching in the Emoji chooser.
Diffstat (limited to 'gtk/gtkemojichooser.c')
-rw-r--r-- | gtk/gtkemojichooser.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/gtk/gtkemojichooser.c b/gtk/gtkemojichooser.c index e660e6c5aa..55a17cc9ca 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((auss)u)")); - g_variant_builder_add (&builder, "(@(auss)u)", item, modifier); + g_variant_builder_init (&builder, G_VARIANT_TYPE ("a((aussas)u)")); + g_variant_builder_add (&builder, "(@(aussas)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, "(@(auss)u)", item2, modifier2); + g_variant_builder_add (&builder, "(@(aussas)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(auss)"), bytes, TRUE)); + chooser->data = g_variant_ref_sink (g_variant_new_from_bytes (G_VARIANT_TYPE ("a(aussas)"), bytes, TRUE)); g_bytes_unref (bytes); } @@ -719,7 +719,9 @@ filter_func (GtkFlowBoxChild *child, GVariant *emoji_data; const char *text; const char *name; + const char **keywords; gboolean res; + int i; res = TRUE; @@ -736,6 +738,10 @@ filter_func (GtkFlowBoxChild *child, g_variant_get_child (emoji_data, 1, "&s", &name); res = g_str_match_string (text, name, TRUE); + g_variant_get_child (emoji_data, 3, "^a&s", &keywords); + for (i = 0; !res && keywords[i]; i++) + res = g_str_match_string (text, keywords[i], TRUE); + out: if (res) section->empty = FALSE; |