зеркало из https://github.com/mozilla/gecko-dev.git
Fixing saving GUI prefs in the Tester plugin -- not part of the build
This commit is contained in:
Родитель
8f1fb003e2
Коммит
b8e8d0be24
|
@ -53,7 +53,8 @@ static CScripter * pScripter = NULL;
|
|||
static void onCommand(HWND hWnd, int id, HWND hWndCtl, UINT codeNotify)
|
||||
{
|
||||
CPlugin * pPlugin = (CPlugin *)GetWindowLong(hWnd, DWL_USER);
|
||||
assert(pPlugin != NULL);
|
||||
if(!pPlugin)
|
||||
return;
|
||||
|
||||
switch (id)
|
||||
{
|
||||
|
@ -79,6 +80,8 @@ static void onCommand(HWND hWnd, int id, HWND hWndCtl, UINT codeNotify)
|
|||
strcat(szLogFileName, ".log");
|
||||
Edit_SetText(GetDlgItem(GetParent(hWnd), IDC_EDIT_LOG_FILE_NAME), szLogFileName);
|
||||
|
||||
pPlugin->updatePrefs(gp_scriptfile, FALSE, szString);
|
||||
|
||||
break;
|
||||
}
|
||||
/*
|
||||
|
|
|
@ -50,16 +50,24 @@ extern CLogger * pLogger;
|
|||
static void onCommand(HWND hWnd, int id, HWND hWndCtl, UINT codeNotify)
|
||||
{
|
||||
CPlugin * pPlugin = (CPlugin *)GetWindowLong(hWnd, DWL_USER);
|
||||
if(!pPlugin)
|
||||
return;
|
||||
|
||||
switch (id)
|
||||
{
|
||||
case IDC_RADIO_MODE_MANUAL:
|
||||
if((codeNotify == BN_CLICKED) && (IsDlgButtonChecked(hWnd, IDC_RADIO_MODE_MANUAL) == BST_CHECKED))
|
||||
{
|
||||
pPlugin->showGUI(sg_manual);
|
||||
pPlugin->updatePrefs(gp_mode, sg_manual);
|
||||
}
|
||||
break;
|
||||
case IDC_RADIO_MODE_AUTO:
|
||||
if((codeNotify == BN_CLICKED) && (IsDlgButtonChecked(hWnd, IDC_RADIO_MODE_AUTO) == BST_CHECKED))
|
||||
{
|
||||
pPlugin->showGUI(sg_auto);
|
||||
pPlugin->updatePrefs(gp_mode, sg_auto);
|
||||
}
|
||||
break;
|
||||
case IDC_BUTTON_FLUSH:
|
||||
pLogger->clearTarget();
|
||||
|
@ -70,10 +78,17 @@ static void onCommand(HWND hWnd, int id, HWND hWndCtl, UINT codeNotify)
|
|||
pLogger->clearLog();
|
||||
break;
|
||||
case IDC_EDIT_LOG_FILE_NAME:
|
||||
if(codeNotify == EN_CHANGE)
|
||||
{
|
||||
char szString[256];
|
||||
Edit_GetText(GetDlgItem(hWnd, IDC_EDIT_LOG_FILE_NAME), szString, sizeof(szString));
|
||||
pPlugin->updatePrefs(gp_logfile, FALSE, szString);
|
||||
}
|
||||
break;
|
||||
case IDC_CHECK_LOG_TO_FILE:
|
||||
if(codeNotify == BN_CLICKED)
|
||||
{
|
||||
pPlugin->updatePrefs(gp_tofile, BST_CHECKED == IsDlgButtonChecked(hWnd, IDC_CHECK_LOG_TO_FILE));
|
||||
EnableWindow(GetDlgItem(hWnd, IDC_EDIT_LOG_FILE_NAME), (BST_CHECKED == IsDlgButtonChecked(hWnd, IDC_CHECK_LOG_TO_FILE)));
|
||||
pPlugin->onLogToFile(BST_CHECKED == IsDlgButtonChecked(hWnd, IDC_CHECK_LOG_TO_FILE));
|
||||
}
|
||||
|
@ -81,6 +96,7 @@ static void onCommand(HWND hWnd, int id, HWND hWndCtl, UINT codeNotify)
|
|||
case IDC_CHECK_LOG_TO_FRAME:
|
||||
if(codeNotify == BN_CLICKED)
|
||||
{
|
||||
pPlugin->updatePrefs(gp_toframe, BST_CHECKED == IsDlgButtonChecked(hWnd, IDC_CHECK_LOG_TO_FRAME));
|
||||
EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_FLUSH), (BST_UNCHECKED == IsDlgButtonChecked(hWnd, IDC_CHECK_SHOW_LOG))
|
||||
&& (BST_CHECKED == IsDlgButtonChecked(hWnd, IDC_CHECK_LOG_TO_FRAME)));
|
||||
EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_CLEAR), (BST_CHECKED == IsDlgButtonChecked(hWnd, IDC_CHECK_LOG_TO_FRAME)));
|
||||
|
@ -91,6 +107,7 @@ static void onCommand(HWND hWnd, int id, HWND hWndCtl, UINT codeNotify)
|
|||
case IDC_CHECK_SHOW_LOG:
|
||||
if(codeNotify == BN_CLICKED)
|
||||
{
|
||||
pPlugin->updatePrefs(gp_flush, IsDlgButtonChecked(hWnd, IDC_CHECK_SHOW_LOG) == BST_CHECKED);
|
||||
EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_FLUSH), (BST_UNCHECKED == IsDlgButtonChecked(hWnd, IDC_CHECK_SHOW_LOG))
|
||||
&& (BST_CHECKED == IsDlgButtonChecked(hWnd, IDC_CHECK_LOG_TO_FRAME)));
|
||||
pLogger->setShowImmediatelyFlag(IsDlgButtonChecked(hWnd, IDC_CHECK_SHOW_LOG) == BST_CHECKED);
|
||||
|
|
|
@ -109,24 +109,41 @@ void CPlugin::savePreferences()
|
|||
getModulePath(szFileName, sizeof(szFileName));
|
||||
strcat(szFileName, szINIFile);
|
||||
|
||||
BOOL bParam = IsDlgButtonChecked(m_hWnd, IDC_RADIO_MODE_AUTO);
|
||||
XP_WritePrivateProfileString(szSection, KEY_AUTO_MODE, bParam ? szYes : szNo, szFileName);
|
||||
XP_WritePrivateProfileString(szSection, KEY_AUTO_MODE, (m_Pref_ShowGUI == sg_auto) ? szYes : szNo, szFileName);
|
||||
XP_WritePrivateProfileString(szSection, KEY_LOG_FILE, m_Pref_szLogFile, szFileName);
|
||||
XP_WritePrivateProfileString(szSection, KEY_SCRIPT_FILE, m_Pref_szScriptFile, szFileName);
|
||||
XP_WritePrivateProfileString(szSection, KEY_TO_FILE, m_Pref_bToFile ? szYes : szNo, szFileName);
|
||||
XP_WritePrivateProfileString(szSection, KEY_TO_FRAME, m_Pref_bToFrame ? szYes : szNo, szFileName);
|
||||
XP_WritePrivateProfileString(szSection, KEY_FLUSH_NOW, m_Pref_bFlushNow ? szYes : szNo, szFileName);
|
||||
}
|
||||
|
||||
char szParam[256];
|
||||
Edit_GetText(GetDlgItem(m_hWnd, IDC_EDIT_LOG_FILE_NAME), szParam, sizeof(szParam));
|
||||
XP_WritePrivateProfileString(szSection, KEY_LOG_FILE, szParam, szFileName);
|
||||
|
||||
Edit_GetText(GetDlgItem(m_hWndAuto, IDC_EDIT_SCRIPT_FILE_NAME), szParam, sizeof(szParam));
|
||||
XP_WritePrivateProfileString(szSection, KEY_SCRIPT_FILE, szParam, szFileName);
|
||||
|
||||
bParam = IsDlgButtonChecked(m_hWnd, IDC_CHECK_LOG_TO_FILE);
|
||||
XP_WritePrivateProfileString(szSection, KEY_TO_FILE, bParam ? szYes : szNo, szFileName);
|
||||
|
||||
bParam = IsDlgButtonChecked(m_hWnd, IDC_CHECK_LOG_TO_FRAME);
|
||||
XP_WritePrivateProfileString(szSection, KEY_TO_FRAME, bParam ? szYes : szNo, szFileName);
|
||||
|
||||
bParam = IsDlgButtonChecked(m_hWnd, IDC_CHECK_SHOW_LOG);
|
||||
XP_WritePrivateProfileString(szSection, KEY_FLUSH_NOW, bParam ? szYes : szNo, szFileName);
|
||||
void CPlugin::updatePrefs(GUIPrefs prefs, int iValue, char * szValue)
|
||||
{
|
||||
switch(prefs)
|
||||
{
|
||||
case gp_mode:
|
||||
m_Pref_ShowGUI = (ShowGUI)iValue;
|
||||
break;
|
||||
case gp_logfile:
|
||||
if(szValue && (strlen(szValue) < sizeof(m_Pref_szLogFile)))
|
||||
strcpy(m_Pref_szLogFile, szValue);
|
||||
break;
|
||||
case gp_scriptfile:
|
||||
if(szValue && (strlen(szValue) < sizeof(m_Pref_szScriptFile)))
|
||||
strcpy(m_Pref_szScriptFile, szValue);
|
||||
break;
|
||||
case gp_tofile:
|
||||
m_Pref_bToFile = (BOOL)iValue;
|
||||
break;
|
||||
case gp_toframe:
|
||||
m_Pref_bToFrame = (BOOL)iValue;
|
||||
break;
|
||||
case gp_flush:
|
||||
m_Pref_bFlushNow = (BOOL)iValue;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CPlugin::getModulePath(LPSTR szPath, int iSize)
|
||||
|
|
|
@ -46,6 +46,16 @@ typedef enum
|
|||
sg_auto
|
||||
} ShowGUI;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
gp_mode = 1,
|
||||
gp_logfile,
|
||||
gp_scriptfile,
|
||||
gp_tofile,
|
||||
gp_toframe,
|
||||
gp_flush
|
||||
}GUIPrefs;
|
||||
|
||||
class CPlugin : public CPluginBase
|
||||
{
|
||||
private:
|
||||
|
@ -107,6 +117,7 @@ public:
|
|||
// utilities
|
||||
void restorePreferences();
|
||||
void savePreferences();
|
||||
void updatePrefs(GUIPrefs prefs, int iValue, char * szValue = NULL);
|
||||
|
||||
// Window message handlers
|
||||
void onInit(HWND hWnd, HWND hWndManual, HWND hWndAuto);
|
||||
|
|
Загрузка…
Ссылка в новой задаче