Commit 7d8711e1 authored by Mike Hearn's avatar Mike Hearn Committed by Alexandre Julliard

- More heapification.

- Split drive code into core, UI and autodetect. - Implement drive autodetection. - Slight redesign of drive tab. - Code cleanup.
parent 14de4815
......@@ -26,23 +26,23 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
IDD_ABOUTCFG DIALOGEX 0, 0, 260, 250
STYLE WS_CHILD
FONT 8, "MS Shell Dlg"
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "Wine Version:",IDC_STATIC,119,17,55,8
LTEXT "CVS",IDC_WINEVER,179,17,56,8
CONTROL IDB_WINE,IDC_STATIC,"Static",SS_BITMAP | SS_CENTERIMAGE |
SS_REALSIZEIMAGE | WS_BORDER,15,17,157,111, WS_EX_TRANSPARENT
LTEXT "http://www.winehq.org/",IDC_STATIC,119,31,106,8
GROUPBOX "Information",IDC_STATIC,8,4,244,106
GROUPBOX " Information ",IDC_STATIC,8,4,244,106
CTEXT "This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.",
IDC_STATIC,119,44,124,59
END
IDD_APPCFG DIALOG DISCARDABLE 0, 0, 260, 250
STYLE WS_CHILD | WS_DISABLED
FONT 8, "MS Shell Dlg"
FONT 8, "MS Sans Serif"
BEGIN
GROUPBOX "Application Settings",IDC_STATIC, 8,4,244,240
GROUPBOX " Application Settings ",IDC_STATIC, 8,4,244,240
LTEXT "Wine can mimic different Windows versions for each application.",
IDC_STATIC,15,20,227,20
CONTROL "Applications",IDC_APP_LISTVIEW,"SysListView32",WS_BORDER | WS_TABSTOP | LVS_LIST | LVS_SINGLESEL | LVS_SHOWSELALWAYS,
......@@ -57,7 +57,7 @@ END
IDD_GRAPHCFG DIALOG DISCARDABLE 0, 0, 260, 250
STYLE WS_CHILD | WS_DISABLED
FONT 8, "MS Shell Dlg"
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "Screen color depth: ",IDC_STATIC,8,10,70,30
COMBOBOX IDC_SCREEN_DEPTH,80,8,170,70,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
......@@ -81,9 +81,9 @@ END
IDD_DLLCFG DIALOG DISCARDABLE 0, 0, 260, 250
STYLE WS_CHILD | WS_DISABLED
FONT 8, "MS Shell Dlg"
FONT 8, "MS Sans Serif"
BEGIN
GROUPBOX "DLL Overrides",IDC_STATIC,8,4,244,240
GROUPBOX " DLL Overrides ",IDC_STATIC,8,4,244,240
LTEXT "Dynamic Link Libraries can be specified individually to be either builtin (provided by Wine) or native (taken from Windows or provided by the application)."
, IDC_STATIC,15,17,228,32
LISTBOX IDC_DLLS_LIST,15,50,142,187,WS_BORDER | WS_TABSTOP | WS_VSCROLL
......@@ -98,62 +98,44 @@ BEGIN
PUSHBUTTON "&Remove DLL override",IDC_DLLS_REMOVEDLL,163,224,82,14
END
IDD_SYSTEMCFG DIALOG DISCARDABLE 0, 0, 260, 250
STYLE WS_CHILD
FONT 8, "MS Shell Dlg"
BEGIN
GROUPBOX "Drives",IDC_STATIC,8,4,244,120
LISTBOX IDC_LIST_DRIVES,15,23,179,90,WS_VSCROLL
PUSHBUTTON "&Add",IDC_DRIVE_ADD,197,22,50,22
PUSHBUTTON "&Remove",IDC_DRIVE_REMOVE,197,51,50,22
PUSHBUTTON "&Edit",IDC_DRIVE_EDIT,197,80,50,22
END
IDD_DRIVECFG DIALOG DISCARDABLE 0, 0, 260, 250
STYLE WS_CHILD | WS_DISABLED
FONT 8, "MS Shell Dlg"
FONT 8, "MS Sans Serif"
BEGIN
GROUPBOX "Drive Mappings",IDC_STATIC,7,107,246,112
LISTBOX IDC_LIST_DRIVES,14,118,232,76,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Add...",IDC_BUTTON_ADD,14,199,37,14
PUSHBUTTON "Remove",IDC_BUTTON_REMOVE,55,199,37,14
PUSHBUTTON "Edit...",IDC_BUTTON_EDIT,97,199,37,14
PUSHBUTTON "Autodetect...",IDC_BUTTON_AUTODETECT,197,199,49,14
LTEXT "WARNING: You don't seem to have a C drive defined. Click 'Add Drive' to add one.", IDS_DRIVE_NO_C, 7,223,250,110
END
GROUPBOX " Drive mappings ",IDC_STATIC,8,4,244,240
LISTBOX IDC_LIST_DRIVES,15,18,232,76,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "&Add...",IDC_BUTTON_ADD,15,98,37,14
PUSHBUTTON "&Remove",IDC_BUTTON_REMOVE,56,98,37,14
PUSHBUTTON "Auto&detect...",IDC_BUTTON_AUTODETECT,197,98,49,14
IDD_DRIVE_EDIT DIALOG DISCARDABLE 0, 0, 203, 169
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Drive Configuration"
FONT 8, "MS Shell Dlg"
BEGIN
DEFPUSHBUTTON "&Ok",ID_BUTTON_OK,145,150,50,16
LTEXT "Letter:",IDC_STATIC,5,23,26,9
EDITTEXT IDC_EDIT_LABEL,63,108,78,13,ES_AUTOHSCROLL
LTEXT "Label:",IDC_STATIC_LABEL,33,111,29,12
LTEXT "Serial:",IDC_STATIC_SERIAL,33,127,29,12
EDITTEXT IDC_EDIT_SERIAL,63,124,78,13,ES_AUTOHSCROLL
LTEXT "Type:",IDC_STATIC_TYPE,5,39,21,10
EDITTEXT IDC_EDIT_PATH,31,5,117,13,ES_AUTOHSCROLL
LTEXT "Path:",IDC_STATIC,5,8,20,9
COMBOBOX IDC_COMBO_LETTER,31,20,77,60,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Browse...",IDC_BUTTON_BROWSE_PATH,154,5,40,13
COMBOBOX IDC_COMBO_TYPE,31,36,77,60,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Show Advanced",IDC_BUTTON_SHOW_HIDE_ADVANCED,134,34,60,16
CONTROL "Autodetect from Device:",IDC_RADIO_AUTODETECT,"Button",
BS_AUTORADIOBUTTON,21,69,93,10
EDITTEXT IDC_EDIT_DEVICE,33,79,108,13,ES_AUTOHSCROLL
PUSHBUTTON "Browse...",IDC_BUTTON_BROWSE_DEVICE,148,79,40,13
CONTROL "Manually Assign:",IDC_RADIO_ASSIGN,"Button",
BS_AUTORADIOBUTTON,21,98,69,10
GROUPBOX "Label and serial number",IDC_BOX_LABELSERIAL,6,58,189,85
/* editing drive details */
LTEXT "&Path:",IDC_STATIC,15,123,20,9
EDITTEXT IDC_EDIT_PATH,41,120,160,13,ES_AUTOHSCROLL | WS_TABSTOP
PUSHBUTTON "&Browse...",IDC_BUTTON_BROWSE_PATH,206,120,40,13
LTEXT "&Type:",IDC_STATIC_TYPE,15,138,21,10
COMBOBOX IDC_COMBO_TYPE,41,135,77,60,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Label and serial number",IDC_LABELSERIAL_STATIC,15,155,55,10
PUSHBUTTON "&Show Advanced",IDC_BUTTON_SHOW_HIDE_ADVANCED,186,136,60,13
CONTROL "Autodetect &from Device:",IDC_RADIO_AUTODETECT,"Button",
BS_AUTORADIOBUTTON,15,166,93,10
EDITTEXT IDC_EDIT_DEVICE,27,176,174,13,ES_AUTOHSCROLL
PUSHBUTTON "Bro&wse...",IDC_BUTTON_BROWSE_DEVICE,206,176,40,13
CONTROL "&Manually Assign:",IDC_RADIO_ASSIGN,"Button",
BS_AUTORADIOBUTTON,15,195,69,10
LTEXT "&Label:",IDC_STATIC_LABEL,33,208,29,12
EDITTEXT IDC_EDIT_LABEL,63,205,78,13,ES_AUTOHSCROLL | WS_TABSTOP
LTEXT "S&erial:",IDC_STATIC_SERIAL,33,225,29,12
EDITTEXT IDC_EDIT_SERIAL,63,221,78,13,ES_AUTOHSCROLL | WS_TABSTOP
END
IDD_AUDIOCFG DIALOG DISCARDABLE 0, 0, 260, 250
STYLE WS_CHILD | WS_DISABLED
FONT 8, "MS Shell Dlg"
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "Audio driver: ",IDC_STATIC,10,20,60,8
COMBOBOX IDC_AUDIO_DRIVER,70,18,85,85,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
......
......@@ -10,6 +10,8 @@ C_SRCS = \
appdefaults.c \
audio.c \
drive.c \
drivedetect.c \
driveui.c \
libraries.c \
main.c \
properties.c \
......
......@@ -105,7 +105,7 @@ init_comboboxes (HWND dialog)
SendDlgItemMessage(dialog, IDC_DOSVER, CB_RESETCONTENT, 0, 0);
/* add the default entries (automatic) which correspond to no setting */
if (currentApp)
if (current_app)
{
SendDlgItemMessage(dialog, IDC_WINVER, CB_ADDSTRING, 0, (LPARAM) "Use global settings");
SendDlgItemMessage(dialog, IDC_DOSVER, CB_ADDSTRING, 0, (LPARAM) "Use global settings");
......@@ -173,7 +173,7 @@ static void init_appsheet(HWND dialog)
size = sizeof(appname);
while (RegEnumKeyEx(key, i, appname, &size, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
{
add_listview_item(listview, appname, strdup(appname));
add_listview_item(listview, appname, strdupA(appname));
i++;
size = sizeof(appname);
......@@ -219,7 +219,7 @@ static int get_listview_selection(HWND listview)
static void on_selection_change(HWND dialog, HWND listview)
{
LVITEM item;
char *oldapp = currentApp;
char *oldapp = current_app;
WINE_TRACE("()\n");
......@@ -230,23 +230,23 @@ static void on_selection_change(HWND dialog, HWND listview)
ListView_GetItem(listview, &item);
currentApp = (char *) item.lParam;
current_app = (char *) item.lParam;
if (currentApp)
if (current_app)
{
WINE_TRACE("currentApp is now %s\n", currentApp);
WINE_TRACE("current_app is now %s\n", current_app);
enable(IDC_APP_REMOVEAPP);
}
else
{
WINE_TRACE("currentApp=NULL, editing global settings\n");
WINE_TRACE("current_app=NULL, editing global settings\n");
/* focus will never be on the button in this callback so it's safe */
disable(IDC_APP_REMOVEAPP);
}
/* reset the combo boxes if we changed from/to global/app-specific */
if ((oldapp && !currentApp) || (!oldapp && currentApp))
if ((oldapp && !current_app) || (!oldapp && current_app))
init_comboboxes(dialog);
update_comboboxes(dialog);
......@@ -276,12 +276,12 @@ static void on_add_app_click(HWND dialog)
HWND listview = GetDlgItem(dialog, IDC_APP_LISTVIEW);
int count = ListView_GetItemCount(listview);
if (currentApp) free(currentApp);
currentApp = strdup(filetitle);
if (current_app) HeapFree(GetProcessHeap(), 0, current_app);
current_app = strdupA(filetitle);
WINE_TRACE("adding %s\n", currentApp);
WINE_TRACE("adding %s\n", current_app);
add_listview_item(listview, currentApp, currentApp);
add_listview_item(listview, current_app, current_app);
ListView_SetItemState(listview, count, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
......@@ -375,9 +375,11 @@ AppDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
break;
case WM_COMMAND:
switch(HIWORD(wParam)) {
switch(HIWORD(wParam))
{
case CBN_SELCHANGE:
switch(LOWORD(wParam)) {
switch(LOWORD(wParam))
{
case IDC_WINVER:
on_winver_change(hDlg);
break;
......@@ -386,7 +388,8 @@ AppDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
break;
}
case BN_CLICKED:
switch(LOWORD(wParam)) {
switch(LOWORD(wParam))
{
case IDC_APP_ADDAPP:
on_add_app_click(hDlg);
break;
......
/*
* Drive autodetection code
*
* 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
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <wine/debug.h>
#include <wine/library.h>
#include "winecfg.h"
#include <stdio.h>
#include <mntent.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/stat.h>
#include <winbase.h>
WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
BOOL gui_mode = TRUE;
static long working_mask = 0;
static char *ignored_fstypes[] = {
"devpts",
"tmpfs",
"proc",
"sysfs",
"swap",
"usbdevfs",
"rpc_pipefs",
NULL
};
static BOOL should_ignore_fstype(char *type)
{
char **s;
for (s = ignored_fstypes; *s; s++)
if (!strcmp(*s, type)) return TRUE;
return FALSE;
}
static BOOL is_drive_defined(char *path)
{
int i;
for (i = 0; i < 26; i++)
if (drives[i].in_use && !strcmp(drives[i].unixpath, path)) return TRUE;
return FALSE;
}
/* returns Z + 1 if there are no more available letters */
static char allocate_letter()
{
char letter;
for (letter = 'C'; letter <= 'Z'; letter++)
if ((DRIVE_MASK_BIT(letter) & working_mask) != 0) break;
return letter;
}
#define FSTAB_OPEN 1
#define NO_MORE_LETTERS 2
#define NO_ROOT 3
#define NO_DRIVE_C 4
static void report_error(int code)
{
char *buffer;
int len;
switch (code)
{
case FSTAB_OPEN:
if (gui_mode)
{
static const char *s = "Could not open your mountpoint description table.\n\nOpening of /etc/fstab failed: %s";
len = snprintf(NULL, 0, s, strerror(errno));
buffer = HeapAlloc(GetProcessHeap(), 0, len + 1);
snprintf(buffer, len, s, strerror(errno));
MessageBox(NULL, s, "", MB_OK | MB_ICONEXCLAMATION);
HeapFree(GetProcessHeap(), 0, buffer);
}
else
{
fprintf(stderr, "winecfg: could not open fstab: %s", strerror(errno));
}
break;
case NO_MORE_LETTERS:
if (gui_mode) MessageBox(NULL, "No more letters are available to auto-detect available drives with.", "", MB_OK | MB_ICONEXCLAMATION);
fprintf(stderr, "winecfg: no more available letters while scanning /etc/fstab");
break;
case NO_ROOT:
if (gui_mode) MessageBox(NULL, "Could not ensure that the root directory was mapped.\n\n"
"This can happen if you run out of drive letters. "
"It's important to have the root directory mapped, otherwise Wine"
"will not be able to always find the programs you want to run. "
"Try unmapping a drive letter then trying again.", "",
MB_OK | MB_ICONEXCLAMATION);
else fprintf(stderr, "winecfg: unable to map root drive\n");
break;
case NO_DRIVE_C:
if (gui_mode)
MessageBox(NULL, "No virtual drive C mapped\n\nTry running wineprefixcreate", "", MB_OK | MB_ICONEXCLAMATION);
else
fprintf(stderr, "winecfg: no drive_c directory\n");
}
}
static void ensure_root_is_mapped()
{
int i;
BOOL mapped = FALSE;
for (i = 0; i < 26; i++)
if (drives[i].in_use && !strcmp(drives[i].unixpath, "/")) mapped = TRUE;
if (!mapped)
{
/* work backwards from Z, trying to map it */
char letter;
for (letter = 'Z'; letter >= 'A'; letter--)
{
if (drives[letter - 'A'].in_use) continue;
add_drive(letter, "/", "System", 0, DRIVE_FIXED);
WINE_TRACE("allocated drive %c as the root drive\n", letter);
}
if (letter == ('A' - 1)) report_error(NO_ROOT);
}
}
static void ensure_drive_c_is_mapped()
{
struct stat buf;
const char *configdir = wine_get_config_dir();
int len;
char *drive_c_dir;
if (drives[2].in_use) return;
len = snprintf(NULL, 0, "%s/../drive_c", configdir);
drive_c_dir = HeapAlloc(GetProcessHeap(), 0, len);
snprintf(drive_c_dir, len, "%s/../drive_c", configdir);
HeapFree(GetProcessHeap(), 0, drive_c_dir);
if (stat(drive_c_dir, &buf) == 0)
{
add_drive('C', "../drive_c", "Virtual Windows Drive", "0", DRIVE_FIXED);
}
else
{
report_error(NO_DRIVE_C);
}
}
int autodetect_drives()
{
struct mntent *ent;
FILE *fstab;
/* we want to build a list of autodetected drives, then ensure each entry
exists in the users setup. so, we superimpose the autodetected drives
onto whatever is pre-existing.
for now let's just rummage around inside the fstab.
*/
load_drives();
working_mask = drive_available_mask('\0');
fstab = fopen("/etc/fstab", "r");
if (!fstab)
{
report_error(FSTAB_OPEN);
return FALSE;
}
while ((ent = getmntent(fstab)))
{
char letter;
char label[256];
int type;
WINE_TRACE("ent->mnt_dir=%s\n", ent->mnt_dir);
if (should_ignore_fstype(ent->mnt_type)) continue;
if (is_drive_defined(ent->mnt_dir)) continue;
/* allocate a drive for it */
letter = allocate_letter();
if (letter == ']')
{
report_error(NO_MORE_LETTERS);
fclose(fstab);
return FALSE;
}
WINE_TRACE("adding drive %c for %s, type %s\n", letter, ent->mnt_dir, ent->mnt_type);
strncpy(label, "Drive X", 8);
label[6] = letter;
if (!strcmp(ent->mnt_type, "nfs")) type = DRIVE_REMOTE;
else if (!strcmp(ent->mnt_type, "nfs4")) type = DRIVE_REMOTE;
else if (!strcmp(ent->mnt_type, "smbfs")) type = DRIVE_REMOTE;
else if (!strcmp(ent->mnt_type, "cifs")) type = DRIVE_REMOTE;
else if (!strcmp(ent->mnt_type, "coda")) type = DRIVE_REMOTE;
else if (!strcmp(ent->mnt_type, "iso9660")) type = DRIVE_CDROM;
else if (!strcmp(ent->mnt_type, "ramfs")) type = DRIVE_RAMDISK;
else type = DRIVE_FIXED;
add_drive(letter, ent->mnt_dir, label, "0", type);
working_mask |= DRIVE_MASK_BIT(letter);
}
fclose(fstab);
ensure_root_is_mapped();
ensure_drive_c_is_mapped();
return TRUE;
}
......@@ -35,7 +35,6 @@
#define IDD_GRAPHCFG 110
#define IDD_DLLCFG 111
#define IDD_DRIVECFG 112
#define IDD_SYSTEMCFG 113
#define IDD_DRIVE_EDIT 114
#define IDB_WINE_LOGO 200
#define IDC_TABABOUT 1001
......@@ -95,13 +94,15 @@
#define IDC_RADIO_AUTODETECT 1068
#define IDC_RADIO_ASSIGN 1069
#define IDC_BUTTON_BROWSE_DEVICE 1070
#define IDC_BOX_LABELSERIAL 1071
#define IDC_STATIC_SERIAL 1072
#define IDC_STATIC_LABEL 1073
#define IDC_ENABLE_DESKTOP 1074
#define IDS_DRIVE_NO_C 1075
#define IDC_BUTTON_SHOW_HIDE_ADVANCED 1076
#define IDC_STATIC_TYPE 1077
#define IDC_LABELSERIAL_STATIC 1078
#define IDC_DRIVE_LABEL 1078
/* graphics */
#define IDC_ENABLE_MANAGED 1100
......
......@@ -19,6 +19,12 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* TODO:
* - Use unicode
* - Icons in listviews/icons
* - Better add app dialog, scan c: for EXE files and add to list in background
* - Use [GNOME] HIG style groupboxes rather than win32 style (looks nicer, imho)
*
*/
#include <assert.h>
......@@ -47,11 +53,11 @@ void set_window_title(HWND dialog)
char *newtitle;
/* update the window title */
if (currentApp)
if (current_app)
{
char *template = "Wine Configuration for %s";
newtitle = HeapAlloc(GetProcessHeap(), 0, strlen(template) + strlen(currentApp) + 1);
sprintf(newtitle, template, currentApp);
newtitle = HeapAlloc(GetProcessHeap(), 0, strlen(template) + strlen(current_app) + 1);
sprintf(newtitle, template, current_app);
}
else
{
......@@ -65,7 +71,7 @@ void set_window_title(HWND dialog)
/**
* get_config_key: Retrieves a configuration value from the registry
* getkey: Retrieves a configuration value from the registry
*
* char *subkey : the name of the config section
* char *name : the name of the config value
......@@ -75,7 +81,7 @@ void set_window_title(HWND dialog)
* not. Caller is responsible for releasing the result.
*
*/
static char *get_config_key (char *subkey, char *name, char *def)
static char *getkey (char *subkey, char *name, char *def)
{
LPBYTE buffer = NULL;
DWORD len;
......@@ -123,7 +129,7 @@ end:
}
/**
* set_config_key: convenience wrapper to set a key/value pair
* setkey: convenience wrapper to set a key/value pair
*
* const char *subKey : the name of the config section
* const char *valueName : the name of the config value
......@@ -133,7 +139,7 @@ end:
*
* If valueName or value is NULL, an empty section will be created
*/
int set_config_key(const char *subkey, const char *name, const char *value) {
int setkey(const char *subkey, const char *name, const char *value) {
DWORD res = 1;
HKEY key = NULL;
......@@ -252,7 +258,7 @@ char *get(char *path, char *name, char *def)
}
/* no, so get from the registry */
val = get_config_key(path, name, def);
val = getkey(path, name, def);
WINE_TRACE("returning %s\n", val);
......@@ -439,7 +445,7 @@ static void process_setting(struct setting *s)
if (s->value)
{
WINE_TRACE("Setting %s:%s to '%s'\n", s->path, s->name, s->value);
set_config_key(s->path, s->name, s->value);
setkey(s->path, s->name, s->value);
}
else
{
......@@ -465,7 +471,7 @@ void apply(void)
/* ================================== utility functions ============================ */
char *currentApp = NULL; /* the app we are currently editing, or NULL if editing global */
char *current_app = 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)
......@@ -474,10 +480,10 @@ char *keypath(char *section)
if (result) HeapFree(GetProcessHeap(), 0, result);
if (currentApp)
if (current_app)
{
result = HeapAlloc(GetProcessHeap(), 0, strlen("AppDefaults\\") + strlen(currentApp) + 2 /* \\ */ + strlen(section) + 1 /* terminator */);
sprintf(result, "AppDefaults\\%s\\%s", currentApp, section);
result = HeapAlloc(GetProcessHeap(), 0, strlen("AppDefaults\\") + strlen(current_app) + 2 /* \\ */ + strlen(section) + 1 /* terminator */);
sprintf(result, "AppDefaults\\%s\\%s", current_app, section);
}
else
{
......@@ -494,6 +500,10 @@ void PRINTERROR(void)
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
0, GetLastError(), MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
(LPSTR)&msg, 0, NULL);
/* eliminate trailing newline, is this a Wine bug? */
*(strrchr(msg, '\n')) = '\0';
WINE_TRACE("error: '%s'\n", msg);
}
......
......@@ -38,15 +38,7 @@
#define IS_OPTION_FALSE(ch) \
((ch) == 'n' || (ch) == 'N' || (ch) == 'f' || (ch) == 'F' || (ch) == '0')
#define return_if_fail(try) \
if (!(try)) { \
WINE_ERR("check (" #try ") at %s:%d failed, returning\n", __FILE__, __LINE__ - 1); \
return; \
}
#define WRITEME(owner) MessageBox(owner, "Write me!", "", MB_OK | MB_ICONEXCLAMATION);
extern char *currentApp; /* NULL means editing global settings */
extern char *current_app; /* NULL means editing global settings */
/* Use get and set to alter registry settings. The changes made through set
won't be committed to the registry until process_all_settings is called,
......@@ -55,6 +47,7 @@ extern char *currentApp; /* NULL means editing global settings */
You are expected to release the result of get. The parameters to set will
be copied, so release them too when necessary.
*/
void set(char *path, char *name, char *value);
char *get(char *path, char *name, char *def);
BOOL exists(char *path, char *name);
......@@ -62,37 +55,52 @@ void apply(void);
char **enumerate_values(char *path);
/* 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
the user is editing the global settings.
no explicit free is needed of the string returned by this function
*/
char *keypath(char *section);
/* Initializes the transaction system */
int initialize(void);
extern HKEY config_key;
/* hack for the property sheet control */
void set_window_title(HWND dialog);
/* Graphics */
void initGraphDlg (HWND hDlg);
void saveGraphDlgSettings (HWND hDlg);
/* Window procedures */
INT_PTR CALLBACK GraphDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
/* Drive management */
void initDriveDlg (HWND hDlg);
void saveDriveSettings (HWND hDlg);
INT_PTR CALLBACK DriveDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK DriveEditDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK AppDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK LibrariesDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
/* Audio config dialog */
INT_PTR CALLBACK AudioDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
/* some basic utilities to make win32 suck less */
/* Drive management */
void load_drives();
int autodetect_drives();
struct drive
{
char letter;
char *unixpath;
char *label;
char *serial;
DWORD type; /* one of the DRIVE_ constants from winbase.h */
BOOL in_use;
};
#define DRIVE_MASK_BIT(B) 1 << (toupper(B) - 'A')
long drive_available_mask(char letter);
BOOL add_drive(char letter, char *targetpath, char *label, char *serial, unsigned int type);
void delete_drive(struct drive *pDrive);
void apply_drive_changes();
extern struct drive drives[26]; /* one for each drive letter */
BOOL gui_mode;
/* Some basic utilities to make win32 suck less */
#define disable(id) EnableWindow(GetDlgItem(dialog, id), 0);
#define enable(id) EnableWindow(GetDlgItem(dialog, id), 1);
void PRINTERROR(void); /* WINE_TRACE() the plaintext error message from GetLastError() */
......@@ -104,15 +112,20 @@ static inline char *strdupA(char *s)
return strcpy(r, s);
}
static inline char *get_control_text(HWND dialog, WORD id)
static inline char *get_text(HWND dialog, WORD id)
{
HWND item = GetDlgItem(dialog, id);
int len = GetWindowTextLength(item) + 1;
char *result = HeapAlloc(GetProcessHeap(), 0, len);
if (GetWindowText(item, result, len) == 0) return NULL;
char *result = len ? HeapAlloc(GetProcessHeap(), 0, len) : NULL;
if (!result || GetWindowText(item, result, len) == 0) return NULL;
return result;
}
#define WINE_KEY_ROOT "Software\\Wine\\Wine\\Config"
static inline void set_text(HWND dialog, WORD id, char *text)
{
SetWindowText(GetDlgItem(dialog, id), text);
}
#define WINE_KEY_ROOT "Software\\Wine\\Testing\\Config"
#endif
......@@ -145,8 +145,8 @@ static void set_from_desktop_edits(HWND dialog) {
WINE_TRACE("\n");
width = get_control_text(dialog, IDC_DESKTOP_WIDTH);
height = get_control_text(dialog, IDC_DESKTOP_HEIGHT);
width = get_text(dialog, IDC_DESKTOP_WIDTH);
height = get_text(dialog, IDC_DESKTOP_HEIGHT);
if (strcmp(width, "") == 0)
{
......@@ -184,7 +184,7 @@ void on_enable_desktop_clicked(HWND dialog) {
}
static void on_screen_depth_changed(HWND dialog) {
char *newvalue = get_control_text(dialog, IDC_SCREEN_DEPTH);
char *newvalue = get_text(dialog, IDC_SCREEN_DEPTH);
char *spaceIndex = strchr(newvalue, ' ');
WINE_TRACE("newvalue=%s\n", newvalue);
......
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