ui/gtk/window.c

branch
newapi
changeset 410
a080c69125d1
parent 409
86fbc80f0be7
child 411
3e91b7aff6a1
--- a/ui/gtk/window.c	Thu Dec 05 16:44:05 2024 +0100
+++ b/ui/gtk/window.c	Thu Dec 05 20:02:30 2024 +0100
@@ -190,10 +190,19 @@
         ui_fill_headerbar(obj, headerbar);
     }
 #elif GTK_MAJOR_VERSION >= 4
+    GtkWidget *content_box = ui_gtk_vbox_new(0);
     WINDOW_SET_CONTENT(obj->widget, vbox);
+    if(sidebar) {
+        GtkWidget *paned = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL);
+        GtkWidget *sidebar_vbox = ui_gtk_vbox_new(0);
+        gtk_paned_set_start_child(GTK_PANED(paned), sidebar_vbox);
+        gtk_paned_set_end_child(GTK_PANED(paned), content_box);
+        BOX_ADD_EXPAND(GTK_BOX(vbox), paned);
+        g_object_set_data(G_OBJECT(obj->widget), "ui_sidebar", sidebar_vbox);
+    } else {
+        BOX_ADD_EXPAND(GTK_BOX(vbox), content_box);
+    }
 #else
-    gtk_container_add(GTK_CONTAINER(obj->widget), vbox);
-    
     if(!simple) {
         // menu
         if(uic_get_menu_list()) {
@@ -214,6 +223,20 @@
         //GtkWidget *hb = ui_create_headerbar(obj);
         //gtk_window_set_titlebar(GTK_WINDOW(obj->widget), hb);
     }
+    
+    GtkWidget *content_box = ui_gtk_vbox_new(0);
+    WINDOW_SET_CONTENT(obj->widget, vbox);
+    if(sidebar) {
+        GtkWidget *paned = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL);
+        GtkWidget *sidebar_vbox = ui_gtk_vbox_new(0);
+        gtk_paned_add1(GTK_PANED(paned), sidebar_vbox);
+        gtk_paned_add2(GTK_PANED(paned), content_box);
+        BOX_ADD_EXPAND(GTK_BOX(vbox), paned);
+        g_object_set_data(G_OBJECT(obj->widget), "ui_sidebar", sidebar_vbox);
+    } else {
+        BOX_ADD_EXPAND(GTK_BOX(vbox), content_box);
+    }
+    
 #endif
     
     // window content
@@ -229,8 +252,6 @@
     gtk_container_add(GTK_CONTAINER(frame), content_box);
     obj->container = ui_box_container(obj, content_box);
     */
-    GtkWidget *content_box = ui_gtk_vbox_new(0);
-    BOX_ADD_EXPAND(GTK_BOX(vbox), content_box);
     obj->container = ui_box_container(obj, content_box, UI_CONTAINER_VBOX);
     
     nwindows++;

mercurial