diff options
-rw-r--r-- | ChangeLog | 15 | ||||
-rw-r--r-- | library/demos/filebox.tcl | 9 | ||||
-rw-r--r-- | macosx/tkMacOSXDialog.c | 57 |
3 files changed, 44 insertions, 37 deletions
@@ -1,12 +1,17 @@ +2007-10-26 Daniel Steffen <das@users.sourceforge.net> + + * macosx/tkMacOSXDialog.c: TIP#242 cleanup. + * library/demos/filebox.tcl: demo TIP#242 -typevariable. + 2007-10-25 Joe English <jenglish@users.sourceforge.net> * generic/ttk/ttkNotebook.c: [Bug 1817596]. 2007-10-25 Jeff Hobbs <jeffh@ActiveState.com> - * doc/getOpenFile.n: TIP#242 implementation of -typevariable to - * library/tkfbox.tcl: return type of selected file in file dialogs. - * library/xmfbox.tcl: [Bug #1156388] + * doc/getOpenFile.n: TIP#242 implementation of -typevariable to + * library/tkfbox.tcl: return type of selected file in file dialogs. + * library/xmfbox.tcl: [Bug 1156388] * macosx/tkMacOSXDialog.c: * tests/filebox.test: * tests/winDialog.test: @@ -14,7 +19,7 @@ 2007-10-25 Don Porter <dgp@users.sourceforge.net> - * generic/tkPlace.c: Prevent segfault in place geometry manager. + * generic/tkPlace.c: Prevent segfault in place geometry manager. Thanks to Colin McDonald. [Bug 1818491] 2007-10-24 Joe English <jenglish@users.sourceforge.net> @@ -31,7 +36,7 @@ 2007-10-24 Pat Thoyts <patthoyts@users.sourceforge.net> - * win/tkWinDraw.c: Applied patch #1723362 for transparent bitmaps + * win/tkWinDraw.c: Applied [Patch 1723362] for transparent bitmaps. * generic/tkWindow.c: permit wm manage of any widget (esp: ttk::frame) diff --git a/library/demos/filebox.tcl b/library/demos/filebox.tcl index e27974b..c64888e 100644 --- a/library/demos/filebox.tcl +++ b/library/demos/filebox.tcl @@ -2,7 +2,7 @@ # # This demonstration script prompts the user to select a file. # -# RCS: @(#) $Id: filebox.tcl,v 1.6 2004/12/21 11:56:35 dkf Exp $ +# RCS: @(#) $Id: filebox.tcl,v 1.7 2007/10/26 07:56:02 das Exp $ if {![info exists widgetDemo]} { error "This script should be run from the \"widget\" demo." @@ -61,10 +61,13 @@ proc fileDialog {w ent operation} { {"All files" *} } if {$operation == "open"} { - set file [tk_getOpenFile -filetypes $types -parent $w] + set type "Tcl Scripts" + set file [tk_getOpenFile -filetypes $types -parent $w \ + -typevariable type] + puts "You selected filetype \"$type\"" } else { set file [tk_getSaveFile -filetypes $types -parent $w \ - -initialfile Untitled -defaultextension .txt] + -initialfile Untitled -defaultextension .txt] } if {[string compare $file ""]} { $ent delete 0 end diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index a8767c3..552650d 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXDialog.c,v 1.31 2007/10/25 21:44:22 hobbs Exp $ + * RCS: @(#) $Id: tkMacOSXDialog.c,v 1.32 2007/10/26 07:56:00 das Exp $ */ #include "tkMacOSXPrivate.h" @@ -364,10 +364,10 @@ Tk_GetOpenFileObjCmd( title, message, initialtype, multiple, OPEN_FILE, parent); if (typeVariablePtr) { + FileFilter *filterPtr = ofd.fl.filters; int i = ofd.curType; - FileFilter *filterPtr; - for (filterPtr = ofd.fl.filters; - filterPtr && i > 0; i--) { + + while (filterPtr && i-- > 0) { filterPtr = filterPtr->next; } Tcl_SetVar(interp, Tcl_GetString(typeVariablePtr), filterPtr->name, 0); @@ -1015,34 +1015,33 @@ OpenEventProc( { NavHandlerUserData *data = (NavHandlerUserData*) callBackUD; OpenFileData *ofd = data->ofdPtr; + switch (callBackSelector) { case kNavCBStart: - if (ofd && ofd->initialType >= 0) { - /* Select initial filter */ - int i = ofd->initialType; - FileFilter *filterPtr; - - for (filterPtr = ofd->fl.filters; - filterPtr && i > 0; i--) { - filterPtr = filterPtr->next; - } - if (filterPtr) { - NavMenuItemSpec selectItem; - OSStatus err; - selectItem.version = kNavMenuItemSpecVersion; - selectItem.menuCreator = 0; - selectItem.menuType = ofd->initialType; - selectItem.menuItemName[0] = strlen(filterPtr->name); - strncpy(&selectItem.menuItemName[1], filterPtr->name, 255); - err = NavCustomControl(callBackParams->context, kNavCtlSelectCustomType, &selectItem); - if (err != noErr) { - fprintf(stderr,"NavCustomControl kNavCtlSelectCustomType Failed, %d\n", (int)err ); - } - } - } - break; + if (ofd && ofd->initialType >= 0) { + /* Select initial filter */ + FileFilter *filterPtr = ofd->fl.filters; + int i = ofd->initialType; + + while (filterPtr && i-- > 0) { + filterPtr = filterPtr->next; + } + if (filterPtr) { + NavMenuItemSpec selectItem; + + selectItem.version = kNavMenuItemSpecVersion; + selectItem.menuCreator = 0; + selectItem.menuType = ofd->initialType; + selectItem.menuItemName[0] = strlen(filterPtr->name); + strncpy((char*) &selectItem.menuItemName[1], + filterPtr->name, 255); + ChkErr(NavCustomControl, callBackParams->context, + kNavCtlSelectCustomType, &selectItem); + } + } + break; case kNavCBPopupMenuSelect: - data->ofdPtr->curType = ((NavMenuItemSpec *) + ofd->curType = ((NavMenuItemSpec *) callBackParams->eventData.eventDataParms.param)->menuType; break; case kNavCBAccept: |