2 * Viking - GPS data editor
3 * Copyright (C) 2007 Guilhem Bonnefille <guilhem.bonnefille@gmail.com>
5 * Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br>
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.
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.
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
28 #include <glib/gi18n.h>
29 #include <glib/gprintf.h>
33 static gboolean spawn_command_line_async(const gchar * cmd,
36 gchar *cmdline = NULL;
39 cmdline = g_strdup_printf("%s '%s'", cmd, arg);
40 g_debug("Running: %s", cmdline);
42 status = g_spawn_command_line_async(cmdline, NULL);
49 void open_url(GtkWindow *parent, const gchar * url)
52 ShellExecute(NULL, NULL, (char *) url, NULL, ".\\", 0);
54 const gchar *browsers[] = {
55 "xdg-open", "gnome-open", "kfmclient openURL",
56 "sensible-browser", "firefox", "epiphany",
57 "iceweasel", "seamonkey", "galeon", "mozilla",
58 "opera", "konqueror", "netscape", "links -g",
63 const gchar *browser = g_getenv("BROWSER");
64 if (browser == NULL || browser[0] == '\0') {
65 /* $BROWSER not set -> use first entry */
66 browser = browsers[i++];
69 if (spawn_command_line_async(browser, url)) {
73 browser = browsers[i++];
76 a_dialog_error_msg ( parent, _("Could not launch web browser.") );
80 void new_email(GtkWindow *parent, const gchar * address)
82 gchar *uri = g_strdup_printf("mailto:%s", address);
84 ShellExecute(NULL, NULL, (char *) uri, NULL, ".\\", 0);
86 if (!spawn_command_line_async("xdg-email", uri))
87 a_dialog_error_msg ( parent, _("Could not create new email.") );
93 gchar *uri_escape(gchar *str)
95 gchar *esc_str = g_malloc(3*strlen(str));
99 for (src = str; *src; src++) {
102 else if (g_ascii_isalnum(*src))
105 g_sprintf(dst, "%%%02X", *src);