diff options
author | dgp <dgp@users.sourceforge.net> | 2011-10-24 19:36:08 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2011-10-24 19:36:08 (GMT) |
commit | 01401e184830a82f44b4befbf48e2c28eab2e5d5 (patch) | |
tree | 53d88728b4e76bfba87436db447585566b576a24 /win | |
parent | 70a8983986e67b157b1ba85d4984926147ef82e4 (diff) | |
parent | bb5cf6ea1f9419bc18120ac76132162637a2941f (diff) | |
download | tk-01401e184830a82f44b4befbf48e2c28eab2e5d5.zip tk-01401e184830a82f44b4befbf48e2c28eab2e5d5.tar.gz tk-01401e184830a82f44b4befbf48e2c28eab2e5d5.tar.bz2 |
Merge TIP 382 implementation to trunk. Still need Carbon migration & Cocoa.
Diffstat (limited to 'win')
-rw-r--r-- | win/tkWinDialog.c | 60 |
1 files changed, 23 insertions, 37 deletions
diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c index 4dc8d9e..9ed5875 100644 --- a/win/tkWinDialog.c +++ b/win/tkWinDialog.c @@ -576,6 +576,7 @@ GetFileName( OFNData ofnData; int cdlgerr; int filterIndex = 0, result = TCL_ERROR, winCode, oldMode, i, multi = 0; + int inValue, confirmOverwrite = 1; const char *extension = NULL, *title = NULL; Tk_Window tkwin = clientData; HWND hWnd; @@ -587,16 +588,20 @@ GetFileName( Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); static const char *const saveOptionStrings[] = { "-defaultextension", "-filetypes", "-initialdir", "-initialfile", - "-parent", "-title", "-typevariable", NULL + "-parent", "-title", "-typevariable", + "-confirmoverwrite", + NULL }; static const char *const openOptionStrings[] = { "-defaultextension", "-filetypes", "-initialdir", "-initialfile", - "-multiple", "-parent", "-title", "-typevariable", NULL + "-parent", "-title", "-typevariable", + "-multiple", + NULL }; - const char *const *optionStrings; enum options { - 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'; @@ -604,16 +609,6 @@ GetFileName( 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; const char *string; @@ -622,26 +617,12 @@ GetFileName( 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", @@ -676,11 +657,6 @@ GetFileName( 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) { @@ -695,6 +671,16 @@ GetFileName( initialTypeObj = Tcl_ObjGetVar2(interp, typeVariableObj, NULL, TCL_GLOBAL_ONLY); break; + case FILE_MULTIPLE_OR_CONFIRMOW: + if (Tcl_GetBooleanFromObj(interp, valuePtr, &inValue) != TCL_OK) { + return TCL_ERROR; + } + if (open) { + multi = inValue; + } else { + confirmOverwrite = inValue; + } + break; } } @@ -723,7 +709,7 @@ GetFileName( if (open != 0) { ofn.Flags |= OFN_FILEMUSTEXIST; - } else { + } else if (confirmOverwrite) { ofn.Flags |= OFN_OVERWRITEPROMPT; } if (tsdPtr->debugFlag != 0) { |