[gtk/gbsneto/filechooser-column-view: 74/105] searchenginemodel: Use GListModel API to filter
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gbsneto/filechooser-column-view: 74/105] searchenginemodel: Use GListModel API to filter
- Date: Wed, 12 Oct 2022 20:42:36 +0000 (UTC)
commit b720556228cc1ef00fef5b479fc7051c657b53b4
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sun Oct 9 17:21:29 2022 -0300
searchenginemodel: Use GListModel API to filter
We now start a mini-series of commits that will ultimately remove
the GtkTreeModel implementation of GtkFileSystemModel.
As a first step, port GtkSearchEngineModel iter through the files
using GListModel API.
gtk/gtksearchenginemodel.c | 48 +++++++++++++++++++++++-----------------------
1 file changed, 24 insertions(+), 24 deletions(-)
---
diff --git a/gtk/gtksearchenginemodel.c b/gtk/gtksearchenginemodel.c
index 3923ea6813..18fde279bc 100644
--- a/gtk/gtksearchenginemodel.c
+++ b/gtk/gtksearchenginemodel.c
@@ -81,37 +81,37 @@ static gboolean
do_search (gpointer data)
{
GtkSearchEngineModel *model = data;
- GtkTreeIter iter;
GList *hits = NULL;
gboolean got_results = FALSE;
- if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model->model), &iter))
+ for (guint i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (model->model)); i++)
{
- do
- {
- GFileInfo *info;
-
- info = _gtk_file_system_model_get_info (model->model, &iter);
- if (info_matches_query (model->query, info))
- {
- GFile *file;
- GtkSearchHit *hit;
-
- file = _gtk_file_system_model_get_file (model->model, &iter);
- hit = g_new (GtkSearchHit, 1);
- hit->file = g_object_ref (file);
- hit->info = g_object_ref (info);
- hits = g_list_prepend (hits, hit);
- }
- }
- while (gtk_tree_model_iter_next (GTK_TREE_MODEL (model->model), &iter));
+ GtkFileSystemItem *item;
+ GFileInfo *info;
- if (hits)
+ item = g_list_model_get_item (G_LIST_MODEL (model->model), i);
+ info = _gtk_file_system_item_get_file_info (item);
+
+ if (info_matches_query (model->query, info))
{
- _gtk_search_engine_hits_added (GTK_SEARCH_ENGINE (model), hits);
- g_list_free_full (hits, (GDestroyNotify)_gtk_search_hit_free);
- got_results = TRUE;
+ GFile *file;
+ GtkSearchHit *hit;
+
+ file = _gtk_file_system_item_get_file (item);
+ hit = g_new (GtkSearchHit, 1);
+ hit->file = g_object_ref (file);
+ hit->info = g_object_ref (info);
+ hits = g_list_prepend (hits, hit);
}
+
+ g_clear_object (&item);
+ }
+
+ if (hits)
+ {
+ _gtk_search_engine_hits_added (GTK_SEARCH_ENGINE (model), hits);
+ g_list_free_full (hits, (GDestroyNotify)_gtk_search_hit_free);
+ got_results = TRUE;
}
model->idle = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]