From: Václav Slavík Date: Tue, 22 Jan 2008 10:20:02 +0000 (+0000) Subject: use xdg-open in wxLaunchDefaultBrowser() on Unix if available X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/ae46a7fd15bff134460b9af46af896136b018fad?ds=sidebyside use xdg-open in wxLaunchDefaultBrowser() on Unix if available git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51329 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index 2beddfe3a6..df728c2228 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -1081,6 +1081,20 @@ bool wxLaunchDefaultBrowser(const wxString& urlOrig, 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("PATH", &path) && + wxFindFileInPath(&xdg_open, path, "xdg-open") ) + { + if ( wxExecute(xdg_open + " " + url) ) + return true; + } + wxString desktop = wxTheApp->GetTraits()->GetDesktopEnvironment(); // GNOME and KDE desktops have some applications which should be always installed