[nautilus/wip/alexpandelea/fts: 2/2] add preference for fts



commit c8204febdc9d151cc3d5babb9c211a04357afbac
Author: Alexandru Pandelea <alexandru pandelea gmail com>
Date:   Sat Jun 17 15:44:31 2017 +0300

    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 e162ebb..c4dedbc 100644
--- a/data/org.gnome.nautilus.gschema.xml
+++ b/data/org.gnome.nautilus.gschema.xml
@@ -217,6 +217,11 @@
       <summary>Enable new experimental views</summary>
       <description>Whether to use the new experimental views using the latest GTK+ widgets to help giving 
feedback and shaping their future.</description>
     </key>
+    <key type="b" name="fts-default">
+      <default>true</default>
+      <summary>Whether to have full text search as default when opening a new window/tab</summary>
+      <description>If set to true, then Nautilus will also match the file contents besides the 
name</description>
+    </key>
   </schema>
 
   <schema path="/org/gnome/nautilus/compression/" id="org.gnome.nautilus.compression" 
gettext-domain="nautilus">
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index b73ebbc..7c01770 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 7e52f6c..f508f7d 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 c4952e9..a6d2a01 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 be455c7..8a9bcb0 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 493a3f1..12662c6 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 a8f15bc..fcbffe0 100644
--- a/src/resources/ui/nautilus-preferences-window.ui
+++ b/src/resources/ui/nautilus-preferences-window.ui
@@ -1028,6 +1028,36 @@
                         <property name="position">4</property>
                       </packing>
                     </child>
+                    <child>
+                      <object class="GtkLabel" id="fts_label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Full Text Search:</property>
+                        <property name="xalign">0</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">5</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkCheckButton" id="fts_checkbutton">
+                        <property name="label" translatable="yes">Set as _default</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="xalign">0</property>
+                        <property name="draw_indicator">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">6</property>
+                      </packing>
+                    </child>
                   </object>
                   <packing>
                     <property name="expand">False</property>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]