diff options
author | hobbs <hobbs> | 2000-11-02 01:18:20 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2000-11-02 01:18:20 (GMT) |
commit | 830f722f704259df342e5f54edc4e99b79d0b047 (patch) | |
tree | f59a593f4579d811487b4c9f33bf3c1207f737c4 | |
parent | ea6d17a2849fbb98e1462a33c03b7a4e97474c13 (diff) | |
download | tk-830f722f704259df342e5f54edc4e99b79d0b047.zip tk-830f722f704259df342e5f54edc4e99b79d0b047.tar.gz tk-830f722f704259df342e5f54edc4e99b79d0b047.tar.bz2 |
* win/tkWinDialog.c (GetFileNameW, GetFileNameA,
Tk_ChooseDirectoryObjCmd): created work-around for change in
NT5.0/98 that caused no initialdir setting to open the browser up
in the user's documents dir.
-rw-r--r-- | win/tkWinDialog.c | 66 |
1 files changed, 61 insertions, 5 deletions
diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c index de9f4a8..92cfeb9 100644 --- a/win/tkWinDialog.c +++ b/win/tkWinDialog.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinDialog.c,v 1.15 2000/11/02 00:18:02 ericm Exp $ + * RCS: @(#) $Id: tkWinDialog.c,v 1.16 2000/11/02 01:18:20 hobbs Exp $ * */ @@ -577,7 +577,7 @@ GetFileNameW(clientData, interp, objc, objv, open) } case FILE_INITDIR: { Tcl_DStringFree(&utfDirString); - if (Tcl_TranslateFileName(interp, string, + if (Tcl_TranslateFileName(interp, string, &utfDirString) == NULL) { goto end; } @@ -675,8 +675,26 @@ GetFileNameW(clientData, interp, objc, objv, open) Tcl_UtfToExternalDString(unicodeEncoding, Tcl_DStringValue(&utfDirString), Tcl_DStringLength(&utfDirString), &dirString); - ofn.lpstrInitialDir = (WCHAR *) Tcl_DStringValue(&dirString); + } else { + /* + * NT 5.0 changed the meaning of lpstrInitialDir, so we have + * to ensure that we set the [pwd] if the user didn't specify + * anything else. + */ + Tcl_DString cwd; + + Tcl_DStringFree(&utfDirString); + if ((Tcl_GetCwd(interp, &utfDirString) == (char *) NULL) || + (Tcl_TranslateFileName(interp, + Tcl_DStringValue(&utfDirString), &cwd) == NULL)) { + Tcl_ResetResult(interp); + } else { + Tcl_UtfToExternalDString(unicodeEncoding, Tcl_DStringValue(&cwd), + Tcl_DStringLength(&cwd), &dirString); + } + Tcl_DStringFree(&cwd); } + ofn.lpstrInitialDir = (WCHAR *) Tcl_DStringValue(&dirString); if (title != NULL) { Tcl_UtfToExternalDString(unicodeEncoding, title, -1, &titleString); @@ -1094,8 +1112,27 @@ GetFileNameA(clientData, interp, objc, objv, open) if (Tcl_DStringValue(&utfDirString)[0] != '\0') { Tcl_UtfToExternalDString(NULL, Tcl_DStringValue(&utfDirString), Tcl_DStringLength(&utfDirString), &dirString); - ofn.lpstrInitialDir = (LPTSTR) Tcl_DStringValue(&dirString); + } else { + /* + * NT 5.0 changed the meaning of lpstrInitialDir, so we have + * to ensure that we set the [pwd] if the user didn't specify + * anything else. + */ + Tcl_DString cwd; + + Tcl_DStringFree(&utfDirString); + if ((Tcl_GetCwd(interp, &utfDirString) == (char *) NULL) || + (Tcl_TranslateFileName(interp, + Tcl_DStringValue(&utfDirString), &cwd) == NULL)) { + Tcl_ResetResult(interp); + } else { + Tcl_UtfToExternalDString(NULL, Tcl_DStringValue(&cwd), + Tcl_DStringLength(&cwd), &dirString); + } + Tcl_DStringFree(&cwd); } + ofn.lpstrInitialDir = (LPTSTR) Tcl_DStringValue(&dirString); + if (title != NULL) { Tcl_UtfToExternalDString(NULL, title, -1, &titleString); ofn.lpstrTitle = (LPTSTR) Tcl_DStringValue(&titleString); @@ -1531,8 +1568,27 @@ Tk_ChooseDirectoryObjCmd(clientData, interp, objc, objv) if (Tcl_DStringValue(&utfDirString)[0] != '\0') { Tcl_UtfToExternalDString(NULL, Tcl_DStringValue(&utfDirString), Tcl_DStringLength(&utfDirString), &dirString); - ofn.lpstrInitialDir = (LPTSTR) Tcl_DStringValue(&dirString); + } else { + /* + * NT 5.0 changed the meaning of lpstrInitialDir, so we have + * to ensure that we set the [pwd] if the user didn't specify + * anything else. + */ + Tcl_DString cwd; + + Tcl_DStringFree(&utfDirString); + if ((Tcl_GetCwd(interp, &utfDirString) == (char *) NULL) || + (Tcl_TranslateFileName(interp, + Tcl_DStringValue(&utfDirString), &cwd) == NULL)) { + Tcl_ResetResult(interp); + } else { + Tcl_UtfToExternalDString(NULL, Tcl_DStringValue(&cwd), + Tcl_DStringLength(&cwd), &dirString); + } + Tcl_DStringFree(&cwd); } + ofn.lpstrInitialDir = (LPTSTR) Tcl_DStringValue(&dirString); + if (mustExist) { ofn.Flags |= OFN_PATHMUSTEXIST; } |