diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-05-11 10:43:33 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-05-11 10:43:33 (GMT) |
commit | 4749967fe161376a673a9017b6c5faf1cfc8dea8 (patch) | |
tree | 5f2b504d490d6c9ec67469478535c77cf965bd5e | |
parent | effd1929a965eb973d4d5c9b0d0e21b7640228c0 (diff) | |
parent | bda0a45a208de3d182d90ff66dbfd432a9cf771f (diff) | |
download | tk-4749967fe161376a673a9017b6c5faf1cfc8dea8.zip tk-4749967fe161376a673a9017b6c5faf1cfc8dea8.tar.gz tk-4749967fe161376a673a9017b6c5faf1cfc8dea8.tar.bz2 |
Merge 8.6
-rw-r--r-- | macosx/tkMacOSXDialog.c | 60 |
1 files changed, 24 insertions, 36 deletions
diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index 01cbb9f..33d677a 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -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); @@ -1758,8 +1746,8 @@ FontchooserCget( } break; case FontchooserVisible: - resObj = Tcl_NewWideIntObj([[[NSFontManager sharedFontManager] - fontPanel:NO] isVisible] != 0); + resObj = Tcl_NewBooleanObj([[[NSFontManager sharedFontManager] + fontPanel:NO] isVisible]); break; default: resObj = Tcl_NewObj(); |