diff options
author | Carlos Soriano <csoriano@gnome.org> | 2016-02-02 22:06:48 +0100 |
---|---|---|
committer | Carlos Soriano <csoriano@gnome.org> | 2016-02-03 16:33:55 +0100 |
commit | ae55fec152123e482a40e608b8e6903502e39988 (patch) | |
tree | c860e25a71bcc8a0b2879580984c9dd23a965c82 /src/nautilus-query-editor.c | |
parent | 27ac388fab62b60cfafead06cf5a46cf1779d8a0 (diff) | |
download | nautilus-ae55fec152123e482a40e608b8e6903502e39988.tar.gz |
preferences: add remote and local recursive search
Instead of using a switch in the search popover.
The search popover is meant to be as a temporary filter. That means
that the "Search subfolders" switch that was present there was reset
every time a new search was performed.
Even if the nature of the popover is temporary and therefore should be
understandable that the switch is also temporary, this can bring
confusion in such a sensible matter.
To avoid confusion, add two preferences, one for remote file systems
and one for local file systems to allow the choice to make a recursive
or non recursive search, and remove the switch to avoid frustration.
Also, I expect this choice to be more a permanent one than a temporary
one, as in, I expect users to what they really want is to make a
permanent choice whether they want recursive search or not.
For local file systems, on what I can gather, either wants to emulate
the type-ahead search, because it's file system is slow to perform
a recursive search and will always be, therefore a permanent choice,
or the opposite where the file system of the user is fast enough to
perform a recursive search, which will most of the cases be like that,
and therefore also a permanent choice.
For remote file systems is similar. Either the internet connection of
the user is fast enough for the whole session or use, therefore wants
recursive search always enabled, or it's not, and therefore it doesn't
want recursive search enabled.
Diffstat (limited to 'src/nautilus-query-editor.c')
-rw-r--r-- | src/nautilus-query-editor.c | 57 |
1 files changed, 33 insertions, 24 deletions
diff --git a/src/nautilus-query-editor.c b/src/nautilus-query-editor.c index e2b5bd0c1..320b3cf45 100644 --- a/src/nautilus-query-editor.c +++ b/src/nautilus-query-editor.c @@ -70,33 +70,35 @@ G_DEFINE_TYPE_WITH_PRIVATE (NautilusQueryEditor, nautilus_query_editor, GTK_TYPE static void -query_recursive_changed (GObject *object, - GParamSpec *pspec, - NautilusQueryEditor *editor) +recursive_search_preferences_changed (GSettings *settings, + gchar *key, + NautilusQueryEditor *editor) { NautilusQueryEditorPrivate *priv; - gchar *key; + NautilusFile *file; + gchar *recursive_search_key; + gboolean recursive; - priv = nautilus_query_editor_get_instance_private (editor); - key = "local-recursive-search"; - if (priv->location) { - NautilusFile *file; + priv = nautilus_query_editor_get_instance_private (editor); - file = nautilus_file_get (priv->location); + if (!priv->location || !priv->query) + return; - if (nautilus_file_is_remote (file)) { - key = "remote-recursive-search"; - } + file = nautilus_file_get (priv->location); - nautilus_file_unref (file); + if (nautilus_file_is_remote (file)) { + recursive_search_key = "remote-recursive-search"; + } else { + recursive_search_key = "local-recursive-search"; } - g_settings_set_boolean (nautilus_preferences, - key, - nautilus_query_get_recursive (NAUTILUS_QUERY (object))); - - nautilus_query_editor_changed (editor); + nautilus_file_unref (file); + recursive = g_settings_get_boolean (nautilus_preferences, recursive_search_key); + if (recursive != nautilus_query_get_recursive (priv->query)) { + nautilus_query_set_recursive (priv->query, recursive); + nautilus_query_editor_changed (editor); + } } @@ -110,6 +112,10 @@ nautilus_query_editor_dispose (GObject *object) g_clear_object (&priv->location); g_clear_object (&priv->query); + g_signal_handlers_disconnect_by_func (nautilus_preferences, + recursive_search_preferences_changed, + object); + G_OBJECT_CLASS (nautilus_query_editor_parent_class)->dispose (object); } @@ -287,12 +293,6 @@ create_query (NautilusQueryEditor *editor) nautilus_query_editor_set_query (editor, query); - g_signal_connect (query, - "notify::recursive", - G_CALLBACK (query_recursive_changed), - editor); - - nautilus_file_unref (file); } @@ -336,6 +336,15 @@ nautilus_query_editor_on_stop_search (GtkWidget *entry, static void nautilus_query_editor_init (NautilusQueryEditor *editor) { + g_signal_connect (nautilus_preferences, + "changed::remote-recursive-search", + G_CALLBACK (recursive_search_preferences_changed), + editor); + + g_signal_connect (nautilus_preferences, + "changed::local-recursive-search", + G_CALLBACK (recursive_search_preferences_changed), + editor); } static gboolean |