From a9cb1b92a39e49167c0769f22f0cfb167b31da0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Tue, 22 Jan 2008 10:19:39 +0000 Subject: [PATCH] use xdg-open in wxLaunchDefaultBrowser() on Unix if available git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@51328 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/common/utilscmn.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index 255c261e52..90d6f6149a 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -119,6 +119,7 @@ All (Unix): - Fixed shared libraries to not depend on GStreamer when built with --enable-media; only wxMedia library depends on it now. +- wxLaunchDefaultBrowser() now uses xdg-open if available. wxMSW: diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index 3b0d0a1754..8d347a19c0 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -864,6 +864,20 @@ static bool wxLaunchDefaultBrowserBaseImpl(const wxString& url, int flags) #ifdef __UNIX__ + // Our best best is to use xdg-open from freedesktop.org cross-desktop + // compatibility suite xdg-utils + // (see http://portland.freedesktop.org/wiki/) -- this is installed on + // most modern distributions and may be tweaked by them to handle + // distribution specifics. Only if that fails, try to find the right + // browser ourselves. + wxString path, xdg_open; + if ( wxGetEnv(_T("PATH"), &path) && + wxFindFileInPath(&xdg_open, path, _T("xdg-open")) ) + { + if ( wxExecute(xdg_open + _T(" ") + url) ) + return true; + } + wxString desktop = wxTheApp->GetTraits()->GetDesktopEnvironment(); // GNOME and KDE desktops have some applications which should be always installed