[nautilus] slot: reidrect an empty search to the query editor location
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] slot: reidrect an empty search to the query editor location
- Date: Tue, 17 Jul 2012 01:56:14 +0000 (UTC)
commit 6e33c7faefb42d4f0eace063e91bf26eb7326f99
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Mon Jul 16 21:45:35 2012 -0400
slot: reidrect an empty search to the query editor location
Instead of relying on search engines returning the exact result set for
an empty query. This is also faster.
src/nautilus-window-slot.c | 20 ++++++++++++++++----
src/nautilus-window-slot.h | 1 +
src/nautilus-window.c | 7 +++++--
3 files changed, 22 insertions(+), 6 deletions(-)
---
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 033fb2f..feec424 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -64,6 +64,8 @@ sync_search_directory (NautilusWindowSlot *slot)
{
NautilusDirectory *directory;
NautilusQuery *query;
+ gchar *text;
+ GFile *location;
g_assert (NAUTILUS_IS_FILE (slot->viewed_file));
@@ -71,11 +73,21 @@ sync_search_directory (NautilusWindowSlot *slot)
g_assert (NAUTILUS_IS_SEARCH_DIRECTORY (directory));
query = nautilus_query_editor_get_query (slot->query_editor);
- nautilus_search_directory_set_query (NAUTILUS_SEARCH_DIRECTORY (directory),
- query);
- g_object_unref (query);
- nautilus_window_slot_reload (slot);
+ text = nautilus_query_get_text (query);
+
+ if (!strlen (text)) {
+ location = nautilus_query_editor_get_location (slot->query_editor);
+ slot->load_with_search = TRUE;
+ nautilus_window_slot_open_location (slot, location, 0);
+ g_object_unref (location);
+ } else {
+ nautilus_search_directory_set_query (NAUTILUS_SEARCH_DIRECTORY (directory),
+ query);
+ nautilus_window_slot_reload (slot);
+ }
+ g_free (text);
+ g_object_unref (query);
nautilus_directory_unref (directory);
}
diff --git a/src/nautilus-window-slot.h b/src/nautilus-window-slot.h
index c925c4e..b72f812 100644
--- a/src/nautilus-window-slot.h
+++ b/src/nautilus-window-slot.h
@@ -105,6 +105,7 @@ struct NautilusWindowSlot {
gboolean tried_mount;
NautilusWindowGoToCallback open_callback;
gpointer open_callback_user_data;
+ gboolean load_with_search;
GCancellable *find_mount_cancellable;
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 9c222e8..f7e5c3a 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -712,15 +712,18 @@ nautilus_window_sync_search_widgets (NautilusWindow *window)
{
NautilusDirectory *directory;
NautilusSearchDirectory *search_directory;
+ NautilusWindowSlot *slot;
search_directory = NULL;
+ slot = window->details->active_slot;
- directory = nautilus_directory_get (window->details->active_slot->location);
+ directory = nautilus_directory_get (slot->location);
if (NAUTILUS_IS_SEARCH_DIRECTORY (directory)) {
search_directory = NAUTILUS_SEARCH_DIRECTORY (directory);
}
- if (search_directory != NULL) {
+ if (search_directory != NULL || slot->load_with_search) {
+ slot->load_with_search = FALSE;
toggle_toolbar_search_button (window, TRUE);
} else {
toggle_toolbar_search_button (window, FALSE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]