Commit 2ae3945d authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

winecfg: Don't mix the strings in unix and windows locales.

parent 7c1a7491
...@@ -563,13 +563,13 @@ static void paint(HWND dialog) ...@@ -563,13 +563,13 @@ static void paint(HWND dialog)
EndPaint(dialog, &ps); EndPaint(dialog, &ps);
} }
BOOL browse_for_unix_folder(HWND dialog, char *pszPath) BOOL browse_for_unix_folder(HWND dialog, WCHAR *pszPath)
{ {
static WCHAR wszUnixRootDisplayName[] = static WCHAR wszUnixRootDisplayName[] =
{ ':',':','{','C','C','7','0','2','E','B','2','-','7','D','C','5','-','1','1','D','9','-', { ':',':','{','C','C','7','0','2','E','B','2','-','7','D','C','5','-','1','1','D','9','-',
'C','6','8','7','-','0','0','0','4','2','3','8','A','0','1','C','D','}', 0 }; 'C','6','8','7','-','0','0','0','4','2','3','8','A','0','1','C','D','}', 0 };
char pszChoosePath[256]; WCHAR pszChoosePath[FILENAME_MAX];
BROWSEINFOA bi = { BROWSEINFOW bi = {
dialog, dialog,
NULL, NULL,
NULL, NULL,
...@@ -583,7 +583,7 @@ BOOL browse_for_unix_folder(HWND dialog, char *pszPath) ...@@ -583,7 +583,7 @@ BOOL browse_for_unix_folder(HWND dialog, char *pszPath)
LPITEMIDLIST pidlUnixRoot, pidlSelectedPath; LPITEMIDLIST pidlUnixRoot, pidlSelectedPath;
HRESULT hr; HRESULT hr;
LoadString(GetModuleHandle(NULL), IDS_CHOOSE_PATH, pszChoosePath, 256); LoadStringW(GetModuleHandle(NULL), IDS_CHOOSE_PATH, pszChoosePath, FILENAME_MAX);
hr = SHGetDesktopFolder(&pDesktop); hr = SHGetDesktopFolder(&pDesktop);
if (!SUCCEEDED(hr)) return FALSE; if (!SUCCEEDED(hr)) return FALSE;
...@@ -596,12 +596,12 @@ BOOL browse_for_unix_folder(HWND dialog, char *pszPath) ...@@ -596,12 +596,12 @@ BOOL browse_for_unix_folder(HWND dialog, char *pszPath)
} }
bi.pidlRoot = pidlUnixRoot; bi.pidlRoot = pidlUnixRoot;
pidlSelectedPath = SHBrowseForFolderA(&bi); pidlSelectedPath = SHBrowseForFolderW(&bi);
SHFree(pidlUnixRoot); SHFree(pidlUnixRoot);
if (pidlSelectedPath) { if (pidlSelectedPath) {
STRRET strSelectedPath; STRRET strSelectedPath;
char *pszSelectedPath; WCHAR *pszSelectedPath;
HRESULT hr; HRESULT hr;
hr = IShellFolder_GetDisplayNameOf(pDesktop, pidlSelectedPath, SHGDN_FORPARSING, hr = IShellFolder_GetDisplayNameOf(pDesktop, pidlSelectedPath, SHGDN_FORPARSING,
...@@ -612,11 +612,11 @@ BOOL browse_for_unix_folder(HWND dialog, char *pszPath) ...@@ -612,11 +612,11 @@ BOOL browse_for_unix_folder(HWND dialog, char *pszPath)
return FALSE; return FALSE;
} }
hr = StrRetToStr(&strSelectedPath, pidlSelectedPath, &pszSelectedPath); hr = StrRetToStrW(&strSelectedPath, pidlSelectedPath, &pszSelectedPath);
SHFree(pidlSelectedPath); SHFree(pidlSelectedPath);
if (!SUCCEEDED(hr)) return FALSE; if (!SUCCEEDED(hr)) return FALSE;
lstrcpy(pszPath, pszSelectedPath); lstrcpyW(pszPath, pszSelectedPath);
CoTaskMemFree(pszSelectedPath); CoTaskMemFree(pszSelectedPath);
return TRUE; return TRUE;
...@@ -740,9 +740,9 @@ DriveDlgProc (HWND dialog, UINT msg, WPARAM wParam, LPARAM lParam) ...@@ -740,9 +740,9 @@ DriveDlgProc (HWND dialog, UINT msg, WPARAM wParam, LPARAM lParam)
case IDC_BUTTON_BROWSE_PATH: case IDC_BUTTON_BROWSE_PATH:
{ {
char szTargetPath[FILENAME_MAX]; WCHAR szTargetPath[FILENAME_MAX];
if (browse_for_unix_folder(dialog, szTargetPath)) if (browse_for_unix_folder(dialog, szTargetPath))
set_text(dialog, IDC_EDIT_PATH, szTargetPath); set_textW(dialog, IDC_EDIT_PATH, szTargetPath);
break; break;
} }
......
...@@ -705,7 +705,7 @@ static void on_theme_install(HWND dialog) ...@@ -705,7 +705,7 @@ static void on_theme_install(HWND dialog)
/* Information about symbolic link targets of certain User Shell Folders. */ /* Information about symbolic link targets of certain User Shell Folders. */
struct ShellFolderInfo { struct ShellFolderInfo {
int nFolder; int nFolder;
char szLinkTarget[FILENAME_MAX]; char szLinkTarget[FILENAME_MAX]; /* in unix locale */
}; };
static struct ShellFolderInfo asfiInfo[] = { static struct ShellFolderInfo asfiInfo[] = {
...@@ -720,6 +720,19 @@ static struct ShellFolderInfo *psfiSelected = NULL; ...@@ -720,6 +720,19 @@ static struct ShellFolderInfo *psfiSelected = NULL;
#define NUM_ELEMS(x) (sizeof(x)/sizeof(*(x))) #define NUM_ELEMS(x) (sizeof(x)/sizeof(*(x)))
/* create a unicode string from a string in Unix locale */
static WCHAR *strdupU2W(const char *unix_str)
{
WCHAR *unicode_str;
int lenW;
lenW = MultiByteToWideChar(CP_UNIXCP, 0, unix_str, -1, NULL, 0);
unicode_str = HeapAlloc(GetProcessHeap(), 0, lenW * sizeof(WCHAR));
if (unicode_str)
MultiByteToWideChar(CP_UNIXCP, 0, unix_str, -1, unicode_str, lenW);
return unicode_str;
}
static void init_shell_folder_listview_headers(HWND dialog) { static void init_shell_folder_listview_headers(HWND dialog) {
LVCOLUMN listColumn; LVCOLUMN listColumn;
RECT viewRect; RECT viewRect;
...@@ -773,14 +786,14 @@ static void read_shell_folder_link_targets(void) { ...@@ -773,14 +786,14 @@ static void read_shell_folder_link_targets(void) {
static void update_shell_folder_listview(HWND dialog) { static void update_shell_folder_listview(HWND dialog) {
int i; int i;
LVITEM item; LVITEMW item;
LONG lSelected = SendDlgItemMessage(dialog, IDC_LIST_SFPATHS, LVM_GETNEXTITEM, (WPARAM)-1, LONG lSelected = SendDlgItemMessage(dialog, IDC_LIST_SFPATHS, LVM_GETNEXTITEM, (WPARAM)-1,
MAKELPARAM(LVNI_SELECTED,0)); MAKELPARAM(LVNI_SELECTED,0));
SendDlgItemMessage(dialog, IDC_LIST_SFPATHS, LVM_DELETEALLITEMS, 0, 0); SendDlgItemMessage(dialog, IDC_LIST_SFPATHS, LVM_DELETEALLITEMS, 0, 0);
for (i=0; i<NUM_ELEMS(asfiInfo); i++) { for (i=0; i<NUM_ELEMS(asfiInfo); i++) {
char buffer[MAX_PATH]; WCHAR buffer[MAX_PATH];
HRESULT hr; HRESULT hr;
LPITEMIDLIST pidlCurrent; LPITEMIDLIST pidlCurrent;
...@@ -794,7 +807,7 @@ static void update_shell_folder_listview(HWND dialog) { ...@@ -794,7 +807,7 @@ static void update_shell_folder_listview(HWND dialog) {
STRRET strRet; STRRET strRet;
hr = IShellFolder_GetDisplayNameOf(psfParent, pidlLast, SHGDN_FORADDRESSBAR, &strRet); hr = IShellFolder_GetDisplayNameOf(psfParent, pidlLast, SHGDN_FORADDRESSBAR, &strRet);
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
hr = StrRetToBufA(&strRet, pidlLast, buffer, 256); hr = StrRetToBufW(&strRet, pidlLast, buffer, MAX_PATH);
} }
IShellFolder_Release(psfParent); IShellFolder_Release(psfParent);
} }
...@@ -804,7 +817,7 @@ static void update_shell_folder_listview(HWND dialog) { ...@@ -804,7 +817,7 @@ static void update_shell_folder_listview(HWND dialog) {
/* If there's a dangling symlink for the current shell folder, SHGetFolderLocation /* If there's a dangling symlink for the current shell folder, SHGetFolderLocation
* will fail above. We fall back to the (non-verified) path of the shell folder. */ * will fail above. We fall back to the (non-verified) path of the shell folder. */
if (FAILED(hr)) { if (FAILED(hr)) {
hr = SHGetFolderPath(dialog, asfiInfo[i].nFolder|CSIDL_FLAG_DONT_VERIFY, NULL, hr = SHGetFolderPathW(dialog, asfiInfo[i].nFolder|CSIDL_FLAG_DONT_VERIFY, NULL,
SHGFP_TYPE_CURRENT, buffer); SHGFP_TYPE_CURRENT, buffer);
} }
...@@ -813,13 +826,14 @@ static void update_shell_folder_listview(HWND dialog) { ...@@ -813,13 +826,14 @@ static void update_shell_folder_listview(HWND dialog) {
item.iSubItem = 0; item.iSubItem = 0;
item.pszText = buffer; item.pszText = buffer;
item.lParam = (LPARAM)&asfiInfo[i]; item.lParam = (LPARAM)&asfiInfo[i];
SendDlgItemMessage(dialog, IDC_LIST_SFPATHS, LVM_INSERTITEM, 0, (LPARAM)&item); SendDlgItemMessage(dialog, IDC_LIST_SFPATHS, LVM_INSERTITEMW, 0, (LPARAM)&item);
item.mask = LVIF_TEXT; item.mask = LVIF_TEXT;
item.iItem = i; item.iItem = i;
item.iSubItem = 1; item.iSubItem = 1;
item.pszText = asfiInfo[i].szLinkTarget; item.pszText = strdupU2W(asfiInfo[i].szLinkTarget);
SendDlgItemMessage(dialog, IDC_LIST_SFPATHS, LVM_SETITEM, 0, (LPARAM)&item); SendDlgItemMessage(dialog, IDC_LIST_SFPATHS, LVM_SETITEMW, 0, (LPARAM)&item);
HeapFree(GetProcessHeap(), 0, item.pszText);
} }
/* Ensure that the previously selected item is selected again. */ /* Ensure that the previously selected item is selected again. */
...@@ -837,20 +851,23 @@ static void on_shell_folder_selection_changed(HWND hDlg, LPNMLISTVIEW lpnm) { ...@@ -837,20 +851,23 @@ static void on_shell_folder_selection_changed(HWND hDlg, LPNMLISTVIEW lpnm) {
psfiSelected = (struct ShellFolderInfo *)lpnm->lParam; psfiSelected = (struct ShellFolderInfo *)lpnm->lParam;
EnableWindow(GetDlgItem(hDlg, IDC_LINK_SFPATH), 1); EnableWindow(GetDlgItem(hDlg, IDC_LINK_SFPATH), 1);
if (strlen(psfiSelected->szLinkTarget)) { if (strlen(psfiSelected->szLinkTarget)) {
WCHAR *link;
CheckDlgButton(hDlg, IDC_LINK_SFPATH, BST_CHECKED); CheckDlgButton(hDlg, IDC_LINK_SFPATH, BST_CHECKED);
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_SFPATH), 1); EnableWindow(GetDlgItem(hDlg, IDC_EDIT_SFPATH), 1);
EnableWindow(GetDlgItem(hDlg, IDC_BROWSE_SFPATH), 1); EnableWindow(GetDlgItem(hDlg, IDC_BROWSE_SFPATH), 1);
SetWindowText(GetDlgItem(hDlg, IDC_EDIT_SFPATH), psfiSelected->szLinkTarget); link = strdupU2W(psfiSelected->szLinkTarget);
set_textW(hDlg, IDC_EDIT_SFPATH, link);
HeapFree(GetProcessHeap(), 0, link);
} else { } else {
CheckDlgButton(hDlg, IDC_LINK_SFPATH, BST_UNCHECKED); CheckDlgButton(hDlg, IDC_LINK_SFPATH, BST_UNCHECKED);
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_SFPATH), 0); EnableWindow(GetDlgItem(hDlg, IDC_EDIT_SFPATH), 0);
EnableWindow(GetDlgItem(hDlg, IDC_BROWSE_SFPATH), 0); EnableWindow(GetDlgItem(hDlg, IDC_BROWSE_SFPATH), 0);
SetWindowText(GetDlgItem(hDlg, IDC_EDIT_SFPATH), ""); set_text(hDlg, IDC_EDIT_SFPATH, "");
} }
} else { } else {
psfiSelected = NULL; psfiSelected = NULL;
CheckDlgButton(hDlg, IDC_LINK_SFPATH, BST_UNCHECKED); CheckDlgButton(hDlg, IDC_LINK_SFPATH, BST_UNCHECKED);
SetWindowText(GetDlgItem(hDlg, IDC_EDIT_SFPATH), ""); set_text(hDlg, IDC_EDIT_SFPATH, "");
EnableWindow(GetDlgItem(hDlg, IDC_LINK_SFPATH), 0); EnableWindow(GetDlgItem(hDlg, IDC_LINK_SFPATH), 0);
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_SFPATH), 0); EnableWindow(GetDlgItem(hDlg, IDC_EDIT_SFPATH), 0);
EnableWindow(GetDlgItem(hDlg, IDC_BROWSE_SFPATH), 0); EnableWindow(GetDlgItem(hDlg, IDC_BROWSE_SFPATH), 0);
...@@ -860,8 +877,8 @@ static void on_shell_folder_selection_changed(HWND hDlg, LPNMLISTVIEW lpnm) { ...@@ -860,8 +877,8 @@ static void on_shell_folder_selection_changed(HWND hDlg, LPNMLISTVIEW lpnm) {
/* Keep the contents of the edit control, the listview control and the symlink /* Keep the contents of the edit control, the listview control and the symlink
* information in sync. */ * information in sync. */
static void on_shell_folder_edit_changed(HWND hDlg) { static void on_shell_folder_edit_changed(HWND hDlg) {
LVITEM item; LVITEMW item;
char *text = get_text(hDlg, IDC_EDIT_SFPATH); WCHAR *text = get_textW(hDlg, IDC_EDIT_SFPATH);
LONG iSel = SendDlgItemMessage(hDlg, IDC_LIST_SFPATHS, LVM_GETNEXTITEM, -1, LONG iSel = SendDlgItemMessage(hDlg, IDC_LIST_SFPATHS, LVM_GETNEXTITEM, -1,
MAKELPARAM(LVNI_SELECTED,0)); MAKELPARAM(LVNI_SELECTED,0));
...@@ -870,14 +887,16 @@ static void on_shell_folder_edit_changed(HWND hDlg) { ...@@ -870,14 +887,16 @@ static void on_shell_folder_edit_changed(HWND hDlg) {
return; return;
} }
strncpy(psfiSelected->szLinkTarget, text, FILENAME_MAX); WideCharToMultiByte(CP_UNIXCP, 0, text, -1,
HeapFree(GetProcessHeap(), 0, text); psfiSelected->szLinkTarget, FILENAME_MAX, NULL, NULL);
item.mask = LVIF_TEXT; item.mask = LVIF_TEXT;
item.iItem = iSel; item.iItem = iSel;
item.iSubItem = 1; item.iSubItem = 1;
item.pszText = psfiSelected->szLinkTarget; item.pszText = text;
SendDlgItemMessage(hDlg, IDC_LIST_SFPATHS, LVM_SETITEM, 0, (LPARAM)&item); SendDlgItemMessage(hDlg, IDC_LIST_SFPATHS, LVM_SETITEMW, 0, (LPARAM)&item);
HeapFree(GetProcessHeap(), 0, text);
SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
} }
...@@ -1158,15 +1177,25 @@ ThemeDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) ...@@ -1158,15 +1177,25 @@ ThemeDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
break; break;
case IDC_BROWSE_SFPATH: case IDC_BROWSE_SFPATH:
if (browse_for_unix_folder(hDlg, psfiSelected->szLinkTarget)) { {
WCHAR link[FILENAME_MAX];
if (browse_for_unix_folder(hDlg, link)) {
WideCharToMultiByte(CP_UNIXCP, 0, link, -1,
psfiSelected->szLinkTarget, FILENAME_MAX,
NULL, NULL);
update_shell_folder_listview(hDlg); update_shell_folder_listview(hDlg);
SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
} }
break; break;
}
case IDC_LINK_SFPATH: case IDC_LINK_SFPATH:
if (IsDlgButtonChecked(hDlg, IDC_LINK_SFPATH)) { if (IsDlgButtonChecked(hDlg, IDC_LINK_SFPATH)) {
if (browse_for_unix_folder(hDlg, psfiSelected->szLinkTarget)) { WCHAR link[FILENAME_MAX];
if (browse_for_unix_folder(hDlg, link)) {
WideCharToMultiByte(CP_UNIXCP, 0, link, -1,
psfiSelected->szLinkTarget, FILENAME_MAX,
NULL, NULL);
update_shell_folder_listview(hDlg); update_shell_folder_listview(hDlg);
SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
} else { } else {
......
...@@ -109,7 +109,7 @@ long drive_available_mask(char letter); ...@@ -109,7 +109,7 @@ long drive_available_mask(char letter);
BOOL add_drive(const char letter, const char *targetpath, const char *label, const char *serial, unsigned int type); BOOL add_drive(const char letter, const char *targetpath, const char *label, const char *serial, unsigned int type);
void delete_drive(struct drive *pDrive); void delete_drive(struct drive *pDrive);
void apply_drive_changes(void); void apply_drive_changes(void);
BOOL browse_for_unix_folder(HWND dialog, char *pszPath); BOOL browse_for_unix_folder(HWND dialog, WCHAR *pszPath);
extern struct drive drives[26]; /* one for each drive letter */ extern struct drive drives[26]; /* one for each drive letter */
BOOL gui_mode; BOOL gui_mode;
...@@ -141,11 +141,25 @@ static inline char *get_text(HWND dialog, WORD id) ...@@ -141,11 +141,25 @@ static inline char *get_text(HWND dialog, WORD id)
return result; return result;
} }
static inline WCHAR *get_textW(HWND dialog, WORD id)
{
HWND item = GetDlgItem(dialog, id);
int len = GetWindowTextLengthW(item) + 1;
WCHAR *result = len ? HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)) : NULL;
if (!result || GetWindowTextW(item, result, len) == 0) return NULL;
return result;
}
static inline void set_text(HWND dialog, WORD id, const char *text) static inline void set_text(HWND dialog, WORD id, const char *text)
{ {
SetWindowText(GetDlgItem(dialog, id), text); SetWindowText(GetDlgItem(dialog, id), text);
} }
static inline void set_textW(HWND dialog, WORD id, const WCHAR *text)
{
SetWindowTextW(GetDlgItem(dialog, id), text);
}
#define WINE_KEY_ROOT "Software\\Wine" #define WINE_KEY_ROOT "Software\\Wine"
#define MAXBUFLEN 256 #define MAXBUFLEN 256
......
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