[gtk+/wip/matthiasc/local-search: 3/8] Port to GtkSearchHit



commit 360ce4aaa89e75c6272d9d294a6f19768a03af12
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jul 24 15:41:45 2015 -0400

    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 files changed, 13 insertions(+), 18 deletions(-)
---
diff --git a/gtk/gtksearchenginemodel.c b/gtk/gtksearchenginemodel.c
index 93003b5..a7f00ee 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;
-
-  model = GTK_SEARCH_ENGINE_MODEL (engine);
-
-  if (query)
-    g_object_ref (query);
-
-  if (model->query)
-    g_object_unref (model->query);
+  GtkSearchEngineModel *model = GTK_SEARCH_ENGINE_MODEL (engine);
 
-  model->query = query;
+  g_set_object (&model->query, query);
 }
 
 static void


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