Manage Settings: Changed to remove ConfigEditor if it matches associated editor

This commit is contained in:
Birunthan Mohanathas 2012-11-13 17:54:32 +02:00
parent 89fcfeb4e6
commit fd5de00955
3 changed files with 18 additions and 17 deletions

View File

@ -1827,9 +1827,11 @@ INT_PTR CDialogManage::CTabSettings::OnCommand(WPARAM wParam, LPARAM lParam)
case IDC_MANAGESETTINGS_CONFIGEDITOR_TEXT: case IDC_MANAGESETTINGS_CONFIGEDITOR_TEXT:
if (HIWORD(wParam) == EN_CHANGE) if (HIWORD(wParam) == EN_CHANGE)
{ {
WCHAR buffer[MAX_LINE_LENGTH]; WCHAR buffer[MAX_PATH];
std::wstring editor = (GetWindowText((HWND)lParam, buffer, MAX_LINE_LENGTH) > 0) ? buffer : L""; if (GetWindowText((HWND)lParam, buffer, _countof(buffer)) > 0)
Rainmeter->SetSkinEditor(editor); {
Rainmeter->SetSkinEditor(buffer);
}
} }
break; break;

View File

@ -1503,23 +1503,22 @@ void CRainmeter::SetSkinPath(const std::wstring& skinPath)
WritePrivateProfileString(L"Rainmeter", L"SkinPath", skinPath.c_str(), m_IniFile.c_str()); WritePrivateProfileString(L"Rainmeter", L"SkinPath", skinPath.c_str(), m_IniFile.c_str());
} }
void CRainmeter::SetSkinEditor(const std::wstring& editor) void CRainmeter::SetSkinEditor(const std::wstring& path)
{ {
LPCWSTR tmp = editor.empty() ? NULL : editor.c_str(); assert(!path.empty());
if (!tmp)
{ const WCHAR* pathSz = path.c_str();
// Get the program path associated with .ini files
WCHAR buffer[MAX_PATH]; WCHAR buffer[MAX_PATH];
DWORD cchOut = MAX_PATH; DWORD cchOut = MAX_PATH;
HRESULT hr = AssocQueryString(ASSOCF_NOTRUNCATE, ASSOCSTR_EXECUTABLE, L".ini", L"open", buffer, &cchOut); HRESULT hr = AssocQueryString(ASSOCF_NOTRUNCATE, ASSOCSTR_EXECUTABLE, L".ini", L"open", buffer, &cchOut);
m_SkinEditor = (SUCCEEDED(hr) && cchOut > 0) ? buffer : L"Notepad"; if (SUCCEEDED(hr) && _wcsicmp(pathSz, buffer) == 0)
}
else
{ {
m_SkinEditor = editor; // The selected editor and the associated editor is the same, so remove from Rainmeter.ini.
pathSz = NULL;
} }
WritePrivateProfileString(L"Rainmeter", L"ConfigEditor", tmp, m_IniFile.c_str()); m_SkinEditor = path;
WritePrivateProfileString(L"Rainmeter", L"ConfigEditor", pathSz, m_IniFile.c_str());
} }
void CRainmeter::WriteActive(const std::wstring& folderPath, int fileIndex) void CRainmeter::WriteActive(const std::wstring& folderPath, int fileIndex)

View File

@ -154,7 +154,7 @@ public:
const std::wstring& GetDrive() { return m_Drive; } const std::wstring& GetDrive() { return m_Drive; }
const std::wstring& GetSkinEditor() { return m_SkinEditor; } const std::wstring& GetSkinEditor() { return m_SkinEditor; }
void SetSkinEditor(const std::wstring& editor); void SetSkinEditor(const std::wstring& path);
const std::wstring& GetStatsDate() { return m_StatsDate; } const std::wstring& GetStatsDate() { return m_StatsDate; }
HWND GetWindow() { return m_Window; } HWND GetWindow() { return m_Window; }