summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog16
-rw-r--r--win/tkWinDialog.c64
2 files changed, 69 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 9e141a0..ed08bd3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2000-11-01 Eric Melski <ericm@ajubasolutions.com>
+
+ * win/tkWinDialog.c: Added branch for 0 return from
+ CommDlgExtendedError() switches; this was formerly treated as an
+ error, but it actually is not, since it just means the user hit
+ cancel or closed the dialog. (GetFileNameW): Added better smarts
+ such that -multiple is not considered a valid option for
+ tk_getSaveFile.
+
2000-10-30 David Gravereaux <davygrvy@ajubasolutions.com>
* win/configure.in:
@@ -5,9 +14,9 @@
* win/makefile.vc:
* win/rc/tk.rc:
* win/rc/tk_base.rc (new):
- * win/rc/wish.rc: Added logic to derive filenames better in the resource
- scripts based on compile options along with better support for building
- a static wish shell with cursor resources.
+ * win/rc/wish.rc: Added logic to derive filenames better in the
+ resource scripts based on compile options along with better
+ support for building a static wish shell with cursor resources.
2000-10-27 Jeff Hobbs <hobbs@ajubasolutions.com>
@@ -23,6 +32,7 @@
* win/Makefile.in (test, winhelp, tktest): corrected the
TCL_LIBRARY path specification.
+>>>>>>> 1.236
2000-10-18 Eric Melski <ericm@ajubasolutions.com>
* win/tkWinDraw.c (RenderObject): Applied patch from [Bug: 6368],
diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c
index 2d782a6..de9f4a8 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.14 2000/10/19 00:56:25 ericm Exp $
+ * RCS: @(#) $Id: tkWinDialog.c,v 1.15 2000/11/02 00:18:02 ericm Exp $
*
*/
@@ -319,13 +319,18 @@ Tk_ChooseColorObjCmd(clientData, interp, objc, objv)
* needed.
*/
switch (CommDlgExtendedError()) {
+ case 0: {
+ /* User hit cancel or closed the dialog. */
+ result = TCL_OK;
+ break;
+ }
default: {
Tcl_SetResult(interp, "error while using color dialog",
TCL_STATIC);
+ result = TCL_ERROR;
break;
}
}
- result = TCL_ERROR;
}
return result;
@@ -485,10 +490,16 @@ GetFileNameW(clientData, interp, objc, objv, open)
Tcl_DString extString, filterString, dirString, titleString;
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
- static char *optionStrings[] = {
+ static char *saveOptionStrings[] = {
+ "-defaultextension", "-filetypes", "-initialdir", "-initialfile",
+ "-parent", "-title", NULL
+ };
+ static char *openOptionStrings[] = {
"-defaultextension", "-filetypes", "-initialdir", "-initialfile",
"-multiple", "-parent", "-title", NULL
};
+ char **optionStrings;
+
enum options {
FILE_DEFAULT, FILE_TYPES, FILE_INITDIR, FILE_INITFILE,
FILE_MULTIPLE, FILE_PARENT, FILE_TITLE
@@ -508,6 +519,12 @@ GetFileNameW(clientData, interp, objc, objv, open)
tkwin = (Tk_Window) clientData;
title = NULL;
+ if (open) {
+ optionStrings = openOptionStrings;
+ } else {
+ optionStrings = saveOptionStrings;
+ }
+
for (i = 1; i < objc; i += 2) {
int index;
char *string;
@@ -516,10 +533,24 @@ GetFileNameW(clientData, interp, objc, objv, open)
optionPtr = objv[i];
valuePtr = objv[i + 1];
- if (Tcl_GetIndexFromObj(interp, optionPtr, optionStrings, "option",
- 0, &index) != TCL_OK) {
+ if (Tcl_GetIndexFromObj(interp, optionPtr, optionStrings,
+ "option", 0, &index) != TCL_OK) {
goto end;
}
+ /*
+ * We want to maximize code sharing between the open and save file
+ * dialog implementations; in particular, the switch statement below.
+ * We use different sets of option strings from the GetIndexFromObj
+ * call above, but a single enumeration for both. The save file
+ * dialog doesn't support -multiple, but it falls in the middle of
+ * the enumeration. Ultimately, this means that when the index found
+ * by GetIndexFromObj is >= FILE_MULTIPLE, when doing a save file
+ * dialog, we have to increment the index, so that it matches the
+ * open file dialog enumeration.
+ */
+ if (!open && index >= FILE_MULTIPLE) {
+ index++;
+ }
if (i + 1 == objc) {
string = Tcl_GetStringFromObj(optionPtr, NULL);
Tcl_AppendResult(interp, "value for \"", string, "\" missing",
@@ -635,12 +666,14 @@ GetFileNameW(clientData, interp, objc, objv, open)
ofn.lpstrDefExt = (WCHAR *) Tcl_DStringValue(&extString);
}
- Tcl_UtfToExternalDString(unicodeEncoding, Tcl_DStringValue(&utfFilterString),
+ Tcl_UtfToExternalDString(unicodeEncoding,
+ Tcl_DStringValue(&utfFilterString),
Tcl_DStringLength(&utfFilterString), &filterString);
ofn.lpstrFilter = (WCHAR *) Tcl_DStringValue(&filterString);
if (Tcl_DStringValue(&utfDirString)[0] != '\0') {
- Tcl_UtfToExternalDString(unicodeEncoding, Tcl_DStringValue(&utfDirString),
+ Tcl_UtfToExternalDString(unicodeEncoding,
+ Tcl_DStringValue(&utfDirString),
Tcl_DStringLength(&utfDirString), &dirString);
ofn.lpstrInitialDir = (WCHAR *) Tcl_DStringValue(&dirString);
}
@@ -780,6 +813,11 @@ GetFileNameW(clientData, interp, objc, objv, open)
* needed.
*/
switch (CommDlgExtendedError()) {
+ case 0: {
+ /* User hit cancel or closed the dialog. */
+ result = TCL_OK;
+ break;
+ }
case FNERR_INVALIDFILENAME: {
char *p;
Tcl_DString ds;
@@ -1123,6 +1161,11 @@ GetFileNameA(clientData, interp, objc, objv, open)
* needed.
*/
switch (CommDlgExtendedError()) {
+ case 0: {
+ /* User hit cancel or closed the dialog. */
+ result = TCL_OK;
+ break;
+ }
case FNERR_INVALIDFILENAME: {
char *p;
Tcl_DString ds;
@@ -1545,13 +1588,18 @@ Tk_ChooseDirectoryObjCmd(clientData, interp, objc, objv)
* needed.
*/
switch (CommDlgExtendedError()) {
+ case 0: {
+ /* User hit cancel or closed the dialog. */
+ result = TCL_OK;
+ break;
+ }
default: {
Tcl_SetResult(interp, "error while using color dialog",
TCL_STATIC);
+ result = TCL_ERROR;
break;
}
}
- result = TCL_ERROR;
}
if (ofn.lpstrTitle != NULL) {