| 29 #include <stdio.h> |
29 #include <stdio.h> |
| 30 #include <string.h> |
30 #include <string.h> |
| 31 |
31 |
| 32 #include "toolkit.h" |
32 #include "toolkit.h" |
| 33 #include "window.h" |
33 #include "window.h" |
| 34 #include "stock.h" |
|
| 35 |
34 |
| 36 #include "../common/document.h" |
35 #include "../common/document.h" |
| 37 #include "../common/properties.h" |
36 #include "../common/properties.h" |
| 38 #include "../common/menu.h" |
37 #include "../common/menu.h" |
| 39 #include "../common/toolbar.h" |
38 #include "../common/toolbar.h" |
| |
39 #include "../common/app.h" |
| 40 |
40 |
| 41 static const char *application_name; |
41 static const char *application_name; |
| 42 |
|
| 43 static ui_callback startup_func; |
|
| 44 static void *startup_data; |
|
| 45 static ui_callback open_func; |
|
| 46 static void *open_data; |
|
| 47 static ui_callback exit_func; |
|
| 48 static void *exit_data; |
|
| 49 |
42 |
| 50 static int is_toplevel_realized = 0; |
43 static int is_toplevel_realized = 0; |
| 51 |
44 |
| 52 static int app_argc; |
45 static int app_argc; |
| 53 static char **app_argv; |
46 static char **app_argv; |
| 71 |
64 |
| 72 const char* ui_appname() { |
65 const char* ui_appname() { |
| 73 return application_name; |
66 return application_name; |
| 74 } |
67 } |
| 75 |
68 |
| 76 void ui_onstartup(ui_callback f, void *userdata) { |
|
| 77 startup_func = f; |
|
| 78 startup_data = userdata; |
|
| 79 } |
|
| 80 |
|
| 81 void ui_onopen(ui_callback f, void *userdata) { |
|
| 82 open_func = f; |
|
| 83 open_data = userdata; |
|
| 84 } |
|
| 85 |
|
| 86 void ui_onexit(ui_callback f, void *userdata) { |
|
| 87 exit_func = f; |
|
| 88 exit_data = userdata; |
|
| 89 } |
|
| 90 |
|
| 91 void ui_app_exit_on_shutdown(UiBool exitapp) { |
69 void ui_app_exit_on_shutdown(UiBool exitapp) { |
| 92 exit_on_shutdown = exitapp; |
70 exit_on_shutdown = exitapp; |
| 93 } |
71 } |
| 94 |
72 |
| 95 void ui_main() { |
73 void ui_main() { |
| 96 if(startup_func) { |
74 uic_application_startup(NULL); |
| 97 startup_func(NULL, startup_data); |
|
| 98 } |
|
| 99 application->exec(); |
75 application->exec(); |
| 100 if(exit_func) { |
76 uic_application_exit(NULL); |
| 101 exit_func(NULL, exit_data); |
|
| 102 } |
|
| 103 uic_store_app_properties(); |
77 uic_store_app_properties(); |
| 104 |
78 |
| 105 delete application; |
79 delete application; |
| 106 |
80 |
| 107 if(exit_on_shutdown) { |
81 if(exit_on_shutdown) { |