44 static ui_callback appclose_fnc; |
46 static ui_callback appclose_fnc; |
45 static void *appclose_udata; |
47 static void *appclose_udata; |
46 |
48 |
47 static int is_toplevel_realized = 0; |
49 static int is_toplevel_realized = 0; |
48 |
50 |
|
51 int event_pipe[2]; |
|
52 |
49 static String fallback[] = { |
53 static String fallback[] = { |
50 "*fontList: -dt-interface system-medium-r-normal-s*utf*:", |
54 "*fontList: -dt-interface system-medium-r-normal-s*utf*:", |
51 NULL |
55 NULL |
52 }; |
56 }; |
|
57 |
|
58 void input_proc(XtPointer data, int *source, XtInputId *iid) { |
|
59 void *ptr; |
|
60 read(event_pipe[0], &ptr, sizeof(void*)); |
|
61 } |
53 |
62 |
54 void ui_init(char *appname, int argc, char **argv) { |
63 void ui_init(char *appname, int argc, char **argv) { |
55 application_name = appname; |
64 application_name = appname; |
56 |
65 |
57 XtToolkitInitialize(); |
66 XtToolkitInitialize(); |
107 void ui_show(UiObject *obj) { |
122 void ui_show(UiObject *obj) { |
108 uic_check_group_widgets(obj->ctx); |
123 uic_check_group_widgets(obj->ctx); |
109 XtRealizeWidget(obj->widget); |
124 XtRealizeWidget(obj->widget); |
110 } |
125 } |
111 |
126 |
|
127 void ui_close(UiObject *obj) { |
|
128 // TODO |
|
129 } |
|
130 |
112 void ui_set_enabled(UIWIDGET widget, int enabled) { |
131 void ui_set_enabled(UIWIDGET widget, int enabled) { |
113 XtSetSensitive(widget, enabled); |
132 XtSetSensitive(widget, enabled); |
|
133 } |
|
134 |
|
135 void ui_set_show_all(UIWIDGET widget, int value) { |
|
136 if(!value) { |
|
137 XtUnmanageChild(widget); |
|
138 } |
|
139 } |
|
140 |
|
141 void ui_set_visible(UIWIDGET widget, int visible) { |
|
142 if(visible) { |
|
143 XtManageChild(widget); |
|
144 } else { |
|
145 XtUnmanageChild(widget); |
|
146 } |
|
147 } |
|
148 |
|
149 static Boolean ui_job_finished(void *data) { |
|
150 printf("WorkProc\n"); |
|
151 UiJob *job = data; |
|
152 |
|
153 UiEvent event; |
|
154 event.obj = job->obj; |
|
155 event.window = job->obj->window; |
|
156 event.document = job->obj->document; |
|
157 event.intval = 0; |
|
158 event.eventdata = NULL; |
|
159 |
|
160 job->finish_callback(&event, job->finish_data); |
|
161 free(job); |
|
162 return TRUE; |
|
163 } |
|
164 |
|
165 static void* ui_jobthread(void *data) { |
|
166 UiJob *job = data; |
|
167 int result = job->job_func(job->job_data); |
|
168 if(!result) { |
|
169 printf("XtAppAddWorkProc\n"); |
|
170 write(event_pipe[1], &job, sizeof(void*)); // hack |
|
171 XtAppAddWorkProc(app, ui_job_finished, job); |
|
172 |
|
173 } |
|
174 } |
|
175 |
|
176 void ui_job(UiObject *obj, ui_threadfunc tf, void *td, ui_callback f, void *fd) { |
|
177 UiJob *job = malloc(sizeof(UiJob)); |
|
178 job->obj = obj; |
|
179 job->job_func = tf; |
|
180 job->job_data = td; |
|
181 job->finish_callback = f; |
|
182 job->finish_data = fd; |
|
183 pthread_t pid; |
|
184 pthread_create(&pid, NULL, ui_jobthread, job); |
114 } |
185 } |
115 |
186 |
116 void ui_clipboard_set(char *str) { |
187 void ui_clipboard_set(char *str) { |
117 printf("copy: {%s}\n", str); |
188 printf("copy: {%s}\n", str); |
118 int length = strlen(str) + 1; |
189 int length = strlen(str) + 1; |