improved LaunchDefaultBrowser on FreeBSD systems by using the BROWSER env var when no HTML file MIME mapping is found

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37199 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Surovell
2006-01-28 18:06:09 +00:00
parent c52e0d0e51
commit 13a1e96f92

View File

@@ -621,9 +621,10 @@ bool wxLaunchDefaultBrowser(const wxString& urlOrig, int flags)
SInt32 endSel; SInt32 endSel;
err = ICStart(&inst, 'STKA'); // put your app creator code here err = ICStart(&inst, 'STKA'); // put your app creator code here
if (err == noErr) { if (err == noErr)
{
#if !TARGET_CARBON #if !TARGET_CARBON
err = ICFindConfigFile(inst, 0, nil); err = ICFindConfigFile(inst, 0, NULL);
#endif #endif
if (err == noErr) if (err == noErr)
{ {
@@ -644,15 +645,18 @@ bool wxLaunchDefaultBrowser(const wxString& urlOrig, int flags)
} }
#elif wxUSE_MIMETYPE #elif wxUSE_MIMETYPE
// Non-windows way // Non-windows way
bool ok = false;
wxString cmd;
wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromExtension(_T("html")); wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromExtension(_T("html"));
if ( ft ) if ( ft )
{ {
wxString mt; wxString mt;
ft->GetMimeType(&mt); ft->GetMimeType(&mt);
wxString cmd; ok = ft->GetOpenCommand(&cmd, wxFileType::MessageParameters(url));
bool ok = ft->GetOpenCommand(&cmd, wxFileType::MessageParameters(url));
delete ft; delete ft;
}
if ( !ok || cmd.empty() ) if ( !ok || cmd.empty() )
{ {
@@ -662,13 +666,13 @@ bool wxLaunchDefaultBrowser(const wxString& urlOrig, int flags)
cmd << _T(' ') << url; cmd << _T(' ') << url;
} }
if ( !cmd.empty() && wxExecute(cmd) ) ok = ( !cmd.empty() && wxExecute(cmd) );
return true; if (ok)
} return ok;
else // no file type for html extension
{ // no file type for HTML extension
wxLogError(_T("No default application configured for HTML files.")); wxLogError(_T("No default application configured for HTML files."));
}
#endif // !wxUSE_MIMETYPE && !__WXMSW__ #endif // !wxUSE_MIMETYPE && !__WXMSW__
wxLogSysError(_T("Failed to open URL \"%s\" in default browser."), wxLogSysError(_T("Failed to open URL \"%s\" in default browser."),