]> git.street.me.uk Git - andy/viking.git/blame - src/util.c
Windows port: typo in util.c
[andy/viking.git] / src / util.c
CommitLineData
7d02a0b0
GB
1/*
2 * Viking - GPS data editor
3 * Copyright (C) 2007 Guilhem Bonnefille <guilhem.bonnefille@gmail.com>
4 * Based on:
5 * Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, version 2.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
4c77d5e0
GB
20#ifdef HAVE_CONFIG_H
21#include "config.h"
22#endif
23
e0173c37
MA
24#ifdef WINDOWS
25#include <windows.h>
26#endif
27
4c77d5e0 28#include <glib/gi18n.h>
7d02a0b0
GB
29
30#include "dialog.h"
31
32void open_url(GtkWindow *parent, const gchar * url)
33{
34#ifdef WINDOWS
e0173c37 35 ShellExecute(NULL, NULL, (char *) url, NULL, ".\\", 0);
7d02a0b0
GB
36#else /* WINDOWS */
37 const gchar *browsers[] = {
38 "xdg-open", "gnome-open", "kfmclient openURL",
39 "sensible-browser", "firefox", "epiphany",
40 "iceweasel", "seamonkey", "galeon", "mozilla",
41 "opera", "konqueror", "netscape", "links -g",
42 NULL
43 };
44 gint i=0;
45 gchar *cmdline = NULL;
46
0654760a 47 const gchar *browser = g_getenv("BROWSER");
7d02a0b0
GB
48 if (browser == NULL || browser[0] == '\0') {
49 /* $BROWSER not set -> use first entry */
50 browser = browsers[i++];
51 }
52 do {
53 cmdline = g_strdup_printf("%s '%s'", browser, url);
54 g_debug("Running: %s", cmdline);
55
56 if (g_spawn_command_line_async(cmdline, NULL)) {
57 g_free(cmdline);
58 return;
59 }
60
61 g_free(cmdline);
62 browser = browsers[i++];
63 } while(browser);
64
4c77d5e0 65 a_dialog_error_msg ( parent, _("Could not launch web browser.") );
7d02a0b0
GB
66#endif /* WINDOWS */
67}