This commit is contained in:
Birunthan Mohanathas 2012-06-10 12:17:47 +03:00
parent 233f5fd08c
commit 5dd2f249dd
5 changed files with 29 additions and 39 deletions

View File

@ -1426,7 +1426,7 @@ INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam)
Edit_GetText(item, buffer, MAX_PATH); Edit_GetText(item, buffer, MAX_PATH);
std::wstring theme = buffer; std::wstring theme = buffer;
std::wstring path = Rainmeter->GetSettingsPath() + L"Themes\\"; std::wstring path = Rainmeter->GetThemePath();
CreateDirectory(path.c_str(), 0); CreateDirectory(path.c_str(), 0);
path += theme; path += theme;
@ -1508,9 +1508,7 @@ INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam)
item = GetDlgItem(m_Window, IDC_MANAGETHEMES_LIST); item = GetDlgItem(m_Window, IDC_MANAGETHEMES_LIST);
ListBox_AddString(item, theme.c_str()); ListBox_AddString(item, theme.c_str());
path = Rainmeter->GetSettingsPath(); Rainmeter->ScanForThemes();
path += L"Themes\\";
Rainmeter->ScanForThemes(path);
} }
} }
break; break;
@ -1529,8 +1527,7 @@ INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam)
int sel = ListBox_GetCurSel(item); int sel = ListBox_GetCurSel(item);
const std::vector<std::wstring>& themes = Rainmeter->GetAllThemes(); const std::vector<std::wstring>& themes = Rainmeter->GetAllThemes();
std::wstring args = Rainmeter->GetSettingsPath(); std::wstring args = Rainmeter->GetThemePath();
args += L"Themes\\";
args += themes[sel]; args += themes[sel];
args += L"\\Rainmeter.thm"; args += L"\\Rainmeter.thm";
RunFile(Rainmeter->GetSkinEditor().c_str(), args.c_str()); RunFile(Rainmeter->GetSkinEditor().c_str(), args.c_str());
@ -1550,7 +1547,7 @@ INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam)
break; break;
} }
std::wstring folder = Rainmeter->GetSettingsPath() + L"Themes\\"; std::wstring folder = Rainmeter->GetThemePath();
folder += themes[sel]; folder += themes[sel];
if (CSystem::RemoveFolder(folder)) if (CSystem::RemoveFolder(folder))

View File

@ -498,11 +498,8 @@ void CRainmeter::Bang_WriteKeyValue(std::vector<std::wstring>& args, CMeterWindo
return; return;
} }
const std::wstring& skinPath = GetSkinPath(); if (_wcsnicmp(iniFile, m_SkinPath.c_str(), m_SkinPath.size()) != 0 &&
const std::wstring settingsPath = GetSettingsPath(); _wcsnicmp(iniFile, m_SettingsPath.c_str(), m_SettingsPath.size()) != 0)
if (_wcsnicmp(iniFile, skinPath.c_str(), skinPath.size()) != 0 &&
_wcsnicmp(iniFile, settingsPath.c_str(), settingsPath.size()) != 0)
{ {
LogWithArgs(LOG_ERROR, L"!WriteKeyValue: Illegal path: %s", iniFile); LogWithArgs(LOG_ERROR, L"!WriteKeyValue: Illegal path: %s", iniFile);
return; return;
@ -910,15 +907,15 @@ int CRainmeter::Initialize(LPCWSTR iniPath)
m_SkinPath = m_Path + L"Skins\\"; m_SkinPath = m_Path + L"Skins\\";
} }
// Create user skins, themes, addons, and plugins folders if needed
CreateComponentFolders(bDefaultIniLocation);
// Create a default Rainmeter.ini file if needed // Create a default Rainmeter.ini file if needed
if (_waccess(iniFile, 0) == -1) if (_waccess(iniFile, 0) == -1)
{ {
CreateOptionsFile(); CreateOptionsFile();
} }
// Create user skins, themes, addons, and plugins folders if needed
CreateComponentFolders(bDefaultIniLocation);
delete [] buffer; delete [] buffer;
buffer = NULL; buffer = NULL;
@ -1145,12 +1142,7 @@ void CRainmeter::SetNetworkStatisticsTimer()
void CRainmeter::CreateOptionsFile() void CRainmeter::CreateOptionsFile()
{ {
size_t pos = m_IniFile.find_last_of(L'\\'); CreateDirectory(m_SettingsPath.c_str(), NULL);
if (pos != std::wstring::npos)
{
std::wstring strPath(m_IniFile, 0, pos);
CreateDirectory(strPath.c_str(), NULL);
}
std::wstring defaultIni = GetDefaultThemePath(); std::wstring defaultIni = GetDefaultThemePath();
defaultIni += L"illustro default\\Rainmeter.thm"; defaultIni += L"illustro default\\Rainmeter.thm";
@ -1159,8 +1151,7 @@ void CRainmeter::CreateOptionsFile()
void CRainmeter::CreateDataFile() void CRainmeter::CreateDataFile()
{ {
std::wstring tmpSz = GetSettingsPath(); std::wstring tmpSz = m_SettingsPath + L"Plugins.ini";
tmpSz += L"Plugins.ini";
const WCHAR* pluginsFile = tmpSz.c_str(); const WCHAR* pluginsFile = tmpSz.c_str();
const WCHAR* dataFile = m_DataFile.c_str(); const WCHAR* dataFile = m_DataFile.c_str();
@ -1237,8 +1228,8 @@ void CRainmeter::CreateComponentFolders(bool defaultIniLocation)
void CRainmeter::ReloadSettings() void CRainmeter::ReloadSettings()
{ {
ScanForSkins(m_SkinPath); ScanForSkins();
ScanForThemes(GetThemePath()); ScanForThemes();
ReadGeneralSettings(m_IniFile); ReadGeneralSettings(m_IniFile);
} }
@ -1644,12 +1635,12 @@ int CRainmeter::GetLoadOrder(const std::wstring& folderPath)
/* /*
** Scans all the subfolders and locates the ini-files. ** Scans all the subfolders and locates the ini-files.
*/ */
void CRainmeter::ScanForSkins(const std::wstring& path) void CRainmeter::ScanForSkins()
{ {
m_SkinFolders.clear(); m_SkinFolders.clear();
m_SkinOrders.clear(); m_SkinOrders.clear();
ScanForSkinsRecursive(path, L"", 0, 0); ScanForSkinsRecursive(m_SkinPath, L"", 0, 0);
} }
int CRainmeter::ScanForSkinsRecursive(const std::wstring& path, std::wstring base, int index, UINT level) int CRainmeter::ScanForSkinsRecursive(const std::wstring& path, std::wstring base, int index, UINT level)
@ -1686,7 +1677,7 @@ int CRainmeter::ScanForSkinsRecursive(const std::wstring& path, std::wstring bas
{ {
if (wcscmp(L".", fileData.cFileName) != 0 && if (wcscmp(L".", fileData.cFileName) != 0 &&
wcscmp(L"..", fileData.cFileName) != 0 && wcscmp(L"..", fileData.cFileName) != 0 &&
!(level == 0 && wcscmp(L"Backup", fileData.cFileName) == 0) && !(level == 0 && wcscmp(L"@Backup", fileData.cFileName) == 0) &&
!(level == 1 && wcscmp(L"@Resources", fileData.cFileName) == 0)) !(level == 1 && wcscmp(L"@Resources", fileData.cFileName) == 0))
{ {
subfolders.push_back(filename); subfolders.push_back(filename);
@ -1757,7 +1748,7 @@ int CRainmeter::ScanForSkinsRecursive(const std::wstring& path, std::wstring bas
/* /*
** Scans the given folder for themes ** Scans the given folder for themes
*/ */
void CRainmeter::ScanForThemes(const std::wstring& path) void CRainmeter::ScanForThemes()
{ {
m_Themes.clear(); m_Themes.clear();
@ -1765,7 +1756,8 @@ void CRainmeter::ScanForThemes(const std::wstring& path)
HANDLE hSearch; // Search handle returned by FindFirstFile HANDLE hSearch; // Search handle returned by FindFirstFile
// Scan for folders // Scan for folders
std::wstring folders = path + L"\\*"; std::wstring folders = GetThemePath();
folders += L'*';
hSearch = FindFirstFileEx( hSearch = FindFirstFileEx(
folders.c_str(), folders.c_str(),
@ -2465,7 +2457,8 @@ void CRainmeter::LoadTheme(const std::wstring& name)
// Delete all meter windows // Delete all meter windows
DeleteMeterWindow(NULL); DeleteMeterWindow(NULL);
std::wstring backup = GetSettingsPath() + L"Themes\\Backup"; std::wstring backup = GetThemePath();
backup += L"Backup";
CreateDirectory(backup.c_str(), NULL); CreateDirectory(backup.c_str(), NULL);
backup += L"\\Rainmeter.thm"; backup += L"\\Rainmeter.thm";
@ -2480,7 +2473,7 @@ void CRainmeter::LoadTheme(const std::wstring& name)
CSystem::CopyFiles(m_IniFile, backup); CSystem::CopyFiles(m_IniFile, backup);
// Replace Rainmeter.ini with theme // Replace Rainmeter.ini with theme
std::wstring theme = GetSettingsPath() + L"Themes\\"; std::wstring theme = GetThemePath();
theme += name; theme += name;
std::wstring wallpaper = theme + L"\\RainThemes.bmp"; std::wstring wallpaper = theme + L"\\RainThemes.bmp";
theme += L"\\Rainmeter.thm"; theme += L"\\Rainmeter.thm";

View File

@ -240,8 +240,8 @@ private:
void ActivateActiveSkins(); void ActivateActiveSkins();
void CreateMeterWindow(const std::wstring& folderPath, const std::wstring& file); void CreateMeterWindow(const std::wstring& folderPath, const std::wstring& file);
void WriteActive(const std::wstring& folderPath, int fileIndex); void WriteActive(const std::wstring& folderPath, int fileIndex);
void ScanForSkins(const std::wstring& path); void ScanForSkins();
void ScanForThemes(const std::wstring& path); void ScanForThemes();
void ReadGeneralSettings(const std::wstring& iniFile); void ReadGeneralSettings(const std::wstring& iniFile);
void SetLoadOrder(int folderIndex, int order); void SetLoadOrder(int folderIndex, int order);
int GetLoadOrder(const std::wstring& folderPath); int GetLoadOrder(const std::wstring& folderPath);

View File

@ -1165,8 +1165,7 @@ void CSystem::SetWallpaper(const std::wstring& wallpaper, const std::wstring& st
Bitmap* bitmap = Bitmap::FromFile(wallpaper.c_str()); Bitmap* bitmap = Bitmap::FromFile(wallpaper.c_str());
if (bitmap && bitmap->GetLastStatus() == Ok) if (bitmap && bitmap->GetLastStatus() == Ok)
{ {
std::wstring file = Rainmeter->GetSettingsPath(); std::wstring file = Rainmeter->GetSettingsPath() + L"Wallpaper.bmp";
file += L"Wallpaper.bmp";
const CLSID bmpClsid = { 0x557cf400, 0x1a04, 0x11d3, { 0x9a, 0x73, 0x0, 0x0, 0xf8, 0x1e, 0xf3, 0x2e } }; const CLSID bmpClsid = { 0x557cf400, 0x1a04, 0x11d3, { 0x9a, 0x73, 0x0, 0x0, 0xf8, 0x1e, 0xf3, 0x2e } };
if (bitmap->Save(file.c_str(), &bmpClsid) == Ok) if (bitmap->Save(file.c_str(), &bmpClsid) == Ok)

View File

@ -226,7 +226,7 @@ bool CDialogBackup::CreateBackup()
} }
if ((_waccess(addonsPath.c_str(), 0) == 0 && !AddFolderToBackup(addonsPath, L"", "Addons", true)) || if ((_waccess(addonsPath.c_str(), 0) == 0 && !AddFolderToBackup(addonsPath, L"", "Addons", true)) ||
//(_waccess(skinsPath.c_str(), 0) == 0 && !AddFolderToBackup(skinsPath, L"", "Skins", true)) || (_waccess(skinsPath.c_str(), 0) == 0 && !AddFolderToBackup(skinsPath, L"", "Skins", true)) ||
(_waccess(themesPath.c_str(), 0) == 0 && !AddFolderToBackup(themesPath, L"", "Themes", true)) || (_waccess(themesPath.c_str(), 0) == 0 && !AddFolderToBackup(themesPath, L"", "Themes", true)) ||
#ifdef _WIN64 #ifdef _WIN64
(_waccess(pluginsPath.c_str(), 0) == 0 && !AddFolderToBackup(pluginsPath, L"", "Plugins\\64bit", false))) (_waccess(pluginsPath.c_str(), 0) == 0 && !AddFolderToBackup(pluginsPath, L"", "Plugins\\64bit", false)))
@ -371,7 +371,8 @@ bool CDialogBackup::AddFolderToBackup(const std::wstring& path, std::wstring bas
{ {
if (wcscmp(L".", fd.cFileName) != 0 && if (wcscmp(L".", fd.cFileName) != 0 &&
wcscmp(L"..", fd.cFileName) != 0 && wcscmp(L"..", fd.cFileName) != 0 &&
wcscmp(L"Backup", fd.cFileName) != 0) wcscmp(L"Backup", fd.cFileName) != 0 &&
wcscmp(L"@Backup", fd.cFileName) != 0)
{ {
folders.push_back(fd.cFileName); folders.push_back(fd.cFileName);
} }
@ -443,7 +444,7 @@ void CDialogBackup::CTabBackup::Initialize()
SYSTEMTIME lt; SYSTEMTIME lt;
GetLocalTime(&lt); GetLocalTime(&lt);
_snwprintf_s(buffer, _TRUNCATE, L"%02d.%02d.%02d-%02d.%02d", lt.wYear, lt.wMonth, lt.wDay, lt.wHour, lt.wMinute); _snwprintf_s(buffer, _TRUNCATE, L"%04d.%02d.%02d-%02d.%02d", lt.wYear, lt.wMonth, lt.wDay, lt.wHour, lt.wMinute);
c_Dialog->m_BackupTime = buffer; c_Dialog->m_BackupTime = buffer;