Commit eee85d39 authored by Matthias Clasen's avatar Matthias Clasen

Avoid more GFile<>uri roundtrips

Make GtkSearchHit carry a GFile instead of an uri. Most of the
search engines already have the object around, and converting
to an uri and back is unnecessary extra work.
parent f7bba525
......@@ -7007,9 +7007,7 @@ search_engine_hits_added_cb (GtkSearchEngine *engine,
for (l = hits; l; l = l->next)
{
GtkSearchHit *hit = (GtkSearchHit *)l->data;
file = g_file_new_for_uri (hit->uri);
if (!file)
continue;
file = g_object_ref (hit->file);
if (hit->info)
{
files_with_info = g_list_prepend (files_with_info, file);
......
......@@ -311,7 +311,7 @@ search_hit_equal (gconstpointer a, gconstpointer b)
const GtkSearchHit *ha = (const GtkSearchHit *)a;
const GtkSearchHit *hb = (const GtkSearchHit *)b;
return g_str_equal (ha->uri, hb->uri);
return g_file_equal (ha->file, hb->file);
}
......@@ -320,7 +320,7 @@ search_hit_hash (gconstpointer a)
{
const GtkSearchHit *ha = (const GtkSearchHit *)a;
return g_str_hash (ha->uri);
return g_file_hash (ha->file);
}
GtkSearchHit *
......@@ -329,7 +329,7 @@ _gtk_search_hit_dup (GtkSearchHit *hit)
GtkSearchHit *dup;
dup = g_new (GtkSearchHit, 1);
dup->uri = g_strdup (hit->uri);
dup->file = g_object_ref (hit->file);
if (hit->info)
dup->info = g_object_ref (hit->info);
else
......@@ -341,7 +341,7 @@ _gtk_search_hit_dup (GtkSearchHit *hit)
void
_gtk_search_hit_free (GtkSearchHit *hit)
{
g_free (hit->uri);
g_clear_object (&hit->file);
g_clear_object (&hit->info);
g_free (hit);
}
......
......@@ -42,7 +42,7 @@ typedef struct _GtkSearchHit GtkSearchHit;
struct _GtkSearchHit
{
gchar *uri;
GFile *file;
GFileInfo *info; /* may be NULL */
};
......
......@@ -99,7 +99,7 @@ do_search (gpointer data)
file = _gtk_file_system_model_get_file (model->model, &iter);
hit = g_new (GtkSearchHit, 1);
hit->uri = g_file_get_uri (file);
hit->file = g_object_ref (file);
hit->info = g_object_ref (info);
hits = g_list_prepend (hits, hit);
}
......
......@@ -248,7 +248,7 @@ visit_directory (GFile *dir, SearchThreadData *data)
GtkSearchHit *hit;
hit = g_new (GtkSearchHit, 1);
hit->uri = g_file_get_uri (child);
hit->file = g_object_ref (child);
hit->info = g_object_ref (info);
data->hits = g_list_prepend (data->hits, hit);
}
......
......@@ -300,7 +300,7 @@ query_callback (GObject *object,
v = g_variant_iter_next_value (&iter);
strv = g_variant_get_strv (v, NULL);
hit[i].uri = (gchar*)strv[0];
hit[i].file = g_file_new_for_uri (strv[0]);
hit[i].info = NULL;
g_free (strv);
hits = g_list_prepend (hits, &hit[i]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment