file search - easier way to toggle recursive mode - GIT patch included
I quite frequently want to switch between recursive and non-recursive searches, and going through the settings screen is awkward. In my experience, any search with the /
(forward slash) character always return no results. So my thought was to use the /
to toggle search mode.
I'm only looking for the /
at the beginning of the string (so as to not interfere with network://
and similar). If detected, it toggles back and forth between recursive mode. I guess this is more of a proof-of-concept than anything; it's enough to meet my needs, but not very polished. Areas I would see for improvement:
- I'm only toggling between
LOCAL_ONLY
andNEVER
...not sure if and/or how to deal with theLOCAL_ONLY
vsALWAYS
. Maybe if you're starting with recursive set toALWAYS
orLOCAL_ONLY
that value could be remembered, and it could toggle between that value andNEVER
. Or maybe a different character to toggleALWAYS
. Or it might be preferable to add some sort of UI button or something to do the toggle, rather than a typed character. - Ideally it seems as if it would be better to remove the
/
from the search text after the toggle happens, but I wasn't sure how to do that.
diff --git a/src/nautilus-query-editor.c b/src/nautilus-query-editor.c
index 94b9c4d..614ccfe 100644
--- a/src/nautilus-query-editor.c
+++ b/src/nautilus-query-editor.c
@@ -434,6 +434,13 @@ entry_changed_cb (GtkWidget *entry,
}
text = g_strstrip (g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->entry))));
+ if(g_str_has_prefix (text,"/")) {
+ if(g_settings_get_enum (nautilus_preferences, NAUTILUS_PREFERENCES_RECURSIVE_SEARCH) == NAUTILUS_SPEED_TRADEOFF_NEVER) {
+ g_settings_set_enum (nautilus_preferences, NAUTILUS_PREFERENCES_RECURSIVE_SEARCH, NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY);
+ } else {
+ g_settings_set_enum (nautilus_preferences, NAUTILUS_PREFERENCES_RECURSIVE_SEARCH, NAUTILUS_SPEED_TRADEOFF_NEVER);
+ }
+ }
nautilus_query_set_text (priv->query, text);
nautilus_query_editor_changed (editor);