]> git.street.me.uk Git - andy/viking.git/blob - src/util.c
Mark many strings translatable
[andy/viking.git] / src / util.c
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  */
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23
24 #include <glib/gi18n.h>
25
26 #include "dialog.h"
27
28 void open_url(GtkWindow *parent, const gchar * url)
29 {
30 #ifdef WINDOWS
31   ShellExecute(NULL, NULL, (char *) webpage, NULL, ".\\", 0);
32 #else /* WINDOWS */
33   const gchar *browsers[] = {
34     "xdg-open", "gnome-open", "kfmclient openURL",
35     "sensible-browser", "firefox", "epiphany",
36     "iceweasel", "seamonkey", "galeon", "mozilla",
37     "opera", "konqueror", "netscape", "links -g",
38     NULL
39   };
40   gint i=0;
41   gchar *cmdline = NULL;
42   
43   gchar *browser = g_getenv("BROWSER");
44   if (browser == NULL || browser[0] == '\0') {
45     /* $BROWSER not set -> use first entry */
46     browser = browsers[i++];
47   }
48   do {
49     cmdline = g_strdup_printf("%s '%s'", browser, url);
50     g_debug("Running: %s", cmdline);
51     
52     if (g_spawn_command_line_async(cmdline, NULL)) {
53       g_free(cmdline);
54       return;
55     }
56
57     g_free(cmdline);
58     browser = browsers[i++];
59   } while(browser);
60   
61   a_dialog_error_msg ( parent, _("Could not launch web browser.") );
62 #endif /* WINDOWS */
63 }