--- a/ui/cocoa/toolkit.m Sun Jul 20 22:04:39 2025 +0200 +++ b/ui/cocoa/toolkit.m Sun Aug 24 15:24:16 2025 +0200 @@ -34,7 +34,10 @@ #include "../common/toolbar.h" #include "../common/threadpool.h" +#import "image.h" #import "menu.h" +#import "Toolbar.h" +#import "UiThread.h" #import "AppDelegate.h" @@ -70,6 +73,10 @@ [NSApplication sharedApplication]; //[NSBundle loadNibNamed:@"MainMenu" owner:NSApp ]; //[[NSBundle mainBundle] loadNibNamed:@"MainMenu" owner:NSApp topLevelObjects:&topLevelObjects]; + + ui_icon_init(); + ui_toolbar_init(); + } const char* ui_appname() { @@ -154,9 +161,33 @@ /* ------------------- Job Control / Threadpool functions ------------------- */ void ui_job(UiObject *obj, ui_threadfunc tf, void *td, ui_callback f, void *fd) { + UiThread *thread = [[UiThread alloc]init:obj jobfunc:tf jobdata:td]; + thread.finish_callback = f; + thread.finish_userdata = fd; + [thread start]; +} +@implementation UiAppCallback + +- (id) initWithCallback:(ui_threadfunc)func userdata:(void*)userdata { + self->callback = func; + self->userdata = userdata; + return self; } -void ui_call_mainthread(ui_threadfunc tf, void* td) { +- (void) callMainThread { + [self performSelectorOnMainThread:@selector(mainThread:) + withObject:nil + waitUntilDone:NO]; +} +- (void) mainThread:(id)n { + callback(userdata); } + +@end + +void ui_call_mainthread(ui_threadfunc tf, void* td) { + UiAppCallback *cb = [[UiAppCallback alloc]initWithCallback:tf userdata:td]; + [cb callMainThread]; +}