1 #include <libcaja-private/caja-file-operations.h>
2 #include <libcaja-private/caja-progress-info.h>
3
4 #include "test.h"
5
6 static void
copy_done(GHashTable * debuting_uris,gpointer data)7 copy_done (GHashTable *debuting_uris, gpointer data)
8 {
9 g_print ("Copy done\n");
10 }
11
12 static void
changed_cb(CajaProgressInfo * info,gpointer data)13 changed_cb (CajaProgressInfo *info,
14 gpointer data)
15 {
16 g_print ("Changed: %s -- %s\n",
17 caja_progress_info_get_status (info),
18 caja_progress_info_get_details (info));
19 }
20
21 static void
progress_changed_cb(CajaProgressInfo * info,gpointer data)22 progress_changed_cb (CajaProgressInfo *info,
23 gpointer data)
24 {
25 g_print ("Progress changed: %f\n",
26 caja_progress_info_get_progress (info));
27 }
28
29 static void
finished_cb(CajaProgressInfo * info,gpointer data)30 finished_cb (CajaProgressInfo *info,
31 gpointer data)
32 {
33 g_print ("Finished\n");
34 gtk_main_quit ();
35 }
36
37 int
main(int argc,char * argv[])38 main (int argc, char* argv[])
39 {
40 GtkWidget *window;
41 GList *sources;
42 GFile *dest;
43 GFile *source;
44 int i;
45 GList *infos;
46 CajaProgressInfo *progress_info;
47
48 test_init (&argc, &argv);
49
50 if (argc < 3) {
51 g_print ("Usage test-copy <sources...> <dest dir>\n");
52 return 1;
53 }
54
55 sources = NULL;
56 for (i = 1; i < argc - 1; i++) {
57 source = g_file_new_for_commandline_arg (argv[i]);
58 sources = g_list_prepend (sources, source);
59 }
60 sources = g_list_reverse (sources);
61
62 dest = g_file_new_for_commandline_arg (argv[i]);
63
64 window = test_window_new ("copy test", 5);
65
66 gtk_widget_show (window);
67
68 caja_file_operations_copy (sources,
69 NULL /* GArray *relative_item_points */,
70 dest,
71 GTK_WINDOW (window),
72 copy_done, NULL);
73
74 infos = caja_get_all_progress_info ();
75
76 if (infos == NULL) {
77 return 0;
78 }
79
80 progress_info = CAJA_PROGRESS_INFO (infos->data);
81
82 g_signal_connect (progress_info, "changed", (GCallback)changed_cb, NULL);
83 g_signal_connect (progress_info, "progress-changed", (GCallback)progress_changed_cb, NULL);
84 g_signal_connect (progress_info, "finished", (GCallback)finished_cb, NULL);
85
86 gtk_main ();
87
88 return 0;
89 }
90
91
92