31 #include <string.h> |
31 #include <string.h> |
32 #include <stdbool.h> |
32 #include <stdbool.h> |
33 |
33 |
34 #include "toolkit.h" |
34 #include "toolkit.h" |
35 #include "toolbar.h" |
35 #include "toolbar.h" |
36 #include "model.h" |
|
37 #include "image.h" |
36 #include "image.h" |
38 #include "../common/document.h" |
37 #include "../common/document.h" |
39 #include "../common/properties.h" |
38 #include "../common/properties.h" |
|
39 #include "../common/menu.h" |
|
40 #include "../common/toolbar.h" |
|
41 #include "../common/threadpool.h" |
40 |
42 |
41 #include <cx/utils.h> |
43 #include <cx/utils.h> |
42 #include <cx/string.h> |
44 #include <cx/string.h> |
43 #include <cx/printf.h> |
45 #include <cx/printf.h> |
44 |
46 |
187 int result = job->job_func(job->job_data); |
187 int result = job->job_func(job->job_data); |
188 if(!result) { |
188 if(!result) { |
189 g_idle_add(ui_job_finished, job); |
189 g_idle_add(ui_job_finished, job); |
190 } |
190 } |
191 return NULL; |
191 return NULL; |
|
192 } |
|
193 |
|
194 static gboolean ui_idle_func(void *data) { |
|
195 UiJob *job = data; |
|
196 job->job_func(job->job_data); |
|
197 free(job); |
|
198 return FALSE; |
|
199 } |
|
200 |
|
201 void ui_call_mainthread(ui_threadfunc tf, void* td) { |
|
202 UiJob *job = malloc(sizeof(UiJob)); |
|
203 job->job_func = tf; |
|
204 job->job_data = td; |
|
205 job->finish_callback = NULL; |
|
206 job->finish_data = NULL; |
|
207 job->obj = NULL; |
|
208 g_idle_add(ui_idle_func, job); |
192 } |
209 } |
193 |
210 |
194 void ui_job(UiObject *obj, ui_threadfunc tf, void *td, ui_callback f, void *fd) { |
211 void ui_job(UiObject *obj, ui_threadfunc tf, void *td, ui_callback f, void *fd) { |
195 UiJob *job = malloc(sizeof(UiJob)); |
212 UiJob *job = malloc(sizeof(UiJob)); |
196 job->obj = obj; |
213 job->obj = obj; |
243 void ui_destroy_userdata(GtkWidget *object, void *userdata) { |
260 void ui_destroy_userdata(GtkWidget *object, void *userdata) { |
244 free(userdata); |
261 free(userdata); |
245 } |
262 } |
246 |
263 |
247 void ui_destroy_vardata(GtkWidget *object, UiVarEventData *data) { |
264 void ui_destroy_vardata(GtkWidget *object, UiVarEventData *data) { |
248 ui_destroy_boundvar(data->obj->ctx, data->var); |
265 if(data->var) { |
|
266 ui_destroy_boundvar(data->obj->ctx, data->var); |
|
267 } |
249 free(data); |
268 free(data); |
250 } |
269 } |
251 |
270 |
252 void ui_destroy_boundvar(UiContext *ctx, UiVar *var) { |
271 void ui_destroy_boundvar(UiContext *ctx, UiVar *var) { |
253 uic_unbind_var(var); |
272 uic_unbind_var(var); |
268 UiObject *ui_get_active_window() { |
287 UiObject *ui_get_active_window() { |
269 return active_window; |
288 return active_window; |
270 } |
289 } |
271 |
290 |
272 |
291 |
|
292 #if GTK_MAJOR_VERSION >= 3 |
|
293 |
|
294 static GtkCssProvider* ui_gtk_css_provider; |
|
295 |
|
296 static const char *ui_gtk_css = |
|
297 "#path-textfield-box {" |
|
298 " background-color: @theme_base_color;" |
|
299 " border-radius: 5px;" |
|
300 " padding: 0px;" |
|
301 "}"; |
|
302 |
|
303 void ui_css_init(void) { |
|
304 ui_gtk_css_provider = gtk_css_provider_new(); |
|
305 gtk_css_provider_load_from_data(ui_gtk_css_provider, ui_gtk_css, -1, NULL); |
|
306 |
|
307 GdkScreen *screen = gdk_screen_get_default(); |
|
308 gtk_style_context_add_provider_for_screen( |
|
309 screen, |
|
310 GTK_STYLE_PROVIDER(ui_gtk_css_provider), |
|
311 GTK_STYLE_PROVIDER_PRIORITY_USER); |
|
312 } |
|
313 |
|
314 |
|
315 |
|
316 #endif |