diff -r ea1a2d5de765 -r d276306d801f ui/gtk/container.c --- a/ui/gtk/container.c Tue Jan 12 17:41:08 2016 +0100 +++ b/ui/gtk/container.c Sun Jan 17 19:19:28 2016 +0100 @@ -156,7 +156,18 @@ ct->layout.newline = FALSE; } - gtk_table_attach(GTK_TABLE(ct->widget), widget, grid->x, grid->x+1, grid->y, grid->y+1, GTK_FILL, GTK_FILL, 0, 0); + int hexpand = FALSE; + int vexpand = FALSE; + if(ct->layout.hexpand != UI_LAYOUT_UNDEFINED) { + hexpand = ct->layout.hexpand; + } + if(ct->layout.vexpand != UI_LAYOUT_UNDEFINED) { + vexpand = ct->layout.vexpand; + } + GtkAttachOptions xoptions = hexpand ? GTK_FILL | GTK_EXPAND : GTK_FILL; + GtkAttachOptions yoptions = vexpand ? GTK_FILL | GTK_EXPAND : GTK_FILL; + + gtk_table_attach(GTK_TABLE(ct->widget), widget, grid->x, grid->x+1, grid->y, grid->y+1, xoptions, yoptions, 0, 0); grid->x++; int nw = grid->x > grid->width ? grid->x : grid->width; if(grid->x > grid->width || grid->y > grid->height) { @@ -223,6 +234,7 @@ UIWIDGET ui_grid_sp(UiObject *obj, int margin, int columnspacing, int rowspacing) { UiContainer *ct = uic_get_current_container(obj); + GtkWidget *widget; #ifdef UI_GTK3 GtkWidget *grid = gtk_grid_new(); @@ -238,16 +250,29 @@ gtk_widget_set_margin_top(grid, margin); gtk_widget_set_margin_bottom(grid, margin); + widget = grid; #elif defined(UI_GTK2) GtkWidget *grid = gtk_table_new(1, 1, FALSE); + + gtk_table_set_col_spacings(GTK_TABLE(grid), columnspacing); + gtk_table_set_row_spacings(GTK_TABLE(grid), rowspacing); + + if(margin > 0) { + GtkWidget *a = gtk_alignment_new(0.5, 0.5, 1, 1); + gtk_alignment_set_padding(GTK_ALIGNMENT(a), margin, margin, margin, margin); + gtk_container_add(GTK_CONTAINER(a), grid); + widget = a; + } else { + widget = grid; + } #endif - ct->add(ct, grid, TRUE); + ct->add(ct, widget, TRUE); UiObject *newobj = uic_object_new(obj, grid); newobj->container = ui_grid_container(obj, grid); uic_obj_add(obj, newobj); - return grid; + return widget; } UIWIDGET ui_tabview(UiObject *obj) {