r33: Changed to using cursor to highlight panel items instead of selecting them.
[rox-filer.git] / ROX-Filer / src / main.c
blobc39a0753c8e2f7d75f639cd5abf05694fd02dcc4
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 "gui_support.h"
17 #include "filer.h"
18 #include "mount.h"
19 #include "menu.h"
20 #include "dnd.h"
21 #include "options.h"
22 #include "choices.h"
23 #include "newdir.h"
25 /* XXX: Maybe we shouldn't do so much work in a signal handler? */
26 static void child_died(int signum)
28 int status;
29 int child;
30 FilerWindow *filer_window;
32 /* Find out which children exited. This also has the effect of
33 * allowing the children to die.
37 child = waitpid(-1, &status, WNOHANG | WUNTRACED);
39 if (child == 0 || child == -1)
40 return;
42 filer_window = g_hash_table_lookup(child_to_filer,
43 (gpointer) child);
44 if (filer_window)
45 scan_dir(filer_window);
47 if (!WIFSTOPPED(status))
48 g_hash_table_remove(child_to_filer,
49 (gpointer) child);
51 } while (1);
54 int main(int argc, char **argv)
56 gtk_init(&argc, &argv);
57 choices_init("ROX-Filer");
59 gui_support_init();
60 menu_init();
61 dnd_init();
62 filer_init();
63 mount_init();
64 options_init();
65 newdir_init();
67 signal(SIGCHLD, child_died);
69 if (argc < 2)
70 filer_opendir(getenv("HOME"), FALSE, BOTTOM);
71 else
73 int i = 1;
74 gboolean panel = FALSE;
75 Side side = BOTTOM;
77 while (i < argc)
79 if (argv[i][0] == '-')
81 switch (argv[i][1] + (argv[i][2] << 8))
83 case 't': side = TOP; break;
84 case 'b': side = BOTTOM; break;
85 case 'l': side = LEFT; break;
86 case 'r': side = RIGHT; break;
87 default:
88 fprintf(stderr,
89 "Bad option.\n");
90 return EXIT_FAILURE;
92 panel = TRUE;
94 else
96 filer_opendir(argv[i], panel, side);
97 panel = FALSE;
98 side = BOTTOM;
100 i++;
104 gtk_main();
106 menu_finish();
108 return EXIT_SUCCESS;