r44: Greatly improved the options system. Choice of xterm process is now
[rox-filer.git] / ROX-Filer / src / main.c
blob38b6f52727cd97a5ad24ee7036909179e62c20a1
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 <stdio.h>
10 #include <signal.h>
11 #include <sys/wait.h>
13 #include <gtk/gtk.h>
14 #include <collection.h>
16 #include "main.h"
17 #include "gui_support.h"
18 #include "filer.h"
19 #include "mount.h"
20 #include "menu.h"
21 #include "dnd.h"
22 #include "options.h"
23 #include "choices.h"
24 #include "savebox.h"
25 #include "type.h"
27 int number_of_windows = 0; /* Quit when this reaches 0 again... */
29 /* XXX: Maybe we shouldn't do so much work in a signal handler? */
30 static void child_died(int signum)
32 int status;
33 int child;
34 FilerWindow *filer_window;
36 /* Find out which children exited. This also has the effect of
37 * allowing the children to die.
41 child = waitpid(-1, &status, WNOHANG | WUNTRACED);
43 if (child == 0 || child == -1)
44 return;
46 filer_window = g_hash_table_lookup(child_to_filer,
47 (gpointer) child);
48 if (filer_window)
49 scan_dir(filer_window);
51 if (!WIFSTOPPED(status))
52 g_hash_table_remove(child_to_filer,
53 (gpointer) child);
55 } while (1);
58 int main(int argc, char **argv)
60 gtk_init(&argc, &argv);
61 choices_init("ROX-Filer");
63 gui_support_init();
64 menu_init();
65 dnd_init();
66 filer_init();
67 mount_init();
68 options_init();
69 savebox_init();
70 type_init();
72 options_load();
74 signal(SIGCHLD, child_died);
76 if (argc < 2)
77 filer_opendir(getenv("HOME"), FALSE, BOTTOM);
78 else
80 int i = 1;
81 gboolean panel = FALSE;
82 Side side = BOTTOM;
84 while (i < argc)
86 if (argv[i][0] == '-')
88 switch (argv[i][1] + (argv[i][2] << 8))
90 case 't': side = TOP; break;
91 case 'b': side = BOTTOM; break;
92 case 'l': side = LEFT; break;
93 case 'r': side = RIGHT; break;
94 default:
95 fprintf(stderr,
96 "Bad option.\n");
97 return EXIT_FAILURE;
99 panel = TRUE;
101 else
103 filer_opendir(argv[i], panel, side);
104 panel = FALSE;
105 side = BOTTOM;
107 i++;
111 gtk_main();
113 return EXIT_SUCCESS;