r21: Files can now be copied by dragging them between filer windows.
[rox-filer.git] / ROX-Filer / src / main.c
blob9130afb610fc1fccc72657e76f0c0142794b15d8
1 /* vi: set cindent:
2 * $Id$
4 * ROX-Filer, filer for the ROX desktop project
5 * By Thomas Leonard, <tal197@ecs.soton.ac.uk>.
6 */
8 #include <stdlib.h>
9 #include <signal.h>
10 #include <sys/wait.h>
12 #include <gtk/gtk.h>
13 #include <collection.h>
15 #include "filer.h"
16 #include "menu.h"
17 #include "dnd.h"
19 static void child_died(int signum)
21 int status;
22 int child;
23 FilerWindow *filer_window;
25 /* Find out which children exited. This also has the effect of
26 * allowing the children to die.
30 child = waitpid(-1, &status, WNOHANG | WUNTRACED);
32 if (child == 0 || child == -1)
33 return;
35 filer_window = g_hash_table_lookup(child_to_filer,
36 (gpointer) child);
37 if (filer_window)
38 scan_dir(filer_window);
40 if (!WIFSTOPPED(status))
41 g_hash_table_remove(child_to_filer,
42 (gpointer) child);
44 } while (1);
47 int main(int argc, char **argv)
49 gtk_init(&argc, &argv);
51 menu_init();
52 dnd_init();
53 filer_init();
55 signal(SIGCHLD, child_died);
57 if (argc < 2)
58 filer_opendir(getenv("HOME"));
59 else
61 int i;
62 for (i = 1; i < argc; i++)
63 filer_opendir(argv[i]);
66 gtk_main();
68 return EXIT_SUCCESS;