4 * ROX-Filer, filer for the ROX desktop project
5 * Copyright (C) 1999, Thomas Leonard, <tal197@ecs.soton.ac.uk>.
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the Free
9 * Software Foundation; either version 2 of the License, or (at your option)
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19 * Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <sys/types.h>
32 #ifdef HAVE_GETOPT_LONG
37 #include "collection.h"
40 #include "gui_support.h"
53 int number_of_windows
= 0; /* Quit when this reaches 0 again... */
54 int to_error_log
= -1; /* Write here to log errors */
58 int ngroups
; /* Number of supplemental groups */
59 gid_t
*supplemental_groups
= NULL
;
61 #define VERSION "ROX-Filer 0.1.14\n" \
62 "Copyright (C) 1999 Thomas Leonard.\n" \
63 "ROX-Filer comes with ABSOLUTELY NO WARRANTY,\n" \
64 "to the extent permitted by law.\n" \
65 "You may redistribute copies of ROX-Filer\n" \
66 "under the terms of the GNU General Public License.\n" \
67 "For more information about these matters, " \
68 "see the file named COPYING.\n"
70 #ifdef HAVE_GETOPT_LONG
71 # define USAGE "Try `ROX-Filer/AppRun --help' for more information.\n"
72 # define SHORT_ONLY_WARNING ""
74 # define USAGE "Try `ROX-Filer/AppRun -h' for more information.\n"
75 # define SHORT_ONLY_WARNING \
76 "NOTE: Your system does not support long options - \n" \
77 "you must use the short versions instead.\n\n"
80 #define HELP "Usage: ROX-Filer/AppRun [OPTION]... [DIR]...\n" \
81 "Open filer windows showing each directory listed, or $HOME \n" \
82 "if no directories are given.\n\n" \
83 " -h, --help display this help and exit\n" \
84 " -v, --version display the version information and exit\n" \
85 " -t, --top [DIR] open DIR as a top-edge panel\n" \
86 " -b, --bottom [DIR] open DIR as a bottom-edge panel\n" \
87 " -l, --left [DIR] open DIR as a left-edge panel\n" \
88 " -r, --right [DIR] open DIR as a right-edge panel\n" \
89 " -o, --override override window manager control of panels\n" \
90 "\n" SHORT_ONLY_WARNING \
91 "Report bugs to <tal197@ecs.soton.ac.uk>.\n"
93 #ifdef HAVE_GETOPT_LONG
94 static struct option long_opts
[] =
96 {"top", 1, NULL
, 't'},
97 {"bottom", 1, NULL
, 'b'},
98 {"left", 1, NULL
, 'l'},
99 {"right", 1, NULL
, 'r'},
100 {"override", 0, NULL
, 'o'},
101 {"help", 0, NULL
, 'h'},
102 {"version", 0, NULL
, 'v'},
107 /* Take control of panels away from WM? */
108 gboolean override_redirect
= FALSE
;
110 static void child_died(int signum
)
115 /* Find out which children exited and allow them to die */
118 child
= waitpid(-1, &status
, WNOHANG
);
120 if (child
== 0 || child
== -1)
123 /* fprintf(stderr, "Child %d exited\n", child); */
129 void stderr_cb(gpointer data
, gint source
, GdkInputCondition condition
)
132 static GtkWidget
*log
= NULL
;
133 static GtkWidget
*window
= NULL
;
138 window
= gtk_window_new(GTK_WINDOW_TOPLEVEL
);
139 gtk_window_set_title(GTK_WINDOW(window
), "ROX-Filer error log");
140 gtk_window_set_position(GTK_WINDOW(window
), GTK_WIN_POS_CENTER
);
141 gtk_window_set_default_size(GTK_WINDOW(window
), 600, 300);
142 gtk_signal_connect_object(GTK_OBJECT(window
), "delete_event",
143 gtk_widget_hide
, GTK_OBJECT(window
));
144 log
= gtk_text_new(NULL
, NULL
);
145 gtk_container_add(GTK_CONTAINER(window
), log
);
148 if (!GTK_WIDGET_MAPPED(window
))
149 gtk_widget_show_all(window
);
151 len
= read(source
, buf
, BUFLEN
);
153 gtk_text_insert(GTK_TEXT(log
), NULL
, NULL
, NULL
, buf
, len
);
156 int main(int argc
, char **argv
)
159 struct sigaction act
;
160 GList
*panel_dirs
= NULL
;
161 GList
*panel_sides
= NULL
;
163 gtk_init(&argc
, &argv
);
168 #ifdef HAVE_GETOPT_LONG
170 c
= getopt_long(argc
, argv
, "t:b:l:r:ohv",
171 long_opts
, &long_index
);
173 c
= getopt(argc
, argv
, "t:b:l:r:ohv");
177 break; /* No more options */
182 override_redirect
= TRUE
;
194 panel_sides
= g_list_prepend(panel_sides
,
196 panel_dirs
= g_list_prepend(panel_dirs
,
197 *optarg
== '=' ? optarg
+ 1
206 choices_init("ROX-Filer");
222 /* Let child processes die */
223 act
.sa_handler
= child_died
;
224 sigemptyset(&act
.sa_mask
);
225 act
.sa_flags
= SA_NOCLDSTOP
;
226 sigaction(SIGCHLD
, &act
, NULL
);
230 ngroups
= getgroups(0, NULL
);
233 else if (ngroups
> 0)
235 supplemental_groups
= g_malloc(sizeof(gid_t
) * ngroups
);
236 getgroups(ngroups
, supplemental_groups
);
241 if (get_choice("!!!DANGER!!!",
242 "Running ROX-Filer as root is VERY dangerous. If I "
243 "had a warranty (I don't) then doing this would "
245 "Don't click here", "Quit") != 0)
249 if (optind
== argc
&& !panel_dirs
)
250 filer_opendir(getenv("HOME"), FALSE
, BOTTOM
);
254 GList
*dir
= panel_dirs
;
255 GList
*side
= panel_sides
;
259 int c
= (int) side
->data
;
261 filer_opendir((char *) dir
->data
, TRUE
,
274 filer_opendir(argv
[i
++], FALSE
, BOTTOM
);
278 gdk_input_add(stderr_pipe
[0], GDK_INPUT_READ
, stderr_cb
, NULL
);
279 to_error_log
= stderr_pipe
[1];