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

- introduce keypath() function

- rewrite and clean up appdefaults.c, use a listview rather than treeview - usability tweak: reverse windows version combo so more recent versions come first - usability tweak: improve the add application open dialog box - add accelerator keys - enable/disable controls correctly - begin to standardise on underscore_style for consistency with the rest of wine - comment out the translations for now, the UI will be changing more - begin phasing out libc malloc in favour of the win32 heap
parent c10e3cbf
......@@ -4,6 +4,7 @@
*
* Copyright 2002 Jaco Greeff
* Copyright 2003 Dimitrie O. Paun
* Copyright 2003-2004 Mike Hearn
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -42,15 +43,16 @@ STYLE WS_CHILD | WS_DISABLED
FONT 8, "MS Shell Dlg"
BEGIN
GROUPBOX "Application Settings",IDC_STATIC, 8,4,244,240
LTEXT "Wine provides the ability for Windows applications to mimic various Windows versions and styles",
LTEXT "Wine can mimic different Windows versions for each application.",
IDC_STATIC,15,20,227,20
CONTROL "Applications",IDC_APP_TREEVIEW,"SysTreeView32",WS_BORDER | WS_TABSTOP | TVS_LINESATROOT | TVS_HASLINES | TVS_SHOWSELALWAYS | TVS_HASBUTTONS, 15,40,142,145
PUSHBUTTON "Add application...",IDC_APP_ADDAPP, 163,40,82,60
PUSHBUTTON "Remove application",IDC_APP_REMOVEAPP, 163,125,82,60
LTEXT "Windows Version:",IDC_STATIC,17,192,58,8
LTEXT "DOS Version:",IDC_STATIC,17,211,57,8
COMBOBOX IDC_WINVER,83,190,158,56,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_DOSVER,83,208,158,56,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Applications",IDC_APP_LISTVIEW,"SysListView32",WS_BORDER | WS_TABSTOP | LVS_LIST | LVS_SINGLESEL | LVS_SHOWSELALWAYS,
15,40,230,140
PUSHBUTTON "&Add application...",IDC_APP_ADDAPP, 90,184,75,14
PUSHBUTTON "&Remove application",IDC_APP_REMOVEAPP, 170,184,75,14
LTEXT "&Windows Version:",IDC_STATIC,17,204,58,8
COMBOBOX IDC_WINVER,83,202,163,56,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "&DOS Version:",IDC_STATIC,17,223,57,8
COMBOBOX IDC_DOSVER,83,224,163,56,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
END
IDD_GRAPHCFG DIALOG DISCARDABLE 0, 0, 260, 250
......
......@@ -25,35 +25,25 @@
#include "properties.h"
static VERSION_DESC sWinVersions[] = {
{"", "Use default(Global setting)"},
{"win20", "Windows 2.0"},
{"win30", "Windows 3.0"},
{"win31", "Windows 3.1"},
{"nt351", "Windows NT 3.5"},
{"nt40", "Windows NT 4.0"},
{"win95", "Windows 95"},
{"win98", "Windows 98"},
{"winme", "Windows ME"},
{"win2k", "Windows 2000"},
{"winxp", "Windows XP"},
{"win2003", "Windows 2003"},
{"winxp", "Windows XP"},
{"win2k", "Windows 2000"},
{"winme", "Windows ME"},
{"win98", "Windows 98"},
{"win95", "Windows 95"},
{"nt40", "Windows NT 4.0"},
{"nt351", "Windows NT 3.5"},
{"win31", "Windows 3.1"},
{"win30", "Windows 3.0"},
{"win20", "Windows 2.0"},
{"", ""}
};
static VERSION_DESC sDOSVersions[] = {
{"", "Use default(Global setting)"},
{"6.22", "MS-DOS 6.22"},
{"", ""}
};
#if 0
static VERSION_DESC sWineDrivers[] = {
{"x11drv", "X11 Interface"},
{"ttydrv", "TTY Interface"},
{"", ""}
};
#endif
static DLL_DESC sDLLType[] = {
{"oleaut32", DLL_BUILTIN},
{"ole32", DLL_BUILTIN},
......
......@@ -4,6 +4,7 @@
* Copyright 2002 Jaco Greeff
* Copyright 2003 Dimitrie O. Paun
* Copyright 2003 Mark Westcott
* Copyright 2004 Mike Hearn
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -119,7 +120,7 @@
#define IDC_DOUBLE_BUFFER 1104
/* applications tab */
#define IDC_APP_TREEVIEW 1200
#define IDC_APP_LISTVIEW 1200
#define IDC_APP_ADDAPP 1201
#define IDC_APP_REMOVEAPP 1202
......
......@@ -3,7 +3,7 @@
*
* Copyright 2002 Jaco Greeff
* Copyright 2003 Dimitrie O. Paun
* Copyright 2003 Mike Hearn
* Copyright 2003-2004 Mike Hearn
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -86,7 +86,7 @@ char *getConfigValue (const char *subkey, const char *valueName, const char *def
if( res==ERROR_FILE_NOT_FOUND )
{
WINE_TRACE("Section key not present - using default\n");
return strdup(defaultResult);
return defaultResult ? strdup(defaultResult) : NULL;
}
else
{
......@@ -98,7 +98,7 @@ char *getConfigValue (const char *subkey, const char *valueName, const char *def
res = RegQueryValueExA( hSubKey, valueName, NULL, NULL, NULL, &dataLength);
if( res == ERROR_FILE_NOT_FOUND ) {
WINE_TRACE("Value not present - using default\n");
buffer = strdup(defaultResult);
buffer = defaultResult ? strdup(defaultResult) : NULL;
goto end;
} else if( res!=ERROR_SUCCESS ) {
WINE_ERR("Couldn't query value's length (res=%ld)\n", res );
......@@ -123,7 +123,8 @@ end:
}
/*****************************************************************************
* setConfigValue : Sets a configuration key in the registry. Section will be created if it doesn't already exist
* setConfigValue : Sets a configuration key in the registry. Section
* will be created if it doesn't already exist
*
* HKEY hCurrent : the registry key that the configuration is rooted at
* const char *subKey : the name of the config section
......@@ -285,6 +286,28 @@ void processTransQueue(void)
/* ================================== utility functions ============================ */
char *currentApp = NULL; /* the app we are currently editing, or NULL if editing global */
/* returns a registry key path suitable for passing to addTransaction */
char *keypath(char *section)
{
static char *result = NULL;
if (result) release(result);
if (currentApp)
{
result = alloc(strlen("AppDefaults\\") + strlen(currentApp) + 2 /* \\ */ + strlen(section) + 1 /* terminator */);
sprintf(result, "AppDefaults\\%s\\%s", currentApp, section);
}
else
{
result = strdupA(section);
}
return result;
}
/* returns a string with the window text of the dialog item. user is responsible for freeing the result */
char *getDialogItemText(HWND hDlg, WORD controlID) {
HWND item = GetDlgItem(hDlg, controlID);
......
......@@ -3,6 +3,7 @@
*
* Copyright 2002 Jaco Greeff
* Copyright 2003 Dimitrie O. Paun
* Copyright 2004 Mike Hearn
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -67,9 +68,14 @@ extern int instantApply; /* non-zero means apply all changes instantly */
#define EDITING_APP 1
extern int appSettings; /* non-zero means we are editing appdefault settings */
/* returns a string of the form AppDefaults\\appname.exe\\section */
/* no explicit free is needed of the string returned by this function */
char *getSectionForApp(char *section);
extern char *currentApp; /* NULL means editing global settings */
/* returns a string of the form "AppDefaults\\appname.exe\\section", or just "section" if
* the user is editing the global settings.
*
* no explicit free is needed of the string returned by this function
*/
char *keypath(char *section);
/* Commits a transaction to the registry */
void processTransaction(struct transaction *trans);
......@@ -91,6 +97,7 @@ void destroyTransaction(struct transaction *trans);
int initialize(void);
extern HKEY configKey;
/* don't use these directly! */
int setConfigValue (const char *subkey, const char *valueName, const char *value);
char *getConfigValue (const char *subkey, const char *valueName, const char *defaultResult);
HRESULT doesConfigValueExist (const char *subkey, const char *valueName);
......@@ -118,8 +125,18 @@ INT_PTR CALLBACK AudioDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
char *getDialogItemText(HWND hDlg, WORD controlID);
#define disable(id) EnableWindow(GetDlgItem(dialog, id), 0);
#define enable(id) EnableWindow(GetDlgItem(dialog, id), 1);
#define alloc(size) HeapAlloc(GetProcessHeap(), 0, size);
#define release(ptr) HeapFree(GetProcessHeap(), 0, ptr);
void PRINTERROR(void); /* WINE_TRACE() the plaintext error message from GetLastError() */
/* returns a string in the win32 heap */
static inline char *strdupA(char *s)
{
char *r = alloc(strlen(s));
return strcpy(r, s);
}
#define WINE_KEY_ROOT "Software\\Wine\\Wine\\Config"
#endif
......@@ -28,12 +28,12 @@
#include "resource.h"
#include "En.rc"
#include "Es.rc"
#include "It.rc"
#include "Nl.rc"
#include "Pt.rc"
#include "Ru.rc"
#include "Si.rc"
/* #include "Es.rc" */
/* #include "It.rc" */
/* #include "Nl.rc" */
/* #include "Pt.rc" */
/* #include "Ru.rc" */
/* #include "Si.rc" */
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
......
......@@ -2,7 +2,7 @@
* Graphics configuration code
*
* Copyright 2003 Mark Westcott
* Copyright 2003 Mike Hearn
* Copyright 2003-2004 Mike Hearn
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -35,21 +35,10 @@
WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
#define RES_MAXLEN 5 /* the maximum number of characters in a screen dimension. 5 digits should be plenty, what kind of crazy person runs their screen >10,000 pixels across? */
#define section (appSettings == EDITING_GLOBAL ? "graphics" : (getSectionForApp("graphics")))
int updatingUI;
int appSettings = EDITING_GLOBAL; /* start by editing global */
char *currentApp; /* the app we are currently editing, or NULL if editing global */
char *getSectionForApp(char *pSection)
{
static char *lastResult = NULL;
if (lastResult) HeapFree(GetProcessHeap(), 0, lastResult);
lastResult = HeapAlloc(GetProcessHeap(), 0, strlen("AppDefaults\\") + strlen(currentApp) + 2 /* \\ */ + strlen(pSection) + 1 /* terminator */);
sprintf(lastResult, "AppDefaults\\%s\\%s", currentApp, pSection);
return lastResult;
}
void updateGUIForDesktopMode(HWND dialog) {
WINE_TRACE("\n");
......@@ -57,7 +46,7 @@ void updateGUIForDesktopMode(HWND dialog) {
updatingUI = TRUE;
/* do we have desktop mode enabled? */
if (doesConfigValueExist(section, "Desktop") == S_OK) {
if (doesConfigValueExist(keypath("x11drv"), "Desktop") == S_OK) {
CheckDlgButton(dialog, IDC_ENABLE_DESKTOP, BST_CHECKED);
/* enable the controls */
enable(IDC_DESKTOP_WIDTH);
......@@ -95,7 +84,7 @@ void initGraphDlg (HWND hDlg)
updatingUI = TRUE;
/* desktop size */
buf = getConfigValue(section, "Desktop", default_desktop);
buf = getConfigValue(keypath("x11drv"), "Desktop", default_desktop);
bufindex = strchr(buf, 'x');
if(!bufindex) /* handle invalid "Desktop" values */
{
......@@ -115,7 +104,7 @@ void initGraphDlg (HWND hDlg)
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(section, "ScreenDepth", "24");
buf = getConfigValue(keypath("x11drv"), "ScreenDepth", "24");
if (strcmp(buf, "8") == 0)
SendDlgItemMessage(hDlg, IDC_SCREEN_DEPTH, CB_SETCURSEL, 0, 0);
else if (strcmp(buf, "16") == 0)
......@@ -131,14 +120,14 @@ void initGraphDlg (HWND hDlg)
SendDlgItemMessage(hDlg, IDC_DESKTOP_WIDTH, EM_LIMITTEXT, RES_MAXLEN, 0);
SendDlgItemMessage(hDlg, IDC_DESKTOP_HEIGHT, EM_LIMITTEXT, RES_MAXLEN, 0);
buf = getConfigValue(section, "DXGrab", "Y");
buf = getConfigValue(keypath("x11drv"), "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(section, "DesktopDoubleBuffered", "Y");
buf = getConfigValue(keypath("x11drv"), "DesktopDoubleBuffered", "Y");
if (IS_OPTION_TRUE(*buf))
CheckDlgButton(hDlg, IDC_DOUBLE_BUFFER, BST_CHECKED);
else
......@@ -166,7 +155,7 @@ void setFromDesktopSizeEdits(HWND hDlg) {
if (strcmp(height, "") == 0) strcpy(height, "480");
sprintf(newStr, "%sx%s", width, height);
addTransaction(section, "Desktop", ACTION_SET, newStr);
addTransaction(keypath("x11drv"), "Desktop", ACTION_SET, newStr);
free(width);
free(height);
......@@ -180,7 +169,7 @@ void onEnableDesktopClicked(HWND hDlg) {
setFromDesktopSizeEdits(hDlg);
} else {
/* it was just checked, so remove the config values */
addTransaction(section, "Desktop", ACTION_REMOVE, NULL);
addTransaction(keypath("x11drv"), "Desktop", ACTION_REMOVE, NULL);
}
updateGUIForDesktopMode(hDlg);
}
......@@ -193,23 +182,23 @@ void onScreenDepthChanged(HWND hDlg) {
if (updatingUI) return;
*spaceIndex = '\0';
addTransaction(section, "ScreenDepth", ACTION_SET, newvalue);
addTransaction(keypath("x11drv"), "ScreenDepth", ACTION_SET, newvalue);
free(newvalue);
}
void onDXMouseGrabClicked(HWND hDlg) {
if (IsDlgButtonChecked(hDlg, IDC_DX_MOUSE_GRAB) == BST_CHECKED)
addTransaction(section, "DXGrab", ACTION_SET, "Y");
addTransaction(keypath("x11drv"), "DXGrab", ACTION_SET, "Y");
else
addTransaction(section, "DXGrab", ACTION_SET, "N");
addTransaction(keypath("x11drv"), "DXGrab", ACTION_SET, "N");
}
void onDoubleBufferClicked(HWND hDlg) {
if (IsDlgButtonChecked(hDlg, IDC_DOUBLE_BUFFER) == BST_CHECKED)
addTransaction(section, "DesktopDoubleBuffered", ACTION_SET, "Y");
addTransaction(keypath("x11drv"), "DesktopDoubleBuffered", ACTION_SET, "Y");
else
addTransaction(section, "DesktopDoubleBuffered", ACTION_SET, "N");
addTransaction(keypath("x11drv"), "DesktopDoubleBuffered", ACTION_SET, "N");
}
INT_PTR CALLBACK
......
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