[nautilus/wip/csoriano/search-popover: 13/29] search-popover: use gsettings for last/modified filter type



commit 52f491671d7c8c42adc748ceae4c9e0d0eaaae0e
Author: Carlos Soriano <csoriano gnome org>
Date:   Sun Jan 31 12:26:29 2016 +0100

    search-popover: use gsettings for last/modified filter type
    
    We weren't syncing the last used/ last modified setting in the search
    popover when changed location, which means the query didn't get the
    last used user choice.
    We don't want however to listen to a gsetting key and change every
    ongoing search, so instead what we do is get the setting for the
    initial creation of a search, and then every user change will set
    the gsetting value, but will only affect the next created searches, not
    the ongoing ones.

 data/org.gnome.nautilus.gschema.xml  |   10 ++++++++++
 libnautilus-private/nautilus-query.c |    4 +++-
 src/nautilus-search-popover.c        |   16 ++++++++++++++++
 3 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/data/org.gnome.nautilus.gschema.xml b/data/org.gnome.nautilus.gschema.xml
index e5632cc..d91b79e 100644
--- a/data/org.gnome.nautilus.gschema.xml
+++ b/data/org.gnome.nautilus.gschema.xml
@@ -49,6 +49,11 @@
     <value value="1" nick="end"/>
   </enum>
 
+  <enum id="org.gnome.nautilus.SearchFilterTimeType">
+    <value value="0" nick="last_modified"/>
+    <value value="1" nick="last_used"/>
+  </enum>
+
   <schema path="/org/gnome/nautilus/" id="org.gnome.nautilus" gettext-domain="nautilus">
     <child schema="org.gnome.nautilus.preferences" name="preferences"/>
     <child schema="org.gnome.nautilus.icon-view" name="icon-view"/>
@@ -81,6 +86,11 @@
       <summary>Whether to enable recursive search or not on remote locations</summary>
       <description>Enables or disables recursive search on remote locations in Nautilus.</description>
     </key>
+    <key name="search-filter-time-type" enum="org.gnome.nautilus.SearchFilterTimeType">
+      <default>'last_modified'</default>
+      <summary>Filter the search dates using either last used or last modified</summary>
+      <description>Filter the search dates using either last used or last modified.</description>
+    </key>
     <key type="b" name="show-delete-permanently">
       <default>false</default>
       <summary>Whether to show a context menu item to delete permanently</summary>
diff --git a/libnautilus-private/nautilus-query.c b/libnautilus-private/nautilus-query.c
index 639ff17..baa4579 100644
--- a/libnautilus-private/nautilus-query.c
+++ b/libnautilus-private/nautilus-query.c
@@ -26,6 +26,8 @@
 #include <eel/eel-glib-extensions.h>
 #include <glib/gi18n.h>
 
+#include <libnautilus-private/nautilus-global-preferences.h>
+
 #include "nautilus-file-utilities.h"
 #include "nautilus-query.h"
 #include "nautilus-private-enum-types.h"
@@ -298,7 +300,7 @@ nautilus_query_init (NautilusQuery *query)
 {
         query->show_hidden = TRUE;
         query->location = g_file_new_for_path (g_get_home_dir ());
-        query->search_type = NAUTILUS_QUERY_SEARCH_TYPE_LAST_MODIFIED;
+        query->search_type = g_settings_get_enum (nautilus_preferences, "search-filter-time-type");
         query->search_content = NAUTILUS_QUERY_SEARCH_CONTENT_SIMPLE;
 }
 
diff --git a/src/nautilus-search-popover.c b/src/nautilus-search-popover.c
index 7eb155e..818fc51 100644
--- a/src/nautilus-search-popover.c
+++ b/src/nautilus-search-popover.c
@@ -536,6 +536,8 @@ search_time_type_changed (GtkToggleButton       *button,
       type = NAUTILUS_QUERY_SEARCH_TYPE_LAST_ACCESS;
     }
 
+  g_settings_set_enum (nautilus_preferences, "search-filter-time-type", type);
+
   g_signal_emit (popover, signals[CHANGED], 0, NAUTILUS_SEARCH_FILTER_LAST, type);
 }
 
@@ -1028,6 +1030,8 @@ nautilus_search_popover_class_init (NautilusSearchPopoverClass *klass)
 static void
 nautilus_search_popover_init (NautilusSearchPopover *self)
 {
+  NautilusQuerySearchType filter_time_type;
+
   gtk_widget_init_template (GTK_WIDGET (self));
 
   /* Fuzzy dates listbox */
@@ -1045,6 +1049,18 @@ nautilus_search_popover_init (NautilusSearchPopover *self)
                                 NULL);
 
   fill_types_listbox (self);
+
+  filter_time_type = g_settings_get_enum (nautilus_preferences, "search-filter-time-type");
+  if (filter_time_type == NAUTILUS_QUERY_SEARCH_TYPE_LAST_MODIFIED)
+    {
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->last_modified_button), TRUE);
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->last_used_button), FALSE);
+    }
+  else
+    {
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->last_modified_button), FALSE);
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->last_used_button), TRUE);
+    }
 }
 
 GtkWidget*


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