diff options
author | Guy Harris <guy@alum.mit.edu> | 2008-06-21 18:09:17 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2008-06-21 18:09:17 +0000 |
commit | 8f244766f380b2f69364b51a0f44461d49e9563f (patch) | |
tree | 32d8ca495a020be5d28e61b9ec0d464b27cf667f | |
parent | 4e3df102d787638cf17738d8654b2af4c9baf02b (diff) |
If we have xdg-open, always run that to launch a Web browser, and ignore
the Web browser setting; that should honor the user's *real* preferred
Web browser setting (i.e., the one they've selected in their desktop
environment).
Don't bother defining HTML_VIEWER as "xdg-open" if we have xdg-open - we
don't need it.
svn path=/trunk/; revision=25514
-rw-r--r-- | configure.in | 22 | ||||
-rw-r--r-- | gtk/webbrowser.c | 36 |
2 files changed, 49 insertions, 9 deletions
diff --git a/configure.in b/configure.in index 1faa82a783..ae9af77db1 100644 --- a/configure.in +++ b/configure.in @@ -53,9 +53,22 @@ then # AC_MSG_ERROR(I couldn't find pod2html; make sure it's installed and in your path) fi + +# +# XXX - this looks for various HTML viewers on the host, not the target; +# we really want to know what's available on the target, for cross-builds. +# That would probably require us to, at run time, look for xdg-open and, +# if we don't find it, look for mozilla, htmlview, etc. +# AC_PATH_PROG(HTML_VIEWER, xdg-open) -if test "x$HTML_VIEWER" = x +if test "x$HTML_VIEWER" != x then + # + # HTML_VIEWER is the full path of xdg-open, so we use that. + # just run that? + # + AC_DEFINE(HAVE_XDG_OPEN, 1, [Define if we have xdg-open]) +else AC_PATH_PROG(HTML_VIEWER, htmlview) if test "x$HTML_VIEWER" = x then @@ -63,13 +76,6 @@ then else AC_DEFINE_UNQUOTED(HTML_VIEWER, "htmlview", [HTML viewer, e.g. mozilla]) fi -else - # - # XXX - define something to be the full path of xdg-open, so we - # just run that? - # - AC_DEFINE(HAVE_XDG_OPEN, 1, [Define if we have xdg-open]) - AC_DEFINE_UNQUOTED(HTML_VIEWER, "xdg-open", [HTML viewer, e.g. mozilla]) fi AC_PATH_PROG(LEX, flex) diff --git a/gtk/webbrowser.c b/gtk/webbrowser.c index 88914f731f..50b6a2dfd2 100644 --- a/gtk/webbrowser.c +++ b/gtk/webbrowser.c @@ -61,6 +61,8 @@ /* Mac OS X - use Launch Services to start a browser */ #include <CoreFoundation/CoreFoundation.h> #include <ApplicationServices/ApplicationServices.h> +#elif defined(HAVE_XDG_OPEN) +/* UNIX+X11 desktop with Portland Group stuff - use xdg-open to start a browser */ #else /* Everything else - launch the browser ourselves */ #define MUST_LAUNCH_BROWSER_OURSELVES @@ -125,6 +127,38 @@ browser_open_url (const gchar *url) CFRelease(url_CFURL); return (status == 0); +#elif defined(HAVE_XDG_OPEN) + + GError *error = NULL; + gchar *argv[3]; + gboolean retval; + + g_return_val_if_fail (url != NULL, FALSE); + + argv[0] = "xdg-open"; + argv[1] = (char *)url; /* Grr - g_spawn_async() shouldn't modify this */ + argv[2] = NULL; + + /* + * XXX - use g_spawn_on_screen() so the browser window shows up on + * the same screen? + */ + retval = g_spawn_async (NULL, argv, NULL, + G_SPAWN_SEARCH_PATH, + NULL, NULL, + NULL, &error); + + if (! retval) + { + simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, + "%sCould not execute xdg-open: %s\n\n\"%s\"", + simple_dialog_primary_start(), simple_dialog_primary_end(), + error->message); + g_error_free (error); + } + + return retval; + #elif defined(MUST_LAUNCH_BROWSER_OURSELVES) GError *error = NULL; @@ -307,7 +341,7 @@ filemanager_open_directory (const gchar *path) argv[2] = NULL; /* - * XXX - use g_spawn_on_screen() so the browser window shows up on + * XXX - use g_spawn_on_screen() so the file managaer window shows up on * the same screen? */ retval = g_spawn_async (NULL, argv, NULL, |