37 extern "C" { |
37 extern "C" { |
38 #endif |
38 #endif |
39 |
39 |
40 #pragma clang diagnostic ignored "-Wdeprecated-declarations" |
40 #pragma clang diagnostic ignored "-Wdeprecated-declarations" |
41 |
41 |
|
42 |
|
43 #if GLIB_MAJOR_VERSION * 1000 + GLIB_MINOR_VERSION > 2074 |
|
44 #define UI_G_APPLICATION_FLAGS G_APPLICATION_DEFAULT_FLAGS |
|
45 #else |
|
46 #define UI_G_APPLICATION_FLAGS G_APPLICATION_FLAGS_NONE |
|
47 #endif |
|
48 |
|
49 #ifdef UI_LIBADWAITA |
|
50 #define UI_APPLICATION AdwApplication* |
|
51 #define UI_APPLICATION_NEW(id) adw_application_new(id, UI_G_APPLICATION_FLAGS) |
|
52 #elif GTK_MAJOR_VERSION >= 3 |
|
53 #define UI_APPLICATION GtkApplication* |
|
54 #define UI_APPLICATION_NEW(id) gtk_application_new(id, UI_G_APPLICATION_FLAGS) |
|
55 #endif |
|
56 |
|
57 #if GTK_MAJOR_VERSION >= 4 |
|
58 #define WINDOW_SHOW(window) gtk_window_present(GTK_WINDOW(window)) |
|
59 #define WINDOW_DESTROY(window) gtk_window_destroy(GTK_WINDOW(window)) |
|
60 #define WINDOW_SET_CONTENT(window, child) gtk_window_set_child(GTK_WINDOW(window), child) |
|
61 #define BOX_ADD(box, child) gtk_box_append(GTK_BOX(box), child) |
|
62 #define BOX_ADD_EXPAND(box, child) gtk_widget_set_hexpand(child, TRUE); gtk_widget_set_vexpand(child, TRUE); gtk_box_append(GTK_BOX(box), child) |
|
63 #define BOX_ADD_NO_EXPAND(box, child) gtk_box_append(GTK_BOX(box), child) |
|
64 #define BOX_REMOVE(box, child) gtk_box_remove(GTK_BOX(box), child) |
|
65 #define ENTRY_SET_TEXT(entry, text) gtk_editable_set_text(GTK_EDITABLE(entry), text) |
|
66 #define ENTRY_GET_TEXT(entry) gtk_editable_get_text(GTK_EDITABLE(entry)) |
|
67 #define SCROLLEDWINDOW_NEW() gtk_scrolled_window_new() |
|
68 #define SCROLLEDWINDOW_SET_CHILD(sw, child) gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), child) |
|
69 #define SCROLLEDWINDOW_GET_CHILD(sw) gtk_scrolled_window_get_child(GTK_SCROLLED_WINDOW(sw)) |
|
70 #define FRAME_SET_CHILD(frame, child) gtk_frame_set_child(GTK_FRAME(frame), child) |
|
71 #define EXPANDER_SET_CHILD(expander, child) gtk_expander_set_child(GTK_EXPANDER(expander), child) |
|
72 #define WIDGET_ADD_CSS_CLASS(w, cssclass) gtk_widget_add_css_class(w, cssclass) |
|
73 #define WIDGET_REMOVE_CSS_CLASS(w, cssclass) gtk_widget_remove_css_class(w, cssclass) |
|
74 #define ICON_IMAGE(icon) gtk_image_new_from_icon_name(icon) |
|
75 #define LISTBOX_REMOVE(listbox, row) gtk_list_box_remove(GTK_LIST_BOX(listbox), row) |
|
76 #define LISTBOX_ROW_SET_CHILD(row, child) gtk_list_box_row_set_child(GTK_LIST_BOX_ROW(row), child) |
|
77 #else |
|
78 #define WINDOW_SHOW(window) gtk_widget_show_all(window) |
|
79 #define WINDOW_DESTROY(window) gtk_widget_destroy(window) |
|
80 #define WINDOW_SET_CONTENT(window, child) gtk_container_add(GTK_CONTAINER(window), child) |
|
81 #define BOX_ADD(box, child) gtk_container_add(GTK_CONTAINER(box), child) |
|
82 #define BOX_ADD_EXPAND(box, child) gtk_box_pack_start(GTK_BOX(box), child, TRUE, TRUE, 0) |
|
83 #define BOX_ADD_NO_EXPAND(box, child) gtk_box_pack_start(GTK_BOX(box), child, TRUE, FALSE, 0) |
|
84 #define BOX_REMOVE(box, child) gtk_container_remove(GTK_CONTAINER(box), child) |
|
85 #define ENTRY_SET_TEXT(entry, text) gtk_entry_set_text(GTK_ENTRY(entry), text) |
|
86 #define ENTRY_GET_TEXT(entry) gtk_entry_get_text(GTK_ENTRY(entry)) |
|
87 #define SCROLLEDWINDOW_NEW() gtk_scrolled_window_new(NULL, NULL) |
|
88 #define SCROLLEDWINDOW_SET_CHILD(sw, child) gtk_container_add(GTK_CONTAINER(sw), child) |
|
89 #define SCROLLEDWINDOW_GET_CHILD(sw) gtk_bin_get_child(GTK_BIN(sw)) |
|
90 #define FRAME_SET_CHILD(frame, child) gtk_container_add(GTK_CONTAINER(frame), child) |
|
91 #define EXPANDER_SET_CHILD(expander, child) gtk_container_add(GTK_CONTAINER(expander), child) |
|
92 #define WIDGET_ADD_CSS_CLASS(w, cssclass) gtk_style_context_add_class(gtk_widget_get_style_context(w), cssclass) |
|
93 #define WIDGET_REMOVE_CSS_CLASS(w, cssclass) gtk_style_context_remove_class(gtk_widget_get_style_context(w), cssclass) |
|
94 #define ICON_IMAGE(icon) gtk_image_new_from_icon_name(icon, GTK_ICON_SIZE_BUTTON) |
|
95 #define LISTBOX_REMOVE(listbox, row) gtk_container_remove(GTK_CONTAINER(listbox), row) |
|
96 #define LISTBOX_ROW_SET_CHILD(row, child) gtk_container_add(GTK_CONTAINER(row), child) |
|
97 #endif |
|
98 |
|
99 #ifdef UI_GTK2 |
|
100 #undef SCROLLEDWINDOW_SET_CHILD |
|
101 #define SCROLLEDWINDOW_SET_CHILD(sw, child) gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw), child) |
|
102 #endif |
|
103 |
|
104 #if GTK_MAJOR_VERSION >= 4 |
|
105 #define UI_GTK_SINCE_V4(st) st |
|
106 #define UI_GTK_SINCE_V3(st) |
|
107 #define UI_GTK_V2(st) |
|
108 #define UI_GTK_V3(st) |
|
109 #define UI_GTK_V4(st) st |
|
110 #elif GTK_MAJOR_VERSION >= 3 |
|
111 #define UI_GTK_SINCE_V4(st) st |
|
112 #define UI_GTK_SINCE_V3(st) st |
|
113 #define UI_GTK_V2(st) |
|
114 #define UI_GTK_V3(st) st |
|
115 #define UI_GTK_V4(st) |
|
116 #else |
|
117 #define UI_GTK_SINCE_V4(st) |
|
118 #define UI_GTK_SINCE_V3(st) |
|
119 #define UI_GTK_V2(st) st |
|
120 #define UI_GTK_V3(st) |
|
121 #define UI_GTK_V4(st) |
|
122 #endif |
|
123 |
|
124 |
42 typedef struct UiEventData { |
125 typedef struct UiEventData { |
43 UiObject *obj; |
126 UiObject *obj; |
44 ui_callback callback; |
127 ui_callback callback; |
45 void *userdata; |
128 void *userdata; |
46 int value; |
129 int value; |
|
130 void *customdata; |
47 } UiEventData; |
131 } UiEventData; |
48 |
132 |
|
133 typedef struct UiEventDataExt { |
|
134 UiObject *obj; |
|
135 ui_callback callback; |
|
136 void *userdata; |
|
137 ui_callback callback2; |
|
138 void *userdata2; |
|
139 int value0; |
|
140 int value1; |
|
141 int value2; |
|
142 int value3; |
|
143 void *customdata0; |
|
144 void *customdata1; |
|
145 void *customdata2; |
|
146 void *customdata3; |
|
147 } UiEventDataExt; |
|
148 |
49 typedef struct UiVarEventData { |
149 typedef struct UiVarEventData { |
50 UiObject *obj; |
150 UiObject *obj; |
51 UiVar *var; |
151 UiVar *var; |
52 UiObserver **observers; |
152 UiObserver **observers; |
|
153 ui_callback callback; |
|
154 void *userdata; |
53 } UiVarEventData; |
155 } UiVarEventData; |
54 |
156 |
55 |
157 #ifndef UI_GTK4 |
56 typedef struct UiJob { |
|
57 UiObject *obj; |
|
58 ui_threadfunc job_func; |
|
59 void *job_data; |
|
60 ui_callback finish_callback; |
|
61 void *finish_data; |
|
62 } UiJob; |
|
63 |
|
64 struct UiSelection { |
158 struct UiSelection { |
65 GtkSelectionData *data; |
159 GtkSelectionData *data; |
66 }; |
160 }; |
|
161 #endif |
67 |
162 |
68 typedef enum UiOrientation UiOrientation; |
163 #ifdef UI_APPLICATION |
69 enum UiOrientation { UI_HORIZONTAL = 0, UI_VERTICAL }; |
|
70 |
|
71 #ifndef UI_GTK2 |
|
72 void ui_app_quit(); |
164 void ui_app_quit(); |
73 GtkApplication* ui_get_application(); |
165 GtkApplication* ui_get_application(); |
74 #endif |
166 #endif |
75 |
167 |
76 int ui_get_scalefactor(); |
168 int ui_get_scalefactor(); |
77 |
169 |
|
170 void ui_set_name_and_style(GtkWidget *widget, const char *name, const char *style); |
|
171 void ui_set_widget_groups(UiContext *ctx, GtkWidget *widget, const int *groups); |
|
172 void ui_set_widget_ngroups(UiContext *ctx, GtkWidget *widget, const int *groups, size_t ngroups); |
|
173 |
78 void ui_destroy_userdata(GtkWidget *object, void *userdata); |
174 void ui_destroy_userdata(GtkWidget *object, void *userdata); |
79 void ui_destroy_vardata(GtkWidget *object, UiVarEventData *data); |
175 void ui_destroy_vardata(GtkWidget *object, UiVarEventData *data); |
|
176 void ui_destroy_widget_var(GtkWidget *object, UiVar *var); |
80 void ui_destroy_boundvar(UiContext *ctx, UiVar *var); |
177 void ui_destroy_boundvar(UiContext *ctx, UiVar *var); |
81 |
178 |
82 void ui_set_active_window(UiObject *obj); |
179 void ui_set_active_window(UiObject *obj); |
83 UiObject *ui_get_active_window(); |
180 UiObject *ui_get_active_window(); |
|
181 |
|
182 #if GTK_MAJOR_VERSION >= 3 |
|
183 void ui_css_init(void); |
|
184 #endif |
84 |
185 |
85 #ifdef __cplusplus |
186 #ifdef __cplusplus |
86 } |
187 } |
87 #endif |
188 #endif |
88 |
189 |