diff options
author | dgp <dgp@users.sourceforge.net> | 2017-08-03 16:01:28 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2017-08-03 16:01:28 (GMT) |
commit | 051f04558369d4df68f9c7df05f1207ef72f609c (patch) | |
tree | 0a300450b0530545dfe68a96008da306771cb239 | |
parent | 96f9f5dda5fa6c34ba1d80eb40aacad05a9c931f (diff) | |
parent | c748753887adf6aa9ec1aed918f2af04fabde21a (diff) | |
download | tk-rc1.zip tk-rc1.tar.gz tk-rc1.tar.bz2 |
merge 8.6rc1
-rw-r--r-- | changes | 2 | ||||
-rw-r--r-- | macosx/tkMacOSXDialog.c | 72 |
2 files changed, 46 insertions, 28 deletions
@@ -7408,4 +7408,6 @@ Tk Cocoa 2.0: More drawing internals refinements (culler,walzer) 2017-08-02 (bug)[b601ce] Resource exhaustion processing corrupt GIF (nash) +2017-08-03 (bug)[9eab54] Fix -initialdir for OSX file dialogs (gollwitzer) + --- Released 8.6.7, August 4, 2017 --- http://core.tcl.tk/tk/ for details diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index 5bfcaf1..1383225 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -159,6 +159,23 @@ static const short alertNativeButtonIndexAndTypeToButtonIndex[][3] = { [TYPE_YESNOCANCEL] = {5, 6, 4}, }; +/* + * Construct a file URL from directory and filename. Either may + * be nil. If both are nil, returns nil. + */ +#if MAC_OS_X_VERSION_MIN_REQUIRED > 1050 +static NSURL *getFileURL(NSString *directory, NSString *filename) { + NSURL *url = nil; + if (directory) { + url = [NSURL fileURLWithPath:directory isDirectory:YES]; + } + if (filename) { + url = [NSURL URLWithString:filename relativeToURL:url]; + } + return url; +} +#endif + #pragma mark TKApplication(TKDialog) @@ -538,7 +555,6 @@ Tk_GetOpenFileObjCmd( if (len) { filename = [[[NSString alloc] initWithUTF8String:str] autorelease]; - [openpanel setNameFieldStringValue:filename]; } break; case OPEN_MESSAGE: @@ -572,12 +588,14 @@ Tk_GetOpenFileObjCmd( } } - /* From OSX 10.11, the title string is silently ignored. - * Prepend the title to the message - * NOTE should be conditional on OSX version, but - * -mmacosx-version-min does not revert this behaviour*/ if (title) { [openpanel setTitle:title]; + + /* From OSX 10.11, the title string is silently ignored in the open panel. + * 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 (message) { NSString *fullmessage = [[NSString alloc] initWithFormat:@"%@\n%@",title,message]; [message release]; @@ -659,15 +677,11 @@ Tk_GetOpenFileObjCmd( @selector(tkFilePanelDidEnd:returnCode:contextInfo:) contextInfo:callbackInfo]; #else - if (directory) { - [openpanel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]]; - } - /*check for file name, otherwise set to empty string; crashes with uncaught exception if set to nil*/ - if (filename) { - [openpanel setNameFieldStringValue:filename]; - } else { - [openpanel setNameFieldStringValue:@""]; + if (directory || filename ) { + NSURL * fileURL = getFileURL(directory, filename); + [openpanel setDirectoryURL:fileURL]; } + [openpanel beginSheetModalForWindow:parent completionHandler:^(NSInteger returnCode) { [NSApp tkFilePanelDidEnd:openpanel @@ -680,14 +694,9 @@ Tk_GetOpenFileObjCmd( modalReturnCode = [openpanel runModalForDirectory:directory file:filename]; #else - if (directory) { - [openpanel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]]; - } - /*check for file name, otherwise set to empty string; crashes with uncaught exception if set to nil*/ - if (filename) { - [openpanel setNameFieldStringValue:filename]; - } else { - [openpanel setNameFieldStringValue:@""]; + if (directory || filename ) { + NSURL * fileURL = getFileURL(directory, filename); + [openpanel setDirectoryURL:fileURL]; } modalReturnCode = [openpanel runModal]; @@ -830,13 +839,20 @@ Tk_GetSaveFileObjCmd( if (title) { [savepanel setTitle:title]; - if (message) { - NSString *fullmessage = [[NSString alloc] initWithFormat:@"%@\n%@",title,message]; - [message release]; - [title release]; - message = fullmessage; - } else { - message = 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 (haveParentOption) { + if (message) { + NSString *fullmessage = [[NSString alloc] initWithFormat:@"%@\n%@",title,message]; + [message release]; + [title release]; + message = fullmessage; + } else { + message = title; + } } } |