Look for the mkvmerge GUI guide in various paths before asking the user to select one.

This commit is contained in:
Moritz Bunkus 2005-09-01 15:05:05 +00:00
parent 4e4abc11c6
commit 6fe7ae4afd

View File

@ -1155,17 +1155,45 @@ mmg_dialog::on_help(wxCommandEvent &evt) {
if (help == NULL) { if (help == NULL) {
wxDirDialog dlg(this, wxT("Chosoe the location of the mkvmerge GUI " wxDirDialog dlg(this, wxT("Chosoe the location of the mkvmerge GUI "
"help files")); "help files"));
vector<wxString> potential_help_paths;
vector<wxString>::const_iterator php;
wxString help_path; wxString help_path;
wxConfigBase *cfg; wxConfigBase *cfg;
bool first; bool first;
help_path = wxGetCwd();
cfg = wxConfigBase::Get(); cfg = wxConfigBase::Get();
cfg->SetPath(wxT("/GUI")); cfg->SetPath(wxT("/GUI"));
if (!cfg->Read(wxT("help_path"), &help_path))
if (cfg->Read(wxT("installation_path"), &help_path)) if (cfg->Read(wxT("installation_path"), &help_path)) {
help_path += wxT("/doc"); help_path += wxT("/doc");
first = true; potential_help_paths.push_back(help_path);
}
#if !defined(SYS_WINDOWS)
// Debian, probably others
potential_help_paths.push_back(wxT("/usr/share/doc/mkvtoolnix"));
potential_help_paths.push_back(wxT("/usr/share/doc/mkvtoolnix/doc"));
potential_help_paths.push_back(wxT("/usr/share/doc/mkvtoolnix-gui"));
// SuSE
potential_help_paths.push_back(wxT("/usr/share/doc/packages/mkvtoolnix"));
// Fedora Core
potential_help_paths.push_back(wxT("/usr/share/doc/mkvtoolnix-" VERSION));
// (Almost the) same for /usr/local
potential_help_paths.push_back(wxT("/usr/local/share/doc/mkvtoolnix"));
potential_help_paths.push_back(wxT("/usr/local/share/doc/packages/mkvtoolnix"));
potential_help_paths.push_back(wxT("/usr/local/share/doc/mkvtoolnix-" VERSION));
#endif
if (cfg->Read(wxT("help_path"), &help_path))
potential_help_paths.push_back(help_path);
potential_help_paths.push_back(wxGetCwd() + wxT("/doc"));
potential_help_paths.push_back(wxGetCwd());
help_path = wxT("");
foreach(php, potential_help_paths)
if (wxFileExists(*php + wxT("/mkvmerge-gui.hhp"))) {
help_path = *php;
break;
}
while (!wxFileExists(help_path + wxT("/mkvmerge-gui.hhp"))) { while (!wxFileExists(help_path + wxT("/mkvmerge-gui.hhp"))) {
if (first) { if (first) {
wxMessageBox(wxT("The mkvmerge GUI help file was not found. This " wxMessageBox(wxT("The mkvmerge GUI help file was not found. This "
@ -1187,8 +1215,8 @@ mmg_dialog::on_help(wxCommandEvent &evt) {
if (dlg.ShowModal() == wxID_CANCEL) if (dlg.ShowModal() == wxID_CANCEL)
return; return;
help_path = dlg.GetPath(); help_path = dlg.GetPath();
cfg->Write(wxT("help_path"), help_path);
} }
cfg->Write(wxT("help_path"), help_path);
help = new wxHtmlHelpController; help = new wxHtmlHelpController;
help->AddBook(wxFileName(help_path + wxT("/mkvmerge-gui.hhp")), false); help->AddBook(wxFileName(help_path + wxT("/mkvmerge-gui.hhp")), false);
} }