240 ct->current = widget; |
240 ct->current = widget; |
241 } |
241 } |
242 |
242 |
243 |
243 |
244 |
244 |
245 static GtkWidget* box_set_margin(GtkWidget *box, int margin) { |
245 GtkWidget* ui_box_set_margin(GtkWidget *box, int margin) { |
246 GtkWidget *ret = box; |
246 GtkWidget *ret = box; |
247 #if GTK_MAJOR_VERSION >= 3 |
247 #if GTK_MAJOR_VERSION >= 3 |
248 #if GTK_MAJOR_VERSION * 1000 + GTK_MINOR_VERSION >= 3012 |
248 #if GTK_MAJOR_VERSION * 1000 + GTK_MINOR_VERSION >= 3012 |
249 gtk_widget_set_margin_start(box, margin); |
249 gtk_widget_set_margin_start(box, margin); |
250 gtk_widget_set_margin_end(box, margin); |
250 gtk_widget_set_margin_end(box, margin); |
268 UiContainer *ct = current->container; |
268 UiContainer *ct = current->container; |
269 UI_APPLY_LAYOUT1(current, args); |
269 UI_APPLY_LAYOUT1(current, args); |
270 |
270 |
271 GtkWidget *box = type == UI_CONTAINER_VBOX ? ui_gtk_vbox_new(args.spacing) : ui_gtk_hbox_new(args.spacing); |
271 GtkWidget *box = type == UI_CONTAINER_VBOX ? ui_gtk_vbox_new(args.spacing) : ui_gtk_hbox_new(args.spacing); |
272 ui_set_name_and_style(box, args.name, args.style_class); |
272 ui_set_name_and_style(box, args.name, args.style_class); |
273 GtkWidget *widget = args.margin > 0 ? box_set_margin(box, args.margin) : box; |
273 GtkWidget *widget = args.margin > 0 ? ui_box_set_margin(box, args.margin) : box; |
274 ct->add(ct, widget, TRUE); |
274 ct->add(ct, widget, TRUE); |
275 |
275 |
276 UiObject *newobj = uic_object_new(obj, box); |
276 UiObject *newobj = uic_object_new(obj, box); |
277 newobj->container = ui_box_container(obj, box, type); |
277 newobj->container = ui_box_container(obj, box, type); |
278 uic_obj_add(obj, newobj); |
278 uic_obj_add(obj, newobj); |
286 |
286 |
287 UIEXPORT UIWIDGET ui_hbox_create(UiObject *obj, UiContainerArgs args) { |
287 UIEXPORT UIWIDGET ui_hbox_create(UiObject *obj, UiContainerArgs args) { |
288 return ui_box_create(obj, args, UI_CONTAINER_HBOX); |
288 return ui_box_create(obj, args, UI_CONTAINER_HBOX); |
289 } |
289 } |
290 |
290 |
291 static GtkWidget* create_grid(int colspacing, int rowspacing) { |
291 GtkWidget* ui_create_grid_widget(int colspacing, int rowspacing) { |
292 #if GTK_MAJOR_VERSION >= 3 |
292 #if GTK_MAJOR_VERSION >= 3 |
293 GtkWidget *grid = gtk_grid_new(); |
293 GtkWidget *grid = gtk_grid_new(); |
294 gtk_grid_set_column_spacing(GTK_GRID(grid), colspacing); |
294 gtk_grid_set_column_spacing(GTK_GRID(grid), colspacing); |
295 gtk_grid_set_row_spacing(GTK_GRID(grid), rowspacing); |
295 gtk_grid_set_row_spacing(GTK_GRID(grid), rowspacing); |
296 #else |
296 #else |
304 UIWIDGET ui_grid_create(UiObject *obj, UiContainerArgs args) { |
304 UIWIDGET ui_grid_create(UiObject *obj, UiContainerArgs args) { |
305 UiObject* current = uic_current_obj(obj); |
305 UiObject* current = uic_current_obj(obj); |
306 UI_APPLY_LAYOUT1(current, args); |
306 UI_APPLY_LAYOUT1(current, args); |
307 GtkWidget *widget; |
307 GtkWidget *widget; |
308 |
308 |
309 GtkWidget *grid = create_grid(args.columnspacing, args.rowspacing); |
309 GtkWidget *grid = ui_create_grid_widget(args.columnspacing, args.rowspacing); |
310 ui_set_name_and_style(grid, args.name, args.style_class); |
310 ui_set_name_and_style(grid, args.name, args.style_class); |
311 widget = box_set_margin(grid, args.margin); |
311 widget = ui_box_set_margin(grid, args.margin); |
312 current->container->add(current->container, widget, TRUE); |
312 current->container->add(current->container, widget, TRUE); |
313 |
313 |
314 UiObject *newobj = uic_object_new(obj, grid); |
314 UiObject *newobj = uic_object_new(obj, grid); |
315 newobj->container = ui_grid_container(obj, grid); |
315 newobj->container = ui_grid_container(obj, grid); |
316 uic_obj_add(obj, newobj); |
316 uic_obj_add(obj, newobj); |
619 sub = ui_gtk_hbox_new(data->spacing); |
619 sub = ui_gtk_hbox_new(data->spacing); |
620 newobj->container = ui_box_container(newobj, sub, data->subcontainer); |
620 newobj->container = ui_box_container(newobj, sub, data->subcontainer); |
621 break; |
621 break; |
622 } |
622 } |
623 case UI_CONTAINER_GRID: { |
623 case UI_CONTAINER_GRID: { |
624 sub = create_grid(data->columnspacing, data->rowspacing); |
624 sub = ui_create_grid_widget(data->columnspacing, data->rowspacing); |
625 newobj->container = ui_grid_container(newobj, sub); |
625 newobj->container = ui_grid_container(newobj, sub); |
626 break; |
626 break; |
627 } |
627 } |
628 } |
628 } |
629 newobj->widget = sub; |
629 newobj->widget = sub; |
630 GtkWidget *widget = box_set_margin(sub, data->margin); |
630 GtkWidget *widget = ui_box_set_margin(sub, data->margin); |
631 |
631 |
632 data->add_tab(data->widget, tab_index, name, widget); |
632 data->add_tab(data->widget, tab_index, name, widget); |
633 |
633 |
634 return newobj; |
634 return newobj; |
635 } |
635 } |