Fix add application (memory error).

Fix apply button lighting up in audio tab.
Fix video tab(crash when checking desktop, apply button not lighting
up.
Deal with invalid Desktop registry value in video tab.
Fix apply button in libraries tab.
Cleaned up and documented all the conversions in the libraries tab.
This commit is contained in:
Crestez Leonard 2005-01-14 19:48:41 +00:00 committed by Alexandre Julliard
parent c767318895
commit 3e55df3925
5 changed files with 102 additions and 144 deletions

View File

@ -277,13 +277,12 @@ static void on_add_app_click(HWND dialog)
{
HWND listview = GetDlgItem(dialog, IDC_APP_LISTVIEW);
int count = ListView_GetItemCount(listview);
char* new_app;
HeapFree(GetProcessHeap(), 0, current_app);
current_app = strdupA(filetitle);
WINE_TRACE("adding %s\n", current_app);
new_app = strdupA(filetitle);
WINE_TRACE("adding %s\n", new_app);
add_listview_item(listview, current_app, current_app);
add_listview_item(listview, new_app, new_app);
ListView_SetItemState(listview, count, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);

View File

@ -64,22 +64,21 @@ void selectAudioDriver(HWND hDlg, char *drivername)
}
}
void
initAudioDlg (HWND hDlg)
void initAudioDlg (HWND hDlg)
{
char *curAudioDriver = get("Winmm", "Drivers", "winealsa.drv");
const AUDIO_DRIVER *pAudioDrv = NULL;
int i;
char *curAudioDriver = get("Winmm", "Drivers", "winealsa.drv");
const AUDIO_DRIVER *pAudioDrv = NULL;
int i;
if ((pAudioDrv = getAudioDrivers ()))
{
for (i = 0; *pAudioDrv->szName; i++, pAudioDrv++)
{
SendDlgItemMessage (hDlg, IDC_AUDIO_DRIVER, CB_ADDSTRING,
0, (LPARAM) pAudioDrv->szName);
if (!strcmp (pAudioDrv->szDriver, curAudioDriver))
selectAudioDriver(hDlg, (char*)pAudioDrv->szDriver);
}
WINE_TRACE("\n");
pAudioDrv = getAudioDrivers ();
for (i = 0; *pAudioDrv->szName; i++, pAudioDrv++) {
SendDlgItemMessage (hDlg, IDC_AUDIO_DRIVER, CB_ADDSTRING,
0, (LPARAM) pAudioDrv->szName);
if (!strcmp (pAudioDrv->szDriver, curAudioDriver)) {
SendDlgItemMessage(hDlg, IDC_AUDIO_DRIVER, CB_SETCURSEL, i, 0);
}
}
}

View File

@ -47,62 +47,73 @@ struct dll
enum dllmode mode;
};
static enum dllmode parse_override(char *in)
/* Convert a registry string to a dllmode */
static enum dllmode string_to_mode(char *in)
{
int i, j;
int i, j, len;
char *out;
enum dllmode res;
out = HeapAlloc(GetProcessHeap(), 0, strlen(in));
len = strlen(in);
out = HeapAlloc(GetProcessHeap(), 0, len);
/* remove the spaces */
j = 0;
for (i = 0; i < strlen(in); i++)
{
if (in[i] != ' ')
{
out[j] = in[i];
j++;
for (i = j = 0; i <= len; ++i) {
if (in[i] != ' ') {
out[j++] = in[i];
}
}
out[j] = 0;
/* parse the string */
if (strcmp(out, "builtin,native") == 0) return BUILTIN_NATIVE;
else if (strcmp(out, "native,builtin") == 0) return NATIVE_BUILTIN;
else if (strcmp(out, "native") == 0) return NATIVE;
else if (strcmp(out, "builtin") == 0) return BUILTIN;
else if (strcmp(out, "") == 0) return DISABLE;
res = UNKNOWN;
if (strcmp(out, "builtin,native") == 0) res = BUILTIN_NATIVE;
if (strcmp(out, "native,builtin") == 0) res = NATIVE_BUILTIN;
if (strcmp(out, "builtin") == 0) res = BUILTIN;
if (strcmp(out, "native") == 0) res = NATIVE;
if (strcmp(out, "") == 0) res = DISABLE;
return UNKNOWN;
HeapFree(GetProcessHeap(), 0, out);
return res;
}
/* this is used to convert a dllmode to a human readable string. we should read from the translations here */
/* Convert a dllmode to a registry string. */
static char* mode_to_string(enum dllmode mode)
{
if (mode == NATIVE) return "native";
if (mode == BUILTIN) return "builtin";
if (mode == NATIVE_BUILTIN) return "native,builtin";
if (mode == BUILTIN_NATIVE) return "builtin,native";
if (mode == DISABLE) return "";
assert(FALSE);
}
/* Convert a dllmode to a pretty string for display. TODO: use translations. */
static char* mode_to_label(enum dllmode mode)
{
char* res;
WINE_FIXME("translate me");
return mode_to_string(mode);
}
switch (mode) {
case NATIVE:
res = "native";
break;
case BUILTIN:
res = "builtin";
break;
case NATIVE_BUILTIN:
res = "native, builtin";
break;
case BUILTIN_NATIVE:
res = "builtin, native";
break;
case DISABLE:
res = "disabled";
break;
default:
res = "unknown/invalid";
break;
}
/* Convert a control id (IDC_ constant) to a dllmode */
static enum dllmode id_to_mode(DWORD id)
{
if (id == IDC_RAD_BUILTIN) return BUILTIN;
if (id == IDC_RAD_NATIVE) return NATIVE;
if (id == IDC_RAD_NATIVE_BUILTIN) return NATIVE_BUILTIN;
if (id == IDC_RAD_BUILTIN_NATIVE) return BUILTIN_NATIVE;
if (id == IDC_RAD_DISABLE) return DISABLE;
assert( FALSE ); /* should not be reached */
}
return res;
/* Convert a dllmode to a control id (IDC_ constant) */
static DWORD mode_to_id(enum dllmode mode)
{
if (mode == BUILTIN) return IDC_RAD_BUILTIN;
if (mode == NATIVE) return IDC_RAD_NATIVE;
if (mode == NATIVE_BUILTIN) return IDC_RAD_NATIVE_BUILTIN;
if (mode == BUILTIN_NATIVE) return IDC_RAD_BUILTIN_NATIVE;
if (mode == DISABLE) return IDC_RAD_DISABLE;
assert( FALSE ); /* should not be reached */
}
static void set_controls_from_selection(HWND dialog)
@ -127,30 +138,8 @@ static void set_controls_from_selection(HWND dialog)
enable(i);
dll = (struct dll *) SendDlgItemMessage(dialog, IDC_DLLS_LIST, LB_GETITEMDATA, index, 0);
switch (dll->mode)
{
case NATIVE:
id = IDC_RAD_NATIVE;
break;
case BUILTIN:
id = IDC_RAD_BUILTIN;
break;
case NATIVE_BUILTIN:
id = IDC_RAD_NATIVE_BUILTIN;
break;
case BUILTIN_NATIVE:
id = IDC_RAD_BUILTIN_NATIVE;
break;
case DISABLE:
id = IDC_RAD_DISABLE;
break;
case UNKNOWN:
default:
id = -1;
break;
}
id = mode_to_id(dll->mode);
CheckRadioButton(dialog, IDC_RAD_BUILTIN, IDC_RAD_DISABLE, id);
}
@ -204,7 +193,7 @@ static void load_library_settings(HWND dialog)
value = get(keypath("DllOverrides"), *p, NULL);
label = mode_to_label(parse_override(value));
label = mode_to_label(string_to_mode(value));
str = HeapAlloc(GetProcessHeap(), 0, strlen(*p) + 2 + strlen(label) + 2);
strcpy(str, *p);
@ -214,7 +203,7 @@ static void load_library_settings(HWND dialog)
dll = HeapAlloc(GetProcessHeap(), 0, sizeof(struct dll));
dll->name = *p;
dll->mode = parse_override(value);
dll->mode = string_to_mode(value);
index = SendDlgItemMessage(dialog, IDC_DLLS_LIST, LB_ADDSTRING, (WPARAM) -1, (LPARAM) str);
SendDlgItemMessage(dialog, IDC_DLLS_LIST, LB_SETITEMDATA, index, (LPARAM) dll);
@ -263,41 +252,17 @@ static void set_dllmode(HWND dialog, DWORD id)
int sel;
char *str;
#define CONVERT(s) case IDC_RAD_##s: mode = s; break;
switch (id)
{
CONVERT( BUILTIN );
CONVERT( NATIVE );
CONVERT( BUILTIN_NATIVE );
CONVERT( NATIVE_BUILTIN );
CONVERT( DISABLE );
default:
assert( FALSE ); /* should not be reached */
return;
}
#undef CONVERT
mode = id_to_mode(id);
sel = SendDlgItemMessage(dialog, IDC_DLLS_LIST, LB_GETCURSEL, 0, 0);
if (sel == -1) return;
dll = (struct dll *) SendDlgItemMessage(dialog, IDC_DLLS_LIST, LB_GETITEMDATA, sel, 0);
switch (mode)
{
case BUILTIN: str = "builtin"; break;
case NATIVE: str = "native"; break;
case BUILTIN_NATIVE: str = "builtin, native"; break;
case NATIVE_BUILTIN: str = "native, builtin"; break;
case DISABLE: str = ""; break;
default:
assert( FALSE ); /* unreachable */
return;
}
str = mode_to_string(mode);
WINE_TRACE("Setting %s to %s\n", dll->name, str);
SendMessage(GetParent(dialog), PSM_CHANGED, 0, 0);
set(keypath("DllOverrides"), dll->name, str);
load_library_settings(dialog); /* ... and refresh */
@ -316,6 +281,7 @@ static void on_add_click(HWND dialog)
WINE_TRACE("Adding %s as native, builtin", buffer);
SendMessage(GetParent(dialog), PSM_CHANGED, 0, 0);
set(keypath("DllOverrides"), buffer, "native,builtin");
load_library_settings(dialog);
@ -336,6 +302,7 @@ static void on_remove_click(HWND dialog)
SendDlgItemMessage(dialog, IDC_DLLS_LIST, LB_DELETESTRING, sel, 0);
SendMessage(GetParent(dialog), PSM_CHANGED, 0, 0);
set(keypath("DllOverrides"), dll->name, NULL);
HeapFree(GetProcessHeap(), 0, dll->name);

View File

@ -253,7 +253,7 @@ char *get(char *path, char *name, char *def)
if (strcasecmp(name, s->name) != 0) continue;
WINE_TRACE("found %s:%s in settings list, returning %s\n", path, name, s->value);
return strdupA(s->value);
return s->value ? strdupA(s->value) : NULL;
}
/* no, so get from the registry */

View File

@ -46,15 +46,28 @@ void update_gui_for_desktop_mode(HWND dialog) {
/* do we have desktop mode enabled? */
if (exists(keypath("x11drv"), "Desktop"))
{
char* buf, *bufindex;
CheckDlgButton(dialog, IDC_ENABLE_DESKTOP, BST_CHECKED);
enable(IDC_DESKTOP_WIDTH);
enable(IDC_DESKTOP_HEIGHT);
enable(IDC_DESKTOP_SIZE);
enable(IDC_DESKTOP_BY);
SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_WIDTH), "640");
SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_HEIGHT), "480");
buf = get(keypath("x11drv"), "Desktop", "640x480");
bufindex = strchr(buf, 'x');
if (bufindex) {
*bufindex = 0;
++bufindex;
SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_WIDTH), buf);
SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_HEIGHT), bufindex);
} else {
WINE_TRACE("Desktop registry entry is malformed");
SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_WIDTH), "640");
SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_HEIGHT), "480");
}
HeapFree(GetProcessHeap(), 0, buf);
}
else
{
@ -74,31 +87,12 @@ void update_gui_for_desktop_mode(HWND dialog) {
static void init_dialog (HWND dialog)
{
static char *default_desktop = "640x480";
char *buf;
char *bufindex;
char* buf;
update_gui_for_desktop_mode(dialog);
updating_ui = TRUE;
/* desktop size */
buf = get(keypath("x11drv"), "Desktop", default_desktop);
bufindex = strchr(buf, 'x');
if(!bufindex) /* handle invalid "Desktop" values */
{
HeapFree(GetProcessHeap(), 0, buf);
buf = strdupA(default_desktop);
bufindex = strchr(buf, 'x');
}
*bufindex = '\0';
bufindex++;
SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_WIDTH), buf);
SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_HEIGHT), bufindex);
HeapFree(GetProcessHeap(), 0, buf);
SendDlgItemMessage(dialog, IDC_SCREEN_DEPTH, CB_RESETCONTENT, 0, 0);
SendDlgItemMessage(dialog, IDC_SCREEN_DEPTH, CB_ADDSTRING, 0, (LPARAM) "8 bit");
SendDlgItemMessage(dialog, IDC_SCREEN_DEPTH, CB_ADDSTRING, 0, (LPARAM) "16 bit");
@ -148,14 +142,12 @@ static void set_from_desktop_edits(HWND dialog) {
width = get_text(dialog, IDC_DESKTOP_WIDTH);
height = get_text(dialog, IDC_DESKTOP_HEIGHT);
if (strcmp(width, "") == 0)
{
if (width == NULL || strcmp(width, "") == 0) {
HeapFree(GetProcessHeap(), 0, width);
width = strdupA("640");
}
if (strcmp(height, "") == 0)
{
if (height == NULL || strcmp(height, "") == 0) {
HeapFree(GetProcessHeap(), 0, height);
height = strdupA("480");
}
@ -173,10 +165,8 @@ void on_enable_desktop_clicked(HWND dialog) {
WINE_TRACE("\n");
if (IsDlgButtonChecked(dialog, IDC_ENABLE_DESKTOP) == BST_CHECKED) {
/* it was just unchecked, so read the values of the edit boxes, set the config value */
set_from_desktop_edits(dialog);
set_from_desktop_edits(dialog);
} else {
/* it was just checked, so remove the config values */
set(keypath("x11drv"), "Desktop", NULL);
}
@ -196,7 +186,7 @@ static void on_screen_depth_changed(HWND dialog) {
}
static void on_dx_mouse_grab_clicked(HWND dialog) {
if (IsDlgButtonChecked(dialog, IDC_DX_MOUSE_GRAB) == BST_CHECKED)
if (IsDlgButtonChecked(dialog, IDC_DX_MOUSE_GRAB) == BST_CHECKED)
set(keypath("x11drv"), "DXGrab", "Y");
else
set(keypath("x11drv"), "DXGrab", "N");
@ -224,6 +214,7 @@ GraphDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
case WM_COMMAND:
switch(HIWORD(wParam)) {
case EN_CHANGE: {
if (updating_ui) break;
SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
if ( ((LOWORD(wParam) == IDC_DESKTOP_WIDTH) || (LOWORD(wParam) == IDC_DESKTOP_HEIGHT)) && !updating_ui )
set_from_desktop_edits(hDlg);
@ -231,6 +222,7 @@ GraphDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
case BN_CLICKED: {
if (updating_ui) break;
SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
switch(LOWORD(wParam)) {
case IDC_ENABLE_DESKTOP: on_enable_desktop_clicked(hDlg); break;
case IDC_DX_MOUSE_GRAB: on_dx_mouse_grab_clicked(hDlg); break;
@ -239,6 +231,7 @@ GraphDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
break;
}
case CBN_SELCHANGE: {
SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
if (LOWORD(wParam) == IDC_SCREEN_DEPTH) on_screen_depth_changed(hDlg);
break;
}