andlabs-ui/redo/dialog_darwin.m

29 lines
651 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];
2014-08-19 12:09:26 -05:00
beginModal();
2014-08-19 11:44:42 -05:00
ret = [op runModal];
2014-08-19 12:09:26 -05:00
endModal();
2014-08-19 11:44:42 -05:00
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]);
}