Exemplo n.º 1
0
static void
start_or_stop_search_engine (NemoSearchDirectory *search, gboolean adding)
{
	if (adding && (search->details->monitor_list ||
	    search->details->pending_callback_list) &&
	    search->details->query &&
	    !search->details->search_running) {
		/* We need to start the search engine */
		search->details->search_running = TRUE;
		search->details->search_finished = FALSE;
		ensure_search_engine (search);
		nemo_search_engine_set_query (search->details->engine, search->details->query);

		reset_file_list (search);

		nemo_search_engine_start (search->details->engine);
	} else if (!adding && (!search->details->monitor_list ||
		   !search->details->pending_callback_list) &&
		   search->details->engine &&
		   search->details->search_running) {
		search->details->search_running = FALSE;
		nemo_search_engine_stop (search->details->engine);

		reset_file_list (search);
	}

}
Exemplo n.º 2
0
static void
search_force_reload (NemoDirectory *directory)
{
	NemoSearchDirectory *search;

	search = NEMO_SEARCH_DIRECTORY (directory);

	if (!search->details->query) {
		return;
	}
	
	search->details->search_finished = FALSE;

	if (!search->details->engine) {
		return;
	}

	/* Remove file monitors */
	reset_file_list (search);
	
	if (search->details->search_running) {
		nemo_search_engine_stop (search->details->engine);
		nemo_search_engine_set_query (search->details->engine, search->details->query);
		nemo_search_engine_start (search->details->engine);
	}
}
Exemplo n.º 3
0
static void
stop_search (NautilusSearchDirectory *search)
{
	if (!search->details->search_running) {
		return;
	}

	search->details->search_running = FALSE;
	nautilus_search_provider_stop (NAUTILUS_SEARCH_PROVIDER (search->details->engine));

	reset_file_list (search);
}
Exemplo n.º 4
0
static void
search_dispose (GObject *object)
{
	NemoSearchDirectory *search;
	GList *list;

	search = NEMO_SEARCH_DIRECTORY (object);
	
	/* Remove search monitors */
	if (search->details->monitor_list) {
		for (list = search->details->monitor_list; list != NULL; list = list->next) {
			search_monitor_destroy ((SearchMonitor *)list->data, search);
		}

		g_list_free (search->details->monitor_list);
		search->details->monitor_list = NULL;
	}

	reset_file_list (search);
	
	if (search->details->callback_list) {
		/* Remove callbacks */
		g_list_foreach (search->details->callback_list,
				(GFunc)search_callback_destroy, NULL);
		g_list_free (search->details->callback_list);
		search->details->callback_list = NULL;
	}

	if (search->details->pending_callback_list) {
		g_list_foreach (search->details->pending_callback_list,
				(GFunc)search_callback_destroy, NULL);
		g_list_free (search->details->pending_callback_list);
		search->details->pending_callback_list = NULL;
	}

	if (search->details->query) {
		g_object_unref (search->details->query);
		search->details->query = NULL;
	}

	if (search->details->engine) {
		if (search->details->search_running) {
			nemo_search_engine_stop (search->details->engine);
		}
		
		g_object_unref (search->details->engine);
		search->details->engine = NULL;
	}
	
	G_OBJECT_CLASS (nemo_search_directory_parent_class)->dispose (object);
}
static void
search_force_reload (NautilusDirectory *directory)
{
	NautilusSearchDirectory *search;

	search = NAUTILUS_SEARCH_DIRECTORY (directory);

	if (!search->details->query) {
		return;
	}
	
	search->details->search_ready_and_valid = FALSE;

	/* Remove file monitors */
	reset_file_list (search);
	stop_search (search);
}
Exemplo n.º 6
0
static void
search_dispose (GObject *object)
{
	NautilusSearchDirectory *search;
	GList *list;

	search = NAUTILUS_SEARCH_DIRECTORY (object);

	clear_base_model (search);

	/* Remove search monitors */
	if (search->details->monitor_list) {
		for (list = search->details->monitor_list; list != NULL; list = list->next) {
			search_monitor_destroy ((SearchMonitor *)list->data, search);
		}

		g_list_free (search->details->monitor_list);
		search->details->monitor_list = NULL;
	}

	reset_file_list (search);
	
	if (search->details->callback_list) {
		/* Remove callbacks */
		g_list_foreach (search->details->callback_list,
				(GFunc)search_callback_destroy, NULL);
		g_list_free (search->details->callback_list);
		search->details->callback_list = NULL;
	}

	if (search->details->pending_callback_list) {
		g_list_foreach (search->details->pending_callback_list,
				(GFunc)search_callback_destroy, NULL);
		g_list_free (search->details->pending_callback_list);
		search->details->pending_callback_list = NULL;
	}

	g_clear_object (&search->details->query);
	stop_search (search);
        search_disconnect_engine(search);

	g_clear_object (&search->details->engine);
	
	G_OBJECT_CLASS (nautilus_search_directory_parent_class)->dispose (object);
}
Exemplo n.º 7
0
static void
search_force_reload (NautilusDirectory *directory)
{
	NautilusSearchDirectory *search;
        NautilusFile *file;

	search = NAUTILUS_SEARCH_DIRECTORY (directory);

	if (!search->details->query) {
		return;
	}
	
	search->details->search_ready_and_valid = FALSE;

	/* Remove file monitors */
	reset_file_list (search);
	stop_search (search);

	file = nautilus_directory_get_corresponding_file (directory);
	nautilus_file_invalidate_all_attributes (file);
	nautilus_file_unref (file);
}
Exemplo n.º 8
0
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);
        }
}
Exemplo n.º 9
0
static void
start_search (NautilusSearchDirectory *search)
{
	NautilusSearchEngineModel *model_provider;
	NautilusSearchEngineSimple *simple_provider;
	gboolean recursive;

	if (!search->details->query) {
		return;
	}

	if (search->details->search_running) {
		return;
	}

	if (!search->details->monitor_list && !search->details->pending_callback_list) {
		return;
	}

	/* We need to start the search engine */
	search->details->search_running = TRUE;
	search->details->search_ready_and_valid = FALSE;

	set_hidden_files (search);
	nautilus_search_provider_set_query (NAUTILUS_SEARCH_PROVIDER (search->details->engine),
					    search->details->query);

	model_provider = nautilus_search_engine_get_model_provider (search->details->engine);
	nautilus_search_engine_model_set_model (model_provider, search->details->base_model);

	simple_provider = nautilus_search_engine_get_simple_provider (search->details->engine);
	recursive = nautilus_query_get_recursive (search->details->query);
	g_object_set (simple_provider, "recursive", recursive, NULL);

	reset_file_list (search);

	nautilus_search_provider_start (NAUTILUS_SEARCH_PROVIDER (search->details->engine));
}