]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/utilscmn.cpp
removed samples topic overview; the samples are part of mainpages/utilities.h now
[wxWidgets.git] / src / common / utilscmn.cpp
index f3893507e59edeea0ddb8129fb5c9dc5d54af733..e656559ad26e5f2bef1224894a959c6a4c764827 100644 (file)
@@ -1033,7 +1033,7 @@ bool wxLaunchDefaultBrowser(const wxString& urlOrig, int flags)
 
     ::ShellExecuteEx(&sei);
 
-    const int nResult = (int) sei.hInstApp;
+    const INT_PTR nResult = (INT_PTR)sei.hInstApp;
 
     // Firefox returns file not found for some reason, so make an exception
     // for it
@@ -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
@@ -1137,11 +1151,11 @@ bool wxLaunchDefaultBrowser(const wxString& urlOrig, int flags)
         return ok;
 
     // no file type for HTML extension
-    wxLogError(_T("No default application configured for HTML files."));
+    wxLogError(_("No default application configured for HTML files."));
 
 #endif // !wxUSE_MIMETYPE && !__WXMSW__
 
-    wxLogSysError(_T("Failed to open URL \"%s\" in default browser."),
+    wxLogSysError(_("Failed to open URL \"%s\" in default browser."),
                   url.c_str());
 
     return false;