[nautilus/wip/antoniof/other-types-filter: 2/3] search-popover: Add search entry for other types




commit 4eae72cf370d386ab5fcb3e0abdeb87ac479df3d
Author: António Fernandes <antoniof gnome org>
Date:   Wed Jul 20 20:44:53 2022 +0200

    search-popover: Add search entry for other types
    
    Closes https://gitlab.gnome.org/GNOME/nautilus/-/issues/2326

 src/nautilus-search-popover.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
---
diff --git a/src/nautilus-search-popover.c b/src/nautilus-search-popover.c
index 0cb8ff310..a5f2f12cc 100644
--- a/src/nautilus-search-popover.c
+++ b/src/nautilus-search-popover.c
@@ -587,6 +587,7 @@ on_other_types_setup (GtkSignalListItemFactory *factory,
     label = gtk_label_new (NULL);
     gtk_widget_set_halign (label, GTK_ALIGN_START);
     gtk_list_item_set_child (listitem, label);
+    gtk_list_item_set_activatable (listitem, FALSE);
 }
 
 static void
@@ -595,8 +596,12 @@ show_other_types_dialog (NautilusSearchPopover *popover)
     GtkStringList *string_model;
     GtkStringSorter *sorter;
     GtkSortListModel *sort_model;
+    GtkStringFilter *filter;
+    GtkFilterListModel *filter_model;
     g_autoptr (GList) mime_infos = NULL;
     GtkWidget *dialog;
+    GtkWidget *search_entry;
+    GtkWidget *search_bar;
     GtkWidget *scrolled;
     GtkListItemFactory *factory;
     GtkWidget *listview;
@@ -610,7 +615,9 @@ 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));
-    popover->other_types_model = gtk_single_selection_new (G_LIST_MODEL (sort_model));
+    filter = gtk_string_filter_new (gtk_property_expression_new (GTK_TYPE_STRING_OBJECT, NULL, "string"));
+    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));
 
     toplevel = gtk_widget_get_root (GTK_WIDGET (popover));
     dialog = gtk_dialog_new_with_buttons (_("Select type"),
@@ -621,6 +628,13 @@ show_other_types_dialog (NautilusSearchPopover *popover)
                                           NULL);
     gtk_window_set_default_size (GTK_WINDOW (dialog), 400, 600);
 
+    search_entry = gtk_search_entry_new ();
+    search_bar = gtk_search_bar_new ();
+    gtk_search_bar_set_child (GTK_SEARCH_BAR (search_bar), search_entry);
+    gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (search_bar), dialog);
+    g_object_bind_property (search_entry, "text", filter, "search", G_BINDING_SYNC_CREATE);
+    gtk_box_append (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), search_bar);
+
     scrolled = gtk_scrolled_window_new ();
     gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
                                     GTK_POLICY_AUTOMATIC,


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