2015-08-16 21:30:44 -05:00
|
|
|
// 26 june 2015
|
|
|
|
#import "uipriv_darwin.h"
|
|
|
|
|
2015-08-25 18:26:51 -05:00
|
|
|
// note: whether extensions are actually shown depends on a user setting in Finder; we can't control it here
|
2015-08-25 18:10:29 -05:00
|
|
|
static void setupSavePanel(NSSavePanel *s)
|
|
|
|
{
|
|
|
|
[s setCanCreateDirectories:YES];
|
|
|
|
[s setShowsHiddenFiles:YES];
|
|
|
|
[s setExtensionHidden:NO];
|
|
|
|
[s setCanSelectHiddenExtension:NO];
|
|
|
|
[s setTreatsFilePackagesAsDirectories:YES];
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *runSavePanel(NSSavePanel *s)
|
|
|
|
{
|
|
|
|
char *filename;
|
|
|
|
|
|
|
|
if ([s runModal] != NSFileHandlingPanelOKButton)
|
|
|
|
return NULL;
|
|
|
|
filename = uiDarwinNSStringToText([[s URL] path]);
|
|
|
|
return filename;
|
|
|
|
}
|
|
|
|
|
2015-08-16 21:30:44 -05:00
|
|
|
char *uiOpenFile(void)
|
|
|
|
{
|
2015-08-25 18:10:29 -05:00
|
|
|
NSOpenPanel *o;
|
|
|
|
|
|
|
|
o = [NSOpenPanel openPanel];
|
|
|
|
[o setCanChooseFiles:YES];
|
|
|
|
[o setCanChooseDirectories:NO];
|
|
|
|
[o setResolvesAliases:NO];
|
|
|
|
[o setAllowsMultipleSelection:NO];
|
|
|
|
setupSavePanel(o);
|
|
|
|
// panel is autoreleased
|
|
|
|
return runSavePanel(o);
|
2015-08-16 21:30:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
char *uiSaveFile(void)
|
|
|
|
{
|
2015-08-25 18:10:29 -05:00
|
|
|
NSSavePanel *s;
|
|
|
|
|
|
|
|
s = [NSSavePanel savePanel];
|
|
|
|
setupSavePanel(s);
|
|
|
|
// panel is autoreleased
|
|
|
|
return runSavePanel(s);
|
2015-08-16 21:30:44 -05:00
|
|
|
}
|
|
|
|
|
2015-08-25 18:26:51 -05:00
|
|
|
static void msgbox(const char *title, const char *description, NSAlertStyle style)
|
|
|
|
{
|
|
|
|
NSAlert *a;
|
|
|
|
|
|
|
|
a = [NSAlert new];
|
|
|
|
[a setAlertStyle:style];
|
|
|
|
[a setShowsHelp:NO];
|
|
|
|
[a setShowsSuppressionButton:NO];
|
|
|
|
[a setMessageText:toNSString(title)];
|
|
|
|
[a setInformativeText:toNSString(description)];
|
|
|
|
[a addButtonWithTitle:@"OK"];
|
|
|
|
[a runModal];
|
|
|
|
[a release];
|
|
|
|
}
|
|
|
|
|
2015-08-16 21:30:44 -05:00
|
|
|
void uiMsgBox(const char *title, const char *description)
|
|
|
|
{
|
2015-08-25 18:26:51 -05:00
|
|
|
msgbox(title, description, NSInformationalAlertStyle);
|
2015-08-16 21:30:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void uiMsgBoxError(const char *title, const char *description)
|
|
|
|
{
|
2015-08-25 18:26:51 -05:00
|
|
|
msgbox(title, description, NSCriticalAlertStyle);
|
2015-08-16 21:30:44 -05:00
|
|
|
}
|