Commit 71b3e0b6 authored by Matthias Clasen's avatar Matthias Clasen

Store locations as GFile

It is a bit pointless to have the file chooser get a uri from an
existing GFile to put in the query, only to have some of the search
engines reconstruct a GFile from it.
parent 859db921
......@@ -7208,10 +7208,7 @@ search_start_query (GtkFileChooserWidget *impl,
file = gtk_places_sidebar_get_location (GTK_PLACES_SIDEBAR (priv->places_sidebar));
if (file)
{
gchar *location;
location = g_file_get_uri (file);
gtk_query_set_location (priv->search_query, location);
g_free (location);
gtk_query_set_location (priv->search_query, file);
g_object_unref (file);
}
......
......@@ -27,7 +27,7 @@
struct _GtkQueryPrivate
{
gchar *text;
gchar *location_uri;
GFile *location;
GList *mime_types;
gchar **words;
};
......@@ -41,8 +41,8 @@ finalize (GObject *object)
query = GTK_QUERY (object);
g_clear_object (&query->priv->location);
g_free (query->priv->text);
g_free (query->priv->location_uri);
g_strfreev (query->priv->words);
G_OBJECT_CLASS (gtk_query_parent_class)->finalize (object);
......@@ -87,18 +87,17 @@ gtk_query_set_text (GtkQuery *query,
query->priv->words = NULL;
}
const gchar *
GFile *
gtk_query_get_location (GtkQuery *query)
{
return query->priv->location_uri;
return query->priv->location;
}
void
gtk_query_set_location (GtkQuery *query,
const gchar *uri)
gtk_query_set_location (GtkQuery *query,
GFile *file)
{
g_free (query->priv->location_uri);
query->priv->location_uri = g_strdup (uri);
g_set_object (&query->priv->location, file);
}
static gchar *
......
......@@ -22,7 +22,7 @@
#ifndef __GTK_QUERY_H__
#define __GTK_QUERY_H__
#include <glib-object.h>
#include <gio/gio.h>
G_BEGIN_DECLS
......@@ -57,9 +57,9 @@ const gchar *gtk_query_get_text (GtkQuery *query);
void gtk_query_set_text (GtkQuery *query,
const gchar *text);
const gchar *gtk_query_get_location (GtkQuery *query);
GFile *gtk_query_get_location (GtkQuery *query);
void gtk_query_set_location (GtkQuery *query,
const gchar *uri);
GFile *file);
gboolean gtk_query_matches_string (GtkQuery *query,
const gchar *string);
......
......@@ -92,7 +92,6 @@ search_thread_data_new (GtkSearchEngineSimple *engine,
GtkQuery *query)
{
SearchThreadData *data;
const gchar *uri;
GFile *location;
data = g_new0 (SearchThreadData, 1);
......@@ -101,9 +100,9 @@ search_thread_data_new (GtkSearchEngineSimple *engine,
data->directories = g_queue_new ();
data->query = g_object_ref (query);
data->recursive = _gtk_search_engine_get_recursive (GTK_SEARCH_ENGINE (engine));
uri = gtk_query_get_location (query);
if (uri != NULL)
location = g_file_new_for_uri (uri);
location = gtk_query_get_location (query);
if (location)
g_object_ref (location);
else
location = g_file_new_for_path (g_get_home_dir ());
g_queue_push_tail (data->directories, location);
......
......@@ -321,7 +321,7 @@ gtk_search_engine_tracker_start (GtkSearchEngine *engine)
{
GtkSearchEngineTracker *tracker;
const gchar *search_text;
const gchar *location_uri;
GFile *location;
GString *sparql;
gboolean recursive;
......@@ -340,7 +340,7 @@ gtk_search_engine_tracker_start (GtkSearchEngine *engine)
}
search_text = gtk_query_get_text (tracker->query);
location_uri = gtk_query_get_location (tracker->query);
location = gtk_query_get_location (tracker->query);
recursive = _gtk_search_engine_get_recursive (engine);
sparql = g_string_new ("SELECT nie:url(?urn) "
......@@ -360,8 +360,9 @@ gtk_search_engine_tracker_start (GtkSearchEngine *engine)
sparql_append_string_literal_lower_case (sparql, search_text);
g_string_append (sparql, ")");
if (location_uri)
if (location)
{
gchar *location_uri = g_file_get_uri (location);
g_string_append (sparql, " && ");
if (recursive)
g_string_append (sparql, "tracker:uri-is-descendant(");
......@@ -369,6 +370,7 @@ gtk_search_engine_tracker_start (GtkSearchEngine *engine)
g_string_append (sparql, "tracker:uri-is-parent(");
sparql_append_string_literal (sparql, location_uri, FALSE);
g_string_append (sparql, ",nie:url(?urn))");
g_free (location_uri);
}
g_string_append (sparql, ")");
......
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