r4275: If we can't find libc.so.6 for xattr support, try libc.so in case we only...
[rox-filer.git] / ROX-Filer / src / main.c
blob8a8ae9998e5ea070e778898c17d60f2cabcb7e24
1 /*
2 * $Id$
4 * ROX-Filer, filer for the ROX desktop project
5 * Copyright (C) 2005, the ROX-Filer team.
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)
10 * any later version.
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
15 * more details.
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
22 /* main.c - parses command-line options and parameters, plus some global
23 * housekeeping.
25 * New to the code and feeling lost? Read global.h now.
28 #include "config.h"
30 #include <stdlib.h>
31 #include <stdio.h>
32 #include <sys/types.h>
33 #include <signal.h>
34 #include <string.h>
35 #include <sys/wait.h>
36 #include <unistd.h>
37 #include <fcntl.h>
38 #include <pwd.h>
39 #include <grp.h>
40 #include <libxml/parser.h>
42 #ifdef HAVE_GETOPT_LONG
43 # include <getopt.h>
44 #endif
46 #include <gtk/gtk.h>
47 #include <gdk/gdkx.h> /* For rox_x_error */
49 #include "global.h"
51 #include "main.h"
52 #include "support.h"
53 #include "gui_support.h"
54 #include "filer.h"
55 #include "display.h"
56 #include "mount.h"
57 #include "menu.h"
58 #include "dnd.h"
59 #include "options.h"
60 #include "choices.h"
61 #include "type.h"
62 #include "pixmaps.h"
63 #include "dir.h"
64 #include "diritem.h"
65 #include "action.h"
66 #include "i18n.h"
67 #include "remote.h"
68 #include "pinboard.h"
69 #include "run.h"
70 #include "toolbar.h"
71 #include "bind.h"
72 #include "panel.h"
73 #include "session.h"
74 #include "minibuffer.h"
75 #include "xtypes.h"
77 int number_of_windows = 0; /* Quit when this reaches 0 again... */
78 int to_wakeup_pipe = -1; /* Write here to get noticed */
80 /* Information about the ROX-Filer process */
81 uid_t euid;
82 gid_t egid;
83 int ngroups; /* Number of supplemental groups */
84 gid_t *supplemental_groups = NULL;
86 /* Message to display at the top of each filer window */
87 const gchar *show_user_message = NULL;
89 int home_dir_len;
90 const char *home_dir, *app_dir;
92 GtkTooltips *tooltips = NULL;
94 #define COPYING \
95 N_("Copyright (C) 2005 Thomas Leonard.\n" \
96 "ROX-Filer comes with ABSOLUTELY NO WARRANTY,\n" \
97 "to the extent permitted by law.\n" \
98 "You may redistribute copies of ROX-Filer\n" \
99 "under the terms of the GNU General Public License.\n" \
100 "For more information about these matters, " \
101 "see the file named COPYING.\n")
103 #ifdef HAVE_GETOPT_LONG
104 # define USAGE N_("Try `ROX-Filer/AppRun --help' for more information.\n")
105 # define SHORT_ONLY_WARNING ""
106 #else
107 # define USAGE N_("Try `ROX-Filer/AppRun -h' for more information.\n")
108 # define SHORT_ONLY_WARNING \
109 _("NOTE: Your system does not support long options - \n" \
110 "you must use the short versions instead.\n\n")
111 #endif
113 #define BUGS_TO "<rox-devel@lists.sourceforge.net>"
115 #define HELP N_("Usage: ROX-Filer/AppRun [OPTION]... [FILE]...\n" \
116 "Open each directory or file listed, or the current working\n" \
117 "directory if no arguments are given.\n\n" \
118 " -b, --border=PANEL open PANEL as a border panel\n" \
119 " -B, --bottom=PANEL open PAN as a bottom-edge panel\n" \
120 " -c, --client-id=ID used for session management\n" \
121 " -d, --dir=DIR open DIR as directory (not application)\n" \
122 " -D, --close=DIR close DIR and its subdirectories\n" \
123 " -h, --help display this help and exit\n" \
124 " -l, --left=PANEL open PAN as a left-edge panel\n" \
125 " -m, --mime-type=FILE print MIME type of FILE and exit\n" \
126 " -n, --new start new copy; for debugging the filer\n" \
127 " -p, --pinboard=PIN use pinboard PIN as the pinboard\n" \
128 " -r, --right=PANEL open PAN as a right-edge panel\n" \
129 " -R, --RPC invoke method call read from stdin\n" \
130 " -s, --show=FILE open a directory showing FILE\n" \
131 " -S, --rox-session use default panel and pinboard options, and -n\n"\
132 " -t, --top=PANEL open PANEL as a top-edge panel\n" \
133 " -u, --user show user name in each window \n" \
134 " -v, --version display the version information and exit\n" \
135 " -x, --examine=FILE FILE has changed - re-examine it\n" \
136 "\nReport bugs to " BUGS_TO ".\n" \
137 "Home page (including updated versions): http://rox.sourceforge.net/\n")
139 #define SHORT_OPS "c:d:t:b:l:r:B:op:s:hvnux:m:D:RS"
141 #ifdef HAVE_GETOPT_LONG
142 static struct option long_opts[] =
144 {"dir", 1, NULL, 'd'},
145 {"top", 1, NULL, 't'},
146 {"bottom", 1, NULL, 'B'},
147 {"border", 1, NULL, 'b'},
148 {"left", 1, NULL, 'l'},
149 {"override", 0, NULL, 'o'},
150 {"pinboard", 1, NULL, 'p'},
151 {"right", 1, NULL, 'r'},
152 {"help", 0, NULL, 'h'},
153 {"version", 0, NULL, 'v'},
154 {"user", 0, NULL, 'u'},
155 {"new", 0, NULL, 'n'},
156 {"RPC", 0, NULL, 'R'},
157 {"show", 1, NULL, 's'},
158 {"rox-session", 0, NULL, 'S'},
159 {"examine", 1, NULL, 'x'},
160 {"close", 1, NULL, 'D'},
161 {"mime-type", 1, NULL, 'm'},
162 {"client-id", 1, NULL, 'c'},
163 {NULL, 0, NULL, 0},
165 #endif
167 /* Take control of panels away from WM? */
168 Option o_override_redirect;
170 /* Options used when we are called by ROX-Session */
171 enum {
172 SESSION_PANEL_ONLY,
173 SESSION_PINBOARD_ONLY,
174 SESSION_BOTH,
176 Option o_session_panel_or_pin;
177 Option o_session_panel_name;
178 Option o_session_pinboard_name;
180 /* Always start a new filer, even if one seems to be already running */
181 gboolean new_copy = FALSE;
183 /* Maps child PIDs to Callback pointers */
184 static GHashTable *death_callbacks = NULL;
185 static gboolean child_died_flag = FALSE;
187 Option o_dnd_no_hostnames;
189 /* Static prototypes */
190 static void show_features(void);
191 static void soap_add(xmlNodePtr body,
192 xmlChar *function,
193 const xmlChar *arg1_name, const xmlChar *arg1_value,
194 const xmlChar *arg2_name, const xmlChar *arg2_value);
195 static void child_died(int signum);
196 static void child_died_callback(void);
197 static void wake_up_cb(gpointer data, gint source, GdkInputCondition condition);
198 static void xrandr_size_change(GdkScreen *screen, gpointer user_data);
199 static void add_default_panel_and_pinboard(xmlNodePtr body);
200 static GList *build_launch(Option *option, xmlNode *node, guchar *label);
202 /****************************************************************
203 * EXTERNAL INTERFACE *
204 ****************************************************************/
206 /* The value that goes with an option */
207 #define VALUE (*optarg == '=' ? optarg + 1 : optarg)
209 static int rox_x_error(Display *display, XErrorEvent *error)
211 gchar buf[64];
213 XGetErrorText(display, error->error_code, buf, 63);
215 g_warning ("The program '%s' received an X Window System error.\n"
216 "This probably reflects a bug in the program.\n"
217 "The error was '%s'.\n"
218 " (Details: serial %ld error_code %d request_code %d minor_code %d)\n"
219 " (Note to programmers: normally, X errors are reported asynchronously;\n"
220 " that is, you will receive the error a while after causing it.\n"
221 " To debug your program, run it with the --sync command line\n"
222 " option to change this behavior. You can then get a meaningful\n"
223 " backtrace from your debugger.)",
224 g_get_prgname (),
225 buf,
226 error->serial,
227 error->error_code,
228 error->request_code,
229 error->minor_code);
231 /* Try to cope with BadWindow errors */
232 if (error->error_code == BadWindow || error->error_code == BadDrawable)
234 g_warning(_("We got a BadWindow error from the X server. "
235 "This might be due to this GTK bug (during drag-and-drop?):\n"
236 "http://bugzilla.gnome.org/show_bug.cgi?id=152151\n"
237 "Trying to continue..."));
238 return 0;
241 abort();
244 /* Parses the command-line to work out what the user wants to do.
245 * Tries to send the request to an already-running copy of the filer.
246 * If that fails, it initialises all the other modules and executes the
247 * request itself.
249 int main(int argc, char **argv)
251 int wakeup_pipe[2];
252 int i;
253 struct sigaction act;
254 guchar *tmp, *dir;
255 gchar *client_id = NULL;
256 gboolean show_user = FALSE;
257 xmlDocPtr rpc, soap_rpc = NULL, reply;
258 xmlNodePtr body;
259 int fd, ofd0=-1;
261 /* Relocate stdin. We do need it (-R), but it can cause problems if
262 * a child process wants a password, etc...
263 * Do this BEFORE opening anything (e.g., the X connection), in
264 * case fd 0 isn't open at this point.
266 fd = open("/dev/null", O_RDONLY);
267 if (fd > 0)
269 ofd0=dup(0);
270 close(0);
271 dup2(fd, 0);
272 close(fd);
275 home_dir = g_get_home_dir();
276 home_dir_len = strlen(home_dir);
277 app_dir = g_strdup(getenv("APP_DIR"));
279 /* Get internationalisation up and running. This requires the
280 * choices system, to discover the user's preferred language.
282 choices_init();
283 options_init();
284 i18n_init();
285 xattr_init();
287 if (!app_dir)
289 g_warning("APP_DIR environment variable was unset!\n"
290 "Use the AppRun script to invoke ROX-Filer...\n");
291 app_dir = g_get_current_dir();
293 #ifdef HAVE_UNSETENV
294 else
296 /* Don't pass it on to our child processes... */
297 unsetenv("APP_DIR");
299 #endif
301 /* Sometimes we want to take special action when a child
302 * process exits. This hash table is used to convert the
303 * child's PID to the callback function.
305 death_callbacks = g_hash_table_new(NULL, NULL);
307 /* Find out some information about ourself */
308 euid = geteuid();
309 egid = getegid();
310 ngroups = getgroups(0, NULL);
311 if (ngroups < 0)
312 ngroups = 0;
313 else if (ngroups > 0)
315 supplemental_groups = g_malloc(sizeof(gid_t) * ngroups);
316 getgroups(ngroups, supplemental_groups);
319 if (argc == 2 && strcmp(argv[1], "-v") == 0)
321 /* This is used by install.sh to test if the filer
322 * compiled OK. Do this test before gtk_init so that
323 * we don't need an X server to install.
325 g_print("ROX-Filer %s\n", VERSION);
326 g_print(_(COPYING));
327 show_features();
328 return EXIT_SUCCESS;
331 option_add_int(&o_override_redirect, "override_redirect", FALSE);
333 option_add_int(&o_session_panel_or_pin, "session_panel_or_pin",
334 SESSION_BOTH);
335 option_add_string(&o_session_panel_name, "session_panel_name",
336 "Default");
337 option_add_string(&o_session_pinboard_name, "session_pinboard_name",
338 "Default");
339 option_register_widget("launch", build_launch);
341 /* The idea here is to convert the command-line arguments
342 * into a SOAP RPC.
343 * We attempt to invoke the call on an already-running copy of
344 * the filer if possible, or execute it ourselves if not.
346 rpc = soap_new(&body);
348 /* Note: must do this before checking our options,
349 * otherwise we report an error for Gtk's options.
351 gtk_init(&argc, &argv);
352 /* Set a default style for the collection widget */
353 gtk_rc_parse_string("style \"rox-default-collection-style\" {\n"
354 " bg[NORMAL] = \"#f3f3f3\"\n"
355 " fg[NORMAL] = \"#000000\"\n"
356 " bg[INSENSITIVE] = \"#bfbfbf\"\n"
357 " fg[INSENSITIVE] = \"#000000\"\n"
358 "}\n"
359 "style \"rox-default-pinboard-style\" {\n"
360 " bg[NORMAL] = \"#666666\"\n"
361 "}\n"
362 "widget \"rox-pinboard\" style : gtk "
363 "\"rox-default-pinboard-style\"\n"
365 "class \"Collection\" style : gtk "
366 "\"rox-default-collection-style\"\n");
368 g_signal_connect(gdk_screen_get_default(), "size-changed",
369 G_CALLBACK(xrandr_size_change), NULL);
371 /* Process each option in turn */
372 while (1)
374 int c;
375 #ifdef HAVE_GETOPT_LONG
376 int long_index;
377 c = getopt_long(argc, argv, SHORT_OPS,
378 long_opts, &long_index);
379 #else
380 c = getopt(argc, argv, SHORT_OPS);
381 #endif
383 if (c == EOF)
384 break; /* No more options */
386 switch (c)
388 case 'n':
389 new_copy = TRUE;
390 break;
391 case 'o':
392 info_message(_("The -o argument is no longer "
393 "used. You can turn on override "
394 "redirect from the Options box "
395 "instead."));
396 break;
397 case 'v':
398 g_print("ROX-Filer %s\n", VERSION);
399 g_print("%s", _(COPYING));
400 show_features();
401 return EXIT_SUCCESS;
402 case 'h':
403 g_print("%s", _(HELP));
404 g_print("%s", _(SHORT_ONLY_WARNING));
405 return EXIT_SUCCESS;
406 case 'D':
407 case 'd':
408 case 'x':
409 /* Argument is a path */
410 if (c == 'd' && VALUE[0] == '/')
411 tmp = g_strdup(VALUE);
412 else
413 tmp = pathdup(VALUE);
414 soap_add(body,
415 c == 'D' ? "CloseDir" :
416 c == 'd' ? "OpenDir" :
417 c == 'x' ? "Examine" : "Unknown",
418 "Filename", tmp,
419 NULL, NULL);
420 g_free(tmp);
421 break;
422 case 's':
423 tmp = g_path_get_dirname(VALUE);
425 if (tmp[0] == '/')
426 dir = NULL;
427 else
428 dir = pathdup(tmp);
430 soap_add(body, "Show",
431 "Directory", dir ? dir : tmp,
432 "Leafname", g_basename(VALUE));
433 g_free(tmp);
434 g_free(dir);
435 break;
436 case 'l':
437 case 'r':
438 case 't':
439 case 'B':
440 /* Argument is a leaf (or starts with /) */
441 soap_add(body, "Panel", "Name", VALUE,
442 "Side", c == 'l' ? "Left" :
443 c == 'r' ? "Right" :
444 c == 't' ? "Top" :
445 c == 'B' ? "Bottom" :
446 "Unkown");
447 break;
448 case 'b':
449 /* Argument is a leaf (or starts with /) */
450 if (*VALUE)
451 soap_add(body, "Panel", "Name", VALUE,
452 NULL, NULL);
453 else
454 soap_add(body, "Panel",
455 "Side", "Bottom",
456 NULL, NULL);
457 break;
458 case 'p':
459 soap_add(body, "Pinboard",
460 "Name", VALUE, NULL, NULL);
461 break;
462 case 'u':
463 show_user = TRUE;
464 break;
465 case 'm':
467 MIME_type *type;
468 type_init();
469 diritem_init();
470 pixmaps_init();
471 type = type_get_type(VALUE);
472 printf("%s/%s\n", type->media_type,
473 type->subtype);
474 return EXIT_SUCCESS;
476 case 'c':
477 client_id = g_strdup(VALUE);
478 break;
479 case 'R':
480 /* Reconnect stdin */
481 if(ofd0>-1) {
482 close(0);
483 dup2(ofd0, 0);
485 soap_rpc = xmlParseFile("-");
486 if (!soap_rpc)
487 g_error("Invalid XML in RPC");
488 /* Disconnect stdin again */
489 fd = open("/dev/null", O_RDONLY);
490 if (fd > 0)
492 close(0);
493 dup2(fd, 0);
494 close(fd);
497 break;
499 case 'S':
500 new_copy = TRUE;
501 add_default_panel_and_pinboard(body);
502 break;
504 default:
505 printf(_(USAGE));
506 return EXIT_FAILURE;
510 tooltips = gtk_tooltips_new();
512 if (euid == 0 || show_user)
513 show_user_message = g_strdup_printf(_("Running as user '%s'"),
514 user_name(euid));
516 /* Add each remaining (non-option) argument to the list of files
517 * to run.
519 i = optind;
520 while (i < argc)
522 tmp = pathdup(argv[i++]);
524 soap_add(body, "Run", "Filename", tmp, NULL, NULL);
526 g_free(tmp);
529 if (soap_rpc)
531 if (body->xmlChildrenNode)
532 g_error("Can't use -R with other options - sorry!");
533 xmlFreeDoc(rpc);
534 body = NULL;
535 rpc = soap_rpc;
537 else if (!body->xmlChildrenNode)
539 /* The user didn't request any action. Open the current
540 * directory.
542 guchar *dir;
544 dir = g_get_current_dir();
545 soap_add(body, "OpenDir", "Filename", dir, NULL, NULL);
546 g_free(dir);
549 option_add_int(&o_dnd_no_hostnames, "dnd_no_hostnames", 1);
551 /* Try to send the request to an already-running copy of the filer */
552 gui_support_init();
553 if (remote_init(rpc, new_copy))
554 return EXIT_SUCCESS; /* It worked - exit */
556 /* Put ourselves into the background (so 'rox' always works the
557 * same, whether we're already running or not).
558 * Not for -n, though (helps when debugging).
560 if (!new_copy)
562 pid_t child;
564 child = fork();
565 if (child > 0)
566 _exit(0); /* Parent exits */
567 /* Otherwise we're the child (or an error occurred - ignore
568 * it!).
572 /* Initialize the rest of the filer... */
574 pixmaps_init();
576 dnd_init();
577 bind_init();
578 dir_init();
579 diritem_init();
580 menu_init();
581 minibuffer_init();
582 filer_init();
583 toolbar_init();
584 display_init();
585 mount_init();
586 type_init();
587 action_init();
589 pinboard_init();
590 panel_init();
592 /* Let everyone update */
593 options_notify();
595 /* When we get a signal, we can't do much right then. Instead,
596 * we send a char down this pipe, which causes the main loop to
597 * deal with the event next time we're idle.
599 pipe(wakeup_pipe);
600 close_on_exec(wakeup_pipe[0], TRUE);
601 close_on_exec(wakeup_pipe[1], TRUE);
602 gdk_input_add_full(wakeup_pipe[0], GDK_INPUT_READ, wake_up_cb,
603 NULL, NULL);
604 to_wakeup_pipe = wakeup_pipe[1];
606 /* If the pipe is full then we're going to get woken up anyway... */
607 set_blocking(to_wakeup_pipe, FALSE);
609 /* Let child processes die */
610 act.sa_handler = child_died;
611 sigemptyset(&act.sa_mask);
612 act.sa_flags = SA_NOCLDSTOP;
613 sigaction(SIGCHLD, &act, NULL);
615 /* Ignore SIGPIPE - check for EPIPE errors instead */
616 act.sa_handler = SIG_IGN;
617 sigemptyset(&act.sa_mask);
618 act.sa_flags = 0;
619 sigaction(SIGPIPE, &act, NULL);
621 /* Set up session managament if available */
622 session_init(client_id);
623 g_free(client_id);
625 /* See if we need to migrate the Choices directories*/
626 choices_migrate();
628 /* Finally, execute the request */
629 reply = run_soap(rpc);
630 xmlFreeDoc(rpc);
631 if (reply)
633 /* Write the result, if any, to stdout */
634 save_xml_file(reply, "-");
635 xmlFreeDoc(reply);
638 /* Try to find out why we crash with GTK 2.4 */
639 XSetErrorHandler(rox_x_error);
641 /* Enter the main loop, processing events until all our windows
642 * are closed.
644 if (number_of_windows > 0)
645 gtk_main();
647 return EXIT_SUCCESS;
650 /* Register a function to be called when process number 'child' dies. */
651 void on_child_death(gint child, CallbackFn callback, gpointer data)
653 Callback *cb;
655 g_return_if_fail(callback != NULL);
657 cb = g_new(Callback, 1);
659 cb->callback = callback;
660 cb->data = data;
662 g_hash_table_insert(death_callbacks, GINT_TO_POINTER(child), cb);
665 void one_less_window(void)
667 if (--number_of_windows < 1)
668 gtk_main_quit();
671 /****************************************************************
672 * INTERNAL FUNCTIONS *
673 ****************************************************************/
675 static void show_features(void)
677 g_print("\n");
678 g_print(_("Compiled with GTK version %s\n"), GTK_VERSION);
679 g_print(_("Running with GTK version %d.%d.%d\n"),
680 gtk_major_version,
681 gtk_minor_version,
682 gtk_micro_version);
683 g_print("\n-- %s --\n\n", _("features set at compile time"));
684 g_print("%s... %s\n", _("Large File Support"),
685 #ifdef LARGE_FILE_SUPPORT
686 _("Yes")
687 #else
688 _("No")
689 #endif
691 g_print("%s... %s\n", _("Dnotify support"),
692 #ifdef USE_DNOTIFY
693 _("Yes")
694 #else
695 _("No")
696 #endif
698 g_print("%s... %s\n", _("Binary compatibility"),
699 #if defined(HAVE_APSYMBOLS_H) || defined(HAVE_APBUILD_APSYMBOLS_H)
700 _("Yes (can run with older glibc versions)")
701 #else
702 _("No (apsymbols.h not found)")
703 #endif
706 g_print("%s... %s\n", _("Extended attribute support"),
707 xattr_supported(NULL)? _("Yes"): _("No"));
710 static void soap_add(xmlNodePtr body,
711 xmlChar *function,
712 const xmlChar *arg1_name, const xmlChar *arg1_value,
713 const xmlChar *arg2_name, const xmlChar *arg2_value)
715 xmlNodePtr node;
716 xmlNs *rox;
718 rox = xmlSearchNsByHref(body->doc, body, ROX_NS);
720 node = xmlNewChild(body, rox, function, NULL);
722 if (arg1_name)
724 xmlNewTextChild(node, rox, arg1_name, arg1_value);
725 if (arg2_name)
726 xmlNewTextChild(node, rox, arg2_name, arg2_value);
730 /* This is called as a signal handler; simply ensures that
731 * child_died_callback() will get called later.
733 static void child_died(int signum)
735 child_died_flag = TRUE;
736 write(to_wakeup_pipe, "\0", 1); /* Wake up! */
739 static void child_died_callback(void)
741 int status;
742 gint child;
744 child_died_flag = FALSE;
746 /* Find out which children exited and allow them to die */
749 Callback *cb;
751 child = waitpid(-1, &status, WNOHANG);
753 if (child == 0 || child == -1)
754 return;
756 cb = g_hash_table_lookup(death_callbacks,
757 GINT_TO_POINTER(child));
758 if (cb)
760 cb->callback(cb->data);
761 g_hash_table_remove(death_callbacks,
762 GINT_TO_POINTER(child));
765 } while (1);
768 #define BUFLEN 40
769 /* When data is written to_wakeup_pipe, this gets called from the event
770 * loop some time later. Useful for getting out of signal handlers, etc.
772 static void wake_up_cb(gpointer data, gint source, GdkInputCondition condition)
774 char buf[BUFLEN];
776 read(source, buf, BUFLEN);
778 if (child_died_flag)
779 child_died_callback();
780 #ifdef USE_DNOTIFY
781 if (dnotify_wakeup_flag)
782 dnotify_wakeup();
783 #endif
786 static void xrandr_size_change(GdkScreen *screen, gpointer user_data)
788 gui_store_screen_geometry(screen);
790 panel_update_size();
791 pinboard_update_size();
794 static void add_default_panel_and_pinboard(xmlNodePtr body)
796 char *name;
798 if (o_session_panel_or_pin.int_value != SESSION_PANEL_ONLY)
800 name=o_session_pinboard_name.value;
801 if (!name[0])
802 name="Default";
803 soap_add(body, "Pinboard","Name", name, NULL, NULL);
806 if (o_session_panel_or_pin.int_value != SESSION_PINBOARD_ONLY)
808 name = o_session_panel_name.value;
809 if (!name[0])
810 name="Default";
812 soap_add(body, "Panel", "Name", name, NULL, NULL);
816 static GtkWidget *launch_button_new(const char *label, const char *uri)
818 GtkWidget *button;
819 GClosure *closure;
821 button = button_new_mixed(GTK_STOCK_PREFERENCES, label);
822 closure = g_cclosure_new_swap(G_CALLBACK(launch_uri),
823 g_strdup(uri),
824 (GClosureNotify) g_free);
825 g_signal_connect_closure(button, "clicked", closure, FALSE);
827 allow_right_click(button);
829 return button;
832 static GList *build_launch(Option *option, xmlNode *node, guchar *label)
834 GtkWidget *align;
835 char *uri;
837 g_return_val_if_fail(option == NULL, NULL);
838 g_return_val_if_fail(label != NULL, NULL);
840 uri = xmlGetProp(node, "uri");
842 g_return_val_if_fail(uri != NULL, NULL);
844 align = gtk_alignment_new(0, 0.5, 0, 0);
846 gtk_container_add(GTK_CONTAINER(align),
847 launch_button_new(_(label), uri));
849 g_free(uri);
851 return g_list_append(NULL, align);