diff options
author | dgp <dgp@users.sourceforge.net> | 2011-10-17 19:54:09 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2011-10-17 19:54:09 (GMT) |
commit | 4579ddeec583015c60b677739c143a3224d61c07 (patch) | |
tree | 77d0f8580a41bd14e229bb0243411a29df2ebde7 /win | |
parent | 7f0c75ac2e61b2457146f5b2a39e252b250196b5 (diff) | |
download | tk-4579ddeec583015c60b677739c143a3224d61c07.zip tk-4579ddeec583015c60b677739c143a3224d61c07.tar.gz tk-4579ddeec583015c60b677739c143a3224d61c07.tar.bz2 |
Fix up the implementation to account for shared options enumeration.
Diffstat (limited to 'win')
-rw-r--r-- | win/tkWinDialog.c | 63 |
1 files changed, 20 insertions, 43 deletions
diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c index 457f0e9..6b50215 100644 --- a/win/tkWinDialog.c +++ b/win/tkWinDialog.c @@ -592,7 +592,7 @@ GetFileNameW( OFNData ofnData; int cdlgerr; int filterIndex = 0, result = TCL_ERROR, winCode, oldMode, i, multi = 0; - int confirmOverwrite = 1; + int inValue, confirmOverwrite = 1; char *extension = NULL, *title = NULL; Tk_Window tkwin = (Tk_Window) clientData; HWND hWnd; @@ -603,20 +603,21 @@ GetFileNameW( ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); static CONST char *saveOptionStrings[] = { - "-confirmoverwrite", "-defaultextension", "-filetypes", - "-initialdir", "-initialfile", "-parent", "-title", - "-typevariable", "-nocomplain", NULL + "-defaultextension", "-filetypes", "-initialdir", "-initialfile", + "-parent", "-title", "-typevariable", + "-confirmoverwrite", + NULL }; static CONST char *openOptionStrings[] = { "-defaultextension", "-filetypes", "-initialdir", "-initialfile", - "-multiple", "-parent", "-title", "-typevariable", NULL + "-parent", "-title", "-typevariable", + "-multiple", + NULL }; - CONST char **optionStrings; - enum options { - FILE_CONFOW, FILE_DEFAULT, FILE_TYPES, FILE_INITDIR, - FILE_INITFILE, FILE_MULTIPLE, FILE_PARENT, FILE_TITLE, - FILE_TYPEVARIABLE + FILE_DEFAULT, FILE_TYPES, FILE_INITDIR, FILE_INITFILE, + FILE_PARENT, FILE_TITLE, FILE_TYPEVARIABLE, + FILE_MULTIPLE_OR_CONFIRMOW }; file[0] = '\0'; @@ -624,16 +625,6 @@ GetFileNameW( Tcl_DStringInit(&utfFilterString); Tcl_DStringInit(&utfDirString); - /* - * Parse the arguments. - */ - - if (open) { - optionStrings = openOptionStrings; - } else { - optionStrings = saveOptionStrings; - } - for (i = 1; i < objc; i += 2) { int index; char *string; @@ -642,26 +633,12 @@ GetFileNameW( optionPtr = objv[i]; valuePtr = objv[i + 1]; - if (Tcl_GetIndexFromObj(interp, optionPtr, optionStrings, + if (Tcl_GetIndexFromObj(interp, optionPtr, + open ? openOptionStrings : saveOptionStrings, "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_GetString(optionPtr); Tcl_AppendResult(interp, "value for \"", string, "\" missing", @@ -696,11 +673,6 @@ GetFileNameW( sizeof(file), NULL, NULL, NULL); Tcl_DStringFree(&ds); break; - case FILE_MULTIPLE: - if (Tcl_GetBooleanFromObj(interp, valuePtr, &multi) != TCL_OK) { - return TCL_ERROR; - } - break; case FILE_PARENT: tkwin = Tk_NameToWindow(interp, string, tkwin); if (tkwin == NULL) { @@ -715,10 +687,15 @@ GetFileNameW( initialTypeObj = Tcl_ObjGetVar2(interp, typeVariableObj, NULL, TCL_GLOBAL_ONLY); break; - case FILE_CONFOW: - if (Tcl_GetBooleanFromObj(interp, valuePtr, &confirmOverwrite) != TCL_OK) { + case FILE_MULTIPLE_OR_CONFIRMOW: + if (Tcl_GetBooleanFromObj(interp, valuePtr, &inValue) != TCL_OK) { return TCL_ERROR; } + if (open) { + multi = inValue; + } else { + confirmOverwrite = inValue; + } break; } } |