2019-06-01 11:29:46 +00:00
|
|
|
#import <AppKit/AppKit.h>
|
|
|
|
#include "open_dialog.h"
|
|
|
|
|
|
|
|
|
|
|
|
char *do_open_rom_dialog(void)
|
|
|
|
{
|
|
|
|
@autoreleasepool {
|
2021-09-08 21:11:49 +00:00
|
|
|
int stderr_fd = dup(STDERR_FILENO);
|
|
|
|
close(STDERR_FILENO);
|
2019-06-01 11:29:46 +00:00
|
|
|
NSWindow *key = [NSApp keyWindow];
|
|
|
|
NSOpenPanel *dialog = [NSOpenPanel openPanel];
|
|
|
|
dialog.title = @"Open ROM";
|
2020-04-25 19:48:48 +00:00
|
|
|
dialog.allowedFileTypes = @[@"gb", @"gbc", @"sgb", @"isx"];
|
2022-05-21 15:18:34 +00:00
|
|
|
if ([dialog runModal] != NSModalResponseOK) return nil;
|
2019-06-01 11:29:46 +00:00
|
|
|
[key makeKeyAndOrderFront:nil];
|
|
|
|
NSString *ret = [[[dialog URLs] firstObject] path];
|
2021-09-08 21:11:49 +00:00
|
|
|
dup2(stderr_fd, STDERR_FILENO);
|
2019-06-01 11:29:46 +00:00
|
|
|
if (ret) {
|
|
|
|
return strdup(ret.UTF8String);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2020-12-26 13:10:11 +00:00
|
|
|
|
|
|
|
char *do_open_folder_dialog(void)
|
|
|
|
{
|
|
|
|
@autoreleasepool {
|
2021-09-08 21:11:49 +00:00
|
|
|
int stderr_fd = dup(STDERR_FILENO);
|
|
|
|
close(STDERR_FILENO);
|
2020-12-26 13:10:11 +00:00
|
|
|
NSWindow *key = [NSApp keyWindow];
|
|
|
|
NSOpenPanel *dialog = [NSOpenPanel openPanel];
|
|
|
|
dialog.title = @"Select Boot ROMs Folder";
|
|
|
|
dialog.canChooseDirectories = true;
|
|
|
|
dialog.canChooseFiles = false;
|
2022-05-21 15:18:34 +00:00
|
|
|
if ([dialog runModal] != NSModalResponseOK) return nil;
|
2020-12-26 13:10:11 +00:00
|
|
|
[key makeKeyAndOrderFront:nil];
|
|
|
|
NSString *ret = [[[dialog URLs] firstObject] path];
|
2021-09-08 21:11:49 +00:00
|
|
|
dup2(stderr_fd, STDERR_FILENO);
|
2020-12-26 13:10:11 +00:00
|
|
|
if (ret) {
|
|
|
|
return strdup(ret.UTF8String);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2022-05-21 15:18:34 +00:00
|
|
|
|
|
|
|
/* The Cocoa variant of this function isn't as fully featured as the GTK and Windows ones, as Mac users would use
|
|
|
|
the fully featured Cocoa port of SameBoy anyway*/
|
|
|
|
char *do_save_recording_dialog(unsigned frequency)
|
|
|
|
{
|
|
|
|
@autoreleasepool {
|
|
|
|
int stderr_fd = dup(STDERR_FILENO);
|
|
|
|
close(STDERR_FILENO);
|
|
|
|
NSWindow *key = [NSApp keyWindow];
|
|
|
|
NSSavePanel *dialog = [NSSavePanel savePanel];
|
|
|
|
dialog.title = @"Audio recording save location";
|
|
|
|
dialog.allowedFileTypes = @[@"aiff", @"aif", @"aifc", @"wav", @"raw", @"pcm"];
|
|
|
|
if ([dialog runModal] != NSModalResponseOK) return nil;
|
|
|
|
[key makeKeyAndOrderFront:nil];
|
|
|
|
NSString *ret = [[dialog URL] path];
|
|
|
|
dup2(stderr_fd, STDERR_FILENO);
|
|
|
|
if (ret) {
|
|
|
|
return strdup(ret.UTF8String);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|