ui/gtk/container.c

changeset 99
ea1a2d5de765
parent 94
d51e334c1439
child 100
d276306d801f
--- a/ui/gtk/container.c	Mon Nov 30 14:09:55 2015 +0100
+++ b/ui/gtk/container.c	Tue Jan 12 17:41:08 2016 +0100
@@ -123,12 +123,21 @@
         ct->layout.newline = FALSE;
     }
     
-    if(ct->layout.fill != UI_LAYOUT_UNDEFINED) {
-        fill = ui_lb2bool(ct->layout.fill);
+    int hexpand = FALSE;
+    int vexpand = FALSE;
+    if(ct->layout.hexpand != UI_LAYOUT_UNDEFINED) {
+        hexpand = ct->layout.hexpand;
     }
-    if(fill) {
+    if(ct->layout.vexpand != UI_LAYOUT_UNDEFINED) {
+        vexpand = ct->layout.vexpand;
+    }
+    
+    if(hexpand) {
         gtk_widget_set_hexpand(widget, TRUE);
     }
+    if(vexpand) {
+        gtk_widget_set_vexpand(widget, TRUE);
+    }
     
     gtk_grid_attach(GTK_GRID(ct->widget), widget, grid->x, grid->y, 1, 1);
     grid->x++;
@@ -209,16 +218,25 @@
 }
 
 UIWIDGET ui_grid(UiObject *obj) {
-    return ui_grid_sp(obj, 0, 0);
+    return ui_grid_sp(obj, 0, 0, 0);
 }
 
-UIWIDGET ui_grid_sp(UiObject *obj, int columnspacing, int rowspacing) {
+UIWIDGET ui_grid_sp(UiObject *obj, int margin, int columnspacing, int rowspacing) {
     UiContainer *ct = uic_get_current_container(obj);
     
 #ifdef UI_GTK3
     GtkWidget *grid = gtk_grid_new();
     gtk_grid_set_column_spacing(GTK_GRID(grid), columnspacing);
-    gtk_grid_set_row_spacing(GTK_GRID(grid), rowspacing); 
+    gtk_grid_set_row_spacing(GTK_GRID(grid), rowspacing);
+#if GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION >= 12
+    gtk_widget_set_margin_start(grid, margin);
+    gtk_widget_set_margin_end(grid, margin);
+#else
+    gtk_widget_set_margin_left(grid, margin);
+    gtk_widget_set_margin_right(grid, margin);
+#endif
+    gtk_widget_set_margin_top(grid, margin);
+    gtk_widget_set_margin_bottom(grid, margin);
     
 #elif defined(UI_GTK2)
     GtkWidget *grid = gtk_table_new(1, 1, FALSE);
@@ -315,7 +333,7 @@
         return;
     }
     
-    printf("page_change: %d\n", page_num);
+    //printf("page_change: %d\n", page_num);
     UiContext *ctx = tab->ctx;
     ctx->parent->set_document(ctx->parent, ctx->document);
 }
@@ -389,7 +407,18 @@
     ct->layout.fill = ui_bool2lb(fill);
 }
 
+void ui_layout_hexpand(UiObject *obj, UiBool expand) {
+    UiContainer *ct = uic_get_current_container(obj);
+    ct->layout.hexpand = ui_bool2lb(expand);
+}
+
+void ui_layout_vexpand(UiObject *obj, UiBool expand) {
+    UiContainer *ct = uic_get_current_container(obj);
+    ct->layout.vexpand = ui_bool2lb(expand);
+}
+
 void ui_newline(UiObject *obj) {
     UiContainer *ct = uic_get_current_container(obj);
     ct->layout.newline = TRUE;
 }
+

mercurial