[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]
[XaraXtreme-commits] Commit Complete
Commit by : luke
Repository : xara
Revision : 1264
Date : Wed Jun 7 17:37:28 BST 2006
Changed paths:
M /Trunk/XaraLX/Kernel/prefs.cpp
M /Trunk/XaraLX/wxOil/oilprefs.cpp
M /Trunk/XaraLX/wxOil/oilprefs.h
Move prefences to ~/.xaralx/preferences
Diff:
Index: Trunk/XaraLX/Kernel/prefs.cpp
===================================================================
--- Trunk/XaraLX/Kernel/prefs.cpp (revision 1263)
+++ Trunk/XaraLX/Kernel/prefs.cpp (revision 1264)
@@ -987,12 +987,12 @@
OILPrefs = new OILPreferences();
// Flag error if it failed
- if (OILPrefs == NULL)
+ if (OILPrefs == NULL || !OILPrefs->Init())
return FALSE;
// TODO: Get Appname and orgnisation name from central location? product.h?
- OILPrefs->SetAppName(_T("XaraLX"));
- OILPrefs->SetVendorName(_T("XaraGroup"));
+ //OILPrefs->SetAppName(_T("XaraLX"));
+ //OILPrefs->SetVendorName(_T("XaraGroup"));
// Flag that the class has been set up and initialised and so enable the writing out
// on exit.
Index: Trunk/XaraLX/wxOil/oilprefs.h
===================================================================
--- Trunk/XaraLX/wxOil/oilprefs.h (revision 1263)
+++ Trunk/XaraLX/wxOil/oilprefs.h (revision 1264)
@@ -117,9 +117,14 @@
********************************************************************************************/
-class OILPreferences : public wxConfig
+class OILPreferences
{
+protected:
+ std::auto_ptr<wxConfig> m_pConfig;
+
public:
+ OILPreferences();
+
// Initialise the OILPreferences object
BOOL Init();
Index: Trunk/XaraLX/wxOil/oilprefs.cpp
===================================================================
--- Trunk/XaraLX/wxOil/oilprefs.cpp (revision 1263)
+++ Trunk/XaraLX/wxOil/oilprefs.cpp (revision 1264)
@@ -109,6 +109,10 @@
#include "product.h" // PRODUCT_OPTIONS_REGISTRYKEY
+OILPreferences::OILPreferences()
+{
+}
+
/********************************************************************************************
> BOOL OILPreferences::Init()
@@ -123,6 +127,22 @@
BOOL OILPreferences::Init()
{
+ wxStandardPaths Paths;
+ wxString strPath( Paths.GetUserConfigDir() );
+ strPath += _T("/.xaralx");
+
+ // Create directory iff not exist
+ if( !wxDir::Exists( strPath ) )
+ ::wxMkdir( strPath );
+
+ TRACEUSER( "jlh92", _T("OILPreferences::Init %s
"), PCTSTR(strPath) );
+
+ // Open config file
+ strPath += _T("/preferences");
+ m_pConfig = std::auto_ptr<wxConfig>( new wxConfig( _T("xaralx"), _T("Xara"), strPath ) );
+
+ TRACEUSER( "jlh92", _T("OILPreferences::Init2 %s
"), PCTSTR(strPath) );
+
// Always succeed
return TRUE;
}
@@ -140,7 +160,7 @@
void OILPreferences::WipePreferenceFile()
{
- DeleteAll();
+ m_pConfig->DeleteAll();
}
/********************************************************************************************
@@ -156,9 +176,9 @@
void OILPreferences::WipeDangerousPrefs()
{
// wipe the potentially dangerous settings from the registry
- DeleteGroup(_T("Gallery"));
- DeleteGroup(_T("Options/Templates"));
- DeleteGroup(_T("Options/NewTemplates"));
+ m_pConfig->DeleteGroup(_T("Gallery"));
+ m_pConfig->DeleteGroup(_T("Options/Templates"));
+ m_pConfig->DeleteGroup(_T("Options/NewTemplates"));
// DeleteRegKeyAndSubKeys (hAppStateRegKey, PRODUCT_REGISTRYKEY_GALLERY);
// HKEY optsKey = OpenRegKey(hAppStateRegKey, PRODUCT_REGISTRYKEY_OPTIONS);
@@ -197,7 +217,7 @@
case PREF_INT:
{
/*TYPENOTE: Correct*/ long l = (long)(*Data.pInt);
- Worked = wxConfig::Write(strKey, l);
+ Worked = m_pConfig->Write(strKey, l);
break;
}
@@ -209,17 +229,17 @@
// (Could write UINT32 prefs as strings...)
//
/*TYPENOTE: Correct*/ long l = (long)(*Data.pUInt);
- Worked = wxConfig::Write(strKey, l);
+ Worked = m_pConfig->Write(strKey, l);
break;
}
case PREF_DOUBLE:
- Worked = wxConfig::Write(strKey, (double)*(Data.pDouble));
+ Worked = m_pConfig->Write(strKey, (double)*(Data.pDouble));
break;
case PREF_STRING:
- Worked = wxConfig::Write(strKey, wxString((TCHAR*)*(Data.pString)));
-// Worked = wxConfig::Write(strKey, *(Data.pString)); // use this form when StringBase derived classes support direct conversion
+ Worked = m_pConfig->Write(strKey, wxString((TCHAR*)*(Data.pString)));
+// Worked = m_pConfig->Write(strKey, *(Data.pString)); // use this form when StringBase derived classes support direct conversion
break;
default:
@@ -282,7 +302,7 @@
// Use the value already in pData->Int as the value to return if the
// preference is not found.
/*TYPENOTE: Correct*/ long l;
- if (wxConfig::Read(strKey, &l))
+ if (m_pConfig->Read(strKey, &l))
*pData.pInt = (INT32)l; // Do not write directly as may be longer than 32 bits
break;
}
@@ -292,7 +312,7 @@
// Note that signed value is read and cast directly into Unsigned memory
// allocation reversing the effects fo the cast used in Write above...
/*TYPENOTE: Correct*/ long l;
- if (wxConfig::Read(strKey, &l))
+ if (m_pConfig->Read(strKey, &l))
*pData.pUInt = (UINT32)l; // Do not write directly as may be longer than 32 bits
break;
}
@@ -300,7 +320,7 @@
{
// Get the textual version of the double and convert it to a double.
// default to null string
- wxConfig::Read(strKey, (double*)(pData.pDouble));
+ m_pConfig->Read(strKey, (double*)(pData.pDouble));
break;
}
case PREF_STRING:
@@ -308,7 +328,7 @@
// Just get the string - need to ask for the address of the String's
// text buffer so we can pass it to the SDK profile API.
wxString str;
- wxConfig::Read(strKey, &str);
+ m_pConfig->Read(strKey, &str);
str.Truncate(256);
*(pData.pString) = (LPCTSTR)str;
// *(pData.pString) = String_256(str); // use this form when StringBase derived classes support direct conversion
@@ -384,6 +404,6 @@
BOOL OILPreferences::CloseOutput()
{
- Flush();
+ m_pConfig->Flush();
return TRUE;
}
Xara