Module: wine Branch: master Commit: 6b3d624d4b39206541849bd08c15cd40c25f7b87 URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=6b3d624d4b39206541849bd0...
Author: Frank Richter frank.richter@gmail.com Date: Wed Aug 16 18:30:48 2006 +0200
winecfg: Use WCHARs for window title, current app.
---
programs/winecfg/appdefaults.c | 25 ++++++++++--------------- programs/winecfg/winecfg.c | 23 +++++++++++++---------- programs/winecfg/winecfg.h | 2 +- 3 files changed, 24 insertions(+), 26 deletions(-)
diff --git a/programs/winecfg/appdefaults.c b/programs/winecfg/appdefaults.c index 8725757..bca7f7a 100644 --- a/programs/winecfg/appdefaults.c +++ b/programs/winecfg/appdefaults.c @@ -153,7 +153,9 @@ static void init_appsheet(HWND dialog)
/* we use the lparam field of the item so we can alter the presentation later and not change code * for instance, to use the tile view or to display the EXEs embedded 'display name' */ - add_listview_item(listview, load_string (IDS_DEFAULT_SETTINGS), NULL); + LoadStringW (GetModuleHandle (NULL), IDS_DEFAULT_SETTINGS, appname, + sizeof(appname)/sizeof(appname[0])); + add_listview_item(listview, appname, NULL);
/* because this list is only populated once, it's safe to bypass the settings list here */ if (RegOpenKey(config_key, "AppDefaults", &key) == ERROR_SUCCESS) @@ -208,7 +210,7 @@ static int get_listview_selection(HWND l static void on_selection_change(HWND dialog, HWND listview) { LVITEM item; - char *oldapp = current_app; + WCHAR* oldapp = current_app;
WINE_TRACE("()\n");
@@ -221,11 +223,11 @@ static void on_selection_change(HWND dia
SendMessage(listview, LVM_GETITEM, 0, (LPARAM) &item);
- current_app = (char *) item.lParam; + current_app = (WCHAR*) item.lParam;
if (current_app) { - WINE_TRACE("current_app is now %s\n", current_app); + WINE_TRACE("current_app is now %s\n", wine_dbgstr_w (current_app)); enable(IDC_APP_REMOVEAPP); } else @@ -287,21 +289,15 @@ static void on_add_app_click(HWND dialog HWND listview = GetDlgItem(dialog, IDC_APP_LISTVIEW); int count = ListView_GetItemCount(listview); WCHAR* new_app; - char* new_appA; - DWORD new_appA_len;
- new_app = strdupW(filetitle); - - if (list_contains_file(listview, new_app)) + if (list_contains_file(listview, filetitle)) return;
+ new_app = strdupW(filetitle); + WINE_TRACE("adding %s\n", wine_dbgstr_w (new_app));
- new_appA_len = WideCharToMultiByte (CP_ACP, 0, new_app, -1, NULL, 0, NULL, NULL); - new_appA = HeapAlloc (GetProcessHeap(), 0, new_appA_len); - WideCharToMultiByte (CP_ACP, 0, new_app, -1, new_appA, new_appA_len, NULL, NULL); - - add_listview_item(listview, new_app, new_appA); + add_listview_item(listview, new_app, new_app);
ListView_SetItemState(listview, count, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
@@ -327,7 +323,6 @@ static void on_remove_app_click(HWND dia section[strlen(section)] = '\0'; /* remove last backslash */ set_reg_key(config_key, section, NULL, NULL); /* delete the section */ SendMessage(listview, LVM_GETITEMW, 0, (LPARAM) &item); - HeapFree (GetProcessHeap(), 0, item.pszText); HeapFree (GetProcessHeap(), 0, (void*)item.lParam); SendMessage(listview, LVM_DELETEITEM, selection, 0); ListView_SetItemState(listview, selection - 1, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); diff --git a/programs/winecfg/winecfg.c b/programs/winecfg/winecfg.c index dfa5aeb..818efed 100644 --- a/programs/winecfg/winecfg.c +++ b/programs/winecfg/winecfg.c @@ -53,22 +53,24 @@ HMENU hPopupMenus = 0; */ void set_window_title(HWND dialog) { - char newtitle[256]; + WCHAR newtitle[256];
/* update the window title */ if (current_app) { - char apptitle[256]; - LoadString(GetModuleHandle(NULL), IDS_WINECFG_TITLE_APP, apptitle, 256); - sprintf(newtitle, apptitle, current_app); + WCHAR apptitle[256]; + LoadStringW (GetModuleHandle(NULL), IDS_WINECFG_TITLE_APP, apptitle, + sizeof(apptitle)/sizeof(apptitle[0])); + wsprintfW (newtitle, apptitle, current_app); } else { - LoadString(GetModuleHandle(NULL), IDS_WINECFG_TITLE, newtitle, 256); + LoadStringW (GetModuleHandle(NULL), IDS_WINECFG_TITLE, newtitle, + sizeof(newtitle)/sizeof(newtitle[0])); }
- WINE_TRACE("setting title to %s\n", newtitle); - SendMessage(GetParent(dialog), PSM_SETTITLE, 0, (LPARAM) newtitle); + WINE_TRACE("setting title to %s\n", wine_dbgstr_w (newtitle)); + SendMessageW (GetParent(dialog), PSM_SETTITLEW, 0, (LPARAM) newtitle); }
@@ -316,6 +318,7 @@ char *get_reg_key(HKEY root, const char
if (root != s->root) continue; if (strcasecmp(path, s->path) != 0) continue; + if (!s->name) continue; if (strcasecmp(name, s->name) != 0) continue;
WINE_TRACE("found %s:%s in settings list, returning %s\n", path, name, s->value); @@ -584,7 +587,7 @@ void apply(void)
/* ================================== utility functions ============================ */
-char *current_app = NULL; /* the app we are currently editing, or NULL if editing global */ +WCHAR* 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(const char *section) @@ -595,8 +598,8 @@ char *keypath(const char *section)
if (current_app) { - result = HeapAlloc(GetProcessHeap(), 0, strlen("AppDefaults\") + strlen(current_app) + 2 /* \ */ + strlen(section) + 1 /* terminator */); - sprintf(result, "AppDefaults\%s", current_app); + result = HeapAlloc(GetProcessHeap(), 0, strlen("AppDefaults\") + lstrlenW(current_app)*2 + 2 /* \ */ + strlen(section) + 1 /* terminator */); + wsprintf(result, "AppDefaults\%ls", current_app); if (section[0]) sprintf( result + strlen(result), "\%s", section ); } else diff --git a/programs/winecfg/winecfg.h b/programs/winecfg/winecfg.h index 3cd3d45..e23c7bb 100644 --- a/programs/winecfg/winecfg.h +++ b/programs/winecfg/winecfg.h @@ -38,7 +38,7 @@ #define IS_OPTION_TRUE(ch) \ #define IS_OPTION_FALSE(ch) \ ((ch) == 'n' || (ch) == 'N' || (ch) == 'f' || (ch) == 'F' || (ch) == '0')
-extern char *current_app; /* NULL means editing global settings */ +extern WCHAR* current_app; /* NULL means editing global settings */
/* Use get_reg_key and set_reg_key to alter registry settings. The changes made through set_reg_key won't be committed to the registry until process_all_settings is called,