summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntónio Fernandes <antoniof@gnome.org>2022-12-19 18:46:05 +0000
committerAntónio Fernandes <antoniof@gnome.org>2023-01-06 19:34:10 +0000
commitd0ffdabdbb87df7949731a44c52f62d6dcd39580 (patch)
tree84eb7fb0894fbe8c848811201e48b81866f9abd4
parenteef066c28cf2cfaf265c089fb9519a5c3e672d40 (diff)
downloadnautilus-d0ffdabdbb87df7949731a44c52f62d6dcd39580.tar.gz
search-popover: Search other types description
Currently we search only the mime-type string, because it was more convenient for programming. But it's obviously inconvenient for users, because the string shown in the list (i.e. the localized description) doesn't match the strings being searched. This becomes worse when the language is not English. Use a more advanced expression to search both the mime type string as well as its localized description. This fixes https://gitlab.gnome.org/GNOME/nautilus/-/issues/2659
-rw-r--r--src/nautilus-search-popover.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/nautilus-search-popover.c b/src/nautilus-search-popover.c
index 57561f541..e8e313659 100644
--- a/src/nautilus-search-popover.c
+++ b/src/nautilus-search-popover.c
@@ -603,6 +603,16 @@ on_other_types_setup (GtkSignalListItemFactory *factory,
gtk_list_item_set_child (listitem, label);
}
+static gchar *
+join_type_and_description (GtkStringObject *object,
+ gpointer user_data)
+{
+ const gchar *content_type = gtk_string_object_get_string (object);
+ g_autofree gchar *description = g_content_type_get_description (content_type);
+
+ return g_strdup_printf ("%s %s", content_type, description);
+}
+
static void
show_other_types_dialog (NautilusSearchPopover *popover)
{
@@ -628,7 +638,10 @@ show_other_types_dialog (NautilusSearchPopover *popover)
}
sorter = gtk_string_sorter_new (gtk_property_expression_new (GTK_TYPE_STRING_OBJECT, NULL, "string"));
sort_model = gtk_sort_list_model_new (G_LIST_MODEL (string_model), GTK_SORTER (sorter));
- filter = gtk_string_filter_new (gtk_property_expression_new (GTK_TYPE_STRING_OBJECT, NULL, "string"));
+ filter = gtk_string_filter_new (gtk_cclosure_expression_new (G_TYPE_STRING,
+ NULL, 0, NULL,
+ G_CALLBACK (join_type_and_description),
+ NULL, NULL));
filter_model = gtk_filter_list_model_new (G_LIST_MODEL (sort_model), GTK_FILTER (filter));
popover->other_types_model = gtk_single_selection_new (G_LIST_MODEL (filter_model));