andlabs-ui/prev/dialog_darwin.m

31 lines
784 B
Mathematica
Raw Normal View History

2014-08-19 11:44:42 -05:00
// 19 august 2014
#import "objc_darwin.h"
#import <Cocoa/Cocoa.h>
#define toNSWindow(x) ((NSWindow *) (x))
void openFile(id parent, void *data)
2014-08-19 11:44:42 -05:00
{
NSOpenPanel *op;
op = [NSOpenPanel openPanel];
[op setCanChooseFiles:YES];
[op setCanChooseDirectories:NO];
[op setResolvesAliases:NO];
[op setAllowsMultipleSelection:NO];
[op setShowsHiddenFiles:YES];
[op setCanSelectHiddenExtension:NO];
[op setExtensionHidden:NO];
[op setAllowsOtherFileTypes:YES];
[op setTreatsFilePackagesAsDirectories:YES];
[op beginSheetModalForWindow:toNSWindow(parent) completionHandler:^(NSInteger ret){
if (ret != NSFileHandlingPanelOKButton) {
finishOpenFile(NULL, data);
return;
}
// string freed on the Go side
finishOpenFile(strdup([[[op URL] path] UTF8String]), data);
}];
2014-08-19 11:44:42 -05:00
}