From f75dd076093970f42c020063f04446e8e3abef86 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 26 Sep 2011 11:56:02 +0000 Subject: Support Visual Studio 11 --- ChangeLog | 4 +++ win/rules.vc | 106 +++++++++++++++++++++++++++++++---------------------------- 2 files changed, 59 insertions(+), 51 deletions(-) diff --git a/ChangeLog b/ChangeLog index d0964fb..fb75794 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-09-26 Jan Nijtmans + + * win/rules.vc: Supporrt Visual Studio 11 + 2011-09-06 Jan Nijtmans * unix/tcl.m4: Add --disable-rpath option to configure diff --git a/win/rules.vc b/win/rules.vc index eab35c8..b813668 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -6,7 +6,7 @@ # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -# +# # Copyright (c) 2001-2003 David Gravereaux. # Copyright (c) 2003-2006 Patrick Thoyts #------------------------------------------------------------------------------ @@ -27,18 +27,6 @@ _INSTALLDIR = C:\Program Files\Tcl _INSTALLDIR = $(INSTALLDIR:/=\) !endif -!ifndef MACHINE -!if "$(CPU)" == "" || "$(CPU)" == "i386" -MACHINE = IX86 -!else -MACHINE = $(CPU) -!endif -!endif - -!ifndef CFG_ENCODING -CFG_ENCODING = \"cp1252\" -!endif - #---------------------------------------------------------- # Set the proper copy method to avoid overwrite questions # to the user when copying files and selecting the right @@ -47,17 +35,66 @@ CFG_ENCODING = \"cp1252\" !if "$(OS)" == "Windows_NT" RMDIR = rmdir /S /Q +ERRNULL = 2>NUL !if ![ver | find "4.0" > nul] -CPY = echo y | xcopy /i +CPY = echo y | xcopy /i >NUL +COPY = copy >NUL !else CPY = xcopy /i /y >NUL +COPY = copy /y >NUL !endif -!else -CPY = xcopy /i +!else # "$(OS)" != "Windows_NT" +CPY = xcopy /i >_JUNK.OUT # On Win98 NUL does not work here. +COPY = copy >_JUNK.OUT # On Win98 NUL does not work here. RMDIR = deltree /Y +NULL = \NUL # Used in testing directory existence +ERRNULL = >NUL # Win9x shell cannot redirect stderr !endif MKDIR = mkdir -COPY = copy /y >NUL + +#------------------------------------------------------------------------------ +# Determine the host and target architectures and compiler version. +#------------------------------------------------------------------------------ + +_HASH=^# +_VC_MANIFEST_EMBED_EXE= +_VC_MANIFEST_EMBED_DLL= +VCVER=0 +!if ![echo VCVERSION=_MSC_VER > vercl.x] \ + && ![echo $(_HASH)if defined(_M_IX86) >> vercl.x] \ + && ![echo ARCH=IX86 >> vercl.x] \ + && ![echo $(_HASH)elif defined(_M_AMD64) >> vercl.x] \ + && ![echo ARCH=AMD64 >> vercl.x] \ + && ![echo $(_HASH)endif >> vercl.x] \ + && ![cl -nologo -TC -P vercl.x $(ERRNULL)] +!include vercl.i +!if ![echo VCVER= ^\> vercl.vc] \ + && ![set /a $(VCVERSION) / 100 - 6 >> vercl.vc] +!include vercl.vc +!endif +!endif +!if ![del $(ERRNUL) /q/f vercl.x vercl.i vercl.vc] +!endif + +!if ![reg query HKLM\Hardware\Description\System\CentralProcessor\0 /v Identifier | findstr /i x86] +NATIVE_ARCH=IX86 +!else +NATIVE_ARCH=AMD64 +!endif + +# Since MSVC8 we must deal with manifest resources. +!if $(VCVERSION) >= 1400 +_VC_MANIFEST_EMBED_EXE=if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;1 +_VC_MANIFEST_EMBED_DLL=if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;2 +!endif + +!ifndef MACHINE +MACHINE=$(ARCH) +!endif + +!ifndef CFG_ENCODING +CFG_ENCODING = \"cp1252\" +!endif !message =============================================================================== @@ -120,14 +157,11 @@ OPTIMIZATIONS = $(OPTIMIZATIONS) -GL DEBUGFLAGS = -# the platform SDK has broken headers that break the runtime checks for amd64 -!if "$(MACHINE)" != "AMD64" !if [nmakehlp -c -RTC1] DEBUGFLAGS = $(DEBUGFLAGS) -RTC1 !elseif [nmakehlp -c -GZ] DEBUGFLAGS = $(DEBUGFLAGS) -GZ !endif -!endif COMPILERFLAGS =-W3 @@ -178,36 +212,6 @@ LINKERFLAGS =-ltcg !endif #---------------------------------------------------------- -# MSVC8 (ships with Visual Studio 2005) generates a manifest -# file that we should link into the binaries. This is how. -#---------------------------------------------------------- - -_VC_MANIFEST_EMBED_EXE= -_VC_MANIFEST_EMBED_DLL= -VCVER=0 -!if ![echo VCVERSION=_MSC_VER > vercl.x] \ - && ![cl -nologo -TC -P vercl.x $(ERRNULL)] -!include vercl.i -!if $(VCVERSION) >= 1600 -VCVER=10 -!elseif $(VCVERSION) >= 1500 -VCVER=9 -!elseif $(VCVERSION) >= 1400 -VCVER=8 -!elseif $(VCVERSION) >= 1300 -VCVER=7 -!elseif $(VCVERSION) >= 1200 -VCVER=6 -!endif -!endif - -# Since MSVC8 we must deal with manifest resources. -!if $(VCVERSION) >= 1400 -_VC_MANIFEST_EMBED_EXE=if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;1 -_VC_MANIFEST_EMBED_DLL=if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;2 -!endif - -#---------------------------------------------------------- # Decode the options requested. #---------------------------------------------------------- @@ -510,7 +514,7 @@ TCLTOOLSDIR = $(_TCLDIR)\tools !message *** Output directory will be '$(OUT_DIR)' !message *** Suffix for binaries will be '$(SUFX)' !message *** Optional defines are '$(OPTDEFINES)' -!message *** Compiler version $(VCVER) +!message *** Compiler version $(VCVER). Target machine is $(MACHINE) !message *** Compiler options '$(OPTIMIZATIONS) $(DEBUGFLAGS)' !message *** Link options '$(LINKERFLAGS)' -- cgit v0.12 From 7571c73ea570497dcb0c8900ba99fcef9f4cbbfe Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 4 Oct 2011 17:53:34 +0000 Subject: Contributed implementation patch for TIP 382. --- library/tkfbox.tcl | 8 +++++++- 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) { -- cgit v0.12 From 7f0c75ac2e61b2457146f5b2a39e252b250196b5 Mon Sep 17 00:00:00 2001 From: dgp Date: Wed, 5 Oct 2011 19:18:20 +0000 Subject: Revise the proposed "-nocomplain" option to "-confirmoverwrite" --- library/tkfbox.tcl | 4 ++-- win/tkWinDialog.c | 20 +++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/library/tkfbox.tcl b/library/tkfbox.tcl index ffffb3e..214a31b 100644 --- a/library/tkfbox.tcl +++ b/library/tkfbox.tcl @@ -986,7 +986,7 @@ proc ::tk::dialog::file::Config {dataName type argList} { # The "-nocomplain" option is only available for the "save" file dialog. # if {$type eq "save"} { - lappend specs {-nocomplain "" "" "0"} + lappend specs {-confirmoverwrite "" "" "1"} } # 2: default values depending on the type of the dialog @@ -1865,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") && !$data(-nocomplain) && [file exists $selectFilePath]} { + if {($data(type) eq "save") && $data(-confirmoverwrite) && [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 aca8e5d..457f0e9 100644 --- a/win/tkWinDialog.c +++ b/win/tkWinDialog.c @@ -591,7 +591,8 @@ GetFileNameW( WCHAR file[TK_MULTI_MAX_PATH]; OFNData ofnData; int cdlgerr; - int filterIndex = 0, result = TCL_ERROR, winCode, oldMode, i, multi = 0, noComplain = 0; + int filterIndex = 0, result = TCL_ERROR, winCode, oldMode, i, multi = 0; + int confirmOverwrite = 1; char *extension = NULL, *title = NULL; Tk_Window tkwin = (Tk_Window) clientData; HWND hWnd; @@ -602,8 +603,9 @@ GetFileNameW( ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); static CONST char *saveOptionStrings[] = { - "-defaultextension", "-filetypes", "-initialdir", "-initialfile", - "-parent", "-title", "-typevariable", "-nocomplain", NULL + "-confirmoverwrite", "-defaultextension", "-filetypes", + "-initialdir", "-initialfile", "-parent", "-title", + "-typevariable", "-nocomplain", NULL }; static CONST char *openOptionStrings[] = { "-defaultextension", "-filetypes", "-initialdir", "-initialfile", @@ -612,9 +614,9 @@ GetFileNameW( CONST char **optionStrings; enum options { - FILE_DEFAULT, FILE_TYPES, FILE_INITDIR, FILE_INITFILE, - FILE_MULTIPLE, FILE_PARENT, FILE_TITLE, FILE_TYPEVARIABLE, - FILE_NOCOMPLAIN + FILE_CONFOW, FILE_DEFAULT, FILE_TYPES, FILE_INITDIR, + FILE_INITFILE, FILE_MULTIPLE, FILE_PARENT, FILE_TITLE, + FILE_TYPEVARIABLE }; file[0] = '\0'; @@ -713,8 +715,8 @@ GetFileNameW( initialTypeObj = Tcl_ObjGetVar2(interp, typeVariableObj, NULL, TCL_GLOBAL_ONLY); break; - case FILE_NOCOMPLAIN: - if (Tcl_GetBooleanFromObj(interp, valuePtr, &noComplain) != TCL_OK) { + case FILE_CONFOW: + if (Tcl_GetBooleanFromObj(interp, valuePtr, &confirmOverwrite) != TCL_OK) { return TCL_ERROR; } break; @@ -746,7 +748,7 @@ GetFileNameW( if (open != 0) { ofn.Flags |= OFN_FILEMUSTEXIST; - } else if (noComplain == 0) { + } else if (confirmOverwrite) { ofn.Flags |= OFN_OVERWRITEPROMPT; } if (tsdPtr->debugFlag != 0) { -- cgit v0.12 From bf90364eb7e18c50416631c1dc5f6401871886df Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 11 Oct 2011 11:33:00 +0000 Subject: Add dummy user_data field to XVirtualEvent, for improved upwards compatibility with Tk 8.5 --- ChangeLog | 6 ++++++ generic/tk.h | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/ChangeLog b/ChangeLog index fb75794..8cf7f10 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-10-11 Jan Nijtmans + + * generic/tk.h: Add dummy user_data field to + XVirtualEvent, for improved upwards compatibility + with Tk 8.5. + 2011-09-26 Jan Nijtmans * win/rules.vc: Supporrt Visual Studio 11 diff --git a/generic/tk.h b/generic/tk.h index f03992f..e777947 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -653,6 +653,10 @@ typedef struct Tk_GeomMgr { * the most information to the user. The only difference is the changing * of the detail field for a virtual event so that it holds the name of the * virtual event being triggered. + * + * When using this structure, if you want your code to work correctly + * in Tk 8.5 as well, you should ensure that you zero out all the + * fields first using memset() or bzero(). */ typedef struct { @@ -669,6 +673,7 @@ typedef struct { unsigned int state; /* key or button mask */ Tk_Uid name; /* Name of virtual event. */ Bool same_screen; /* same screen flag */ + Tcl_Obj *user_data; /* not used in Tk 8.4 */ } XVirtualEvent; typedef struct { -- cgit v0.12 From 4579ddeec583015c60b677739c143a3224d61c07 Mon Sep 17 00:00:00 2001 From: dgp Date: Mon, 17 Oct 2011 19:54:09 +0000 Subject: Fix up the implementation to account for shared options enumeration. --- library/tkfbox.tcl | 2 +- win/tkWinDialog.c | 63 +++++++++++++++++------------------------------------- 2 files changed, 21 insertions(+), 44 deletions(-) diff --git a/library/tkfbox.tcl b/library/tkfbox.tcl index 214a31b..78112e1 100644 --- a/library/tkfbox.tcl +++ b/library/tkfbox.tcl @@ -983,7 +983,7 @@ proc ::tk::dialog::file::Config {dataName type argList} { lappend specs {-multiple "" "" "0"} } - # The "-nocomplain" option is only available for the "save" file dialog. + # The "-confirmoverwrite" option is only for the "save" file dialog. # if {$type eq "save"} { lappend specs {-confirmoverwrite "" "" "1"} 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; } } -- cgit v0.12 From 5281d93c05b1c0faec54131ade30cab376fea319 Mon Sep 17 00:00:00 2001 From: dgp Date: Mon, 17 Oct 2011 20:10:41 +0000 Subject: Implementation for Carbon. --- macosx/tkMacOSXDialog.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index 7328f0e..c99cdbc 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -84,7 +84,8 @@ static int NavServicesGetFile(Tcl_Interp *interp, OpenFileData *ofd, AEDesc *initialDescPtr, char *initialFile, AEDescList *selectDescPtr, CFStringRef title, CFStringRef message, - const char *initialType, int multiple, int isOpen, + const char *initialType, int multiple, + int confirmOverwrite, int isOpen, Tk_Window parent); static int HandleInitialDirectory(Tcl_Interp *interp, char *initialFile, char *initialDir, FSRef *dirRef, @@ -366,7 +367,7 @@ Tk_GetOpenFileObjCmd( TCL_GLOBAL_ONLY); } result = NavServicesGetFile(interp, &ofd, initialPtr, NULL, &selectDesc, - title, message, initialtype, multiple, OPEN_FILE, parent); + title, message, initialtype, multiple, false, OPEN_FILE, parent); if (typeVariablePtr) { FileFilter *filterPtr = ofd.fl.filters; @@ -422,6 +423,7 @@ Tk_GetSaveFileObjCmd( Tcl_Obj *CONST objv[]) /* Argument objects. */ { int i, result = TCL_ERROR; + int confirmOverwrite = 1; char *initialFile = NULL; Tk_Window parent = NULL; AEDesc initialDesc = {typeNull, NULL}; @@ -431,11 +433,13 @@ Tk_GetSaveFileObjCmd( OpenFileData ofd; static const char *saveOptionStrings[] = { "-defaultextension", "-filetypes", "-initialdir", "-initialfile", - "-message", "-parent", "-title", "-typevariable", NULL + "-message", "-parent", "-title", "-typevariable", + "-confirmoverwrite", NULL }; enum saveOptions { SAVE_DEFAULT, SAVE_FILETYPES, SAVE_INITDIR, SAVE_INITFILE, SAVE_MESSAGE, SAVE_PARENT, SAVE_TITLE, SAVE_TYPEVARIABLE, + SAVE_CONFIRMOW }; if (!fileDlgInited) { @@ -508,6 +512,12 @@ Tk_GetSaveFileObjCmd( title = CFStringCreateWithBytes(NULL, (unsigned char *) choice, choiceLen, kCFStringEncodingUTF8, false); break; + case SAVE_CONFIRMOW: + if (Tcl_GetBooleanFromObj(interp, objv[i + 1], &confirmOverwrite) + != TCL_OK) { + return TCL_ERROR; + } + break; } } @@ -515,7 +525,7 @@ Tk_GetSaveFileObjCmd( initialPtr = &initialDesc; } result = NavServicesGetFile(interp, &ofd, initialPtr, initialFile, NULL, - title, message, NULL, false, SAVE_FILE, parent); + title, message, NULL, false, confirmOverwrite, SAVE_FILE, parent); TkFreeFileFilters(&ofd.fl); end: if (initialDesc.dataHandle) { @@ -627,7 +637,7 @@ Tk_ChooseDirectoryObjCmd( initialPtr = &initialDesc; } result = NavServicesGetFile(interp, &ofd, initialPtr, NULL, NULL, title, - message, NULL, false, CHOOSE_FOLDER, parent); + message, NULL, false, false, CHOOSE_FOLDER, parent); TkFreeFileFilters(&ofd.fl); end: if (initialDesc.dataHandle) { @@ -778,6 +788,7 @@ NavServicesGetFile( CFStringRef message, const char *initialtype, int multiple, + int confirmOverwrite, int isOpen, Tk_Window parent) { @@ -799,6 +810,9 @@ NavServicesGetFile( if (multiple) { options.optionFlags |= kNavAllowMultipleFiles; } + if (!confirmOverwrite) { + options.optionFlags |= kNavDontConfirmReplacement; + } options.modality = kWindowModalityAppModal; if (parent && ((TkWindow *) parent)->window != None && TkMacOSXHostToplevelExists(parent)) { -- cgit v0.12 From 4136000e1510b2c72b2e60eaef06bf08c6c6c7e5 Mon Sep 17 00:00:00 2001 From: dgp Date: Wed, 19 Oct 2011 15:03:24 +0000 Subject: add docs --- doc/getOpenFile.n | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/getOpenFile.n b/doc/getOpenFile.n index f95fc49..8162078 100644 --- a/doc/getOpenFile.n +++ b/doc/getOpenFile.n @@ -35,6 +35,12 @@ whether the existing file should be overwritten or not. The following \fIoption\-value\fR pairs are possible as command line arguments to these two commands: .TP +\fB\-confirmoverwrite\fR \fIboolean\fR +Configures how the Save dialog reacts when the selected file already +exists, and saving would overwrite it. A true value requests a +confirmation dialog be presented to the user. A false value requests +that the overwrite take place without confirmation. Default value is true. +.TP \fB\-defaultextension\fR \fIextension\fR Specifies a string that will be appended to the filename if the user enters a filename without an extension. The default value is the empty -- cgit v0.12