ui/cocoa/toolkit.m

changeset 109
c3dfcb8f0be7
parent 108
77254bd6dccb
child 112
c3f2f16fa4b8
equal deleted inserted replaced
108:77254bd6dccb 109:c3dfcb8f0be7
32 #include "../common/properties.h" 32 #include "../common/properties.h"
33 #include "../common/menu.h" 33 #include "../common/menu.h"
34 #include "../common/toolbar.h" 34 #include "../common/toolbar.h"
35 #include "../common/threadpool.h" 35 #include "../common/threadpool.h"
36 36
37 #import "image.h"
37 #import "menu.h" 38 #import "menu.h"
39 #import "Toolbar.h"
40 #import "UiThread.h"
38 41
39 #import "AppDelegate.h" 42 #import "AppDelegate.h"
40 43
41 static const char *application_name; 44 static const char *application_name;
42 45
68 uic_load_app_properties(); 71 uic_load_app_properties();
69 72
70 [NSApplication sharedApplication]; 73 [NSApplication sharedApplication];
71 //[NSBundle loadNibNamed:@"MainMenu" owner:NSApp ]; 74 //[NSBundle loadNibNamed:@"MainMenu" owner:NSApp ];
72 //[[NSBundle mainBundle] loadNibNamed:@"MainMenu" owner:NSApp topLevelObjects:&topLevelObjects]; 75 //[[NSBundle mainBundle] loadNibNamed:@"MainMenu" owner:NSApp topLevelObjects:&topLevelObjects];
76
77 ui_icon_init();
78 ui_toolbar_init();
79
73 } 80 }
74 81
75 const char* ui_appname() { 82 const char* ui_appname() {
76 return application_name; 83 return application_name;
77 } 84 }
152 } 159 }
153 160
154 /* ------------------- Job Control / Threadpool functions ------------------- */ 161 /* ------------------- Job Control / Threadpool functions ------------------- */
155 162
156 void ui_job(UiObject *obj, ui_threadfunc tf, void *td, ui_callback f, void *fd) { 163 void ui_job(UiObject *obj, ui_threadfunc tf, void *td, ui_callback f, void *fd) {
157 164 UiThread *thread = [[UiThread alloc]init:obj jobfunc:tf jobdata:td];
165 thread.finish_callback = f;
166 thread.finish_userdata = fd;
167 [thread start];
158 } 168 }
159 169
170 @implementation UiAppCallback
171
172 - (id) initWithCallback:(ui_threadfunc)func userdata:(void*)userdata {
173 self->callback = func;
174 self->userdata = userdata;
175 return self;
176 }
177
178 - (void) callMainThread {
179 [self performSelectorOnMainThread:@selector(mainThread:)
180 withObject:nil
181 waitUntilDone:NO];
182 }
183
184 - (void) mainThread:(id)n {
185 callback(userdata);
186 }
187
188 @end
189
160 void ui_call_mainthread(ui_threadfunc tf, void* td) { 190 void ui_call_mainthread(ui_threadfunc tf, void* td) {
161 191 UiAppCallback *cb = [[UiAppCallback alloc]initWithCallback:tf userdata:td];
192 [cb callMainThread];
162 } 193 }

mercurial