ui/gtk/container.c

changeset 802
cc73993a3ff9
parent 801
e096c441e874
child 803
f0c4322741c8
equal deleted inserted replaced
801:e096c441e874 802:cc73993a3ff9
35 #include "toolkit.h" 35 #include "toolkit.h"
36 #include "headerbar.h" 36 #include "headerbar.h"
37 37
38 #include "../common/context.h" 38 #include "../common/context.h"
39 #include "../common/object.h" 39 #include "../common/object.h"
40 #include "../common/container.h"
40 41
41 #include "../ui/properties.h" 42 #include "../ui/properties.h"
42 43
43 44
44 void ui_container_begin_close(UiObject *obj) { 45 void ui_container_begin_close(UiObject *obj) {
69 #else 70 #else
70 return gtk_hbox_new(FALSE, spacing); 71 return gtk_hbox_new(FALSE, spacing);
71 #endif 72 #endif
72 } 73 }
73 74
74 // TODO: refactoring
75 GtkWidget* ui_subcontainer_create( 75 GtkWidget* ui_subcontainer_create(
76 UiSubContainerType type, 76 UiSubContainerType type,
77 UiObject *obj, 77 UiObject *obj,
78 int spacing, 78 int spacing,
79 int columnspacing, 79 int columnspacing,
178 UI_GTK_V2(ct->width = 0); 178 UI_GTK_V2(ct->width = 0);
179 UI_GTK_V2(ct->height = 1); 179 UI_GTK_V2(ct->height = 1);
180 return (UiContainerX*)ct; 180 return (UiContainerX*)ct;
181 } 181 }
182 182
183 /*
184 * TODO: move to common
185 * prepares the layout horizontal and vertical fill/expand settings
186 * based on fill and defaults
187 */
188 static void layout_setup_expand_fill(
189 UiLayout *layout,
190 UiBool def_hexpand,
191 UiBool def_vexpand,
192 UiBool def_hfill,
193 UiBool def_vfill)
194 {
195 if(layout->fill) {
196 layout->hfill = TRUE;
197 layout->vfill = TRUE;
198 layout->hexpand = TRUE;
199 layout->vexpand = TRUE;
200 return;
201 }
202
203 if(!layout->override_defaults) {
204 if(def_hexpand) {
205 layout->hexpand = TRUE;
206 }
207 if(def_hfill) {
208 layout->hfill = TRUE;
209 }
210 if(def_vexpand) {
211 layout->vexpand = TRUE;
212 }
213 if(def_vfill) {
214 layout->vfill = TRUE;
215 }
216 }
217 }
218 183
219 #if GTK_MAJOR_VERSION >= 3 184 #if GTK_MAJOR_VERSION >= 3
220 void ui_grid_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout) { 185 void ui_grid_container_add(UiContainerPrivate *ct, GtkWidget *widget, UiLayout *layout) {
221 UiGridContainer *grid = (UiGridContainer*)ct; 186 UiGridContainer *grid = (UiGridContainer*)ct;
222 187
224 grid->x = 0; 189 grid->x = 0;
225 grid->y++; 190 grid->y++;
226 ct->container.newline = FALSE; 191 ct->container.newline = FALSE;
227 } 192 }
228 193
229 layout_setup_expand_fill(layout, grid->def_hexpand, grid->def_vexpand, grid->def_hfill, grid->def_vfill); 194 uic_layout_setup_expand_fill(layout, grid->def_hexpand, grid->def_vexpand, grid->def_hfill, grid->def_vfill);
230 195
231 if(!layout->hfill) { 196 if(!layout->hfill) {
232 gtk_widget_set_halign(widget, GTK_ALIGN_START); 197 gtk_widget_set_halign(widget, GTK_ALIGN_START);
233 } 198 }
234 if(!layout->vfill) { 199 if(!layout->vfill) {
255 grid->x = 0; 220 grid->x = 0;
256 grid->y++; 221 grid->y++;
257 ct->container.newline = FALSE; 222 ct->container.newline = FALSE;
258 } 223 }
259 224
260 layout_setup_expand_fill(layout, grid->def_hexpand, grid->def_vexpand, grid->def_hfill, grid->def_vfill); 225 uic_layout_setup_expand_fill(layout, grid->def_hexpand, grid->def_vexpand, grid->def_hfill, grid->def_vfill);
261 226
262 GtkAttachOptions xoptions = 0; 227 GtkAttachOptions xoptions = 0;
263 GtkAttachOptions yoptions = 0; 228 GtkAttachOptions yoptions = 0;
264 if(layout->hexpand) { 229 if(layout->hexpand) {
265 xoptions = GTK_EXPAND; 230 xoptions = GTK_EXPAND;

mercurial