summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2016-01-31 12:26:29 +0100
committerCarlos Soriano <csoriano@gnome.org>2016-02-02 22:22:38 +0100
commit52f491671d7c8c42adc748ceae4c9e0d0eaaae0e (patch)
tree883aad5e5d137a724f9c097d0e4ce58618f094d7
parent37df827f51fab83a725df6dd14985456d8b38a76 (diff)
downloadnautilus-52f491671d7c8c42adc748ceae4c9e0d0eaaae0e.tar.gz
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.
-rw-r--r--data/org.gnome.nautilus.gschema.xml10
-rw-r--r--libnautilus-private/nautilus-query.c4
-rw-r--r--src/nautilus-search-popover.c16
3 files changed, 29 insertions, 1 deletions
diff --git a/data/org.gnome.nautilus.gschema.xml b/data/org.gnome.nautilus.gschema.xml
index e5632cc0a..d91b79e6c 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 639ff1708..baa457945 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 7eb155ef3..818fc5104 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*