From 9e5ad14da005539b5cbc050ce5ba8ff0683b326b Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Wed, 8 Jun 2016 16:11:06 +0200 Subject: [PATCH] Start implementing untested ui_browser_window_cocoa_open function --- ui/drivers/cocoa/ui_cocoa_browser_window.m | 19 +++++++++++++++++++ ui/ui_companion_driver.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/ui/drivers/cocoa/ui_cocoa_browser_window.m b/ui/drivers/cocoa/ui_cocoa_browser_window.m index bd1d2135b8..5369e31134 100644 --- a/ui/drivers/cocoa/ui_cocoa_browser_window.m +++ b/ui/drivers/cocoa/ui_cocoa_browser_window.m @@ -25,6 +25,25 @@ static bool ui_browser_window_cocoa_open(ui_browser_window_state_t *state) { + NSOpenPanel* panel = (NSOpenPanel*)[NSOpenPanel openPanel]; + NSArray *filetypes = [[NSArray alloc] initWithObjects:BOXSTRING("dylib"), BOXSTRING("Core"), nil]; + [panel setAllowedFileTypes:filetypes]; +#if defined(MAC_OS_X_VERSION_10_6) + [panel setMessage:BOXSTRING(state->title)]; + if ([panel runModalForDirectory:BOXSTRING(state->path) file:nil] == 1) + return true; +#else + [panel setTitle:NSLocalizedString(BOXSTRING(string->title), BOXSTRING("open panel"))]; + [panel setDirectory:BOXSTRING(state->startdir)]; + [panel setCanChooseDirectories:NO]; + [panel setCanChooseFiles:YES]; + [panel setAllowsMultipleSelection:NO]; + [panel setTreatsFilePackagesAsDirectories:NO]; + NSInteger result = [panel runModal]; + if (result == 1) + return true; +#endif + return false; } diff --git a/ui/ui_companion_driver.h b/ui/ui_companion_driver.h index f119e73fa4..e26bb70b24 100644 --- a/ui/ui_companion_driver.h +++ b/ui/ui_companion_driver.h @@ -65,7 +65,9 @@ typedef struct ui_msg_window_state typedef struct ui_browser_window_state { + void *window; char *filters; + char *startdir; char *path; char *title; } ui_browser_window_state_t;