summaryrefslogtreecommitdiff
path: root/src/nautilus-query-editor.c
diff options
context:
space:
mode:
authorAlexandru Pandelea <alexandru.pandelea@gmail.com>2017-05-26 23:22:12 +0300
committerAlexandru Pandelea <alexandru.pandelea@gmail.com>2017-06-22 16:49:41 +0300
commit11cbe223a554549dc1b42d0c91a3d5b569bc3971 (patch)
tree6e4d3794d80611b4c0469da5f9455da2bb5b8948 /src/nautilus-query-editor.c
parentba5ed9b169ec99d03cc355137bce16573b892478 (diff)
downloadnautilus-11cbe223a554549dc1b42d0c91a3d5b569bc3971.tar.gz
implement fts
The search text can now also match the contents of a file, besides the file name. This is done with the help of a Tracker query, using fts:match, which matces both the contents of a file and the filename. The user also has the option to choose whether to use or not the Full Text Search. This can be done with a preference, which represents the default option when opening a new tab/window or from the search popover. https://bugzilla.gnome.org/show_bug.cgi?id=775961
Diffstat (limited to 'src/nautilus-query-editor.c')
-rw-r--r--src/nautilus-query-editor.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/nautilus-query-editor.c b/src/nautilus-query-editor.c
index 5d9eca9c1..94b9c4d70 100644
--- a/src/nautilus-query-editor.c
+++ b/src/nautilus-query-editor.c
@@ -115,6 +115,7 @@ static void
update_information_label (NautilusQueryEditor *editor)
{
NautilusQueryEditorPrivate *priv;
+ gboolean fts_sensitive = TRUE;
priv = nautilus_query_editor_get_instance_private (editor);
@@ -131,6 +132,7 @@ update_information_label (NautilusQueryEditor *editor)
if (nautilus_file_is_other_locations (file))
{
label = _("Searching locations only");
+ fts_sensitive = FALSE;
}
else if (g_str_has_prefix (uri, "computer://"))
{
@@ -139,17 +141,22 @@ update_information_label (NautilusQueryEditor *editor)
else if (g_str_has_prefix (uri, "network://"))
{
label = _("Searching network locations only");
+ fts_sensitive = FALSE;
}
else if (nautilus_file_is_remote (file) &&
!settings_search_is_recursive (editor))
{
label = _("Remote location — only searching the current folder");
+ fts_sensitive = FALSE;
}
else if (!settings_search_is_recursive (editor))
{
label = _("Only searching the current folder");
}
+ nautilus_search_popover_set_fts_sensitive (NAUTILUS_SEARCH_POPOVER (priv->popover),
+ fts_sensitive);
+
gtk_widget_set_visible (priv->label, label != NULL);
gtk_label_set_label (GTK_LABEL (priv->label), label);
@@ -376,14 +383,19 @@ create_query (NautilusQueryEditor *editor)
NautilusQuery *query;
NautilusFile *file;
gboolean recursive;
+ gboolean fts_enabled;
priv = nautilus_query_editor_get_instance_private (editor);
g_return_if_fail (!priv->query);
+ fts_enabled = nautilus_search_popover_get_fts_enabled (NAUTILUS_SEARCH_POPOVER (priv->popover));
+
file = nautilus_file_get (priv->location);
query = nautilus_query_new ();
+ nautilus_query_set_search_content (query, fts_enabled);
+
recursive = settings_search_is_recursive (editor);
nautilus_query_set_text (query, gtk_entry_get_text (GTK_ENTRY (priv->entry)));
@@ -571,6 +583,29 @@ search_popover_time_type_changed_cb (NautilusSearchPopover *popover,
}
static void
+search_popover_fts_changed_cb (GObject *popover,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ NautilusQueryEditorPrivate *priv;
+ NautilusQueryEditor *editor;
+
+ editor = user_data;
+
+ priv = nautilus_query_editor_get_instance_private (NAUTILUS_QUERY_EDITOR (editor));
+
+ if (!priv->query)
+ {
+ create_query (editor);
+ }
+
+ nautilus_query_set_search_content (priv->query,
+ nautilus_search_popover_get_fts_enabled (NAUTILUS_SEARCH_POPOVER (popover)));
+
+ nautilus_query_editor_changed (editor);
+}
+
+static void
entry_tag_clicked (NautilusQueryEditor *editor)
{
NautilusQueryEditorPrivate *priv;
@@ -672,6 +707,8 @@ setup_widgets (NautilusQueryEditor *editor)
G_CALLBACK (search_popover_mime_type_changed_cb), editor);
g_signal_connect (priv->popover, "time-type",
G_CALLBACK (search_popover_time_type_changed_cb), editor);
+ g_signal_connect (priv->popover, "notify::fts-enabled",
+ G_CALLBACK (search_popover_fts_changed_cb), editor);
/* show everything */
gtk_widget_show_all (vbox);