4 * ROX-Filer, filer for the ROX desktop project
5 * By Thomas Leonard, <tal197@ecs.soton.ac.uk>.
10 #include <sys/types.h>
17 #include "collection.h"
20 #include "gui_support.h"
30 int number_of_windows
= 0; /* Quit when this reaches 0 again... */
32 static void child_died(int signum
)
37 /* Find out which children exited and allow them to die */
40 child
= waitpid(-1, &status
, WNOHANG
);
42 if (child
== 0 || child
== -1)
45 /* fprintf(stderr, "Child %d exited\n", child); */
51 void stderr_cb(gpointer data
, gint source
, GdkInputCondition condition
)
54 static GtkWidget
*log
= NULL
;
55 static GtkWidget
*window
= NULL
;
60 window
= gtk_window_new(GTK_WINDOW_TOPLEVEL
);
61 gtk_window_set_title(GTK_WINDOW(window
), "ROX-Filer error log");
62 gtk_window_set_position(GTK_WINDOW(window
), GTK_WIN_POS_CENTER
);
63 gtk_window_set_default_size(GTK_WINDOW(window
), 600, 300);
64 gtk_signal_connect_object(GTK_OBJECT(window
), "delete_event",
65 gtk_widget_hide
, GTK_OBJECT(window
));
66 log
= gtk_text_new(NULL
, NULL
);
67 gtk_container_add(GTK_CONTAINER(window
), log
);
70 if (!GTK_WIDGET_MAPPED(window
))
71 gtk_widget_show_all(window
);
73 len
= read(source
, buf
, BUFLEN
);
75 gtk_text_insert(GTK_TEXT(log
), NULL
, NULL
, NULL
, buf
, len
);
78 int main(int argc
, char **argv
)
81 struct sigaction act
= {};
83 gtk_init(&argc
, &argv
);
84 choices_init("ROX-Filer");
97 /* Let child processes die */
98 act
.sa_handler
= child_died
;
99 sigemptyset(&act
.sa_mask
);
100 act
.sa_flags
= SA_NOCLDSTOP
;
101 sigaction(SIGCHLD
, &act
, NULL
);
105 if (get_choice("!!!DANGER!!!",
106 "Running ROX-Filer as root is VERY dangerous. If it "
107 "had a warranty (it doesn't) then doing this would "
109 "Don't click here", "Quit") != 0)
114 filer_opendir(getenv("HOME"), FALSE
, BOTTOM
);
118 gboolean panel
= FALSE
;
123 if (argv
[i
][0] == '-')
125 switch (argv
[i
][1] + (argv
[i
][2] << 8))
127 case 't': side
= TOP
; break;
128 case 'b': side
= BOTTOM
; break;
129 case 'l': side
= LEFT
; break;
130 case 'r': side
= RIGHT
; break;
140 filer_opendir(argv
[i
], panel
, side
);
149 dup2(stderr_pipe
[1], STDERR_FILENO
);
150 gdk_input_add(stderr_pipe
[0], GDK_INPUT_READ
, stderr_cb
, NULL
);
151 fcntl(STDERR_FILENO
, F_SETFD
, 0);