static void search_engine_hits_added (NautilusSearchEngine *engine, GList *hits, NautilusSearchDirectory *search) { GList *hit_list; GList *file_list; NautilusFile *file; SearchMonitor *monitor; GList *monitor_list; file_list = NULL; for (hit_list = hits; hit_list != NULL; hit_list = hit_list->next) { NautilusSearchHit *hit = hit_list->data; const char *uri; uri = nautilus_search_hit_get_uri (hit); if (g_str_has_suffix (uri, NAUTILUS_SAVED_SEARCH_EXTENSION)) { /* Never return saved searches themselves as hits */ continue; } nautilus_search_hit_compute_scores (hit, search->details->query); file = nautilus_file_get_by_uri (uri); nautilus_file_set_search_relevance (file, nautilus_search_hit_get_relevance (hit)); for (monitor_list = search->details->monitor_list; monitor_list; monitor_list = monitor_list->next) { monitor = monitor_list->data; /* Add monitors */ nautilus_file_monitor_add (file, monitor, monitor->monitor_attributes); } g_signal_connect (file, "changed", G_CALLBACK (file_changed), search), file_list = g_list_prepend (file_list, file); g_hash_table_add (search->details->files_hash, file); } search->details->files = g_list_concat (search->details->files, file_list); nautilus_directory_emit_files_added (NAUTILUS_DIRECTORY (search), file_list); file = nautilus_directory_get_corresponding_file (NAUTILUS_DIRECTORY (search)); nautilus_file_emit_changed (file); nautilus_file_unref (file); on_search_directory_search_ready_and_valid (search); }
static void search_engine_finished (NautilusSearchEngine *engine, NautilusSearchProviderStatus status, NautilusSearchDirectory *search) { /* If the search engine is going to restart means it finished an old search * that was stopped or cancelled. * Don't emit the done loading signal in this case, since this means the search * directory tried to start a new search before all the search providers were finished * in the search engine. * If we emit the done-loading signal in this situation the client will think * that it finished the current search, not an old one like it's actually * happening. */ if (status == NAUTILUS_SEARCH_PROVIDER_STATUS_NORMAL) { on_search_directory_search_ready_and_valid (search); nautilus_directory_emit_done_loading (NAUTILUS_DIRECTORY (search)); } else if (status == NAUTILUS_SEARCH_PROVIDER_STATUS_RESTARTING) { /* Remove file monitors of the files from an old search that just * actually finished */ reset_file_list (search); } }