301:f9e7c57e1e2f | 302:b00cbbfeec7a |
---|---|
44 #include <cx/string.h> | 44 #include <cx/string.h> |
45 #include <cx/printf.h> | 45 #include <cx/printf.h> |
46 | 46 |
47 #include <pthread.h> | 47 #include <pthread.h> |
48 | 48 |
49 #ifndef UI_GTK2 | 49 #ifdef UI_APPLICATION |
50 static GtkApplication *app; | 50 UI_APPLICATION app; |
51 #endif | 51 #endif |
52 | 52 |
53 static const char *application_name; | 53 static const char *application_name; |
54 | 54 |
55 static ui_callback startup_func; | 55 static ui_callback startup_func; |
121 printf("activate\n"); | 121 printf("activate\n"); |
122 } | 122 } |
123 #endif | 123 #endif |
124 | 124 |
125 void ui_main() { | 125 void ui_main() { |
126 #ifndef UI_GTK2 | 126 #ifdef UI_APPLICATION |
127 cxmutstr appid = cx_asprintf( | 127 cxmutstr appid = cx_asprintf( |
128 "ui.%s", | 128 "ui.%s", |
129 application_name ? application_name : "application1"); | 129 application_name ? application_name : "application1"); |
130 | 130 app = UI_APPLICATION_NEW(appid.ptr); |
131 app = gtk_application_new( | |
132 appid.ptr, | |
133 G_APPLICATION_FLAGS_NONE); | |
134 g_signal_connect (app, "startup", G_CALLBACK (app_startup), NULL); | 131 g_signal_connect (app, "startup", G_CALLBACK (app_startup), NULL); |
135 g_signal_connect (app, "activate", G_CALLBACK (app_activate), NULL); | 132 g_signal_connect (app, "activate", G_CALLBACK (app_activate), NULL); |
136 g_application_run(G_APPLICATION (app), 0, NULL); | 133 g_application_run(G_APPLICATION (app), 0, NULL); |
137 g_object_unref (app); | 134 g_object_unref (app); |
138 | 135 |
153 void ui_app_quit() { | 150 void ui_app_quit() { |
154 g_application_quit(G_APPLICATION(app)); | 151 g_application_quit(G_APPLICATION(app)); |
155 } | 152 } |
156 | 153 |
157 GtkApplication* ui_get_application() { | 154 GtkApplication* ui_get_application() { |
158 return app; | 155 return GTK_APPLICATION(app); |
159 } | 156 } |
160 #endif | 157 #endif |
161 | 158 |
162 void ui_show(UiObject *obj) { | 159 void ui_show(UiObject *obj) { |
163 uic_check_group_widgets(obj->ctx); | 160 uic_check_group_widgets(obj->ctx); |