nautilus-3.6.3/test/test-nautilus-search-engine.c

No issues found

 1 #include <libnautilus-private/nautilus-search-provider.h>
 2 #include <libnautilus-private/nautilus-search-engine.h>
 3 #include <gtk/gtk.h>
 4 
 5 static void
 6 hits_added_cb (NautilusSearchEngine *engine, GSList *hits)
 7 {      
 8 	g_print ("hits added\n");
 9 	while (hits) {
10 		g_print (" - %s\n", (char *)hits->data);
11 		hits = hits->next;
12 	}
13 }
14 
15 static void
16 finished_cb (NautilusSearchEngine *engine)
17 {
18 	g_print ("finished!\n");
19 	gtk_main_quit ();
20 }
21 
22 int 
23 main (int argc, char* argv[])
24 {
25 	NautilusSearchEngine *engine;
26         NautilusSearchEngineModel *model;
27         NautilusDirectory *directory;
28 	NautilusQuery *query;
29         GFile *location;
30 	
31 	gtk_init (&argc, &argv);
32 
33 	engine = nautilus_search_engine_new ();
34 	g_signal_connect (engine, "hits-added", 
35 			  G_CALLBACK (hits_added_cb), NULL);
36 	g_signal_connect (engine, "finished", 
37 			  G_CALLBACK (finished_cb), NULL);
38 
39 	query = nautilus_query_new ();
40 	nautilus_query_set_text (query, "richard hult");
41 	nautilus_search_provider_set_query (NAUTILUS_SEARCH_PROVIDER (engine), query);
42 	g_object_unref (query);
43 
44         location = g_file_new_for_path (g_get_home_dir ());
45         directory = nautilus_directory_get (location);
46         g_object_unref (location);
47 
48         model = nautilus_search_engine_get_model_provider (engine);
49         nautilus_search_engine_model_set_model (model, directory);
50         g_object_unref (directory);
51 
52 	nautilus_search_provider_start (NAUTILUS_SEARCH_PROVIDER (engine));
53 	nautilus_search_provider_stop (NAUTILUS_SEARCH_PROVIDER (engine));
54         g_object_unref (engine);
55 
56 	gtk_main ();
57 	return 0;
58 }