application/main.c

branch
newapi
changeset 347
6f0d0b0d97f5
parent 345
d2ccc543f432
equal deleted inserted replaced
346:a20213cb3d2f 347:6f0d0b0d97f5
48 48
49 MyDocument *doc1; 49 MyDocument *doc1;
50 MyDocument *doc2; 50 MyDocument *doc2;
51 51
52 UIWIDGET tabview; 52 UIWIDGET tabview;
53
54 static UiCondVar *cond;
55 static int thr_end = 0;
56 static int thr_started = 0;
57
58 int threadfunc(void *data) {
59 printf("thr wait for data...\n");
60 ui_condvar_wait(cond);
61 printf("thr data received: {%s} [%d]\n", cond->data, cond->intdata);
62 ui_condvar_destroy(cond);
63 cond = NULL;
64
65 return 0;
66 }
67
68 void action_start_thread(UiEvent *event, void *data) {
69 if(!thr_started) {
70 cond = ui_condvar_create();
71 ui_job(event->obj, threadfunc, NULL, NULL, NULL);
72 thr_started = 1;
73 }
74 }
75
76 void action_notify_thread(UiEvent *event, void *data) {
77 if(!thr_end) {
78 ui_condvar_signal(cond, "hello thread", 123);
79 thr_end = 1;
80 }
81 }
53 82
54 void action_menu(UiEvent *event, void *userdata) { 83 void action_menu(UiEvent *event, void *userdata) {
55 84
56 } 85 }
57 86
250 ui_radiobutton(obj, .label = "Radio 3", .varname = "radio"); 279 ui_radiobutton(obj, .label = "Radio 3", .varname = "radio");
251 } 280 }
252 } 281 }
253 } 282 }
254 ui_tab(obj, "Tab 2") { 283 ui_tab(obj, "Tab 2") {
255 ui_button(obj, .label = "Button 1", .onclick=action_tab2_button); 284 ui_button(obj, .label = "Button 1 Start Thread", .onclick=action_start_thread);
256 ui_button(obj, .label = "Button 2", .onclick=action_tab2_button); 285 ui_button(obj, .label = "Button 2 Notify Thread", .onclick=action_notify_thread);
257 ui_button(obj, .label = "Button 3", .onclick=action_tab2_button); 286 ui_button(obj, .label = "Button 3", .onclick=action_tab2_button);
258 ui_button(obj, .label = "Button 4", .onclick=action_tab2_button); 287 ui_button(obj, .label = "Button 4", .onclick=action_tab2_button);
259 ui_button(obj, .label = "Button 5", .onclick=action_tab2_button); 288 ui_button(obj, .label = "Button 5", .onclick=action_tab2_button);
260 ui_button(obj, .label = "Button 6", .onclick=action_tab2_button); 289 ui_button(obj, .label = "Button 6", .onclick=action_tab2_button);
261 } 290 }

mercurial