Skins are now read from the My Documents by default.

Added the revision number to the about dialog (use UpdateRevision.py to update it).
Added a check to the startup which verifies that the rainmeter.ini is writable.
The skin folder can be opened from the context menu.
This commit is contained in:
Kimmo Pekkola 2009-07-24 07:56:37 +00:00
parent c1ecbb8374
commit a7c6c939ac
30 changed files with 249 additions and 82 deletions

View File

@ -154,6 +154,7 @@
ProgramDataBaseFileName=".\x64/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -429,6 +430,7 @@
ProgramDataBaseFileName=".\x32/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -448,6 +450,7 @@
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\Library\x32\Release"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\x32/Release/Rainmeter.pdb"
SubSystem="2"
EntryPointSymbol="wWinMainCRTStartup"

View File

@ -24,6 +24,7 @@
#include "Measure.h"
#include "resource.h"
#include "AboutDialog.h"
#include "../revision-number.h"
#include <commctrl.h>
extern CRainmeter* Rainmeter;
@ -201,7 +202,7 @@ void ScanPlugins()
WIN32_FIND_DATA fileData; // Data structure describes the file found
HANDLE hSearch; // Search handle returned by FindFirstFile
std::wstring files = CRainmeter::FixPath(L"*.dll", PATH_FOLDER_PLUGIN, L"");
std::wstring files = Rainmeter->GetPluginPath() + L"*.dll";
g_Plugins.clear();
@ -216,7 +217,7 @@ void ScanPlugins()
info.version = 0;
// Try to get the version and author
std::wstring tmpSz = CRainmeter::FixPath(fileData.cFileName, PATH_FOLDER_PLUGIN, L"");
std::wstring tmpSz = Rainmeter->GetPluginPath() + fileData.cFileName;
HMODULE dll = LoadLibrary(tmpSz.c_str());
if (dll)
{
@ -284,7 +285,7 @@ BOOL OnInitAboutDialog(HWND window)
HWND widget;
widget = GetDlgItem(window, IDC_VERSION_STRING);
swprintf(tmpSz, L"%s version %s", APPNAME, APPVERSION);
swprintf(tmpSz, L"%s version %s rev %i %s", APPNAME, APPVERSION, revision_number, APPBITS);
SetWindowText(widget, tmpSz);
widget = GetDlgItem(window, IDC_BUILD_STRING);

View File

@ -107,13 +107,14 @@ BEGIN
MENUITEM "Click Through", ID_CONTEXT_SKINMENU_CLICKTHROUGH
MENUITEM "Keep on screen", ID_CONTEXT_SKINMENU_KEEPONSCREEN
MENUITEM "Keep on Screen", ID_CONTEXT_SKINMENU_KEEPONSCREEN
MENUITEM SEPARATOR
MENUITEM "Edit Skin...", ID_CONTEXT_SKINMENU_EDITSKIN
MENUITEM "Open Skin's folder", ID_CONTEXT_SKINMENU_OPENSKINSFOLDER
MENUITEM "Refresh Skin", ID_CONTEXT_SKINMENU_REFRESH
MENUITEM SEPARATOR
MENUITEM "Close skin", ID_CONTEXT_CLOSESKIN
MENUITEM "Close Skin", ID_CONTEXT_CLOSESKIN
END
END

View File

@ -246,6 +246,7 @@
ProgramDataBaseFileName=".\x32/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -264,6 +265,7 @@
OutputFile="../TestBench/x32/Release/Rainmeter.dll"
LinkIncremental="1"
SuppressStartupBanner="true"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\x32/Release/Rainmeter.pdb"
ImportLibrary=".\x32/Release/Rainmeter.lib"
TargetMachine="1"
@ -520,6 +522,7 @@
ProgramDataBaseFileName=".\x64/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -72,7 +72,7 @@ bool CMeasurePlugin::Update()
WCHAR buffer[MAX_PATH];
GetCurrentDirectory(MAX_PATH, buffer);
SetCurrentDirectory(Rainmeter->FixPath(L"", PATH_FOLDER_CURRENT_SKIN, m_MeterWindow->GetSkinName()).c_str());
SetCurrentDirectory(m_MeterWindow->MakePathAbsolute(L"").c_str());
if(UpdateFunc)
{
@ -115,7 +115,7 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
{
m_PluginName = L"..\\" + m_PluginName;
}
m_PluginName = Rainmeter->FixPath(m_PluginName, PATH_FOLDER_PLUGIN, L"");
m_PluginName = Rainmeter->GetPluginPath() + m_PluginName;
m_Plugin = LoadLibrary(m_PluginName.c_str());
@ -155,7 +155,7 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
WCHAR buffer[MAX_PATH];
GetCurrentDirectory(MAX_PATH, buffer);
SetCurrentDirectory(Rainmeter->FixPath(L"", PATH_FOLDER_CURRENT_SKIN, m_MeterWindow->GetSkinName()).c_str());
SetCurrentDirectory(m_MeterWindow->MakePathAbsolute(L"").c_str());
double maxValue;
maxValue = InitializeFunc(m_Plugin, parser.GetFilename().c_str(), section, m_ID);

View File

@ -97,7 +97,7 @@ void CMeterBar::ReadConfig(const WCHAR* section)
m_Color = parser.ReadColor(section, L"BarColor", Color::Green);
m_ImageName = parser.ReadString(section, L"BarImage", L"");
m_ImageName = Rainmeter->FixPath(m_ImageName, PATH_FOLDER_CURRENT_SKIN, m_MeterWindow->GetSkinName());
m_ImageName = m_MeterWindow->MakePathAbsolute(m_ImageName);
m_Border = parser.ReadInt(section, L"BarBorder", 0);

View File

@ -169,7 +169,7 @@ void CMeterBitmap::ReadConfig(const WCHAR* section)
CConfigParser& parser = m_MeterWindow->GetParser();
m_ImageName = parser.ReadString(section, L"BitmapImage", L"");
m_ImageName = Rainmeter->FixPath(m_ImageName, PATH_FOLDER_CURRENT_SKIN, m_MeterWindow->GetSkinName());
m_ImageName = m_MeterWindow->MakePathAbsolute(m_ImageName);
m_FrameCount = parser.ReadInt(section, L"BitmapFrames", 1);
m_ZeroFrame = 0!=parser.ReadInt(section, L"BitmapZeroFrame", 0);

View File

@ -136,7 +136,7 @@ void CMeterButton::ReadConfig(const WCHAR* section)
CConfigParser& parser = m_MeterWindow->GetParser();
m_ImageName = parser.ReadString(section, L"ButtonImage", L"");
m_ImageName = Rainmeter->FixPath(m_ImageName, PATH_FOLDER_CURRENT_SKIN, m_MeterWindow->GetSkinName());
m_ImageName = m_MeterWindow->MakePathAbsolute(m_ImageName);
m_Command = parser.ReadString(section, L"ButtonCommand", L"");
}

View File

@ -150,13 +150,13 @@ void CMeterHistogram::ReadConfig(const WCHAR* section)
m_SecondaryMeasureName = parser.ReadString(section, L"SecondaryMeasureName", L"");
m_PrimaryImageName = parser.ReadString(section, L"PrimaryImage", L"");
m_PrimaryImageName = Rainmeter->FixPath(m_PrimaryImageName, PATH_FOLDER_CURRENT_SKIN, m_MeterWindow->GetSkinName());
m_PrimaryImageName = m_MeterWindow->MakePathAbsolute(m_PrimaryImageName);
m_SecondaryImageName = parser.ReadString(section, L"SecondaryImage", L"");
m_SecondaryImageName = Rainmeter->FixPath(m_SecondaryImageName, PATH_FOLDER_CURRENT_SKIN, m_MeterWindow->GetSkinName());
m_SecondaryImageName = m_MeterWindow->MakePathAbsolute(m_SecondaryImageName);
m_BothImageName = parser.ReadString(section, L"BothImage", L"");
m_BothImageName = Rainmeter->FixPath(m_BothImageName, PATH_FOLDER_CURRENT_SKIN, m_MeterWindow->GetSkinName());
m_BothImageName = m_MeterWindow->MakePathAbsolute(m_BothImageName);
m_Autoscale = 0!=parser.ReadInt(section, L"AutoScale", 0);
m_Flip = 0!=parser.ReadInt(section, L"Flip", 0);

View File

@ -178,7 +178,7 @@ void CMeterImage::ReadConfig(const WCHAR* section)
CConfigParser& parser = m_MeterWindow->GetParser();
m_ImageName = parser.ReadString(section, L"ImageName", L"");
m_ImageName = Rainmeter->FixPath(m_ImageName, PATH_FOLDER_CURRENT_SKIN, m_MeterWindow->GetSkinName());
m_ImageName = m_MeterWindow->MakePathAbsolute(m_ImageName);
if (-1 != parser.ReadInt(section, L"W", -1) && -1 != parser.ReadInt(section, L"H", -1))
{
@ -200,7 +200,7 @@ bool CMeterImage::Update()
if (!val.empty())
{
// Load the new image
val = Rainmeter->FixPath(val, PATH_FOLDER_CURRENT_SKIN, m_MeterWindow->GetSkinName());
val = m_MeterWindow->MakePathAbsolute(val);
if (val != m_ImageName)
{
m_ImageName = val;

View File

@ -88,7 +88,7 @@ void CMeterRotator::ReadConfig(const WCHAR* section)
CConfigParser& parser = m_MeterWindow->GetParser();
m_ImageName = parser.ReadString(section, L"ImageName", L"");
m_ImageName = Rainmeter->FixPath(m_ImageName, PATH_FOLDER_CURRENT_SKIN, m_MeterWindow->GetSkinName());
m_ImageName = m_MeterWindow->MakePathAbsolute(m_ImageName);
m_OffsetX = parser.ReadFloat(section, L"OffsetX", 0.0);
m_OffsetY = parser.ReadFloat(section, L"OffsetY", 0.0);

View File

@ -61,7 +61,7 @@ MULTIMONITOR_INFO CMeterWindow::m_Monitors = { 0 };
** Constructor
**
*/
CMeterWindow::CMeterWindow(std::wstring& config, std::wstring& iniFile)
CMeterWindow::CMeterWindow(std::wstring& path, std::wstring& config, std::wstring& iniFile)
{
m_Background = NULL;
m_Window = NULL;
@ -124,6 +124,7 @@ CMeterWindow::CMeterWindow(std::wstring& config, std::wstring& iniFile)
m_BackgroundMode = BGMODE_IMAGE;
m_SolidBevel = BEVELTYPE_NONE;
m_SkinPath = path;
m_SkinName = config;
m_SkinIniFile = iniFile;
@ -1279,7 +1280,7 @@ void CMeterWindow::WriteConfig()
*/
void CMeterWindow::ReadSkin()
{
std::wstring iniFile = m_Rainmeter->GetSkinPath();
std::wstring iniFile = m_SkinPath;
iniFile += m_SkinName;
iniFile += L"\\";
iniFile += m_SkinIniFile;
@ -1303,7 +1304,7 @@ void CMeterWindow::ReadSkin()
m_Author = m_Parser.ReadString(L"Rainmeter", L"Author", L"");
m_BackgroundName = m_Parser.ReadString(L"Rainmeter", L"Background", L"");
m_BackgroundName = Rainmeter->FixPath(m_BackgroundName, PATH_FOLDER_CURRENT_SKIN, m_SkinName);
m_BackgroundName = MakePathAbsolute(m_BackgroundName);
std::wstring margins = m_Parser.ReadString(L"Rainmeter", L"BackgroundMargins", L"0, 0, 0, 0");
int left = 0, top = 0, right = 0, bottom = 0;
@ -2295,9 +2296,25 @@ LRESULT CMeterWindow::OnCommand(WPARAM wParam, LPARAM lParam)
{
std::wstring command = Rainmeter->GetConfigEditor();
command += L" \"";
command += m_Rainmeter->GetSkinPath() + L"\\" + m_SkinName + L"\\" + m_SkinIniFile + L"\"";
LSExecuteAsAdmin(NULL, command.c_str(), SW_SHOWNORMAL);
command += m_SkinPath + L"\\" + m_SkinName + L"\\" + m_SkinIniFile + L"\"";
if (m_SkinPath == Rainmeter->GetSkinPath())
{
LSExecuteAsAdmin(NULL, command.c_str(), SW_SHOWNORMAL);
}
else
{
LSExecute(NULL, command.c_str(), SW_SHOWNORMAL);
}
}
else if(wParam == ID_CONTEXT_SKINMENU_OPENSKINSFOLDER)
{
std::wstring command;
command += L"\"";
command += m_SkinPath + L"\\" + m_SkinName;
command += L"\"";
LSExecute(NULL, command.c_str(), SW_SHOWNORMAL);
}
else if(wParam == ID_CONTEXT_SKINMENU_REFRESH)
{
Refresh(false);
@ -3115,3 +3132,25 @@ LRESULT CMeterWindow::OnCopyData(WPARAM wParam, LPARAM lParam)
}
}
/*
** MakePathAbsolute
**
** Converts the path to absolute bu adding the skin's path to it (unless it already is absolute).
**
*/
std::wstring CMeterWindow::MakePathAbsolute(std::wstring path)
{
if (path.empty() || path.find(L':') != std::wstring::npos)
{
return path; // It's already absolute path (or it's empty)
}
std::wstring root = m_SkinPath + m_SkinName;
if (root[root.length() - 1] != L'\\')
{
root += L"\\";
}
return root + path;
}

View File

@ -99,14 +99,6 @@ enum BANGCOMMAND
BANG_PLUGIN
};
enum PATH_FOLDER
{
PATH_FOLDER_INI,
PATH_FOLDER_SKINS,
PATH_FOLDER_CURRENT_SKIN,
PATH_FOLDER_PLUGIN
};
typedef struct
{
int count; //Number of monitors
@ -124,7 +116,7 @@ class CMeter;
class CMeterWindow
{
public:
CMeterWindow(std::wstring& config, std::wstring& iniFile);
CMeterWindow(std::wstring& path, std::wstring& config, std::wstring& iniFile);
~CMeterWindow();
int Initialize(CRainmeter& Rainmeter);
@ -177,6 +169,8 @@ public:
LRESULT OnCopyData(WPARAM wParam, LPARAM lParam);
std::wstring MakePathAbsolute(std::wstring path);
protected:
static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
@ -303,7 +297,8 @@ private:
std::list<CMeasure*> m_Measures; // All the measures
std::list<CMeter*> m_Meters; // All the meters
std::wstring m_SkinName; // Name of the current skin folder
std::wstring m_SkinPath; // Path of the skin folder
std::wstring m_SkinName; // Name of the current skin folder
std::wstring m_SkinIniFile; // Name of the current skin iniFile
std::wstring m_ConfigEditor;

View File

@ -30,6 +30,7 @@
#include <commctrl.h>
#include <gdiplus.h>
#include <fstream>
#include <shlobj.h>
using namespace Gdiplus;
@ -674,16 +675,20 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
m_IniFile = m_Path + L"Rainmeter.ini";
m_SkinPath = m_Path + L"Skins\\";
bool bDefaultIniLocation = false;
// If the ini file doesn't exist in the program folder store it to the %APPDATA% instead so that things work better in Vista/Win7
if (_waccess(m_IniFile.c_str(), 0) == -1)
{
WCHAR buffer[4096]; // lets hope the buffer is large enough...
// Expand the environment variables
DWORD ret = ExpandEnvironmentStrings(L"%APPDATA%\\Rainmeter\\rainmeter.ini", buffer, 4096);
DWORD ret = ExpandEnvironmentStrings(L"%APPDATA%\\Rainmeter\\", buffer, 4096);
if (ret != 0 && ret < 4096)
{
m_IniFile = buffer;
m_IniFile += L"rainmeter.ini";
bDefaultIniLocation = true;
// If the ini file doesn't exist in the %APPDATA% either, create a default rainmeter.ini file.
if (_waccess(m_IniFile.c_str(), 0) == -1)
@ -693,6 +698,59 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
}
}
// Read the skin folder from the ini file
WCHAR tmpSz[MAX_LINE_LENGTH];
if (GetPrivateProfileString(L"Rainmeter", L"SkinPath", L"", tmpSz, MAX_LINE_LENGTH, m_IniFile.c_str()) > 0)
{
m_SkinPath = tmpSz;
}
else if (bDefaultIniLocation)
{
// If the skin path is not defined in the rainmeter.ini file use My Documents/Rainmeter/Skins
TCHAR szPath[MAX_PATH] = {0};
HRESULT hr = SHGetFolderPath(NULL, CSIDL_MYDOCUMENTS, NULL, SHGFP_TYPE_CURRENT, szPath);
if (SUCCEEDED(hr))
{
// Make the folders if they don't exist yet
m_SkinPath = szPath;
m_SkinPath += L"\\Rainmeter";
CreateDirectory(m_SkinPath.c_str(), NULL);
m_SkinPath += L"\\Skins";
DWORD result = CreateDirectory(m_SkinPath.c_str(), NULL);
m_SkinPath += L"\\";
if (result != 0)
{
// The folder was created successfully which means that it wasn't available yet.
// Copy the default skin to the Skins folder
std::wstring strFrom(m_Path + L"Skins\\" + L"*.*");
std::wstring strTo(m_SkinPath);
// The strings must end with double nul
strFrom.append(L"0");
strFrom[strFrom.size() - 1] = L'\0';
strTo.append(L"0");
strTo[strTo.size() - 1] = L'\0';
SHFILEOPSTRUCT fo = {0};
fo.wFunc = FO_COPY;
fo.pFrom = strFrom.c_str();
fo.pTo = strTo.c_str();
fo.fFlags = FOF_NO_UI;
int result = SHFileOperation(&fo);
if (result != 0)
{
DebugLog(L"Unable to copy the default skin %i", result);
}
}
}
else
{
DebugLog(L"Unable to get the My Documents location.");
}
}
WritePrivateProfileString(L"Rainmeter", L"SkinPath", m_SkinPath.c_str(), m_IniFile.c_str());
// Set the log file location
m_LogFile = m_IniFile;
size_t posExt = m_LogFile.find(L".ini");
@ -736,10 +794,20 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
DebugLog(L"SkinPath: %s", m_SkinPath.c_str());
DebugLog(L"PluginPath: %s", m_PluginPath.c_str());
// Test that the Rainmeter.ini file is writable
TestSettingsFile(bDefaultIniLocation);
// Tray must exist before configs are read
m_TrayWindow = new CTrayWindow(m_Instance);
ScanForConfigs(m_SkinPath);
if(m_ConfigStrings.empty())
{
std::wstring error = L"There are no available skins at:\n" + m_SkinPath;
MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK | MB_ICONERROR);
}
ReadGeneralSettings(m_IniFile);
if (m_CheckUpdate)
@ -797,7 +865,7 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
// Create meter windows for active configs
for (size_t i = 0; i < m_ConfigStrings.size(); i++)
{
if (m_ConfigStrings[i].active > 0 && m_ConfigStrings[i].active <= m_ConfigStrings[i].iniFiles.size())
if (m_ConfigStrings[i].active > 0 && m_ConfigStrings[i].active <= (int)m_ConfigStrings[i].iniFiles.size())
{
ActivateConfig(i, m_ConfigStrings[i].active - 1);
}
@ -843,6 +911,7 @@ void CRainmeter::ActivateConfig(int configIndex, int iniIndex)
WCHAR buffer[256];
std::wstring skinIniFile = m_ConfigStrings[configIndex].iniFiles[iniIndex];
std::wstring skinConfig = m_ConfigStrings[configIndex].config;
std::wstring skinPath = m_ConfigStrings[configIndex].path;
// Verify that the config is not already active
std::map<std::wstring, CMeterWindow*>::iterator iter = m_Meters.find(skinConfig);
@ -864,7 +933,7 @@ void CRainmeter::ActivateConfig(int configIndex, int iniIndex)
{
m_ConfigStrings[configIndex].active = iniIndex + 1;
CreateMeterWindow(skinConfig, skinIniFile);
CreateMeterWindow(skinPath, skinConfig, skinIniFile);
wsprintf(buffer, L"%i", iniIndex + 1);
WritePrivateProfileString(skinConfig.c_str(), L"Active", buffer, m_IniFile.c_str());
@ -901,9 +970,9 @@ bool CRainmeter::DeactivateConfig(CMeterWindow* meterWindow, int configIndex)
return false;
}
void CRainmeter::CreateMeterWindow(std::wstring config, std::wstring iniFile)
void CRainmeter::CreateMeterWindow(std::wstring path, std::wstring config, std::wstring iniFile)
{
CMeterWindow* mw = new CMeterWindow(config, iniFile);
CMeterWindow* mw = new CMeterWindow(path, config, iniFile);
if (mw)
{
@ -1001,14 +1070,8 @@ void CRainmeter::ScanForConfigs(std::wstring& path)
{
m_ConfigStrings.clear();
m_ConfigMenu.clear();
ScanForConfigsRecursive(path, L"", 0, m_ConfigMenu);
if(m_ConfigStrings.empty())
{
std::wstring error = L"There are no skins available in folder\n" + path;
MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK);
}
ScanForConfigsRecursive(path, L"", 0, m_ConfigMenu);
}
int CRainmeter::ScanForConfigsRecursive(std::wstring& path, std::wstring base, int index, std::vector<CONFIGMENU>& menu)
@ -1022,6 +1085,7 @@ int CRainmeter::ScanForConfigsRecursive(std::wstring& path, std::wstring base, i
{
// Scan for ini-files
CONFIG config;
config.path = path;
config.config = base;
config.active = false;
@ -1425,7 +1489,7 @@ void CRainmeter::ReadGeneralSettings(std::wstring& iniFile)
int active = parser.ReadInt(m_ConfigStrings[i].config.c_str(), L"Active", 0);
// Make sure there is a ini file available
if (active > 0 && active <= m_ConfigStrings[i].iniFiles.size())
if (active > 0 && active <= (int)m_ConfigStrings[i].iniFiles.size())
{
m_ConfigStrings[i].active = active;
}
@ -1610,6 +1674,9 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow)
HMENU configMenu = CreateConfigMenu(m_ConfigMenu);
if (configMenu)
{
AppendMenu(configMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(configMenu, 0, ID_CONTEXT_OPENSKINSFOLDER, L"Open Skins\' Folder");
InsertMenu(subMenu, 3, MF_BYPOSITION | MF_POPUP, (UINT_PTR)configMenu, L"Configs");
}
@ -1837,44 +1904,53 @@ void CRainmeter::ChangeSkinIndex(HMENU menu, int index)
}
}
/*
** FixPath
**
** Converts relative path to absolute.
**
*/
std::wstring CRainmeter::FixPath(const std::wstring& path, PATH_FOLDER folder, const std::wstring& currentSkin)
void CRainmeter::TestSettingsFile(bool bDefaultIniLocation)
{
if (path.empty() || path.find(L':') != std::wstring::npos)
WritePrivateProfileString(L"Rainmeter", L"WriteTest", L"TRUE", m_IniFile.c_str());
WritePrivateProfileString(NULL, NULL, NULL, m_IniFile.c_str()); // FLUSH
WCHAR tmpSz[5];
bool bSuccess = (GetPrivateProfileString(L"Rainmeter", L"WriteTest", L"", tmpSz, 5, m_IniFile.c_str()) > 0);
if (bSuccess)
{
return path; // It's already absolute path (or it's empty)
bSuccess = (wcscmp(L"TRUE", tmpSz) == 0);
WritePrivateProfileString(L"Rainmeter", L"WriteTest", NULL, m_IniFile.c_str());
}
std::wstring root;
switch(folder)
if (!bSuccess)
{
case PATH_FOLDER_INI:
root = Rainmeter->GetPath();
break;
DebugLog(L"The rainmeter.ini file is NOT writable.");
case PATH_FOLDER_SKINS:
root = Rainmeter->GetSkinPath();
break;
std::wstring error;
error += L"The Rainmeter.ini file is not writable. This means that the\n";
error += L"application will not be able to save any settings permanently.\n\n";
case PATH_FOLDER_CURRENT_SKIN:
root = Rainmeter->GetSkinPath() + currentSkin;
break;
if (!bDefaultIniLocation)
{
WCHAR buffer[4096] = {0}; // lets hope the buffer is large enough...
// Expand the environment variables
ExpandEnvironmentStrings(L"%APPDATA%\\Rainmeter\\", buffer, 4096);
case PATH_FOLDER_PLUGIN:
root = Rainmeter->GetPluginPath();
break;
error += L"You should quit Rainmeter and move the settings file from\n\n";
error += m_IniFile;
error += L"\n\nto\n\n";
error += buffer;
error += L"\n\nAlternatively you can also just remove the file and\n";
error += L"it will be automatically recreated to the correct location\n";
error += L"when Rainmeter is restarted the next time (you\'ll lose your\n";
error += L"current settings though).\n";
}
else
{
error += L"Make sure that the settings file is not set as read-only and\n";
error += L"it is located in a folder where you have write permissions.\n\n";
error += L"The settings file is located at:\n";
error += m_IniFile;
}
MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK | MB_ICONERROR);
}
if (root[root.length() - 1] != L'\\')
else
{
root += L"\\";
DebugLog(L"The rainmeter.ini file is writable.");
}
return root + path;
}
}

View File

@ -32,10 +32,11 @@
#define MAKE_VER(major, minor) major * 1000 + minor
#define APPNAME L"Rainmeter"
#define APPVERSION L"0.14.1"
#ifdef _WIN64
#define APPVERSION L"0.14.1 (64-bit)"
#define APPBITS L"(64-bit)"
#else
#define APPVERSION L"0.14.1 (32-bit)"
#define APPBITS L"(32-bit)"
#endif
#define RAINMETER_VERSION MAKE_VER(14, 1)
@ -82,6 +83,7 @@ class CRainmeter
public:
struct CONFIG
{
std::wstring path;
std::wstring config;
std::vector<std::wstring> iniFiles;
std::vector<UINT> commands;
@ -154,12 +156,11 @@ public:
BOOL ExecuteBang(const std::wstring& bang, const std::wstring& arg, CMeterWindow* meterWindow);
std::wstring ParseCommand(const WCHAR* command, CMeterWindow* meterWindow);
void ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow);
static std::wstring FixPath(const std::wstring& path, PATH_FOLDER folder, const std::wstring& currentSkin);
static PLATFORM IsNT();
private:
void CreateMeterWindow(std::wstring config, std::wstring iniFile);
void CreateMeterWindow(std::wstring path, std::wstring config, std::wstring iniFile);
bool DeleteMeterWindow(CMeterWindow* meterWindow);
void ScanForConfigs(std::wstring& path);
void ReadGeneralSettings(std::wstring& path);
@ -170,6 +171,7 @@ private:
int ScanForConfigsRecursive(std::wstring& path, std::wstring base, int index, std::vector<CONFIGMENU>& menu);
HMENU CreateConfigMenu(std::vector<CONFIGMENU>& configMenuData);
void CreateDefaultConfigFile(std::wstring strFile);
void TestSettingsFile(bool bDefaultIniLocation);
CTrayWindow* m_TrayWindow;

View File

@ -334,8 +334,7 @@ void CTrayWindow::ReadConfig(CConfigParser& parser)
// Load the bitmaps if defined
if (!imageName.empty())
{
imageName = Rainmeter->FixPath(imageName, PATH_FOLDER_SKINS, L"");
imageName = Rainmeter->GetSkinPath() + imageName;
if (imageName.size() > 3)
{
std::wstring extension = imageName.substr(imageName.size() - 3);
@ -474,6 +473,14 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
if (Rainmeter->GetDummyLitestep()) PostQuitMessage(0);
quitModule(Rainmeter->GetInstance());
}
else if(wParam == ID_CONTEXT_OPENSKINSFOLDER)
{
std::wstring command;
command += L"\"";
command += Rainmeter->GetSkinPath();
command += L"\"";
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
}
else if((wParam & 0x0ffff) >= ID_CONFIG_FIRST)
{
wParam = wParam & 0x0ffff;

View File

@ -52,6 +52,8 @@
#define ID_CONTEXT_SKINMENU_FROMBOTTOM 4041
#define ID_CONTEXT_SKINMENU_XPERCENTAGE 4042
#define ID_CONTEXT_SKINMENU_YPERCENTAGE 4043
#define ID_CONTEXT_OPENSKINSFOLDER 4044
#define ID_CONTEXT_SKINMENU_OPENSKINSFOLDER 4045
#define ID_CONFIG_EDIT 30000
#define ID_CONFIG_FIRST 30001

View File

@ -153,6 +153,7 @@
ProgramDataBaseFileName=".\x64/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -246,6 +247,7 @@
ProgramDataBaseFileName=".\x32/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -265,6 +267,7 @@
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\Library\x32\Release"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\x32/Release/AdvancedCPU.pdb"
ImportLibrary=".\x32/Release/AdvancedCPU.lib"
TargetMachine="1"

View File

@ -63,6 +63,7 @@
ProgramDataBaseFileName=".\x32/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -82,6 +83,7 @@
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\Library\x32\Release"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\x32/Release/ExamplePlugin.pdb"
ImportLibrary=".\x32/Release/ExamplePlugin.lib"
TargetMachine="1"
@ -511,6 +513,7 @@
ProgramDataBaseFileName=".\x64/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -153,6 +153,7 @@
ProgramDataBaseFileName=".\x64/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -423,6 +424,7 @@
ProgramDataBaseFileName=".\x32/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -442,6 +444,7 @@
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\Library\x32\Release"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\x32/Release/PerfMon.pdb"
ImportLibrary=".\x32/Release/PerfMon.lib"
TargetMachine="1"

View File

@ -153,6 +153,7 @@
ProgramDataBaseFileName=".\x64/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -425,6 +426,7 @@
ProgramDataBaseFileName=".\x32/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -444,6 +446,7 @@
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\Library\x32\Release"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\x32/Release/PingPlugin.pdb"
ImportLibrary=".\x32/Release/PingPlugin.lib"
TargetMachine="1"

View File

@ -241,6 +241,7 @@
ProgramDataBaseFileName=".\x32/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -260,6 +261,7 @@
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\Library\x32\Release"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\x32/Release/PowerPlugin.pdb"
ImportLibrary=".\x32/Release/PowerPlugin.lib"
TargetMachine="1"
@ -511,6 +513,7 @@
ProgramDataBaseFileName=".\x64/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -153,6 +153,7 @@
ProgramDataBaseFileName=".\x64/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -245,6 +246,7 @@
ProgramDataBaseFileName=".\x32/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -264,6 +266,7 @@
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\Library\x32\Release"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\x32/Release/QuotePlugin.pdb"
ImportLibrary=".\x32/Release/QuotePlugin.lib"
TargetMachine="1"

View File

@ -155,6 +155,7 @@
ProgramDataBaseFileName=".\x64/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -249,6 +250,7 @@
ProgramDataBaseFileName=".\x32/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -268,6 +270,7 @@
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\Library\x32\Release"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\x32/Release/RecycleManager.pdb"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"

View File

@ -153,6 +153,7 @@
ProgramDataBaseFileName=".\x64/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -245,6 +246,7 @@
ProgramDataBaseFileName=".\x32/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -264,6 +266,7 @@
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\Library\x32\Release"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\x32/Release/ResMon.pdb"
ImportLibrary=".\x32/Release/ResMon.lib"
TargetMachine="1"

View File

@ -63,6 +63,7 @@
ProgramDataBaseFileName=".\x32/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -82,6 +83,7 @@
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\Library\x32\Release"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\x32/Release/SpeedFanPlugin.pdb"
ImportLibrary=".\x32/Release/SpeedFanPlugin.lib"
TargetMachine="1"
@ -511,6 +513,7 @@
ProgramDataBaseFileName=".\x64/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -63,6 +63,7 @@
ProgramDataBaseFileName=".\x32/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -82,6 +83,7 @@
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\Library\x32\Release"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\x32/Release/SysInfo.pdb"
ImportLibrary=".\x32/Release/SysInfo.lib"
TargetMachine="1"
@ -514,6 +516,7 @@
ProgramDataBaseFileName=".\x64/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -243,6 +243,7 @@
ProgramDataBaseFileName=".\x32/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -262,6 +263,7 @@
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\Library\x32\Release"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\x32/Release/WebParser.pdb"
ImportLibrary=".\x32/Release/WebParser.lib"
TargetMachine="1"
@ -514,6 +516,7 @@
ProgramDataBaseFileName=".\x64/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"

View File

@ -331,6 +331,7 @@
ProgramDataBaseFileName=".\x64/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -423,6 +424,7 @@
ProgramDataBaseFileName=".\x32/Release/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@ -442,6 +444,7 @@
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\Library\x32\Release"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\x32/Release/WindowMessagePlugin.pdb"
ImportLibrary=".\x32/Release/WindowMessagePlugin.lib"
TargetMachine="1"

2
revision-number.h Normal file
View File

@ -0,0 +1,2 @@
#pragma once
const int revision_number = 85;