filechooserentry: Make filtering work again
authorMatthias Clasen <mclasen@redhat.com>
Wed, 12 Apr 2023 10:07:30 +0000 (12:07 +0200)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 21 Apr 2023 07:16:45 +0000 (09:16 +0200)
We need to look at the filchooser::filtered-out
attribute to know which files the filesystem model
has filtered away.

Fixes: #5743
gtk/gtkfilechooserentry.c

index 4f3d2f8c7faeb8ac8ca53d36c27025d0198404da..6c50524adbfb0a3da0712da09db4ec384a07bd54 100644 (file)
@@ -193,28 +193,30 @@ match_func (GtkEntryCompletion *compl,
             gpointer            user_data)
 {
   GtkFileChooserEntry *chooser_entry = user_data;
+  GFileInfo *info;
+
+  gtk_tree_model_get (GTK_TREE_MODEL (chooser_entry->completion_store),
+                      iter,
+                      FILE_INFO_COLUMN, &info,
+                      -1);
+
+  g_assert (info != NULL);
+  g_object_unref (info);
+
+  if (g_file_info_get_attribute_boolean (info, "filechooser::filtered-out"))
+    return FALSE;
 
   /* If we arrive here, the GtkFileSystemModel's GtkFileFilter already filtered out all
    * files that don't start with the current prefix, so we manually apply the GtkFileChooser's
-   * current file filter (e.g. just jpg files) here. */
+   * current file filter (e.g. just jpg files) here.
+   */
   if (chooser_entry->current_filter != NULL)
     {
-      GFileInfo *info;
-
-      gtk_tree_model_get (GTK_TREE_MODEL (chooser_entry->completion_store),
-                          iter,
-                          FILE_INFO_COLUMN, &info,
-                          -1);
-
-      g_assert (info != NULL);
-      g_object_unref (info);
-
       /* We always allow navigating into subfolders, so don't ever filter directories */
       if (g_file_info_get_file_type (info) != G_FILE_TYPE_REGULAR)
         return TRUE;
 
       g_assert (g_file_info_has_attribute (info, "standard::file"));
-
       return gtk_filter_match (GTK_FILTER (chooser_entry->current_filter), info);
     }