ui/gtk/container.c

changeset 669
5b930e8c3a87
parent 659
d6baaa93f7be
child 731
8487d11b9491
--- a/ui/gtk/container.c	Wed Jul 16 19:15:58 2025 +0200
+++ b/ui/gtk/container.c	Thu Jul 17 22:01:52 2025 +0200
@@ -120,12 +120,9 @@
     return (UiContainer*)ct;
 }
 
-void ui_box_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) {
+void ui_box_container_add(UiContainer *ct, GtkWidget *widget) {
     UiBoxContainer *bc = (UiBoxContainer*)ct;
-    if(ct->layout.fill != UI_LAYOUT_UNDEFINED) {
-        fill = ui_lb2bool(ct->layout.fill);
-    }
-    
+    UiBool fill = ct->layout.fill;
     if(bc->has_fill && fill) {
         fprintf(stderr, "UiError: container has 2 filled widgets");
         fill = FALSE;
@@ -180,7 +177,7 @@
 }
 
 #if GTK_MAJOR_VERSION >= 3
-void ui_grid_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) {
+void ui_grid_container_add(UiContainer *ct, GtkWidget *widget) {
     UiGridContainer *grid = (UiGridContainer*)ct;
     
     if(ct->layout.newline) {
@@ -208,9 +205,7 @@
         }
     }
     
-    if(ct->layout.fill != UI_LAYOUT_UNDEFINED) {
-        fill = ui_lb2bool(ct->layout.fill);
-    }
+    UiBool fill = ct->layout.fill;
     if(ct->layout.hexpand) {
         hexpand = TRUE;
         hfill = TRUE;
@@ -249,7 +244,7 @@
 }
 #endif
 #ifdef UI_GTK2
-void ui_grid_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) {
+void ui_grid_container_add(UiContainer *ct, GtkWidget *widget) {
     UiGridContainer *grid = (UiGridContainer*)ct;
     
     if(ct->layout.newline) {
@@ -277,9 +272,7 @@
         }
     }
     
-    if(ct->layout.fill != UI_LAYOUT_UNDEFINED) {
-        fill = ui_lb2bool(ct->layout.fill);
-    }
+    UiBool fill = ct->layout.fill;
     if(ct->layout.hexpand) {
         hexpand = TRUE;
         hfill = TRUE;
@@ -340,7 +333,7 @@
     return ct;
 }
 
-void ui_frame_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) {
+void ui_frame_container_add(UiContainer *ct, GtkWidget *widget) {
     FRAME_SET_CHILD(ct->widget, widget);
 }
 
@@ -354,11 +347,11 @@
     return ct;
 }
 
-void ui_expander_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) {
+void ui_expander_container_add(UiContainer *ct, GtkWidget *widget) {
     EXPANDER_SET_CHILD(ct->widget, widget);
 }
 
-void ui_scrolledwindow_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) {
+void ui_scrolledwindow_container_add(UiContainer *ct, GtkWidget *widget) {
     // TODO: check if the widget implements GtkScrollable
     SCROLLEDWINDOW_SET_CHILD(ct->widget, widget);
     ui_reset_layout(ct->layout);
@@ -385,7 +378,7 @@
     return (UiContainer*)ct;
 }
 
-void ui_tabview_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) {
+void ui_tabview_container_add(UiContainer *ct, GtkWidget *widget) {
     UiGtkTabView *data = ui_widget_get_tabview_data(ct->widget);
     if(!data) {
         fprintf(stderr, "UI Error: widget is not a tabview");
@@ -428,7 +421,7 @@
     GtkWidget *box = type == UI_CONTAINER_VBOX ? ui_gtk_vbox_new(args->spacing) : ui_gtk_hbox_new(args->spacing);
     ui_set_name_and_style(box, args->name, args->style_class);
     GtkWidget *widget = args->margin > 0 ? ui_box_set_margin(box, args->margin) : box;
-    ct->add(ct, widget, TRUE);
+    ct->add(ct, widget);
     
     UiObject *newobj = uic_object_new(obj, box);
     newobj->container = ui_box_container(obj, box, type);
@@ -466,7 +459,7 @@
     GtkWidget *grid = ui_create_grid_widget(args->columnspacing, args->rowspacing);
     ui_set_name_and_style(grid, args->name, args->style_class);
     widget = ui_box_set_margin(grid, args->margin);
-    current->container->add(current->container, widget, TRUE);
+    current->container->add(current->container, widget);
     
     UiObject *newobj = uic_object_new(obj, grid);
     newobj->container = ui_grid_container(obj, grid, args->def_hexpand, args->def_vexpand, args->def_hfill, args->def_vfill);
@@ -488,7 +481,7 @@
         newobj->widget = frame;
         newobj->container = ui_frame_container(obj, frame);
     }
-    current->container->add(current->container, frame, FALSE);
+    current->container->add(current->container, frame);
     uic_obj_add(obj, newobj);
     
     return frame;
@@ -508,7 +501,7 @@
         newobj->widget = expander;
         newobj->container = ui_expander_container(obj, expander);
     }
-    current->container->add(current->container, expander, FALSE);
+    current->container->add(current->container, expander);
     uic_obj_add(obj, newobj);
     
     return expander;
@@ -522,7 +515,7 @@
     GtkWidget *sw = SCROLLEDWINDOW_NEW();
     ui_set_name_and_style(sw, args->name, args->style_class);
     GtkWidget *widget = ui_box_set_margin(sw, args->margin);
-    current->container->add(current->container, widget, TRUE);
+    current->container->add(current->container, widget);
     
     UiObject *newobj = uic_object_new(obj, sw);
     GtkWidget *sub = ui_subcontainer_create(args->subcontainer, newobj, args->spacing, args->columnspacing, args->rowspacing, args->margin);
@@ -817,7 +810,7 @@
     data->subcontainer = args->subcontainer;
     
     UI_APPLY_LAYOUT2(current, args);
-    current->container->add(current->container, widget, TRUE);
+    current->container->add(current->container, widget);
     
     UiObject *newobj = uic_object_new(obj, widget);
     newobj->container = ui_tabview_container(obj, widget);
@@ -934,7 +927,7 @@
     
     GtkWidget *box = ui_gtk_hbox_new(args->alt_spacing);
     ui_set_name_and_style(box, args->name, args->style_class);
-    ct->add(ct, box, FALSE);
+    ct->add(ct, box);
     
     UiObject *newobj = uic_object_new(obj, box);
     newobj->container = ui_headerbar_fallback_container(obj, box);
@@ -965,7 +958,7 @@
     return (UiContainer*)ct;
 }
 
-void ui_headerbar_fallback_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) {
+void ui_headerbar_fallback_container_add(UiContainer *ct, GtkWidget *widget) {
     UiHeaderbarContainer *hb = (UiHeaderbarContainer*)ct;
     BOX_ADD(ct->widget, widget);
 }
@@ -995,7 +988,7 @@
     return (UiContainer*)ct;
 }
 
-void ui_headerbar_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) {
+void ui_headerbar_container_add(UiContainer *ct, GtkWidget *widget) {
     UiHeaderbarContainer *hb = (UiHeaderbarContainer*)ct;
     if(hb->part == 0) {
         UI_HEADERBAR_PACK_START(ct->widget, widget);
@@ -1080,7 +1073,7 @@
     GtkWidget *pane0 = create_paned(orientation);
     
     UI_APPLY_LAYOUT2(current, args);
-    current->container->add(current->container, pane0, TRUE);
+    current->container->add(current->container, pane0);
     
     int max = args->max_panes == 0 ? 2 : args->max_panes;
     
@@ -1113,7 +1106,7 @@
     return (UiContainer*)ct;
 }
 
-void ui_splitpane_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) {
+void ui_splitpane_container_add(UiContainer *ct, GtkWidget *widget) {
     UiSplitPaneContainer *s = (UiSplitPaneContainer*)ct;
     
     if(s->nchildren >= s->max) {
@@ -1206,7 +1199,7 @@
         UiObject *item_obj = cxMapGet(ct->current_items, key);
         if(item_obj) {
             // re-add previously created widget
-            ui_box_container_add(ct->container, item_obj->widget, FALSE);
+            ui_box_container_add(ct->container, item_obj->widget);
         } else {
             // create new widget and object for this list element
             CxMempool *mp = cxMempoolCreateSimple(256);
@@ -1221,7 +1214,7 @@
                     ct->columnspacing,
                     ct->rowspacing,
                     ct->margin);
-            ui_box_container_add(ct->container, obj->widget, FALSE);
+            ui_box_container_add(ct->container, obj->widget);
             if(ct->create_ui) {
                 ct->create_ui(obj, index, elm, ct->userdata);
             }
@@ -1250,7 +1243,7 @@
     GtkWidget *box = args->container == UI_CONTAINER_VBOX ? ui_gtk_vbox_new(args->spacing) : ui_gtk_hbox_new(args->spacing);
     ui_set_name_and_style(box, args->name, args->style_class);
     GtkWidget *widget = args->margin > 0 ? ui_box_set_margin(box, args->margin) : box;
-    ct->add(ct, widget, TRUE);
+    ct->add(ct, widget);
     
     UiGtkItemListContainer *container = malloc(sizeof(UiGtkItemListContainer));
     container->parent = obj;
@@ -1295,7 +1288,7 @@
 
 void ui_layout_fill(UiObject *obj, UiBool fill) {
     UiContainer *ct = uic_get_current_container(obj);
-    ct->layout.fill = ui_bool2lb(fill);
+    ct->layout.fill = fill;
 }
 
 void ui_layout_hexpand(UiObject *obj, UiBool expand) {

mercurial