diff options
author | dgp@users.sourceforge.net <dgp> | 2011-10-04 17:53:34 (GMT) |
---|---|---|
committer | dgp@users.sourceforge.net <dgp> | 2011-10-04 17:53:34 (GMT) |
commit | 16e0659d26c3f09e27dc97e5a5006c77f7fdf204 (patch) | |
tree | 5b4bc1f3f667dfcaf144b9a436b6a296ed6ede81 | |
parent | 535f48ce0196477011a3216451d8eadd0a8872f0 (diff) | |
download | tk-16e0659d26c3f09e27dc97e5a5006c77f7fdf204.zip tk-16e0659d26c3f09e27dc97e5a5006c77f7fdf204.tar.gz tk-16e0659d26c3f09e27dc97e5a5006c77f7fdf204.tar.bz2 |
Contributed implementation patch for TIP 382.
-rw-r--r-- | library/tkfbox.tcl | 8 | ||||
-rw-r--r-- | win/tkWinDialog.c | 14 |
2 files changed, 17 insertions, 5 deletions
diff --git a/library/tkfbox.tcl b/library/tkfbox.tcl index 4ccf3d7..ffffb3e 100644 --- a/library/tkfbox.tcl +++ b/library/tkfbox.tcl @@ -983,6 +983,12 @@ proc ::tk::dialog::file::Config {dataName type argList} { lappend specs {-multiple "" "" "0"} } + # The "-nocomplain" option is only available for the "save" file dialog. + # + if {$type eq "save"} { + lappend specs {-nocomplain "" "" "0"} + } + # 2: default values depending on the type of the dialog # if {![info exists data(selectPath)]} { @@ -1859,7 +1865,7 @@ proc ::tk::dialog::file::Done {w {selectFilePath ""}} { set Priv(selectFile) $data(selectFile) set Priv(selectPath) $data(selectPath) - if {($data(type) eq "save") && [file exists $selectFilePath]} { + if {($data(type) eq "save") && !$data(-nocomplain) && [file exists $selectFilePath]} { set reply [tk_messageBox -icon warning -type yesno -parent $w \ -message [mc "File \"%1\$s\" already exists.\nDo you want\ to overwrite it?" $selectFilePath]] diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c index de7e84f..aca8e5d 100644 --- a/win/tkWinDialog.c +++ b/win/tkWinDialog.c @@ -591,7 +591,7 @@ GetFileNameW( WCHAR file[TK_MULTI_MAX_PATH]; OFNData ofnData; int cdlgerr; - int filterIndex = 0, result = TCL_ERROR, winCode, oldMode, i, multi = 0; + int filterIndex = 0, result = TCL_ERROR, winCode, oldMode, i, multi = 0, noComplain = 0; char *extension = NULL, *title = NULL; Tk_Window tkwin = (Tk_Window) clientData; HWND hWnd; @@ -603,7 +603,7 @@ GetFileNameW( Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); static CONST char *saveOptionStrings[] = { "-defaultextension", "-filetypes", "-initialdir", "-initialfile", - "-parent", "-title", "-typevariable", NULL + "-parent", "-title", "-typevariable", "-nocomplain", NULL }; static CONST char *openOptionStrings[] = { "-defaultextension", "-filetypes", "-initialdir", "-initialfile", @@ -613,7 +613,8 @@ GetFileNameW( enum options { FILE_DEFAULT, FILE_TYPES, FILE_INITDIR, FILE_INITFILE, - FILE_MULTIPLE, FILE_PARENT, FILE_TITLE, FILE_TYPEVARIABLE + FILE_MULTIPLE, FILE_PARENT, FILE_TITLE, FILE_TYPEVARIABLE, + FILE_NOCOMPLAIN }; file[0] = '\0'; @@ -712,6 +713,11 @@ GetFileNameW( initialTypeObj = Tcl_ObjGetVar2(interp, typeVariableObj, NULL, TCL_GLOBAL_ONLY); break; + case FILE_NOCOMPLAIN: + if (Tcl_GetBooleanFromObj(interp, valuePtr, &noComplain) != TCL_OK) { + return TCL_ERROR; + } + break; } } @@ -740,7 +746,7 @@ GetFileNameW( if (open != 0) { ofn.Flags |= OFN_FILEMUSTEXIST; - } else { + } else if (noComplain == 0) { ofn.Flags |= OFN_OVERWRITEPROMPT; } if (tsdPtr->debugFlag != 0) { |