]> git.saurik.com Git - wxWidgets.git/commitdiff
use xdg-open in wxLaunchDefaultBrowser() on Unix if available
authorVáclav Slavík <vslavik@fastmail.fm>
Tue, 22 Jan 2008 10:20:02 +0000 (10:20 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Tue, 22 Jan 2008 10:20:02 +0000 (10:20 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51329 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/utilscmn.cpp

index 2beddfe3a627da816aabcfca23474c2a3048c080..df728c2228cd5cbd36539d3ea753e8d7b59de42a 100644 (file)
@@ -1081,6 +1081,20 @@ bool wxLaunchDefaultBrowser(const wxString& urlOrig, int flags)
 
 #ifdef __UNIX__
 
 
 #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
     wxString desktop = wxTheApp->GetTraits()->GetDesktopEnvironment();
 
     // GNOME and KDE desktops have some applications which should be always installed