diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-05-11 10:32:58 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-05-11 10:32:58 (GMT) |
commit | bda0a45a208de3d182d90ff66dbfd432a9cf771f (patch) | |
tree | fb16357fbde6343a1c5e8c2e65ca8c14313c314b /macosx | |
parent | 4bb160420e2b3b5c71e3a040cf2f1af8c86db858 (diff) | |
download | tk-bda0a45a208de3d182d90ff66dbfd432a9cf771f.zip tk-bda0a45a208de3d182d90ff66dbfd432a9cf771f.tar.gz tk-bda0a45a208de3d182d90ff66dbfd432a9cf771f.tar.bz2 |
Follow-up to [88cfdcb304]: Move callbackInfo handling into showOpenSavePanel()
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/tkMacOSXDialog.c | 58 |
1 files changed, 23 insertions, 35 deletions
diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index 9545b81..f850fbb 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -4,7 +4,7 @@ * Contains the Mac implementation of the common dialog boxes. * * Copyright (c) 1996-1997 Sun Microsystems, Inc. - * Copyright 2001-2009, Apple Inc. + * Copyright (c) 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net> * Copyright (c) 2017 Christian Gollwitzer. * @@ -219,9 +219,9 @@ getFileURL( - (void) tkFilePanelDidEnd: (NSSavePanel *) panel returnCode: (NSModalResponse) returnCode - contextInfo: (void *) contextInfo + contextInfo: (const void *) contextInfo { - FilePanelCallbackInfo *callbackInfo = (FilePanelCallbackInfo *)contextInfo; + const FilePanelCallbackInfo *callbackInfo = (const FilePanelCallbackInfo *)contextInfo; if (returnCode == modalOK) { Tcl_Obj *resultObj; @@ -258,7 +258,7 @@ getFileURL( } - (void) tkAlertDidEnd: (NSAlert *) alert returnCode: (NSInteger) returnCode - contextInfo: (void *) contextInfo + contextInfo: (const void *) contextInfo { AlertCallbackInfo *callbackInfo = (AlertCallbackInfo *)contextInfo; @@ -337,10 +337,13 @@ getFileURL( static NSInteger showOpenSavePanel( NSSavePanel *panel, NSWindow *parent, - FilePanelCallbackInfo *callbackInfo) + Tcl_Interp *interp, + Tcl_Obj *cmdObj, + int multiple) { NSInteger modalReturnCode; int OSVersion = [NSApp macOSVersion]; + const FilePanelCallbackInfo callbackInfo = {interp, cmdObj, multiple}; /* * Use a sheet if -parent is specified (unless there is already a sheet). @@ -352,7 +355,7 @@ static NSInteger showOpenSavePanel( completionHandler:^(NSModalResponse returnCode) { [NSApp tkFilePanelDidEnd:panel returnCode:returnCode - contextInfo:callbackInfo ]; + contextInfo:&callbackInfo ]; }]; modalReturnCode = [NSApp runModalForWindow:panel]; } else if (OSVersion < 110000) { @@ -360,7 +363,7 @@ static NSInteger showOpenSavePanel( completionHandler:^(NSModalResponse returnCode) { [NSApp tkFilePanelDidEnd:panel returnCode:returnCode - contextInfo:callbackInfo ]; + contextInfo:&callbackInfo ]; }]; modalReturnCode = [panel runModal]; } else { @@ -368,16 +371,16 @@ static NSInteger showOpenSavePanel( modalReturnCode = [panel runModal]; [NSApp tkFilePanelDidEnd:panel returnCode:modalReturnCode - contextInfo:callbackInfo ]; + contextInfo:&callbackInfo ]; [parent endSheet:panel]; } } else { modalReturnCode = [panel runModal]; [NSApp tkFilePanelDidEnd:panel returnCode:modalReturnCode - contextInfo:callbackInfo ]; + contextInfo:&callbackInfo ]; } - return callbackInfo->cmdObj ? modalOther : modalReturnCode; + return cmdObj ? modalOther : modalReturnCode; } /* @@ -665,8 +668,6 @@ Tk_GetOpenFileObjCmd( int i, result = TCL_ERROR, haveParentOption = 0; int index, len, multiple = 0; Tcl_Obj *cmdObj = NULL, *typeVariablePtr = NULL, *fileTypesPtr = NULL; - FilePanelCallbackInfo callbackInfoStruct; - FilePanelCallbackInfo *callbackInfo = &callbackInfoStruct; NSString *directory = nil, *filename = nil; NSString *message = nil, *title = nil; NSWindow *parent; @@ -823,9 +824,6 @@ Tk_GetOpenFileObjCmd( } Tcl_IncrRefCount(cmdObj); } - callbackInfo->cmdObj = cmdObj; - callbackInfo->interp = interp; - callbackInfo->multiple = multiple; if (directory || filename) { NSURL *fileURL = getFileURL(directory, filename); @@ -838,7 +836,7 @@ Tk_GetOpenFileObjCmd( parent = nil; parentIsKey = False; } - modalReturnCode = showOpenSavePanel(openpanel, parent, callbackInfo); + modalReturnCode = showOpenSavePanel(openpanel, parent, interp, cmdObj, multiple); if (cmdObj) { Tcl_DecrRefCount(cmdObj); } @@ -940,8 +938,6 @@ Tk_GetSaveFileObjCmd( int confirmOverwrite = 1; int index, len; Tcl_Obj *cmdObj = NULL, *typeVariablePtr = NULL, *fileTypesPtr = NULL; - FilePanelCallbackInfo callbackInfoStruct; - FilePanelCallbackInfo *callbackInfo = &callbackInfoStruct; NSString *directory = nil, *filename = nil, *defaultType = nil; NSString *message = nil, *title = nil; NSWindow *parent; @@ -1101,9 +1097,6 @@ Tk_GetSaveFileObjCmd( } Tcl_IncrRefCount(cmdObj); } - callbackInfo->cmdObj = cmdObj; - callbackInfo->interp = interp; - callbackInfo->multiple = 0; if (directory) { [savepanel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]]; @@ -1126,7 +1119,7 @@ Tk_GetSaveFileObjCmd( parent = nil; parentIsKey = False; } - modalReturnCode = showOpenSavePanel(savepanel, parent, callbackInfo); + modalReturnCode = showOpenSavePanel(savepanel, parent, interp, cmdObj, 0); if (cmdObj) { Tcl_DecrRefCount(cmdObj); } @@ -1183,8 +1176,6 @@ Tk_ChooseDirectoryObjCmd( int i, result = TCL_ERROR, haveParentOption = 0; int index, len, mustexist = 0; Tcl_Obj *cmdObj = NULL; - FilePanelCallbackInfo callbackInfoStruct; - FilePanelCallbackInfo *callbackInfo = &callbackInfoStruct; NSString *directory = nil; NSString *message, *title; NSWindow *parent; @@ -1252,9 +1243,6 @@ Tk_ChooseDirectoryObjCmd( } Tcl_IncrRefCount(cmdObj); } - callbackInfo->cmdObj = cmdObj; - callbackInfo->interp = interp; - callbackInfo->multiple = 0; /* * Check for directory value, set to root if not specified; otherwise @@ -1273,7 +1261,7 @@ Tk_ChooseDirectoryObjCmd( parent = nil; parentIsKey = False; } - modalReturnCode = showOpenSavePanel(panel, parent, callbackInfo); + modalReturnCode = showOpenSavePanel(panel, parent, interp, cmdObj, 0); if (cmdObj) { Tcl_DecrRefCount(cmdObj); } @@ -1367,7 +1355,7 @@ Tk_MessageBoxObjCmd( int index, typeIndex, iconIndex, indexDefaultOption = 0; int defaultNativeButtonIndex = 1; /* 1, 2, 3: right to left */ Tcl_Obj *cmdObj = NULL; - AlertCallbackInfo callbackInfoStruct, *callbackInfo = &callbackInfoStruct; + AlertCallbackInfo callbackInfo; NSString *message, *title; NSWindow *parent; NSArray *buttons; @@ -1495,9 +1483,9 @@ Tk_MessageBoxObjCmd( } Tcl_IncrRefCount(cmdObj); } - callbackInfo->cmdObj = cmdObj; - callbackInfo->interp = interp; - callbackInfo->typeIndex = typeIndex; + callbackInfo.cmdObj = cmdObj; + callbackInfo.interp = interp; + callbackInfo.typeIndex = typeIndex; parent = TkMacOSXGetNSWindowForDrawable(((TkWindow *)tkwin)->window); if (haveParentOption && parent && ![parent attachedSheet]) { parentIsKey = [parent isKeyWindow]; @@ -1506,20 +1494,20 @@ Tk_MessageBoxObjCmd( completionHandler:^(NSModalResponse returnCode) { [NSApp tkAlertDidEnd:alert returnCode:returnCode - contextInfo:callbackInfo]; + contextInfo:&callbackInfo]; }]; #else [alert beginSheetModalForWindow:parent modalDelegate:NSApp didEndSelector:@selector(tkAlertDidEnd:returnCode:contextInfo:) - contextInfo:callbackInfo]; + contextInfo:&callbackInfo]; #endif modalReturnCode = cmdObj ? 0 : [alert runModal]; } else { modalReturnCode = [alert runModal]; [NSApp tkAlertDidEnd:alert returnCode:modalReturnCode - contextInfo:callbackInfo]; + contextInfo:&callbackInfo]; } if (cmdObj) { Tcl_DecrRefCount(cmdObj); |