[gtk/gbsneto/filechooser-column-view: 91/105] filechooserwidget: Reinstate show_and_select_files




commit 7fc783d2d3fdf3ad6577d497e08bf5dcada168c5
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Oct 10 22:36:35 2022 -0400

    filechooserwidget: Reinstate show_and_select_files
    
    Now that we have information about visible and
    filtered-out status of items, we can make this
    function work again.

 gtk/gtkfilechooserwidget.c | 28 ++++++----------------------
 1 file changed, 6 insertions(+), 22 deletions(-)
---
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index 2eb38a4608..ab2a9212d1 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -3535,6 +3535,7 @@ show_and_select_files (GtkFileChooserWidget *impl,
       GFileInfo *info;
       GFile *file;
       guint i;
+      gboolean enabled_hidden, removed_filters;
 
       file = walk->data;
 
@@ -3544,16 +3545,11 @@ show_and_select_files (GtkFileChooserWidget *impl,
       if (!info)
         continue;
 
-      /* TODO: Reimplement showing hidden files and removing filters */
-#if 0
-      gboolean enabled_hidden, removed_filters;
-
       enabled_hidden = impl->show_hidden;
       removed_filters = (impl->current_filter == NULL);
 
-      if (!_gtk_file_system_item_is_visible (item))
+      if (!g_file_info_get_attribute_boolean (info, "filechooser::visible"))
         {
-          GFileInfo *info = _gtk_file_system_item_get_file_info (item);
           if (!enabled_hidden &&
               (g_file_info_get_is_hidden (info) ||
                g_file_info_get_is_backup (info)))
@@ -3565,11 +3561,7 @@ show_and_select_files (GtkFileChooserWidget *impl,
 
       /* Is it a filtered file? */
 
-      item = _gtk_file_system_model_get_item_for_file (fsmodel, file);
-      if (!item)
-        continue; /* re-get the iter as it may change when the model refilters */
-
-      if (!_gtk_file_system_item_is_visible (item))
+      if (g_file_info_get_attribute_boolean (info, "filechooser::filtered-out"))
         {
           /* Maybe we should have a way to ask the fsmodel if it had filtered a file */
           if (!removed_filters)
@@ -3579,12 +3571,6 @@ show_and_select_files (GtkFileChooserWidget *impl,
             }
         }
 
-      /* Okay, can we select the file now? */
-      item = _gtk_file_system_model_get_info_for_file (fsmodel, file);
-      if (!item)
-        continue;
-#endif
-
       /* TODO: "accidentally" quadratic! */
 
       for (i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (impl->selection_model)); i++)
@@ -3595,15 +3581,13 @@ show_and_select_files (GtkFileChooserWidget *impl,
 
           if (info2 == info)
             {
-              gtk_selection_model_select_item (impl->selection_model,
-                                               i,
-                                               FALSE);
-              g_clear_object (&info);
+              gtk_selection_model_select_item (impl->selection_model, i, FALSE);
+              g_clear_object (&info2);
               selected_a_file = TRUE;
               break;
             }
 
-          g_clear_object (&info);
+          g_clear_object (&info2);
         }
     }
 


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