ui/gtk/toolkit.c

changeset 134
69e8e0936858
parent 133
6dd780cbc8c6
child 139
dbde25a5bc53
equal deleted inserted replaced
133:6dd780cbc8c6 134:69e8e0936858
40 40
41 #include <ucx/utils.h> 41 #include <ucx/utils.h>
42 42
43 #include <pthread.h> 43 #include <pthread.h>
44 44
45 #ifndef UI_GTK2
45 static GtkApplication *app; 46 static GtkApplication *app;
47 #endif
46 48
47 static char *application_name; 49 static char *application_name;
48 50
49 static ui_callback startup_func; 51 static ui_callback startup_func;
50 static void *startup_data; 52 static void *startup_data;
91 exit_func = f; 93 exit_func = f;
92 exit_data = userdata; 94 exit_data = userdata;
93 } 95 }
94 96
95 97
98 #ifndef UI_GTK2
96 static void app_startup(GtkApplication* app, gpointer userdata) { 99 static void app_startup(GtkApplication* app, gpointer userdata) {
97 startup_func(NULL, startup_data); 100 if(startup_func) {
101 startup_func(NULL, startup_data);
102 }
98 } 103 }
99 104
100 static void app_activate(GtkApplication* app, gpointer userdata) { 105 static void app_activate(GtkApplication* app, gpointer userdata) {
101 printf("activate\n"); 106 printf("activate\n");
102 } 107 }
108 #endif
103 109
104 void ui_main() { 110 void ui_main() {
105 #ifndef GTK2_LEGACY 111 #ifndef UI_GTK2
106 sstr_t appid = ucx_sprintf( 112 sstr_t appid = ucx_sprintf(
107 "ui.%s", 113 "ui.%s",
108 application_name ? application_name : "application1"); 114 application_name ? application_name : "application1");
109 115
110 app = gtk_application_new( 116 app = gtk_application_new(
115 g_application_run(G_APPLICATION (app), 0, NULL); 121 g_application_run(G_APPLICATION (app), 0, NULL);
116 g_object_unref (app); 122 g_object_unref (app);
117 123
118 free(appid.ptr); 124 free(appid.ptr);
119 #else 125 #else
126 if(startup_func) {
127 startup_func(NULL, startup_data);
128 }
120 gtk_main(); 129 gtk_main();
121 #endif 130 #endif
122 if(appclose_fnc) { 131 if(exit_func) {
123 appclose_fnc(NULL, appclose_udata); 132 exit_func(NULL, exit_data);
124 } 133 }
125 uic_store_app_properties(); 134 uic_store_app_properties();
126 } 135 }
127 136
137 #ifndef UI_GTK2
128 void ui_app_quit() { 138 void ui_app_quit() {
129 g_application_quit(G_APPLICATION(app)); 139 g_application_quit(G_APPLICATION(app));
130 } 140 }
131 141
132 GtkApplication* ui_get_application() { 142 GtkApplication* ui_get_application() {
133 return app; 143 return app;
134 } 144 }
145 #endif
135 146
136 void ui_show(UiObject *obj) { 147 void ui_show(UiObject *obj) {
137 uic_check_group_widgets(obj->ctx); 148 uic_check_group_widgets(obj->ctx);
138 gtk_widget_show_all(obj->widget); 149 gtk_widget_show_all(obj->widget);
139 } 150 }

mercurial