2008-05-05 Paolo Borelli <pborelli@katamail.com>
[nautilus.git] / test / test-copy.c
blobc71cda907293650cce0a38685a9f2725f2672a21
1 #include "test.h"
3 #include <libnautilus-private/nautilus-file-operations.h>
4 #include <libnautilus-private/nautilus-progress-info.h>
6 static void
7 copy_done (GHashTable *debuting_uris, gpointer data)
9 g_print ("Copy done\n");
12 static void
13 changed_cb (NautilusProgressInfo *info,
14 gpointer data)
16 g_print ("Changed: %s -- %s\n",
17 nautilus_progress_info_get_status (info),
18 nautilus_progress_info_get_details (info));
21 static void
22 progress_changed_cb (NautilusProgressInfo *info,
23 gpointer data)
25 g_print ("Progress changed: %f\n",
26 nautilus_progress_info_get_progress (info));
29 static void
30 finished_cb (NautilusProgressInfo *info,
31 gpointer data)
33 g_print ("Finished\n");
34 gtk_main_quit ();
37 int
38 main (int argc, char* argv[])
40 GtkWidget *window;
41 GList *sources;
42 GFile *dest;
43 GFile *source;
44 int i;
45 GList *infos;
46 NautilusProgressInfo *progress_info;
48 g_thread_init (NULL);
50 test_init (&argc, &argv);
52 if (argc < 3) {
53 g_print ("Usage test-copy <sources...> <dest dir>\n");
54 return 1;
57 sources = NULL;
58 for (i = 1; i < argc - 1; i++) {
59 source = g_file_new_for_commandline_arg (argv[i]);
60 sources = g_list_prepend (sources, source);
62 sources = g_list_reverse (sources);
64 dest = g_file_new_for_commandline_arg (argv[i]);
66 window = test_window_new ("copy test", 5);
68 gtk_widget_show (window);
70 nautilus_file_operations_copy (sources,
71 NULL /* GArray *relative_item_points */,
72 dest,
73 GTK_WINDOW (window),
74 copy_done, NULL);
76 infos = nautilus_get_all_progress_info ();
78 if (infos == NULL) {
79 return 0;
82 progress_info = NAUTILUS_PROGRESS_INFO (infos->data);
84 g_signal_connect (progress_info, "changed", (GCallback)changed_cb, NULL);
85 g_signal_connect (progress_info, "progress-changed", (GCallback)progress_changed_cb, NULL);
86 g_signal_connect (progress_info, "finished", (GCallback)finished_cb, NULL);
88 gtk_main ();
90 return 0;