fix gtk box margin newapi

Sun, 22 Sep 2024 18:01:17 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 22 Sep 2024 18:01:17 +0200
branch
newapi
changeset 304
d554b2a60105
parent 303
dc8b504604f4
child 305
98470af75dcf

fix gtk box margin

application/main.c file | annotate | diff | comparison | revisions
ui/gtk/container.c file | annotate | diff | comparison | revisions
--- a/application/main.c	Sun Sep 22 17:54:33 2024 +0200
+++ b/application/main.c	Sun Sep 22 18:01:17 2024 +0200
@@ -108,11 +108,12 @@
     MyDocument *doc = create_doc();
     ui_attach_document(obj->ctx, doc);
     
-    ui_button(obj, .label = "Test Button", .icon = "application-x-generic", .onclick = action_button);
-    ui_togglebutton(obj, .label = "Toggle");
-    ui_checkbox(obj, .label = "My Checkbox");
-    
-    ui_grid(obj, .fill = 1, .columnspacing = 15, .rowspacing = 15, .margin = 15) {
+    ui_vbox(obj, .fill = UI_OFF, .margin = 15, .spacing = 15) {
+        ui_button(obj, .label = "Test Button", .icon = "application-x-generic", .onclick = action_button);
+        ui_togglebutton(obj, .label = "Toggle");
+        ui_checkbox(obj, .label = "My Checkbox");
+    }
+    ui_grid(obj, .fill = UI_OFF, .columnspacing = 15, .rowspacing = 15, .margin = 15) {
         ui_button(obj, .label = "cell1", .hexpand = TRUE);
         ui_button(obj, .label = "cell2");
         ui_newline(obj);
--- a/ui/gtk/container.c	Sun Sep 22 17:54:33 2024 +0200
+++ b/ui/gtk/container.c	Sun Sep 22 18:01:17 2024 +0200
@@ -249,8 +249,8 @@
 
 static GtkWidget* box_set_margin(GtkWidget *box, int margin) {
     GtkWidget *ret = box;
-#ifdef UI_GTK3
-#if GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION >= 12
+#if GTK_MAJOR_VERSION >= 3
+#if GTK_MAJOR_VERSION * 1000 + GTK_MINOR_VERSION >= 3012
     gtk_widget_set_margin_start(box, margin);
     gtk_widget_set_margin_end(box, margin);
 #else
@@ -303,7 +303,7 @@
     GtkWidget *grid = gtk_grid_new();
     gtk_grid_set_column_spacing(GTK_GRID(grid), args.columnspacing);
     gtk_grid_set_row_spacing(GTK_GRID(grid), args.rowspacing);
-#if GTK_MAJOR_VERSION >= 3 && GTK_MINOR_VERSION >= 12
+#if GTK_MAJOR_VERSION * 1000 + GTK_MINOR_VERSION >= 3012
     gtk_widget_set_margin_start(grid, args.margin);
     gtk_widget_set_margin_end(grid, args.margin);
 #else

mercurial