From c8204febdc9d151cc3d5babb9c211a04357afbac Mon Sep 17 00:00:00 2001 From: Alexandru Pandelea Date: Sat, 17 Jun 2017 15:44:31 +0300 Subject: add preference for fts --- data/org.gnome.nautilus.gschema.xml | 5 +++++ src/nautilus-files-view.c | 1 + src/nautilus-global-preferences.h | 3 +++ src/nautilus-preferences-window.c | 5 +++++ src/nautilus-search-engine-tracker.c | 2 +- src/nautilus-search-popover.c | 11 ++++++++- src/resources/ui/nautilus-preferences-window.ui | 30 +++++++++++++++++++++++++ 7 files changed, 55 insertions(+), 2 deletions(-) diff --git a/data/org.gnome.nautilus.gschema.xml b/data/org.gnome.nautilus.gschema.xml index e162ebb42..c4dedbc95 100644 --- a/data/org.gnome.nautilus.gschema.xml +++ b/data/org.gnome.nautilus.gschema.xml @@ -217,6 +217,11 @@ Enable new experimental views Whether to use the new experimental views using the latest GTK+ widgets to help giving feedback and shaping their future. + + true + Whether to have full text search as default when opening a new window/tab + If set to true, then Nautilus will also match the file contents besides the name + diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c index b73ebbcdd..7c0177093 100644 --- a/src/nautilus-files-view.c +++ b/src/nautilus-files-view.c @@ -3095,6 +3095,7 @@ static char * get_bulk_rename_tool () { char *bulk_rename_tool; + g_settings_get (nautilus_preferences, NAUTILUS_PREFERENCES_BULK_RENAME_TOOL, "^ay", &bulk_rename_tool); return g_strstrip (bulk_rename_tool); } diff --git a/src/nautilus-global-preferences.h b/src/nautilus-global-preferences.h index 7e52f6c77..f508f7d97 100644 --- a/src/nautilus-global-preferences.h +++ b/src/nautilus-global-preferences.h @@ -177,6 +177,9 @@ typedef enum #define NAUTILUS_PREFERENCES_SHOW_DELETE_PERMANENTLY "show-delete-permanently" #define NAUTILUS_PREFERENCES_SHOW_CREATE_LINK "show-create-link" +/* Full Text Search as default */ +#define NAUTILUS_PREFERENCES_FTS_DEFAULT "fts-default" + void nautilus_global_preferences_init (void); extern GSettings *nautilus_preferences; diff --git a/src/nautilus-preferences-window.c b/src/nautilus-preferences-window.c index c4952e9bd..a6d2a013d 100644 --- a/src/nautilus-preferences-window.c +++ b/src/nautilus-preferences-window.c @@ -61,6 +61,8 @@ "automatic_decompression_checkbutton" #define NAUTILUS_PREFERENCES_DIALOG_USE_NEW_VIEWS_WIDGET \ "use_new_views_checkbutton" +#define NAUTILUS_PREFERENCES_DEFAULT_FTS \ + "fts_checkbutton" /* int enums */ #define NAUTILUS_PREFERENCES_DIALOG_THUMBNAIL_LIMIT_WIDGET \ @@ -506,6 +508,9 @@ static void nautilus_preferences_window_setup(GtkBuilder *builder, bind_builder_bool (builder, nautilus_preferences, NAUTILUS_PREFERENCES_DIALOG_USE_NEW_VIEWS_WIDGET, NAUTILUS_PREFERENCES_USE_EXPERIMENTAL_VIEWS); + bind_builder_bool (builder, nautilus_preferences, + NAUTILUS_PREFERENCES_DEFAULT_FTS, + NAUTILUS_PREFERENCES_FTS_DEFAULT); bind_builder_radio ( builder, nautilus_preferences, (const char **) click_behavior_components, diff --git a/src/nautilus-search-engine-tracker.c b/src/nautilus-search-engine-tracker.c index be455c7dc..8a9bcb014 100644 --- a/src/nautilus-search-engine-tracker.c +++ b/src/nautilus-search-engine-tracker.c @@ -422,7 +422,7 @@ nautilus_search_engine_tracker_start (NautilusSearchProvider *provider) } g_string_append (sparql, ")} ORDER BY DESC (fts:rank(?urn))"); - + g_message ("\n%s\n", sparql->str); tracker->details->cancellable = g_cancellable_new (); tracker_sparql_connection_query_async (tracker->details->connection, sparql->str, diff --git a/src/nautilus-search-popover.c b/src/nautilus-search-popover.c index 493a3f151..12662c6c1 100644 --- a/src/nautilus-search-popover.c +++ b/src/nautilus-search-popover.c @@ -848,6 +848,7 @@ nautilus_search_popover_class_init (NautilusSearchPopoverClass *klass) gtk_widget_class_bind_template_callback (widget_class, toggle_calendar_icon_clicked); gtk_widget_class_bind_template_callback (widget_class, types_listbox_row_activated); gtk_widget_class_bind_template_callback (widget_class, search_time_type_changed); + gtk_widget_class_bind_template_callback (widget_class, search_fts_mode_changed); } @@ -886,8 +887,16 @@ nautilus_search_popover_init (NautilusSearchPopover *self) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->last_used_button), TRUE); } + self->fts_enabled = g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_FTS_DEFAULT); + if (self->fts_enabled) + { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->full_text_search_button), TRUE); + } + else + { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->filename_search_button), TRUE); + } - self->fts_enabled = FALSE; } GtkWidget * diff --git a/src/resources/ui/nautilus-preferences-window.ui b/src/resources/ui/nautilus-preferences-window.ui index a8f15bc88..fcbffe088 100644 --- a/src/resources/ui/nautilus-preferences-window.ui +++ b/src/resources/ui/nautilus-preferences-window.ui @@ -1028,6 +1028,36 @@ 4 + + + True + False + Full Text Search: + 0 + + + False + False + 5 + + + + + Set as _default + False + True + True + False + True + 0 + True + + + False + True + 6 + + False -- cgit v1.2.1