99 static gboolean close_request(GtkWidget* self, GdkEvent* event, UiObject *obj) { |
99 static gboolean close_request(GtkWidget* self, GdkEvent* event, UiObject *obj) { |
100 return ui_window_close_request(obj); |
100 return ui_window_close_request(obj); |
101 } |
101 } |
102 #endif |
102 #endif |
103 |
103 |
104 static UiObject* create_window(const char *title, void *window_data, UiBool simple) { |
104 static UiObject* create_window(const char *title, void *window_data, UiBool sidebar, UiBool simple) { |
105 CxMempool *mp = cxBasicMempoolCreate(256); |
105 CxMempool *mp = cxBasicMempoolCreate(256); |
106 UiObject *obj = cxCalloc(mp->allocator, 1, sizeof(UiObject)); |
106 UiObject *obj = cxCalloc(mp->allocator, 1, sizeof(UiObject)); |
107 obj->ref = 0; |
107 obj->ref = 0; |
108 |
108 |
109 #ifdef UI_LIBADWAITA |
109 #ifdef UI_LIBADWAITA |
161 #endif |
161 #endif |
162 |
162 |
163 GtkWidget *vbox = ui_gtk_vbox_new(0); |
163 GtkWidget *vbox = ui_gtk_vbox_new(0); |
164 #ifdef UI_LIBADWAITA |
164 #ifdef UI_LIBADWAITA |
165 GtkWidget *toolbar_view = adw_toolbar_view_new(); |
165 GtkWidget *toolbar_view = adw_toolbar_view_new(); |
166 adw_application_window_set_content(ADW_APPLICATION_WINDOW(obj->widget), toolbar_view); |
|
167 adw_toolbar_view_set_content(ADW_TOOLBAR_VIEW(toolbar_view), vbox); |
166 adw_toolbar_view_set_content(ADW_TOOLBAR_VIEW(toolbar_view), vbox); |
|
167 |
|
168 if(sidebar) { |
|
169 GtkWidget *splitview = adw_overlay_split_view_new(); |
|
170 adw_application_window_set_content(ADW_APPLICATION_WINDOW(obj->widget), splitview); |
|
171 |
|
172 GtkWidget *sidebar_toolbar_view = adw_toolbar_view_new(); |
|
173 adw_overlay_split_view_set_sidebar(ADW_OVERLAY_SPLIT_VIEW(splitview), sidebar_toolbar_view); |
|
174 GtkWidget *sidebar_headerbar = adw_header_bar_new(); |
|
175 adw_toolbar_view_add_top_bar(ADW_TOOLBAR_VIEW(sidebar_toolbar_view), sidebar_headerbar); |
|
176 |
|
177 adw_overlay_split_view_set_content(ADW_OVERLAY_SPLIT_VIEW(splitview), toolbar_view); |
|
178 |
|
179 g_object_set_data(G_OBJECT(obj->widget), "ui_sidebar", sidebar_toolbar_view); |
|
180 } else { |
|
181 adw_application_window_set_content(ADW_APPLICATION_WINDOW(obj->widget), toolbar_view); |
|
182 } |
|
183 |
168 |
184 |
169 GtkWidget *headerbar = adw_header_bar_new(); |
185 GtkWidget *headerbar = adw_header_bar_new(); |
170 adw_toolbar_view_add_top_bar(ADW_TOOLBAR_VIEW(toolbar_view), headerbar); |
186 adw_toolbar_view_add_top_bar(ADW_TOOLBAR_VIEW(toolbar_view), headerbar); |
171 g_object_set_data(G_OBJECT(obj->widget), "ui_headerbar", headerbar); |
187 g_object_set_data(G_OBJECT(obj->widget), "ui_headerbar", headerbar); |
172 |
188 |
221 return obj; |
237 return obj; |
222 } |
238 } |
223 |
239 |
224 |
240 |
225 UiObject* ui_window(const char *title, void *window_data) { |
241 UiObject* ui_window(const char *title, void *window_data) { |
226 return create_window(title, window_data, FALSE); |
242 return create_window(title, window_data, FALSE, FALSE); |
|
243 } |
|
244 |
|
245 UiObject *ui_sidebar_window(const char *title, void *window_data) { |
|
246 return create_window(title, window_data, TRUE, FALSE); |
227 } |
247 } |
228 |
248 |
229 UiObject* ui_simple_window(const char *title, void *window_data) { |
249 UiObject* ui_simple_window(const char *title, void *window_data) { |
230 return create_window(title, window_data, TRUE); |
250 return create_window(title, window_data, FALSE, TRUE); |
231 } |
251 } |
232 |
252 |
233 void ui_window_size(UiObject *obj, int width, int height) { |
253 void ui_window_size(UiObject *obj, int width, int height) { |
234 gtk_window_set_default_size( |
254 gtk_window_set_default_size( |
235 GTK_WINDOW(obj->widget), |
255 GTK_WINDOW(obj->widget), |