From 88b08d691c17b9686938a0b20a37a19ac99cacc3 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Thu, 8 Sep 2011 15:00:12 -0400 Subject: [PATCH] all: remove is_indexed property on NautilusSearchDirectory It doesn't really make sense to artificially change the query target if we're indexed. --- .../nautilus-search-directory.c | 8 ---- .../nautilus-search-directory.h | 1 - .../nautilus-search-engine-simple.c | 7 --- .../nautilus-search-engine-tracker.c | 7 --- libnautilus-private/nautilus-search-engine.c | 9 ---- libnautilus-private/nautilus-search-engine.h | 2 - src/nautilus-query-editor.c | 46 +++++++------------ src/nautilus-query-editor.h | 4 +- src/nautilus-window-pane.c | 18 ++++---- src/nautilus-window-slot.c | 4 +- 10 files changed, 27 insertions(+), 79 deletions(-) diff --git a/libnautilus-private/nautilus-search-directory.c b/libnautilus-private/nautilus-search-directory.c index 84f6b5bbe..43ff7db55 100644 --- a/libnautilus-private/nautilus-search-directory.c +++ b/libnautilus-private/nautilus-search-directory.c @@ -833,14 +833,6 @@ nautilus_search_directory_is_modified (NautilusSearchDirectory *search) return search->details->modified; } -gboolean -nautilus_search_directory_is_indexed (NautilusSearchDirectory *search) -{ - ensure_search_engine (search); - return nautilus_search_engine_is_indexed (search->details->engine); -} - - void nautilus_search_directory_save_to_file (NautilusSearchDirectory *search, const char *save_file_uri) diff --git a/libnautilus-private/nautilus-search-directory.h b/libnautilus-private/nautilus-search-directory.h index d8d12d706..de4ebe032 100644 --- a/libnautilus-private/nautilus-search-directory.h +++ b/libnautilus-private/nautilus-search-directory.h @@ -59,7 +59,6 @@ NautilusSearchDirectory *nautilus_search_directory_new_from_saved_search (const gboolean nautilus_search_directory_is_saved_search (NautilusSearchDirectory *search); gboolean nautilus_search_directory_is_modified (NautilusSearchDirectory *search); -gboolean nautilus_search_directory_is_indexed (NautilusSearchDirectory *search); void nautilus_search_directory_save_search (NautilusSearchDirectory *search); void nautilus_search_directory_save_to_file (NautilusSearchDirectory *search, const char *save_file_uri); diff --git a/libnautilus-private/nautilus-search-engine-simple.c b/libnautilus-private/nautilus-search-engine-simple.c index a357704e0..db4c79091 100644 --- a/libnautilus-private/nautilus-search-engine-simple.c +++ b/libnautilus-private/nautilus-search-engine-simple.c @@ -368,12 +368,6 @@ nautilus_search_engine_simple_stop (NautilusSearchEngine *engine) } } -static gboolean -nautilus_search_engine_simple_is_indexed (NautilusSearchEngine *engine) -{ - return FALSE; -} - static void nautilus_search_engine_simple_set_query (NautilusSearchEngine *engine, NautilusQuery *query) { @@ -407,7 +401,6 @@ nautilus_search_engine_simple_class_init (NautilusSearchEngineSimpleClass *class engine_class->set_query = nautilus_search_engine_simple_set_query; engine_class->start = nautilus_search_engine_simple_start; engine_class->stop = nautilus_search_engine_simple_stop; - engine_class->is_indexed = nautilus_search_engine_simple_is_indexed; } static void diff --git a/libnautilus-private/nautilus-search-engine-tracker.c b/libnautilus-private/nautilus-search-engine-tracker.c index 7aa07fb83..a94159390 100644 --- a/libnautilus-private/nautilus-search-engine-tracker.c +++ b/libnautilus-private/nautilus-search-engine-tracker.c @@ -316,12 +316,6 @@ nautilus_search_engine_tracker_stop (NautilusSearchEngine *engine) } } -static gboolean -nautilus_search_engine_tracker_is_indexed (NautilusSearchEngine *engine) -{ - return TRUE; -} - static void nautilus_search_engine_tracker_set_query (NautilusSearchEngine *engine, NautilusQuery *query) { @@ -353,7 +347,6 @@ nautilus_search_engine_tracker_class_init (NautilusSearchEngineTrackerClass *cla engine_class->set_query = nautilus_search_engine_tracker_set_query; engine_class->start = nautilus_search_engine_tracker_start; engine_class->stop = nautilus_search_engine_tracker_stop; - engine_class->is_indexed = nautilus_search_engine_tracker_is_indexed; g_type_class_add_private (class, sizeof (NautilusSearchEngineTrackerDetails)); } diff --git a/libnautilus-private/nautilus-search-engine.c b/libnautilus-private/nautilus-search-engine.c index e4952d294..a01191f0c 100644 --- a/libnautilus-private/nautilus-search-engine.c +++ b/libnautilus-private/nautilus-search-engine.c @@ -167,15 +167,6 @@ nautilus_search_engine_stop (NautilusSearchEngine *engine) NAUTILUS_SEARCH_ENGINE_GET_CLASS (engine)->stop (engine); } -gboolean -nautilus_search_engine_is_indexed (NautilusSearchEngine *engine) -{ - g_return_val_if_fail (NAUTILUS_IS_SEARCH_ENGINE (engine), FALSE); - g_return_val_if_fail (NAUTILUS_SEARCH_ENGINE_GET_CLASS (engine)->is_indexed != NULL, FALSE); - - return NAUTILUS_SEARCH_ENGINE_GET_CLASS (engine)->is_indexed (engine); -} - void nautilus_search_engine_hits_added (NautilusSearchEngine *engine, GList *hits) { diff --git a/libnautilus-private/nautilus-search-engine.h b/libnautilus-private/nautilus-search-engine.h index 2be4c1e13..35bf9f9a0 100644 --- a/libnautilus-private/nautilus-search-engine.h +++ b/libnautilus-private/nautilus-search-engine.h @@ -48,7 +48,6 @@ typedef struct { void (*set_query) (NautilusSearchEngine *engine, NautilusQuery *query); void (*start) (NautilusSearchEngine *engine); void (*stop) (NautilusSearchEngine *engine); - gboolean (*is_indexed) (NautilusSearchEngine *engine); /* Signals */ void (*hits_added) (NautilusSearchEngine *engine, GList *hits); @@ -65,7 +64,6 @@ NautilusSearchEngine* nautilus_search_engine_new (void); void nautilus_search_engine_set_query (NautilusSearchEngine *engine, NautilusQuery *query); void nautilus_search_engine_start (NautilusSearchEngine *engine); void nautilus_search_engine_stop (NautilusSearchEngine *engine); -gboolean nautilus_search_engine_is_indexed (NautilusSearchEngine *engine); void nautilus_search_engine_hits_added (NautilusSearchEngine *engine, GList *hits); void nautilus_search_engine_hits_subtracted (NautilusSearchEngine *engine, GList *hits); diff --git a/src/nautilus-query-editor.c b/src/nautilus-query-editor.c index 90e8f568b..efcf54e44 100644 --- a/src/nautilus-query-editor.c +++ b/src/nautilus-query-editor.c @@ -63,7 +63,6 @@ typedef struct { } NautilusQueryEditorRowOps; struct NautilusQueryEditorDetails { - gboolean is_indexed; GtkWidget *entry; gboolean change_frozen; guint typing_timeout_id; @@ -1013,10 +1012,8 @@ nautilus_query_editor_init (NautilusQueryEditor *editor) void nautilus_query_editor_set_default_query (NautilusQueryEditor *editor) { - if (!editor->details->is_indexed) { - nautilus_query_editor_add_row (editor, NAUTILUS_QUERY_EDITOR_ROW_LOCATION); - nautilus_query_editor_changed (editor); - } + nautilus_query_editor_add_row (editor, NAUTILUS_QUERY_EDITOR_ROW_LOCATION); + nautilus_query_editor_changed (editor); } static void @@ -1040,22 +1037,20 @@ finish_first_line (NautilusQueryEditor *editor, GtkWidget *hbox, gboolean use_go gtk_widget_set_tooltip_text (button, _("Add a new criterion to this search")); - if (!editor->details->is_indexed) { - if (use_go) { - button = gtk_button_new_with_label (_("Go")); - } else { - button = gtk_button_new_with_label (_("Reload")); - } - gtk_widget_show (button); - - gtk_widget_set_tooltip_text (button, - _("Perform or update the search")); - - g_signal_connect (button, "clicked", - G_CALLBACK (go_search_cb), editor); - - gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0); + if (use_go) { + button = gtk_button_new_with_label (_("Go")); + } else { + button = gtk_button_new_with_label (_("Reload")); } + gtk_widget_show (button); + + gtk_widget_set_tooltip_text (button, + _("Perform or update the search")); + + g_signal_connect (button, "clicked", + G_CALLBACK (go_search_cb), editor); + + gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0); } static void @@ -1161,7 +1156,7 @@ nautilus_query_editor_changed_force (NautilusQueryEditor *editor, gboolean force if (query_is_valid (editor)) { query = nautilus_query_editor_get_query (editor); g_signal_emit (editor, signals[CHANGED], 0, - query, editor->details->is_indexed || force_reload); + query, force_reload); g_object_unref (query); } } @@ -1224,15 +1219,11 @@ nautilus_query_editor_clear_query (NautilusQueryEditor *editor) } GtkWidget * -nautilus_query_editor_new (gboolean start_hidden, - gboolean is_indexed) +nautilus_query_editor_new (gboolean start_hidden) { GtkWidget *editor; editor = g_object_new (NAUTILUS_TYPE_QUERY_EDITOR, NULL); - - NAUTILUS_QUERY_EDITOR (editor)->details->is_indexed = is_indexed; - nautilus_query_editor_set_visible (NAUTILUS_QUERY_EDITOR (editor), !start_hidden); @@ -1276,7 +1267,6 @@ attach_to_external_entry (NautilusQueryEditor *editor) GtkWidget* nautilus_query_editor_new_with_bar (gboolean start_hidden, - gboolean is_indexed, gboolean start_attached, NautilusSearchBar *bar, NautilusWindowSlot *slot) @@ -1285,8 +1275,6 @@ nautilus_query_editor_new_with_bar (gboolean start_hidden, NautilusQueryEditor *editor; editor = NAUTILUS_QUERY_EDITOR (g_object_new (NAUTILUS_TYPE_QUERY_EDITOR, NULL)); - editor->details->is_indexed = is_indexed; - nautilus_query_editor_set_visible (editor, !start_hidden); editor->details->bar = bar; diff --git a/src/nautilus-query-editor.h b/src/nautilus-query-editor.h index 787a37235..dc5627854 100644 --- a/src/nautilus-query-editor.h +++ b/src/nautilus-query-editor.h @@ -61,10 +61,8 @@ typedef struct { #include "nautilus-window-slot.h" GType nautilus_query_editor_get_type (void); -GtkWidget* nautilus_query_editor_new (gboolean start_hidden, - gboolean is_indexed); +GtkWidget* nautilus_query_editor_new (gboolean start_hidden); GtkWidget* nautilus_query_editor_new_with_bar (gboolean start_hidden, - gboolean is_indexed, gboolean start_attached, NautilusSearchBar *bar, NautilusWindowSlot *slot); diff --git a/src/nautilus-window-pane.c b/src/nautilus-window-pane.c index 13b4dfe54..e68d6d0b0 100644 --- a/src/nautilus-window-pane.c +++ b/src/nautilus-window-pane.c @@ -150,30 +150,28 @@ search_bar_activate_callback (NautilusSearchBar *bar, uri = nautilus_search_directory_generate_new_uri (); location = g_file_new_for_uri (uri); - g_free (uri); directory = nautilus_directory_get (location); - g_assert (NAUTILUS_IS_SEARCH_DIRECTORY (directory)); search_directory = NAUTILUS_SEARCH_DIRECTORY (directory); - query = nautilus_search_bar_get_query (NAUTILUS_SEARCH_BAR (pane->search_bar)); + if (query != NULL) { - NautilusWindowSlot *slot = pane->active_slot; - if (!nautilus_search_directory_is_indexed (search_directory)) { - current_uri = nautilus_window_slot_get_location_uri (slot); - nautilus_query_set_location (query, current_uri); - g_free (current_uri); - } + current_uri = nautilus_window_slot_get_location_uri (pane->active_slot); + + nautilus_query_set_location (query, current_uri); nautilus_search_directory_set_query (search_directory, query); + + g_free (current_uri); g_object_unref (query); } nautilus_window_slot_go_to (pane->active_slot, location, FALSE); nautilus_directory_unref (directory); - g_object_unref (location); + g_object_unref (location); + g_free (uri); } static void diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c index 26ca81db4..9b11ca032 100644 --- a/src/nautilus-window-slot.c +++ b/src/nautilus-window-slot.c @@ -85,12 +85,10 @@ real_update_query_editor (NautilusWindowSlot *slot) search_directory = NAUTILUS_SEARCH_DIRECTORY (directory); if (nautilus_search_directory_is_saved_search (search_directory)) { - query_editor = nautilus_query_editor_new (TRUE, - nautilus_search_directory_is_indexed (search_directory)); + query_editor = nautilus_query_editor_new (TRUE); nautilus_window_pane_sync_search_widgets (slot->pane); } else { query_editor = nautilus_query_editor_new_with_bar (FALSE, - nautilus_search_directory_is_indexed (search_directory), slot->pane->window->details->active_pane->active_slot == slot, NAUTILUS_SEARCH_BAR (slot->pane->search_bar), slot);