From: <pst...@us...> - 2008-11-15 23:16:30
|
Revision: 628 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=628&view=rev Author: pstieber Date: 2008-11-15 23:16:27 +0000 (Sat, 15 Nov 2008) Log Message: ----------- 1. Changed FindAndRegisterHelpFilePath from void to bool so the code code determine if the user gave up and not prompt a third time for the help file. 2. Forced the wxWidgets configuration file to be of type wxFileConfig because there seems to be a conflict between wxStandardPaths::GetUserDataDir and wxConfig under Linux. The latter creates a normal file as "$HOME/.AppName", while the former expects the ".AppName" portion to be a directory. This change also removes configuration settings from the registry on windows. Modified Paths: -------------- trunk/jazz/src/JazzPlusPlusApplication.cpp trunk/jazz/src/JazzPlusPlusApplication.h Modified: trunk/jazz/src/JazzPlusPlusApplication.cpp =================================================================== --- trunk/jazz/src/JazzPlusPlusApplication.cpp 2008-11-15 19:47:25 UTC (rev 627) +++ trunk/jazz/src/JazzPlusPlusApplication.cpp 2008-11-15 23:16:27 UTC (rev 628) @@ -23,6 +23,7 @@ #include "WxWidgets.h" #include <wx/stdpaths.h> +#include <wx/fileconf.h> #include "JazzPlusPlusApplication.h" #include "TrackFrame.h" @@ -182,26 +183,35 @@ wxString HelpFileNameAndPath = HelpFilePath + mHelpFileName; // Test for the existence of the help file. - bool HelpFileFound = true; + bool HelpFileFound = false; ifstream Is; Is.open(HelpFileNameAndPath.c_str()); if (!Is) { - // Return a valid path to the data. - FindAndRegisterHelpFilePath(HelpFilePath); - HelpFileNameAndPath = HelpFilePath + mHelpFileName; + // Ask the user to find the help file. + if (FindAndRegisterHelpFilePath(HelpFilePath)) + { + HelpFileNameAndPath = HelpFilePath + mHelpFileName; - // Try one more time. - Is.close(); - Is.clear(); - Is.open(HelpFileNameAndPath.c_str()); - if (!Is) - { - wxString Message = "Failed to add the IPVT book " + mHelpFileName; - ::wxMessageBox(Message); - HelpFileFound = false; + // Try one more time. + Is.close(); + Is.clear(); + Is.open(HelpFileNameAndPath.c_str()); + if (!Is) + { + wxString Message = "Failed to add the IPVT book " + mHelpFileName; + ::wxMessageBox(Message); + } + else + { + HelpFileFound = true; + } } } + else + { + HelpFileFound = true; + } if (HelpFileFound) { @@ -233,6 +243,36 @@ //----------------------------------------------------------------------------- void JZJazzPlusPlusApplication::InsureConfigurationFileExistence() const { + // Determine the expected location of the user's data dir for Jazz++. + wxString UserConfigDir = wxStandardPaths::Get().GetUserDataDir(); + + // Determine if the directory exists. + if (!wxDirExists(UserConfigDir)) + { + // Attempt to create the directory. + if (!wxMkdir(UserConfigDir)) + { + wxString String; + String + << "Unable to create directory \"" + << UserConfigDir << '"'; + ::wxMessageBox(String, "Directory Creation Error"); + } + } + + // Setup the wxWidgets configuration file. + wxFileName WxConfigurationFileName(UserConfigDir, ".jazz"); + + wxFileConfig* pFileConfig = new wxFileConfig( + GetAppName(), + wxEmptyString, + WxConfigurationFileName.GetFullPath(), + wxEmptyString, + wxCONFIG_USE_LOCAL_FILE); + + delete wxConfigBase::Set(pFileConfig); + + // Make sure all of the configuration files are setup. vector<wxString> ConfigurationFileNames; ConfigurationFileNames.push_back("README"); ConfigurationFileNames.push_back("jazz.cfg"); @@ -256,20 +296,6 @@ ConfigurationFileNames.push_back("xgdrmset.jzi"); ConfigurationFileNames.push_back("xgvoices.jzi"); - wxString UserConfigDir = wxStandardPaths::Get().GetUserDataDir(); - - if (!wxDirExists(UserConfigDir)) - { - if (!wxMkdir(UserConfigDir)) - { - wxString String; - String - << "Unable to create directory \"" - << UserConfigDir << '"'; - ::wxMessageBox(String, "Directory Creation Error"); - } - } - for ( vector<wxString>::const_iterator iConfigurationFileName = ConfigurationFileNames.begin(); @@ -306,8 +332,8 @@ // found, create a configuration entry so the code can find the help file path // the next time it starts. //----------------------------------------------------------------------------- -void JZJazzPlusPlusApplication::FindAndRegisterHelpFilePath( - wxString& HelpFilePath) +bool JZJazzPlusPlusApplication::FindAndRegisterHelpFilePath( + wxString& HelpFilePath) const { wxString Message; Message = "Unable to find " + mHelpFileName; @@ -317,10 +343,11 @@ wxFileDialog OpenDialog( 0, "Open the Help File", - "", + HelpFilePath, mHelpFileName, "*.hhp", wxFD_OPEN); + if (OpenDialog.ShowModal() == wxID_OK) { // Generate a c-style string that contains a path to the help file. @@ -336,7 +363,11 @@ // Return the user selected help file path. HelpFilePath = TempHelpFilePath; + + return true; } + + return false; } //----------------------------------------------------------------------------- Modified: trunk/jazz/src/JazzPlusPlusApplication.h =================================================================== --- trunk/jazz/src/JazzPlusPlusApplication.h 2008-11-15 19:47:25 UTC (rev 627) +++ trunk/jazz/src/JazzPlusPlusApplication.h 2008-11-15 23:16:27 UTC (rev 628) @@ -92,7 +92,7 @@ void InsureConfigurationFileExistence() const; - void FindAndRegisterHelpFilePath(wxString& HelpFilePath); + bool FindAndRegisterHelpFilePath(wxString& HelpFilePath) const; private: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |