winecfg: Simplify code a bit.

Enable apply button when needed and don't enable when nothing
changed.
This commit is contained in:
Vitaliy Margolen 2006-01-11 21:12:14 +01:00 committed by Alexandre Julliard
parent 848f67e13e
commit dc6ca17838
1 changed files with 10 additions and 28 deletions

View File

@ -270,8 +270,7 @@ static int fill_drives_list(HWND dialog)
for(i = 0; i < 26; i++) for(i = 0; i < 26; i++)
{ {
LVITEM item; LVITEM item;
char *letter = 0; char letter[4];
int len;
/* skip over any unused drives */ /* skip over any unused drives */
if (!drives[i].in_use) if (!drives[i].in_use)
@ -280,34 +279,19 @@ static int fill_drives_list(HWND dialog)
if (drives[i].letter == 'C') if (drives[i].letter == 'C')
drivec_present = TRUE; drivec_present = TRUE;
len = snprintf(letter, 0, "%c:", 'A' + i); snprintf(letter, sizeof(letter), "%c:", 'A' + i);
len++; /* add a byte for the trailing null */
letter = HeapAlloc(GetProcessHeap(), 0, len);
snprintf(letter, len, "%c:", 'A' + i);
memset(&item, 0, sizeof(item)); memset(&item, 0, sizeof(item));
item.mask = LVIF_TEXT; item.mask = LVIF_TEXT | LVIF_PARAM;
item.iItem = count; item.iItem = count;
item.iSubItem = 0; item.iSubItem = 0;
item.pszText = letter; item.pszText = letter;
item.cchTextMax = lstrlen(item.pszText); item.cchTextMax = lstrlen(item.pszText);
item.lParam = (LPARAM) &drives[i];
lv_insert_item(dialog, &item); lv_insert_item(dialog, &item);
lv_set_item_text(dialog, count, 1, drives[i].unixpath);
item.iSubItem = 1;
item.pszText = drives[i].unixpath;
item.cchTextMax = lstrlen(item.pszText);
lv_set_item(dialog, &item);
item.mask = LVIF_PARAM;
item.iSubItem = 0;
item.lParam = (LPARAM) &drives[i];
lv_set_item(dialog, &item);
HeapFree(GetProcessHeap(), 0, letter);
count++; count++;
} }
@ -331,6 +315,8 @@ static void on_options_click(HWND dialog)
set_reg_key(config_key, "", "ShowDotFiles", "Y"); set_reg_key(config_key, "", "ShowDotFiles", "Y");
else else
set_reg_key(config_key, "", "ShowDotFiles", "N"); set_reg_key(config_key, "", "ShowDotFiles", "N");
SendMessage(GetParent(dialog), PSM_CHANGED, 0, 0);
} }
static void on_add_click(HWND dialog) static void on_add_click(HWND dialog)
@ -659,11 +645,8 @@ static void browse_for_folder(HWND dialog)
hr = StrRetToStr(&strSelectedPath, pidlSelectedPath, &pszSelectedPath); hr = StrRetToStr(&strSelectedPath, pidlSelectedPath, &pszSelectedPath);
SHFree(pidlSelectedPath); SHFree(pidlSelectedPath);
if (!SUCCEEDED(hr)) return; if (!SUCCEEDED(hr)) return;
HeapFree(GetProcessHeap(), 0, current_drive->unixpath); set_text(dialog, IDC_EDIT_PATH, pszSelectedPath);
current_drive->unixpath = strdupA(pszSelectedPath);
fill_drives_list(dialog);
update_controls(dialog);
CoTaskMemFree(pszSelectedPath); CoTaskMemFree(pszSelectedPath);
} }
@ -736,8 +719,6 @@ DriveDlgProc (HWND dialog, UINT msg, WPARAM wParam, LPARAM lParam)
break; break;
case BN_CLICKED: case BN_CLICKED:
SendMessage(GetParent(dialog), PSM_CHANGED, 0, 0);
switch (LOWORD(wParam)) switch (LOWORD(wParam))
{ {
case IDC_SHOW_DOT_FILES: case IDC_SHOW_DOT_FILES:
@ -773,6 +754,7 @@ DriveDlgProc (HWND dialog, UINT msg, WPARAM wParam, LPARAM lParam)
case IDC_BUTTON_AUTODETECT: case IDC_BUTTON_AUTODETECT:
autodetect_drives(); autodetect_drives();
fill_drives_list(dialog); fill_drives_list(dialog);
SendMessage(GetParent(dialog), PSM_CHANGED, 0, 0);
break; break;
case IDC_BUTTON_SHOW_HIDE_ADVANCED: case IDC_BUTTON_SHOW_HIDE_ADVANCED: