Make help buttons fall back to the docs wiki if the scraped html files aren't available locally

Originally committed to SVN as r6084.
This commit is contained in:
Thomas Goyne 2011-12-22 21:22:31 +00:00
parent 8427958a1d
commit ec63fad7c5
5 changed files with 14 additions and 17 deletions

View file

@ -149,7 +149,6 @@
#include <wx/log.h>
#include <wx/menu.h>
#include <wx/menuitem.h>
#include <wx/mimetype.h>
#include <wx/msgdlg.h>
#include <wx/mstream.h>
#include <wx/notebook.h>

View file

@ -42,7 +42,6 @@
#include <wx/dnd.h>
#include <wx/filename.h>
#include <wx/image.h>
#include <wx/mimetype.h>
#include <wx/statline.h>
#include <wx/sysopt.h>
#include <wx/tokenzr.h>

View file

@ -44,7 +44,6 @@
#include <tr1/functional>
#include <wx/filename.h>
#include <wx/mimetype.h>
#include <wx/msgdlg.h>
#endif
@ -94,20 +93,22 @@ HelpButton::HelpButton(wxWindow *parent, wxString const& page, wxPoint position,
void HelpButton::OpenPage(wxString const& pageID) {
init_static();
wxString page = (*pages)[pageID];
// Get the file type
wxFileType *type = wxTheMimeTypesManager->GetFileTypeFromExtension("html");
if (type) {
wxString docsPath = StandardPaths::DecodePath("?data/docs");
#ifdef __WINDOWS__
docsPath.Replace("\\","/");
docsPath = "/" + docsPath;
#endif
wxString path = wxString::Format("file://%s/%s.html",docsPath,page);
if (!wxLaunchDefaultBrowser(path))
wxMessageBox("Documentation files not found.", "Error", wxOK | wxICON_ERROR);
}
wxFileName docFile(StandardPaths::DecodePath("?data/docs/"), page, "html", wxPATH_NATIVE);
wxString url;
// If we can read a file by the constructed name, assume we have a local copy of the manual
if (docFile.IsFileReadable())
// Tested IE8, Firefox 3.5, Safari 4, Chrome 4 and Opera 10 on Windows, they all handle
// various variations of slashes, missing one at the start and using backslashes throughout
// is safe with everything everyone uses. Blame Microsoft.
url = wxString("file://") + docFile.GetFullPath(wxPATH_NATIVE);
else
url = wxString::Format("http://docs.aegisub.org/manual/%s", page);
wxLaunchDefaultBrowser(url);
}
void HelpButton::ClearPages() {

View file

@ -45,7 +45,6 @@
#include <wx/datetime.h>
#include <wx/filefn.h>
#include <wx/filename.h>
#include <wx/mimetype.h>
#include <wx/msgdlg.h>
#include <wx/stdpaths.h>
#include <wx/utils.h>

View file

@ -38,7 +38,6 @@
#ifndef AGI_PRE
#include <wx/filename.h>
#include <wx/mimetype.h>
#include <wx/rawbmp.h>
#include <wx/statline.h>
#endif