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/log.h>
#include <wx/menu.h> #include <wx/menu.h>
#include <wx/menuitem.h> #include <wx/menuitem.h>
#include <wx/mimetype.h>
#include <wx/msgdlg.h> #include <wx/msgdlg.h>
#include <wx/mstream.h> #include <wx/mstream.h>
#include <wx/notebook.h> #include <wx/notebook.h>

View file

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

View file

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

View file

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

View file

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