[winecfg 15] Implement basic appdefaults support
Mike Hearn
mike at theoretic.com
Fri Oct 17 11:53:37 CDT 2003
- 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
diff -ur --exclude-from=diff-exclusions ../head/programs/winecfg/appdefaults.c programs/winecfg/appdefaults.c
--- ../head/programs/winecfg/appdefaults.c 2003-09-30 01:27:55.000000000 +0100
+++ programs/winecfg/appdefaults.c 2003-10-17 17:44:05.000000000 +0100
@@ -34,6 +34,8 @@
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 @@
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 @@
WINE_TRACE("done\n");
RegCloseKey(key);
HeapFree(GetProcessHeap(), 0, subKeyName);
+
}
static void onAppsListSelChange(HWND dialog) {
@@ -107,6 +109,11 @@
{
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 @@
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,7 +141,10 @@
SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR);
break;
case PSN_SETACTIVE:
- refreshDialog(hDlg);
+ if (needToRefresh) {
+ refreshDialog(hDlg);
+ needToRefresh = 0;
+ }
break;
};
Only in programs/winecfg: appdefaults_flymake.c
diff -ur --exclude-from=diff-exclusions ../head/programs/winecfg/drive.c programs/winecfg/drive.c
--- ../head/programs/winecfg/drive.c 2003-10-09 05:39:01.000000000 +0100
+++ programs/winecfg/drive.c 2003-10-17 17:42:04.000000000 +0100
@@ -120,7 +120,7 @@
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 @@
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 @@
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 @@
}
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 @@
}
-void refreshDriveEditDialog(HWND hDlg) {
+void refreshDriveEditDialog(HWND dialog) {
char *path;
char *type;
char *fs;
@@ -380,19 +400,19 @@
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 @@
}
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 @@
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 @@
}
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 @@
if (label) free(label);
if (device) free(device);
+
updatingUI = FALSE;
return;
diff -ur --exclude-from=diff-exclusions ../head/programs/winecfg/Makefile.in programs/winecfg/Makefile.in
--- ../head/programs/winecfg/Makefile.in 2003-10-03 06:01:33.000000000 +0100
+++ programs/winecfg/Makefile.in 2003-10-16 16:36:43.000000000 +0100
@@ -21,3 +21,6 @@
@MAKE_PROG_RULES@
### Dependencies:
+winecfg.res: En.rc
+
+winecfg.o: winecfg.h
diff -ur --exclude-from=diff-exclusions ../head/programs/winecfg/winecfg programs/winecfg/winecfg
--- ../head/programs/winecfg/winecfg 2003-10-11 12:54:01.000000000 +0100
+++ programs/winecfg/winecfg 2003-09-09 18:20:34.000000000 +0100
@@ -64,9 +64,9 @@
if [ -n "$LD_LIBRARY_PATH" ]
then
- LD_LIBRARY_PATH="$topdir/libs:$LD_LIBRARY_PATH"
+ LD_LIBRARY_PATH="$topdir/dlls:$topdir/libs:$LD_LIBRARY_PATH"
else
- LD_LIBRARY_PATH="$topdir/libs"
+ LD_LIBRARY_PATH="$topdir/dlls:$topdir/libs"
fi
WINEDLLPATH="$topdir/dlls:$topdir/programs"
WINESERVER="$topdir/server/wineserver"
Only in programs/winecfg: #winecfg.h#
diff -ur --exclude-from=diff-exclusions ../head/programs/winecfg/winecfg.h programs/winecfg/winecfg.h
--- ../head/programs/winecfg/winecfg.h 2003-10-09 05:39:01.000000000 +0100
+++ programs/winecfg/winecfg.h 2003-10-16 16:37:47.000000000 +0100
@@ -116,6 +116,6 @@
#define enable(id) EnableWindow(GetDlgItem(dialog, id), 1);
-#define WINE_KEY_ROOT "Software\\Wine\\Wine\\Config"
+#define WINE_KEY_ROOT "Software\\Wine\\WineCfg\\Config"
#endif
diff -ur --exclude-from=diff-exclusions ../head/programs/winecfg/x11drvdlg.c programs/winecfg/x11drvdlg.c
--- ../head/programs/winecfg/x11drvdlg.c 2003-09-30 01:27:55.000000000 +0100
+++ programs/winecfg/x11drvdlg.c 2003-10-17 17:31:21.000000000 +0100
@@ -45,7 +45,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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;
More information about the wine-patches
mailing list