Commit f388977f authored by Mike Hearn's avatar Mike Hearn Committed by Alexandre Julliard

- Clear screen depth combo box on page init.

- Some appdefaults support. - Rename hDlg to dialog in some places so enable/disable macros work. - Don't update registry when the GUI is being initially configured.
parent 7832562e
......@@ -34,6 +34,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
int appSettings = EDITING_GLOBAL; /* start by editing global */
char *currentApp; /* the app we are currently editing, or NULL if editing global */
static int needToRefresh = 1;
char *getSectionForApp(char *section) {
static char *lastResult = NULL;
if (lastResult) HeapFree(GetProcessHeap(), 0, lastResult);
......@@ -48,7 +50,6 @@ static void configureFor(HWND dialog, int mode) {
disable(IDC_LIST_APPS);
disable(IDC_ADD_APPDEFAULT);
disable(IDC_REMOVE_APPDEFAULT);
if (currentApp) HeapFree(GetProcessHeap(), 0, currentApp);
} else {
enable(IDC_LIST_APPS);
enable(IDC_ADD_APPDEFAULT);
......@@ -87,6 +88,7 @@ static void refreshDialog(HWND dialog) {
WINE_TRACE("done\n");
RegCloseKey(key);
HeapFree(GetProcessHeap(), 0, subKeyName);
}
static void onAppsListSelChange(HWND dialog) {
......@@ -107,6 +109,11 @@ AppDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
case WM_COMMAND: switch (LOWORD(wParam)) {
case IDC_EDITING_APP:
if (SendDlgItemMessage(hDlg, IDC_LIST_APPS, LB_GETCURSEL, 0, 0) == LB_ERR) {
/* no selection, so select the first one */
SendDlgItemMessage(hDlg, IDC_LIST_APPS, LB_SETCURSEL, 0, 0);
onAppsListSelChange(hDlg);
}
configureFor(hDlg, EDITING_APP);
break;
case IDC_EDITING_GLOBAL:
......@@ -114,9 +121,11 @@ AppDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
break;
case IDC_ADD_APPDEFAULT:
WRITEME(hDlg);
refreshDialog(hDlg);
break;
case IDC_REMOVE_APPDEFAULT:
WRITEME(hDlg);
refreshDialog(hDlg);
break;
case IDC_LIST_APPS:
if (HIWORD(wParam) == LBN_SELCHANGE) onAppsListSelChange(hDlg);
......@@ -132,10 +141,12 @@ AppDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR);
break;
case PSN_SETACTIVE:
refreshDialog(hDlg);
if (needToRefresh) {
refreshDialog(hDlg);
needToRefresh = 0;
}
break;
};
}
break;
case WM_INITDIALOG:
......
......@@ -120,7 +120,7 @@ void removeDrive(char letter) {
addTransaction(driveSection, NULL, ACTION_REMOVE, NULL);
}
int refreshDriveDlg (HWND hDlg)
int refreshDriveDlg (HWND dialog)
{
int i;
char *subKeyName = malloc(MAX_NAME_LENGTH);
......@@ -133,7 +133,7 @@ int refreshDriveDlg (HWND hDlg)
updatingUI = TRUE;
/* Clear the listbox */
SendMessageA(GetDlgItem(hDlg, IDC_LIST_DRIVES), LB_RESETCONTENT, 0, 0);
SendMessageA(GetDlgItem(dialog, IDC_LIST_DRIVES), LB_RESETCONTENT, 0, 0);
for (i = 0;
RegEnumKeyExA(configKey, i, subKeyName, &sizeOfSubKeyName, NULL, NULL, NULL, NULL ) != ERROR_NO_MORE_ITEMS;
++i, sizeOfSubKeyName = MAX_NAME_LENGTH) {
......@@ -195,8 +195,8 @@ int refreshDriveDlg (HWND hDlg)
snprintf(title, titleLen, "Drive %c: %s", driveLetter, label);
/* the first SendMessage call adds the string and returns the index, the second associates that index with it */
itemIndex = SendMessageA(GetDlgItem(hDlg, IDC_LIST_DRIVES), LB_ADDSTRING ,(WPARAM) -1, (LPARAM) title);
SendMessageA(GetDlgItem(hDlg, IDC_LIST_DRIVES), LB_SETITEMDATA, itemIndex, (LPARAM) driveLetter);
itemIndex = SendMessageA(GetDlgItem(dialog, IDC_LIST_DRIVES), LB_ADDSTRING ,(WPARAM) -1, (LPARAM) title);
SendMessageA(GetDlgItem(dialog, IDC_LIST_DRIVES), LB_SETITEMDATA, itemIndex, (LPARAM) driveLetter);
free(title);
free(label);
......@@ -207,15 +207,35 @@ int refreshDriveDlg (HWND hDlg)
}
WINE_TRACE("loaded %d drives\n", driveCount);
SendDlgItemMessage(hDlg, IDC_LIST_DRIVES, LB_SETSEL, TRUE, lastSel);
SendDlgItemMessage(dialog, IDC_LIST_DRIVES, LB_SETSEL, TRUE, lastSel);
/* show the warning if there is no Drive C */
if (!doesDriveCExist)
ShowWindow(GetDlgItem(hDlg, IDS_DRIVE_NO_C), SW_NORMAL);
ShowWindow(GetDlgItem(dialog, IDS_DRIVE_NO_C), SW_NORMAL);
else
ShowWindow(GetDlgItem(hDlg, IDS_DRIVE_NO_C), SW_HIDE);
ShowWindow(GetDlgItem(dialog, IDS_DRIVE_NO_C), SW_HIDE);
free(subKeyName);
/* disable or enable controls depending on whether we are editing global vs app specific config */
if (appSettings == EDITING_GLOBAL) {
WINE_TRACE("enabling controls\n");
enable(IDC_LIST_DRIVES);
enable(IDC_BUTTON_ADD);
enable(IDC_BUTTON_REMOVE);
enable(IDC_BUTTON_EDIT);
enable(IDC_BUTTON_AUTODETECT);
} else {
WINE_TRACE("disabling controls\n");
disable(IDC_LIST_DRIVES);
disable(IDC_BUTTON_ADD);
disable(IDC_BUTTON_REMOVE);
disable(IDC_BUTTON_EDIT);
disable(IDC_BUTTON_AUTODETECT);
}
free(subKeyName);
updatingUI = FALSE;
return driveCount;
}
......@@ -368,7 +388,7 @@ long drive_available_mask(char letter)
}
void refreshDriveEditDialog(HWND hDlg) {
void refreshDriveEditDialog(HWND dialog) {
char *path;
char *type;
char *fs;
......@@ -380,19 +400,19 @@ void refreshDriveEditDialog(HWND hDlg) {
updatingUI = TRUE;
/* Drive letters */
fill_drive_droplist( drive_available_mask( editWindowLetter ), editWindowLetter, hDlg );
fill_drive_droplist( drive_available_mask( editWindowLetter ), editWindowLetter, dialog );
/* path */
path = getDriveValue(editWindowLetter, "Path");
if (path) {
SetWindowText(GetDlgItem(hDlg, IDC_EDIT_PATH), path);
SetWindowText(GetDlgItem(dialog, IDC_EDIT_PATH), path);
} else WINE_WARN("no Path field?\n");
/* drive type */
type = getDriveValue(editWindowLetter, "Type");
if (type) {
for(i = 0, selection = -1; i < sizeof(type_pairs)/sizeof(code_desc_pair); i++) {
SendDlgItemMessage(hDlg, IDC_COMBO_TYPE, CB_ADDSTRING, 0,
SendDlgItemMessage(dialog, IDC_COMBO_TYPE, CB_ADDSTRING, 0,
(LPARAM) type_pairs[i].sDesc);
if(strcasecmp(type_pairs[i].sCode, type) == 0){
selection = i;
......@@ -400,7 +420,7 @@ void refreshDriveEditDialog(HWND hDlg) {
}
if( selection == -1 ) selection = DRIVE_TYPE_DEFAULT;
SendDlgItemMessage(hDlg, IDC_COMBO_TYPE, CB_SETCURSEL, selection, 0);
SendDlgItemMessage(dialog, IDC_COMBO_TYPE, CB_SETCURSEL, selection, 0);
} else WINE_WARN("no Type field?\n");
......@@ -408,7 +428,7 @@ void refreshDriveEditDialog(HWND hDlg) {
fs = getDriveValue(editWindowLetter, "FileSystem");
if (fs) {
for( i=0, selection=-1; i < sizeof(fs_pairs)/sizeof(code_desc_pair); i++) {
SendDlgItemMessage(hDlg, IDC_COMBO_NAMES, CB_ADDSTRING, 0,
SendDlgItemMessage(dialog, IDC_COMBO_NAMES, CB_ADDSTRING, 0,
(LPARAM) fs_pairs[i].sDesc);
if(strcasecmp(fs_pairs[i].sCode, fs) == 0){
selection = i;
......@@ -416,42 +436,42 @@ void refreshDriveEditDialog(HWND hDlg) {
}
if( selection == -1 ) selection = DRIVE_FS_DEFAULT;
SendDlgItemMessage(hDlg, IDC_COMBO_NAMES, CB_SETCURSEL, selection, 0);
SendDlgItemMessage(dialog, IDC_COMBO_NAMES, CB_SETCURSEL, selection, 0);
} else WINE_WARN("no FileSystem field?\n");
/* removeable media properties */
serial = getDriveValue(editWindowLetter, "Serial");
if (serial) {
SendDlgItemMessage(hDlg, IDC_EDIT_SERIAL, WM_SETTEXT, 0,(LPARAM)serial);
SendDlgItemMessage(dialog, IDC_EDIT_SERIAL, WM_SETTEXT, 0,(LPARAM)serial);
} else WINE_WARN("no Serial field?\n");
label = getDriveValue(editWindowLetter, "Label");
if (label) {
SendDlgItemMessage(hDlg, IDC_EDIT_LABEL, WM_SETTEXT, 0,(LPARAM)label);
SendDlgItemMessage(dialog, IDC_EDIT_LABEL, WM_SETTEXT, 0,(LPARAM)label);
} else WINE_WARN("no Label field?\n");
device = getDriveValue(editWindowLetter, "Device");
if (device) {
SendDlgItemMessage(hDlg, IDC_EDIT_DEVICE, WM_SETTEXT, 0,(LPARAM)device);
SendDlgItemMessage(dialog, IDC_EDIT_DEVICE, WM_SETTEXT, 0,(LPARAM)device);
} else WINE_WARN("no Device field?\n");
selection = IDC_RADIO_ASSIGN;
if ((type && strcmp("cdrom", type) == 0) || (type && strcmp("floppy", type) == 0)) {
if (device) {
selection = IDC_RADIO_AUTODETECT;
enable_labelserial_box(hDlg, BOX_MODE_CD_AUTODETECT);
enable_labelserial_box(dialog, BOX_MODE_CD_AUTODETECT);
} else {
selection = IDC_RADIO_ASSIGN;
enable_labelserial_box(hDlg, BOX_MODE_CD_ASSIGN);
enable_labelserial_box(dialog, BOX_MODE_CD_ASSIGN);
}
} else {
enable_labelserial_box(hDlg, BOX_MODE_NORMAL);
enable_labelserial_box(dialog, BOX_MODE_NORMAL);
selection = IDC_RADIO_ASSIGN;
}
CheckRadioButton( hDlg, IDC_RADIO_AUTODETECT, IDC_RADIO_ASSIGN, selection );
if (path) SendDlgItemMessage(hDlg, IDC_EDIT_PATH, WM_SETTEXT, 0,(LPARAM)path);
CheckRadioButton( dialog, IDC_RADIO_AUTODETECT, IDC_RADIO_ASSIGN, selection );
if (path) SendDlgItemMessage(dialog, IDC_EDIT_PATH, WM_SETTEXT, 0,(LPARAM)path);
if (path) free(path);
if (type) free(type);
......@@ -460,6 +480,7 @@ void refreshDriveEditDialog(HWND hDlg) {
if (label) free(label);
if (device) free(device);
updatingUI = FALSE;
return;
......
......@@ -45,7 +45,7 @@ void updateGUIForDesktopMode(HWND dialog) {
updatingUI = TRUE;
/* do we have desktop mode enabled? */
if (doesConfigValueExist("x11drv", "Desktop") == S_OK) {
if (doesConfigValueExist(section, "Desktop") == S_OK) {
CheckDlgButton(dialog, IDC_ENABLE_DESKTOP, BST_CHECKED);
/* enable the controls */
enable(IDC_DESKTOP_WIDTH);
......@@ -77,25 +77,26 @@ void initX11DrvDlg (HWND hDlg)
char *buf;
char *bufindex;
updatingUI = TRUE;
updateGUIForDesktopMode(hDlg);
updatingUI = TRUE;
/* desktop size */
buf = getConfigValue("x11drv", "Desktop", "640x480");
buf = getConfigValue(section, "Desktop", "640x480");
bufindex = strchr(buf, 'x');
*bufindex = '\0';
bufindex++;
SetWindowText(GetDlgItem(hDlg, IDC_DESKTOP_WIDTH), buf);
SetWindowText(GetDlgItem(hDlg, IDC_DESKTOP_HEIGHT), bufindex);
free(buf);
SendDlgItemMessage(hDlg, IDC_SCREEN_DEPTH, CB_RESETCONTENT, 0, 0);
SendDlgItemMessage(hDlg, IDC_SCREEN_DEPTH, CB_ADDSTRING, 0, (LPARAM) "8 bit");
SendDlgItemMessage(hDlg, IDC_SCREEN_DEPTH, CB_ADDSTRING, 0, (LPARAM) "16 bit");
SendDlgItemMessage(hDlg, IDC_SCREEN_DEPTH, CB_ADDSTRING, 0, (LPARAM) "24 bit");
SendDlgItemMessage(hDlg, IDC_SCREEN_DEPTH, CB_ADDSTRING, 0, (LPARAM) "32 bit"); /* is this valid? */
buf = getConfigValue("x11drv", "ScreenDepth", "24");
buf = getConfigValue(section, "ScreenDepth", "24");
if (strcmp(buf, "8") == 0)
SendDlgItemMessage(hDlg, IDC_SCREEN_DEPTH, CB_SETCURSEL, 0, 0);
else if (strcmp(buf, "16") == 0)
......@@ -111,21 +112,21 @@ void initX11DrvDlg (HWND hDlg)
SendDlgItemMessage(hDlg, IDC_DESKTOP_WIDTH, EM_LIMITTEXT, RES_MAXLEN, 0);
SendDlgItemMessage(hDlg, IDC_DESKTOP_HEIGHT, EM_LIMITTEXT, RES_MAXLEN, 0);
buf = getConfigValue("x11drv", "DXGrab", "Y");
buf = getConfigValue(section, "DXGrab", "Y");
if (IS_OPTION_TRUE(*buf))
CheckDlgButton(hDlg, IDC_DX_MOUSE_GRAB, BST_CHECKED);
else
CheckDlgButton(hDlg, IDC_DX_MOUSE_GRAB, BST_UNCHECKED);
free(buf);
buf = getConfigValue("x11drv", "DesktopDoubleBuffered", "Y");
buf = getConfigValue(section, "DesktopDoubleBuffered", "Y");
if (IS_OPTION_TRUE(*buf))
CheckDlgButton(hDlg, IDC_DOUBLE_BUFFER, BST_CHECKED);
else
CheckDlgButton(hDlg, IDC_DOUBLE_BUFFER, BST_UNCHECKED);
free(buf);
buf = getConfigValue("x11drv", "UseTakeFocus", "N");
buf = getConfigValue(section, "UseTakeFocus", "N");
if (IS_OPTION_TRUE(*buf))
CheckDlgButton(hDlg, IDC_USE_TAKE_FOCUS, BST_CHECKED);
else
......@@ -153,7 +154,7 @@ void setFromDesktopSizeEdits(HWND hDlg) {
if (strcmp(height, "") == 0) strcpy(height, "480");
sprintf(newStr, "%sx%s", width, height);
addTransaction("x11drv", "Desktop", ACTION_SET, newStr);
addTransaction(section, "Desktop", ACTION_SET, newStr);
free(width);
free(height);
......@@ -167,7 +168,7 @@ void onEnableDesktopClicked(HWND hDlg) {
setFromDesktopSizeEdits(hDlg);
} else {
/* it was just checked, so remove the config values */
addTransaction("x11drv", "Desktop", ACTION_REMOVE, NULL);
addTransaction(section, "Desktop", ACTION_REMOVE, NULL);
}
updateGUIForDesktopMode(hDlg);
}
......@@ -180,30 +181,30 @@ void onScreenDepthChanged(HWND hDlg) {
if (updatingUI) return;
*spaceIndex = '\0';
addTransaction("x11drv", "ScreenDepth", ACTION_SET, newvalue);
addTransaction(section, "ScreenDepth", ACTION_SET, newvalue);
free(newvalue);
}
void onDXMouseGrabClicked(HWND hDlg) {
if (IsDlgButtonChecked(hDlg, IDC_DX_MOUSE_GRAB) == BST_CHECKED)
addTransaction("x11drv", "DXGrab", ACTION_SET, "Y");
addTransaction(section, "DXGrab", ACTION_SET, "Y");
else
addTransaction("x11drv", "DXGrab", ACTION_SET, "N");
addTransaction(section, "DXGrab", ACTION_SET, "N");
}
void onDoubleBufferClicked(HWND hDlg) {
if (IsDlgButtonChecked(hDlg, IDC_DOUBLE_BUFFER) == BST_CHECKED)
addTransaction("x11drv", "DesktopDoubleBuffered", ACTION_SET, "Y");
addTransaction(section, "DesktopDoubleBuffered", ACTION_SET, "Y");
else
addTransaction("x11drv", "DesktopDoubleBuffered", ACTION_SET, "N");
addTransaction(section, "DesktopDoubleBuffered", ACTION_SET, "N");
}
void onUseTakeFocusClicked(HWND hDlg) {
if (IsDlgButtonChecked(hDlg, IDC_USE_TAKE_FOCUS) == BST_CHECKED)
addTransaction("x11drv", "UseTakeFocus", ACTION_SET, "Y");
addTransaction(section, "UseTakeFocus", ACTION_SET, "Y");
else
addTransaction("x11drv", "UseTakeFocus", ACTION_SET, "N");
addTransaction(section, "UseTakeFocus", ACTION_SET, "N");
}
......@@ -218,11 +219,12 @@ X11DrvDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
switch(HIWORD(wParam)) {
case EN_CHANGE: {
SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
if ( (LOWORD(wParam) == IDC_DESKTOP_WIDTH) || (LOWORD(wParam) == IDC_DESKTOP_HEIGHT) ) setFromDesktopSizeEdits(hDlg);
if ( ((LOWORD(wParam) == IDC_DESKTOP_WIDTH) || (LOWORD(wParam) == IDC_DESKTOP_HEIGHT)) && !updatingUI )
setFromDesktopSizeEdits(hDlg);
break;
}
case BN_CLICKED: {
WINE_TRACE("%d\n", LOWORD(wParam));
if (updatingUI) break;
switch(LOWORD(wParam)) {
case IDC_ENABLE_DESKTOP: onEnableDesktopClicked(hDlg); break;
case IDC_DX_MOUSE_GRAB: onDXMouseGrabClicked(hDlg); break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment