andlabs-ui/redo/dialog_darwin.m

31 lines
770 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>
char *openFile(void)
{
NSOpenPanel *op;
NSInteger ret;
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];
// disable custom events
// TODO doesn't seem to work
dispatch_suspend(dispatch_get_main_queue());
ret = [op runModal];
dispatch_resume(dispatch_get_main_queue());
if (ret != NSFileHandlingPanelOKButton)
return NULL;
2014-08-19 11:45:41 -05:00
// string freed on the Go side
2014-08-19 11:44:42 -05:00
return strdup([[[op URL] path] UTF8String]);
}