[nautilus] search-directory: ensure we call emit_done_loading() when no results



commit 3fb1d8c69c2c072b3a544c1ea7298b2c4e26c61d
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Oct 29 16:48:22 2012 -0400

    search-directory: ensure we call emit_done_loading() when no results
    
    When we receive no results, we should still call
    nautilus_directory_emit_done_loading() and clear the loading state.
    Do this by factoring out an idempotent helper, which will be called both
    from the hits-added and finished callbacks.

 libnautilus-private/nautilus-search-directory.c |   43 ++++++++++++++++-------
 1 files changed, 30 insertions(+), 13 deletions(-)
---
diff --git a/libnautilus-private/nautilus-search-directory.c b/libnautilus-private/nautilus-search-directory.c
index 06901b6..16a6b33 100644
--- a/libnautilus-private/nautilus-search-directory.c
+++ b/libnautilus-private/nautilus-search-directory.c
@@ -507,6 +507,26 @@ search_callback_add_pending_file_callbacks (SearchCallback *callback)
 }
 
 static void
+search_directory_ensure_loaded (NautilusSearchDirectory *search)
+{
+	if (search->details->search_loaded) {
+		return;
+	}
+
+	search->details->search_loaded = TRUE;
+	nautilus_directory_emit_done_loading (NAUTILUS_DIRECTORY (search));
+
+	/* Add all file callbacks */
+	g_list_foreach (search->details->pending_callback_list,
+			(GFunc)search_callback_add_pending_file_callbacks, NULL);
+	search->details->callback_list = g_list_concat (search->details->callback_list,
+							search->details->pending_callback_list);
+
+	g_list_free (search->details->pending_callback_list);
+	search->details->pending_callback_list = NULL;
+}
+
+static void
 search_engine_hits_added (NautilusSearchEngine *engine, GList *hits, 
 			  NautilusSearchDirectory *search)
 {
@@ -554,19 +574,7 @@ search_engine_hits_added (NautilusSearchEngine *engine, GList *hits,
 	nautilus_file_emit_changed (file);
 	nautilus_file_unref (file);
 
-	if (!search->details->search_loaded) {
-		search->details->search_loaded = TRUE;
-		nautilus_directory_emit_done_loading (NAUTILUS_DIRECTORY (search));
-
-		/* Add all file callbacks */
-		g_list_foreach (search->details->pending_callback_list,
-				(GFunc)search_callback_add_pending_file_callbacks, NULL);
-		search->details->callback_list = g_list_concat (search->details->callback_list,
-								search->details->pending_callback_list);
-
-		g_list_free (search->details->pending_callback_list);
-		search->details->pending_callback_list = NULL;
-	}
+	search_directory_ensure_loaded (search);
 }
 
 static void
@@ -582,6 +590,12 @@ search_engine_error (NautilusSearchEngine *engine, const char *error_message, Na
 }
 
 static void
+search_engine_finished (NautilusSearchEngine *engine, NautilusSearchDirectory *search)
+{
+	search_directory_ensure_loaded (search);
+}
+
+static void
 search_force_reload (NautilusDirectory *directory)
 {
 	NautilusSearchDirectory *search;
@@ -762,6 +776,9 @@ nautilus_search_directory_init (NautilusSearchDirectory *search)
 	g_signal_connect (search->details->engine, "error",
 			  G_CALLBACK (search_engine_error),
 			  search);
+	g_signal_connect (search->details->engine, "finished",
+			  G_CALLBACK (search_engine_finished),
+			  search);
 }
 
 static void



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