removed alot of warnings
[k8lowj.git] / src / spawn.c
blob1303942644366c74a19f018365588f222ef2b7ea
1 /* logjam - a GTK client for LiveJournal.
2 * Copyright (C) 2000-2003 Evan Martin <evan@livejournal.com>
4 * vim: tabstop=4 shiftwidth=4 noexpandtab :
5 */
7 #include "glib-all.h"
8 #include "util-gtk.h"
9 #include <stdio.h>
11 #ifndef G_OS_WIN32
12 #include <unistd.h>
14 #include <sys/types.h>
15 #include <sys/wait.h>
16 #endif
17 #include <signal.h>
19 #include "conf.h"
20 #include "spawn.h"
22 #ifdef G_OS_WIN32
23 #include <windows.h>
24 void
25 spawn_url(GtkWindow *parent, const char *url) {
26 ShellExecute(NULL, "open", url, NULL, NULL, SW_SHOWNORMAL);
28 #else
30 /* http://lxr.mozilla.org/seamonkey/source/xpfe/bootstrap/nsAppRunner.cpp#1413
31 * when sending remote commands,
32 * mozilla returns 0 on success and nonzero on failure. */
33 const CommandList spawn_commands[] = {
34 { "GNOME Browser",
35 "gnome-open '%s'" },
36 { "Mozilla Firefox",
37 "firefox '%s'" },
38 { "Debian (sensible-browser)",
39 "sensible-browser '%s'" },
40 { "Galeon",
41 "galeon '%s'" },
42 { "Mozilla",
43 "mozilla -remote 'openURL(%s, new-window)' || mozilla '%s'" },
44 { "Opera",
45 "opera -remote 'openURL(%s,new-window)' || " /* note no space */
46 "opera '%s'" },
47 { "Konqueror",
48 "kfmclient exec '%s'" },
49 { "Netscape",
50 "netscape -remote 'openURL(%s, new-window)' || netscape '%s'" },
51 { 0, 0 }
54 void
55 spawn_url(GtkWindow *parent, const char *url) {
56 char *cmd;
57 GError *err = NULL;
58 char *argv[4] = { "/bin/sh", "-c", NULL, NULL };
60 /* and now, a hack because I don't know how many %s's
61 * are in spawn_command. */
62 #define ARGS_HACK url,url,url,url,url,url
63 cmd = g_strdup_printf(conf.spawn_command, ARGS_HACK);
65 argv[2] = cmd;
66 if (!g_spawn_async(NULL, argv, NULL, 0, NULL, NULL, NULL, &err)) {
67 jam_warning(parent, _("Error spawning URL '%s': %s\n"),
68 url, err->message);
69 g_error_free(err);
71 g_free(cmd);
73 #endif /* G_OS_WIN32 */