summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorculler <culler>2021-10-28 13:33:03 (GMT)
committerculler <culler>2021-10-28 13:33:03 (GMT)
commit554073edbdc9a4d3ac707404b7b78f76eb5e46ba (patch)
tree6e0e780f0ab360e08b9900096ff8cf98a31deae4
parentb073b90aa63190350a96903dcac16bbc701c4204 (diff)
downloadtk-554073edbdc9a4d3ac707404b7b78f76eb5e46ba.zip
tk-554073edbdc9a4d3ac707404b7b78f76eb5e46ba.tar.gz
tk-554073edbdc9a4d3ac707404b7b78f76eb5e46ba.tar.bz2
One more round - thanks to Ned Deily for testing with IDLE.
-rw-r--r--macosx/tkMacOSXDialog.c77
1 files changed, 35 insertions, 42 deletions
diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c
index afb57fb..b6f4503 100644
--- a/macosx/tkMacOSXDialog.c
+++ b/macosx/tkMacOSXDialog.c
@@ -350,39 +350,38 @@ static NSInteger showOpenSavePanel(
FilePanelCallbackInfo *callbackInfo)
{
NSInteger modalReturnCode;
- int osVersion = [NSApp macOSVersion];
+ int OSVersion = [NSApp macOSVersion];
- if (parent && ![parent attachedSheet]) {
-
- /*
- * A completion handler is not needed except on macOS 10.15, where we
- * have to start the sheet differently.
- */
+ /*
+ * Use a sheet if -parent is specified (unless there is already a sheet).
+ */
- if (osVersion >= 101500 && osVersion < 110000 ) {
+ if (parent && ![parent attachedSheet]) {
+ if (OSVersion < 101500) {
[panel beginSheetModalForWindow:parent
completionHandler:^(NSModalResponse returnCode) {
[NSApp tkFilePanelDidEnd:panel
returnCode:returnCode
contextInfo:callbackInfo ];
}];
+ modalReturnCode = [NSApp runModalForWindow:panel];
+ } else if (OSVersion < 110000) {
+ [panel beginSheetModalForWindow:parent
+ completionHandler:^(NSModalResponse returnCode) {
+ [NSApp tkFilePanelDidEnd:panel
+ returnCode:returnCode
+ contextInfo:callbackInfo ];
+ }];
+ modalReturnCode = [panel runModal];
} else {
[parent beginSheet: panel completionHandler:nil];
+ modalReturnCode = [panel runModal];
+ [NSApp tkFilePanelDidEnd:panel
+ returnCode:modalReturnCode
+ contextInfo:callbackInfo ];
}
-
- }
- /*
- * On macOS 10.15 and higher, calling runModalForWindow generates
- * warnings on stderr.
- */
-
- if ( osVersion > 101400) {
- modalReturnCode = [panel runModal];
} else {
- modalReturnCode = [NSApp runModalForWindow:panel];
- }
-
- if (osVersion < 101500 || osVersion >= 110000 ) {
+ modalReturnCode = [panel runModal];
[NSApp tkFilePanelDidEnd:panel
returnCode:modalReturnCode
contextInfo:callbackInfo ];
@@ -680,11 +679,10 @@ Tk_GetOpenFileObjCmd(
NSString *directory = nil, *filename = nil;
NSString *message = nil, *title = nil;
NSWindow *parent;
+ openpanel = [NSOpenPanel openPanel];
NSInteger modalReturnCode = modalError;
BOOL parentIsKey = NO;
- openpanel = [NSOpenPanel openPanel];
-
for (i = 1; i < objc; i += 2) {
if (Tcl_GetIndexFromObjStruct(interp, objv[i], openOptionStrings,
sizeof(char *), "option", TCL_EXACT, &index) != TCL_OK) {
@@ -747,6 +745,7 @@ Tk_GetOpenFileObjCmd(
}
}
if (title) {
+ [openpanel setTitle:title];
/*
* From OSX 10.11, the title string is silently ignored in the open
@@ -763,8 +762,6 @@ Tk_GetOpenFileObjCmd(
} else {
message = title;
}
- } else {
- [openpanel setTitle:title];
}
}
@@ -955,13 +952,10 @@ Tk_GetSaveFileObjCmd(
NSString *directory = nil, *filename = nil, *defaultType = nil;
NSString *message = nil, *title = nil;
NSWindow *parent;
+ savepanel = [NSSavePanel savePanel];
NSInteger modalReturnCode = modalError;
BOOL parentIsKey = NO;
- if (savepanel == nil) {
- savepanel = [NSSavePanel savePanel];
- [savepanel setDelegate:NSApp];
- }
for (i = 1; i < objc; i += 2) {
if (Tcl_GetIndexFromObjStruct(interp, objv[i], saveOptionStrings,
sizeof(char *), "option", TCL_EXACT, &index) != TCL_OK) {
@@ -1034,26 +1028,25 @@ Tk_GetSaveFileObjCmd(
}
if (title) {
+ [savepanel setTitle:title];
/*
* From OSX 10.11, the title string is silently ignored, if the save
* panel is a sheet. Prepend the title to the message in this case.
+ * NOTE: should be conditional on OSX version, but -mmacosx-version-min
+ * does not revert this behaviour.
*/
- if ([NSApp macOSVersion] > 101000) {
- if (haveParentOption) {
- if (message) {
- NSString *fullmessage =
- [[NSString alloc] initWithFormat:@"%@\n%@",title,message];
- [message release];
- [title release];
- message = fullmessage;
- } else {
- message = title;
- }
+ if (haveParentOption) {
+ if (message) {
+ NSString *fullmessage =
+ [[NSString alloc] initWithFormat:@"%@\n%@",title,message];
+ [message release];
+ [title release];
+ message = fullmessage;
+ } else {
+ message = title;
}
- } else {
- [savepanel setTitle:title];
}
}