From 1069e2b9ccbb9c9a63fe56c93026209ab5839897 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 24 Jul 2015 15:41:45 -0400 Subject: [PATCH] Port to GtkSearchHit GtkSearchEngineModel was still trying to return uris as hits. This is not working anymore, we are expected to return GtkSearchHit structs. --- gtk/gtksearchenginemodel.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/gtk/gtksearchenginemodel.c b/gtk/gtksearchenginemodel.c index 93003b5b55..a7f00eec4d 100644 --- a/gtk/gtksearchenginemodel.c +++ b/gtk/gtksearchenginemodel.c @@ -90,23 +90,26 @@ do_search (gpointer data) do { GFileInfo *info; - GFile *file; - gchar *uri; 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); - uri = g_file_get_uri (file); - hits = g_list_prepend (hits, uri); + hit = g_new (GtkSearchHit, 1); + hit->uri = g_file_get_uri (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)); + } + while (gtk_tree_model_iter_next (GTK_TREE_MODEL (model->model), &iter)); if (hits) { _gtk_search_engine_hits_added (GTK_SEARCH_ENGINE (model), hits); - g_list_free_full (hits, g_free); + g_list_free_full (hits, (GDestroyNotify)_gtk_search_hit_free); } } @@ -144,19 +147,11 @@ gtk_search_engine_model_stop (GtkSearchEngine *engine) static void gtk_search_engine_model_set_query (GtkSearchEngine *engine, - GtkQuery *query) + GtkQuery *query) { - GtkSearchEngineModel *model; + GtkSearchEngineModel *model = GTK_SEARCH_ENGINE_MODEL (engine); - model = GTK_SEARCH_ENGINE_MODEL (engine); - - if (query) - g_object_ref (query); - - if (model->query) - g_object_unref (model->query); - - model->query = query; + g_set_object (&model->query, query); } static void