Fix wxLaunchDefaultBrowser on wxMSW for local files/directories: the bug could be reproduced using "Open screenshots folder" menu item in screenshotgen application.
Move platform-specific code in platform-specific utils source files. Perform safer URL scheme check. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57934 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -434,6 +434,87 @@ private:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
// these functions are in src/osx/carbon/utils.cpp for wxMac
|
||||
#ifndef __WXMAC__
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Launch document with default app
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxLaunchDefaultApplication(const wxString& document, int flags)
|
||||
{
|
||||
wxUnusedVar(flags);
|
||||
|
||||
// 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.
|
||||
wxString path, xdg_open;
|
||||
if ( wxGetEnv("PATH", &path) &&
|
||||
wxFindFileInPath(&xdg_open, path, "xdg-open") )
|
||||
{
|
||||
if ( wxExecute(xdg_open + " " + document) )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Launch default browser
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxDoLaunchDefaultBrowser(const wxString& url, int flags)
|
||||
{
|
||||
wxUnusedVar(flags);
|
||||
|
||||
// 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
|
||||
// together with their main parts, which give us the
|
||||
if (desktop == wxT("GNOME"))
|
||||
{
|
||||
wxArrayString errors;
|
||||
wxArrayString output;
|
||||
|
||||
// gconf will tell us the path of the application to use as browser
|
||||
long res = wxExecute( wxT("gconftool-2 --get /desktop/gnome/applications/browser/exec"),
|
||||
output, errors, wxEXEC_NODISABLE );
|
||||
if (res >= 0 && errors.GetCount() == 0)
|
||||
{
|
||||
wxString cmd = output[0];
|
||||
cmd << _T(' ') << url;
|
||||
if (wxExecute(cmd))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (desktop == wxT("KDE"))
|
||||
{
|
||||
// kfmclient directly opens the given URL
|
||||
if (wxExecute(wxT("kfmclient openURL ") + url))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // __WXMAC__
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxExecute implementations
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -871,7 +952,7 @@ bool wxIsPlatform64Bit()
|
||||
machine.Contains(wxT("alpha"));
|
||||
}
|
||||
|
||||
// these functions are in mac/utils.cpp for wxMac
|
||||
// these functions are in src/osx/utilsexc_base.cpp for wxMac
|
||||
#ifndef __WXMAC__
|
||||
|
||||
wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin)
|
||||
|
Reference in New Issue
Block a user