Bug Summary

File:ctk/ctkboxgadget.c
Warning:line 190, column 37
Division by zero

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name ctkboxgadget.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/ctk -resource-dir /usr/lib/llvm-16/lib/clang/16 -D HAVE_CONFIG_H -I . -I .. -D G_LOG_DOMAIN="Ctk" -D G_LOG_USE_STRUCTURED=1 -D CTK_VERSION="3.25.5" -D CTK_BINARY_VERSION="3.0.0" -D CTK_COMPILATION -D CTK_PRINT_BACKEND_ENABLE_UNSUPPORTED -D CTK_LIBDIR="/usr/lib" -D CTK_LOCALEDIR="/usr/share/locale" -D CTK_DATADIR="/usr/share" -D CTK_DATA_PREFIX="/usr" -D CTK_SYSCONFDIR="/usr/etc" -D CTK_HOST="x86_64-pc-linux-gnu" -D CTK_PRINT_BACKENDS="file,cups" -D X11_DATA_PREFIX="/usr" -D ISO_CODES_PREFIX="" -I .. -I ../ctk -I .. -I ../cdk -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -D G_ENABLE_DEBUG -D G_ENABLE_CONSISTENCY_CHECKS -D GLIB_MIN_REQUIRED_VERSION=GLIB_VERSION_2_66 -D GLIB_MAX_ALLOWED_VERSION=GLIB_VERSION_2_66 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/atk-1.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/gio-unix-2.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/pango-1.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -D PIC -internal-isystem /usr/lib/llvm-16/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/rootdir/ctk -ferror-limit 19 -fvisibility=hidden -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-09-19-172241-43638-1 -x c ctkboxgadget.c
1/*
2 * Copyright © 2015 Red Hat Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authors: Benjamin Otte <otte@gnome.org>
18 */
19
20#include "config.h"
21
22#include "ctkboxgadgetprivate.h"
23
24#include "ctkcssnodeprivate.h"
25#include "ctkmain.h"
26#include "ctkprivate.h"
27#include "ctksizerequest.h"
28#include "ctkwidgetprivate.h"
29
30/* CtkBoxGadget is a container gadget implementation that arranges its
31 * children in a row, either horizontally or vertically. Children can
32 * be either widgets or gadgets, and can be set to expand horizontally
33 * or vertically, or both.
34 */
35
36typedef struct _CtkBoxGadgetPrivate CtkBoxGadgetPrivate;
37struct _CtkBoxGadgetPrivate {
38 CtkOrientation orientation;
39 GArray *children;
40
41 guint draw_focus : 1;
42 guint draw_reverse : 1;
43 guint allocate_reverse : 1;
44 guint align_reverse : 1;
45};
46
47typedef gboolean (* ComputeExpandFunc) (GObject *object, CtkOrientation orientation);
48
49typedef struct _CtkBoxGadgetChild CtkBoxGadgetChild;
50struct _CtkBoxGadgetChild {
51 GObject *object;
52 gboolean expand;
53 CtkAlign align;
54};
55
56G_DEFINE_TYPE_WITH_CODE (CtkBoxGadget, ctk_box_gadget, CTK_TYPE_CSS_GADGET,static void ctk_box_gadget_init (CtkBoxGadget *self); static void
ctk_box_gadget_class_init (CtkBoxGadgetClass *klass); static
GType ctk_box_gadget_get_type_once (void); static gpointer ctk_box_gadget_parent_class
= ((void*)0); static gint CtkBoxGadget_private_offset; static
void ctk_box_gadget_class_intern_init (gpointer klass) { ctk_box_gadget_parent_class
= g_type_class_peek_parent (klass); if (CtkBoxGadget_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &CtkBoxGadget_private_offset
); ctk_box_gadget_class_init ((CtkBoxGadgetClass*) klass); } __attribute__
((__unused__)) static inline gpointer ctk_box_gadget_get_instance_private
(CtkBoxGadget *self) { return (((gpointer) ((guint8*) (self)
+ (glong) (CtkBoxGadget_private_offset)))); } GType ctk_box_gadget_get_type
(void) { static GType static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0))
; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= ctk_box_gadget_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType ctk_box_gadget_get_type_once (void
) { GType g_define_type_id = g_type_register_static_simple ((
ctk_css_gadget_get_type ()), g_intern_static_string ("CtkBoxGadget"
), sizeof (CtkBoxGadgetClass), (GClassInitFunc)(void (*)(void
)) ctk_box_gadget_class_intern_init, sizeof (CtkBoxGadget), (
GInstanceInitFunc)(void (*)(void)) ctk_box_gadget_init, (GTypeFlags
) 0); { {{ CtkBoxGadget_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (CtkBoxGadgetPrivate)); };} } return
g_define_type_id; }
57 G_ADD_PRIVATE (CtkBoxGadget))static void ctk_box_gadget_init (CtkBoxGadget *self); static void
ctk_box_gadget_class_init (CtkBoxGadgetClass *klass); static
GType ctk_box_gadget_get_type_once (void); static gpointer ctk_box_gadget_parent_class
= ((void*)0); static gint CtkBoxGadget_private_offset; static
void ctk_box_gadget_class_intern_init (gpointer klass) { ctk_box_gadget_parent_class
= g_type_class_peek_parent (klass); if (CtkBoxGadget_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &CtkBoxGadget_private_offset
); ctk_box_gadget_class_init ((CtkBoxGadgetClass*) klass); } __attribute__
((__unused__)) static inline gpointer ctk_box_gadget_get_instance_private
(CtkBoxGadget *self) { return (((gpointer) ((guint8*) (self)
+ (glong) (CtkBoxGadget_private_offset)))); } GType ctk_box_gadget_get_type
(void) { static GType static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0))
; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= ctk_box_gadget_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType ctk_box_gadget_get_type_once (void
) { GType g_define_type_id = g_type_register_static_simple ((
ctk_css_gadget_get_type ()), g_intern_static_string ("CtkBoxGadget"
), sizeof (CtkBoxGadgetClass), (GClassInitFunc)(void (*)(void
)) ctk_box_gadget_class_intern_init, sizeof (CtkBoxGadget), (
GInstanceInitFunc)(void (*)(void)) ctk_box_gadget_init, (GTypeFlags
) 0); { {{ CtkBoxGadget_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (CtkBoxGadgetPrivate)); };} } return
g_define_type_id; }
58
59static gboolean
60ctk_box_gadget_child_is_visible (GObject *child)
61{
62 if (CTK_IS_WIDGET (child)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(child)); GType __t = ((ctk_widget_get_type ())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
63 return ctk_widget_get_visible (CTK_WIDGET (child)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((child)), ((ctk_widget_get_type ()))))))
);
64 else
65 return ctk_css_gadget_get_visible (CTK_CSS_GADGET (child)((((CtkCssGadget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (child), ((ctk_css_gadget_get_type ()))))))
);
66}
67
68static gboolean
69ctk_box_gadget_child_compute_expand (CtkBoxGadget *gadget,
70 CtkBoxGadgetChild *child)
71{
72 CtkBoxGadgetPrivate *priv = ctk_box_gadget_get_instance_private (CTK_BOX_GADGET (gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (gadget), ((ctk_box_gadget_get_type ()))))))
);
73
74 if (child->expand)
75 return TRUE(!(0));
76
77 if (CTK_IS_WIDGET (child->object)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(child->object)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
78 return ctk_widget_compute_expand (CTK_WIDGET (child->object)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((child->object)), ((ctk_widget_get_type ()))))))
, priv->orientation);
79
80 return FALSE(0);
81}
82
83static CtkAlign
84ctk_box_gadget_child_get_align (CtkBoxGadget *gadget,
85 CtkBoxGadgetChild *child)
86{
87 CtkBoxGadgetPrivate *priv = ctk_box_gadget_get_instance_private (CTK_BOX_GADGET (gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (gadget), ((ctk_box_gadget_get_type ()))))))
);
88 CtkAlign align;
89
90 if (CTK_IS_WIDGET (child->object)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(child->object)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
91 {
92 if (priv->orientation == CTK_ORIENTATION_HORIZONTAL)
93 g_object_get (child->object, "valign", &align, NULL((void*)0));
94 else
95 g_object_get (child->object, "halign", &align, NULL((void*)0));
96 }
97 else
98 align = child->align;
99
100 return align;
101}
102
103static CtkAlign
104effective_align (CtkAlign align,
105 gboolean reverse)
106{
107 switch (align)
108 {
109 case CTK_ALIGN_START:
110 return reverse ? CTK_ALIGN_END : CTK_ALIGN_START;
111 case CTK_ALIGN_END:
112 return reverse ? CTK_ALIGN_START : CTK_ALIGN_END;
113 default:
114 return align;
115 }
116}
117
118static void
119ctk_box_gadget_measure_child (GObject *child,
120 CtkOrientation orientation,
121 gint for_size,
122 gint *minimum,
123 gint *natural,
124 gint *minimum_baseline,
125 gint *natural_baseline)
126{
127 if (CTK_IS_WIDGET (child)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(child)); GType __t = ((ctk_widget_get_type ())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
128 {
129 _ctk_widget_get_preferred_size_for_size (CTK_WIDGET (child)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((child)), ((ctk_widget_get_type ()))))))
,
130 orientation,
131 for_size,
132 minimum, natural,
133 minimum_baseline, natural_baseline);
134 }
135 else
136 {
137 ctk_css_gadget_get_preferred_size (CTK_CSS_GADGET (child)((((CtkCssGadget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (child), ((ctk_css_gadget_get_type ()))))))
,
138 orientation,
139 for_size,
140 minimum, natural,
141 minimum_baseline, natural_baseline);
142 }
143}
144
145static void
146ctk_box_gadget_distribute (CtkBoxGadget *gadget,
147 gint for_size,
148 gint size,
149 CtkRequestedSize *sizes)
150{
151 CtkBoxGadgetPrivate *priv = ctk_box_gadget_get_instance_private (CTK_BOX_GADGET (gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (gadget), ((ctk_box_gadget_get_type ()))))))
);
152 guint i, n_expand;
153
154 n_expand = 0;
155
156 for (i = 0 ; i < priv->children->len; i++)
7
Assuming 'i' is < field 'len'
8
Loop condition is true. Entering loop body
10
Assuming 'i' is < field 'len'
11
Loop condition is true. Entering loop body
14
Assuming 'i' is >= field 'len'
15
Loop condition is false. Execution continues on line 171
157 {
158 CtkBoxGadgetChild *child = &g_array_index (priv->children, CtkBoxGadgetChild, i)(((CtkBoxGadgetChild*) (void *) (priv->children)->data)
[(i)])
;
159
160 ctk_box_gadget_measure_child (child->object,
161 priv->orientation,
162 for_size,
163 &sizes[i].minimum_size, &sizes[i].natural_size,
164 NULL((void*)0), NULL((void*)0));
165 if (ctk_box_gadget_child_is_visible (child->object) &&
9
Assuming the condition is false
12
Assuming the condition is true
13
Taking true branch
166 ctk_box_gadget_child_compute_expand (gadget, child))
167 n_expand++;
168 size -= sizes[i].minimum_size;
169 }
170
171 if G_UNLIKELY (size < 0)(size < 0)
16
Assuming 'size' is >= 0
17
Taking false branch
172 {
173 g_critical ("%s: assertion 'size >= 0' failed in %s", G_STRFUNC((const char*) (__func__)), G_OBJECT_TYPE_NAME (ctk_css_gadget_get_owner (CTK_CSS_GADGET (gadget)))(g_type_name ((((((GTypeClass*) (((GTypeInstance*) (ctk_css_gadget_get_owner
(((((CtkCssGadget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (gadget), ((ctk_css_gadget_get_type ())))))))))->g_class
))->g_type)))))
);
174 return;
175 }
176
177 size = ctk_distribute_natural_allocation (size, priv->children->len, sizes);
178
179 if (size <= 0 || n_expand
18.1
'n_expand' is not equal to 0
== 0)
18
Assuming 'size' is > 0
19
Taking false branch
180 return;
181
182 for (i = 0 ; i < priv->children->len; i++)
20
Loop condition is true. Entering loop body
24
Loop condition is true. Entering loop body
183 {
184 CtkBoxGadgetChild *child = &g_array_index (priv->children, CtkBoxGadgetChild, i)(((CtkBoxGadgetChild*) (void *) (priv->children)->data)
[(i)])
;
185
186 if (!ctk_box_gadget_child_is_visible (child->object) ||
21
Assuming the condition is false
22
Taking false branch
25
Assuming the condition is false
26
Taking false branch
187 !ctk_box_gadget_child_compute_expand (gadget, child))
188 continue;
189
190 sizes[i].minimum_size += size / n_expand;
27
Division by zero
191 /* distribute all pixels, even if there's a remainder */
192 size -= size / n_expand;
193 n_expand--;
23
The value 0 is assigned to 'n_expand'
194 }
195
196}
197
198static void
199ctk_box_gadget_measure_orientation (CtkCssGadget *gadget,
200 CtkOrientation orientation,
201 gint for_size,
202 gint *minimum,
203 gint *natural,
204 gint *minimum_baseline G_GNUC_UNUSED__attribute__ ((__unused__)),
205 gint *natural_baseline G_GNUC_UNUSED__attribute__ ((__unused__)))
206{
207 CtkBoxGadgetPrivate *priv = ctk_box_gadget_get_instance_private (CTK_BOX_GADGET (gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (gadget), ((ctk_box_gadget_get_type ()))))))
);
208 gint child_min, child_nat;
209 guint i;
210
211 *minimum = 0;
212 *natural = 0;
213
214 for (i = 0 ; i < priv->children->len; i++)
215 {
216 CtkBoxGadgetChild *child = &g_array_index (priv->children, CtkBoxGadgetChild, i)(((CtkBoxGadgetChild*) (void *) (priv->children)->data)
[(i)])
;
217
218 ctk_box_gadget_measure_child (child->object,
219 orientation,
220 for_size,
221 &child_min, &child_nat,
222 NULL((void*)0), NULL((void*)0));
223
224 *minimum += child_min;
225 *natural += child_nat;
226 }
227}
228
229static void
230ctk_box_gadget_measure_opposite (CtkCssGadget *gadget,
231 CtkOrientation orientation,
232 gint for_size,
233 gint *minimum,
234 gint *natural,
235 gint *minimum_baseline,
236 gint *natural_baseline)
237{
238 CtkBoxGadgetPrivate *priv = ctk_box_gadget_get_instance_private (CTK_BOX_GADGET (gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (gadget), ((ctk_box_gadget_get_type ()))))))
);
239 int child_min, child_nat, child_min_baseline, child_nat_baseline;
240 int total_min, above_min, below_min, total_nat, above_nat, below_nat;
241 CtkRequestedSize *sizes;
242 guint i;
243
244 if (for_size >= 0)
4
Assuming 'for_size' is >= 0
5
Taking true branch
245 {
246 sizes = g_newa (CtkRequestedSize, priv->children->len)((CtkRequestedSize*) __builtin_alloca (sizeof (CtkRequestedSize
) * (gsize) (priv->children->len)))
;
247 ctk_box_gadget_distribute (CTK_BOX_GADGET (gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (gadget), ((ctk_box_gadget_get_type ()))))))
, -1, for_size, sizes)
;
6
Calling 'ctk_box_gadget_distribute'
248 }
249
250 above_min = below_min = above_nat = below_nat = -1;
251 total_min = total_nat = 0;
252
253 for (i = 0 ; i < priv->children->len; i++)
254 {
255 CtkBoxGadgetChild *child = &g_array_index (priv->children, CtkBoxGadgetChild, i)(((CtkBoxGadgetChild*) (void *) (priv->children)->data)
[(i)])
;
256
257 ctk_box_gadget_measure_child (child->object,
258 orientation,
259 for_size >= 0 ? sizes[i].minimum_size : -1,
260 &child_min, &child_nat,
261 &child_min_baseline, &child_nat_baseline);
262
263 if (child_min_baseline >= 0)
264 {
265 below_min = MAX (below_min, child_min - child_min_baseline)(((below_min) > (child_min - child_min_baseline)) ? (below_min
) : (child_min - child_min_baseline))
;
266 above_min = MAX (above_min, child_min_baseline)(((above_min) > (child_min_baseline)) ? (above_min) : (child_min_baseline
))
;
267 below_nat = MAX (below_nat, child_nat - child_nat_baseline)(((below_nat) > (child_nat - child_nat_baseline)) ? (below_nat
) : (child_nat - child_nat_baseline))
;
268 above_nat = MAX (above_nat, child_nat_baseline)(((above_nat) > (child_nat_baseline)) ? (above_nat) : (child_nat_baseline
))
;
269 }
270 else
271 {
272 total_min = MAX (total_min, child_min)(((total_min) > (child_min)) ? (total_min) : (child_min));
273 total_nat = MAX (total_nat, child_nat)(((total_nat) > (child_nat)) ? (total_nat) : (child_nat));
274 }
275 }
276
277 if (above_min >= 0)
278 {
279 total_min = MAX (total_min, above_min + below_min)(((total_min) > (above_min + below_min)) ? (total_min) : (
above_min + below_min))
;
280 total_nat = MAX (total_nat, above_nat + below_nat)(((total_nat) > (above_nat + below_nat)) ? (total_nat) : (
above_nat + below_nat))
;
281 /* assume CTK_BASELINE_POSITION_CENTER for now */
282 if (minimum_baseline)
283 *minimum_baseline = above_min + (total_min - (above_min + below_min)) / 2;
284 if (natural_baseline)
285 *natural_baseline = above_nat + (total_nat - (above_nat + below_nat)) / 2;
286 }
287
288 *minimum = total_min;
289 *natural = total_nat;
290}
291
292static void
293ctk_box_gadget_get_preferred_size (CtkCssGadget *gadget,
294 CtkOrientation orientation,
295 gint for_size,
296 gint *minimum,
297 gint *natural,
298 gint *minimum_baseline,
299 gint *natural_baseline)
300{
301 CtkBoxGadgetPrivate *priv = ctk_box_gadget_get_instance_private (CTK_BOX_GADGET (gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (gadget), ((ctk_box_gadget_get_type ()))))))
);
302
303 if (priv->orientation == orientation)
1
Assuming 'orientation' is not equal to field 'orientation'
2
Taking false branch
304 ctk_box_gadget_measure_orientation (gadget, orientation, for_size, minimum, natural, minimum_baseline, natural_baseline);
305 else
306 ctk_box_gadget_measure_opposite (gadget, orientation, for_size, minimum, natural, minimum_baseline, natural_baseline);
3
Calling 'ctk_box_gadget_measure_opposite'
307}
308
309static void
310ctk_box_gadget_allocate_child (GObject *child,
311 CtkOrientation box_orientation,
312 CtkAlign child_align,
313 CtkAllocation *allocation,
314 int baseline,
315 CtkAllocation *out_clip)
316{
317 if (CTK_IS_WIDGET (child)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(child)); GType __t = ((ctk_widget_get_type ())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
318 {
319 ctk_widget_size_allocate_with_baseline (CTK_WIDGET (child)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((child)), ((ctk_widget_get_type ()))))))
, allocation, baseline);
320 ctk_widget_get_clip (CTK_WIDGET (child)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((child)), ((ctk_widget_get_type ()))))))
, out_clip);
321 }
322 else
323 {
324 CtkAllocation child_allocation;
325 int minimum, natural;
326 int minimum_baseline, natural_baseline;
327
328 if (box_orientation == CTK_ORIENTATION_HORIZONTAL)
329 {
330 child_allocation.width = allocation->width;
331 child_allocation.x = allocation->x;
332
333 ctk_css_gadget_get_preferred_size (CTK_CSS_GADGET (child)((((CtkCssGadget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (child), ((ctk_css_gadget_get_type ()))))))
,
334 CTK_ORIENTATION_VERTICAL,
335 allocation->width,
336 &minimum, &natural,
337 &minimum_baseline, &natural_baseline);
338
339 switch (child_align)
340 {
341 case CTK_ALIGN_FILL:
342 child_allocation.height = allocation->height;
343 child_allocation.y = allocation->y;
344 break;
345 case CTK_ALIGN_START:
346 child_allocation.height = MIN(natural, allocation->height)(((natural) < (allocation->height)) ? (natural) : (allocation
->height))
;
347 child_allocation.y = allocation->y;
348 break;
349 case CTK_ALIGN_END:
350 child_allocation.height = MIN(natural, allocation->height)(((natural) < (allocation->height)) ? (natural) : (allocation
->height))
;
351 child_allocation.y = allocation->y + allocation->height - child_allocation.height;
352 break;
353 case CTK_ALIGN_BASELINE:
354 if (minimum_baseline >= 0 && baseline >= 0)
355 {
356 child_allocation.height = MIN(natural, allocation->height)(((natural) < (allocation->height)) ? (natural) : (allocation
->height))
;
357 child_allocation.y = allocation->y + MAX(0, baseline - minimum_baseline)(((0) > (baseline - minimum_baseline)) ? (0) : (baseline -
minimum_baseline))
;
358 break;
359 }
360 case CTK_ALIGN_CENTER:
361 child_allocation.height = MIN(natural, allocation->height)(((natural) < (allocation->height)) ? (natural) : (allocation
->height))
;
362 child_allocation.y = allocation->y + (allocation->height - child_allocation.height) / 2;
363 break;
364 default:
365 g_assert_not_reached ()do { g_assertion_message_expr ("Ctk", "ctkboxgadget.c", 365, (
(const char*) (__func__)), ((void*)0)); } while (0)
;
366 }
367 }
368 else
369 {
370 child_allocation.height = allocation->height;
371 child_allocation.y = allocation->y;
372
373 ctk_css_gadget_get_preferred_size (CTK_CSS_GADGET (child)((((CtkCssGadget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (child), ((ctk_css_gadget_get_type ()))))))
,
374 CTK_ORIENTATION_HORIZONTAL,
375 allocation->height,
376 &minimum, &natural,
377 NULL((void*)0), NULL((void*)0));
378
379 switch (child_align)
380 {
381 case CTK_ALIGN_FILL:
382 child_allocation.width = allocation->width;
383 child_allocation.x = allocation->x;
384 break;
385 case CTK_ALIGN_START:
386 child_allocation.width = MIN(natural, allocation->width)(((natural) < (allocation->width)) ? (natural) : (allocation
->width))
;
387 child_allocation.x = allocation->x;
388 break;
389 case CTK_ALIGN_END:
390 child_allocation.width = MIN(natural, allocation->width)(((natural) < (allocation->width)) ? (natural) : (allocation
->width))
;
391 child_allocation.x = allocation->x + allocation->width - child_allocation.width;
392 break;
393 case CTK_ALIGN_BASELINE:
394 case CTK_ALIGN_CENTER:
395 child_allocation.width = MIN(natural, allocation->width)(((natural) < (allocation->width)) ? (natural) : (allocation
->width))
;
396 child_allocation.x = allocation->x + (allocation->width - child_allocation.width) / 2;
397 break;
398 default:
399 g_assert_not_reached ()do { g_assertion_message_expr ("Ctk", "ctkboxgadget.c", 399, (
(const char*) (__func__)), ((void*)0)); } while (0)
;
400 }
401 }
402
403 ctk_css_gadget_allocate (CTK_CSS_GADGET (child)((((CtkCssGadget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (child), ((ctk_css_gadget_get_type ()))))))
, &child_allocation, baseline, out_clip);
404 }
405}
406
407static void
408ctk_box_gadget_allocate (CtkCssGadget *gadget,
409 const CtkAllocation *allocation,
410 int baseline,
411 CtkAllocation *out_clip)
412{
413 CtkBoxGadgetPrivate *priv = ctk_box_gadget_get_instance_private (CTK_BOX_GADGET (gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (gadget), ((ctk_box_gadget_get_type ()))))))
);
414 CtkRequestedSize *sizes;
415 CtkAllocation child_allocation, child_clip;
416 CtkAlign child_align;
417 guint i;
418
419 child_allocation = *allocation;
420 sizes = g_newa (CtkRequestedSize, priv->children->len)((CtkRequestedSize*) __builtin_alloca (sizeof (CtkRequestedSize
) * (gsize) (priv->children->len)))
;
421
422 if (priv->orientation == CTK_ORIENTATION_HORIZONTAL)
423 {
424 ctk_box_gadget_distribute (CTK_BOX_GADGET (gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (gadget), ((ctk_box_gadget_get_type ()))))))
, allocation->height, allocation->width, sizes);
425
426 if (priv->allocate_reverse)
427 child_allocation.x = allocation->x + allocation->width;
428
429 for (i = 0; i < priv->children->len; i++)
430 {
431 guint idx = priv->allocate_reverse ? priv->children->len - 1 - i : i;
432 CtkBoxGadgetChild *child = &g_array_index (priv->children, CtkBoxGadgetChild, idx)(((CtkBoxGadgetChild*) (void *) (priv->children)->data)
[(idx)])
;
433 child_allocation.width = sizes[idx].minimum_size;
434 child_allocation.height = allocation->height;
435 child_allocation.y = allocation->y;
436 if (priv->allocate_reverse)
437 child_allocation.x -= child_allocation.width;
438
439 child_align = ctk_box_gadget_child_get_align (CTK_BOX_GADGET (gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (gadget), ((ctk_box_gadget_get_type ()))))))
, child);
440 ctk_box_gadget_allocate_child (child->object,
441 priv->orientation,
442 effective_align (child_align, priv->align_reverse),
443 &child_allocation,
444 baseline,
445 &child_clip);
446
447 if (i == 0)
448 *out_clip = child_clip;
449 else
450 cdk_rectangle_union (out_clip, &child_clip, out_clip);
451
452 if (!priv->allocate_reverse)
453 child_allocation.x += sizes[idx].minimum_size;
454 }
455 }
456 else
457 {
458 ctk_box_gadget_distribute (CTK_BOX_GADGET (gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (gadget), ((ctk_box_gadget_get_type ()))))))
, allocation->width, allocation->height, sizes);
459
460 if (priv->allocate_reverse)
461 child_allocation.y = allocation->y + allocation->height;
462
463 for (i = 0 ; i < priv->children->len; i++)
464 {
465 guint idx = priv->allocate_reverse ? priv->children->len - 1 - i : i;
466 CtkBoxGadgetChild *child = &g_array_index (priv->children, CtkBoxGadgetChild, idx)(((CtkBoxGadgetChild*) (void *) (priv->children)->data)
[(idx)])
;
467 child_allocation.height = sizes[idx].minimum_size;
468 child_allocation.width = allocation->width;
469 child_allocation.x = allocation->x;
470 if (priv->allocate_reverse)
471 child_allocation.y -= child_allocation.height;
472
473 child_align = ctk_box_gadget_child_get_align (CTK_BOX_GADGET (gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (gadget), ((ctk_box_gadget_get_type ()))))))
, child);
474 ctk_box_gadget_allocate_child (child->object,
475 priv->orientation,
476 effective_align (child_align, priv->align_reverse),
477 &child_allocation,
478 -1,
479 &child_clip);
480
481 if (i == 0)
482 *out_clip = child_clip;
483 else
484 cdk_rectangle_union (out_clip, &child_clip, out_clip);
485
486 if (!priv->allocate_reverse)
487 child_allocation.y += sizes[idx].minimum_size;
488 }
489 }
490}
491
492static gboolean
493ctk_box_gadget_draw (CtkCssGadget *gadget,
494 cairo_t *cr,
495 int x G_GNUC_UNUSED__attribute__ ((__unused__)),
496 int y G_GNUC_UNUSED__attribute__ ((__unused__)),
497 int width G_GNUC_UNUSED__attribute__ ((__unused__)),
498 int height G_GNUC_UNUSED__attribute__ ((__unused__)))
499{
500 CtkBoxGadgetPrivate *priv = ctk_box_gadget_get_instance_private (CTK_BOX_GADGET (gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (gadget), ((ctk_box_gadget_get_type ()))))))
);
501 CtkWidget *owner = ctk_css_gadget_get_owner (gadget);
502 guint i;
503
504 for (i = 0; i < priv->children->len; i++)
505 {
506 guint draw_index = priv->draw_reverse ? priv->children->len - 1 - i : i;
507 CtkBoxGadgetChild *child = &g_array_index (priv->children, CtkBoxGadgetChild, draw_index)(((CtkBoxGadgetChild*) (void *) (priv->children)->data)
[(draw_index)])
;
508
509 if (CTK_IS_WIDGET (child->object)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(child->object)); GType __t = ((ctk_widget_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
510 ctk_container_propagate_draw (CTK_CONTAINER (owner)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((owner)), ((ctk_container_get_type ()))))))
, CTK_WIDGET (child->object)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((child->object)), ((ctk_widget_get_type ()))))))
, cr);
511 else
512 ctk_css_gadget_draw (CTK_CSS_GADGET (child->object)((((CtkCssGadget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (child->object), ((ctk_css_gadget_get_type ()))))))
, cr);
513 }
514
515 if (priv->draw_focus && ctk_widget_has_visible_focus (owner))
516 return TRUE(!(0));
517
518 return FALSE(0);
519}
520
521static void
522ctk_box_gadget_finalize (GObject *object)
523{
524 CtkBoxGadgetPrivate *priv = ctk_box_gadget_get_instance_private (CTK_BOX_GADGET (object)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (object), ((ctk_box_gadget_get_type ()))))))
);
525
526 g_array_free (priv->children, TRUE(!(0)));
527
528 G_OBJECT_CLASS (ctk_box_gadget_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((ctk_box_gadget_parent_class)), (((GType) ((20) << (
2))))))))
->finalize (object);
529}
530
531static void
532ctk_box_gadget_class_init (CtkBoxGadgetClass *klass)
533{
534 CtkCssGadgetClass *gadget_class = CTK_CSS_GADGET_CLASS (klass)((((CtkCssGadgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) (klass), ((ctk_css_gadget_get_type ()))))))
;
535 GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
;
536
537 object_class->finalize = ctk_box_gadget_finalize;
538
539 gadget_class->get_preferred_size = ctk_box_gadget_get_preferred_size;
540 gadget_class->allocate = ctk_box_gadget_allocate;
541 gadget_class->draw = ctk_box_gadget_draw;
542}
543
544static void
545ctk_box_gadget_clear_child (gpointer data)
546{
547 CtkBoxGadgetChild *child = data;
548
549 g_object_unref (child->object);
550}
551
552static void
553ctk_box_gadget_init (CtkBoxGadget *gadget)
554{
555 CtkBoxGadgetPrivate *priv = ctk_box_gadget_get_instance_private (gadget);
556
557 priv->children = g_array_new (FALSE(0), FALSE(0), sizeof (CtkBoxGadgetChild));
558 g_array_set_clear_func (priv->children, ctk_box_gadget_clear_child);
559}
560
561CtkCssGadget *
562ctk_box_gadget_new_for_node (CtkCssNode *node,
563 CtkWidget *owner)
564{
565 return g_object_new (CTK_TYPE_BOX_GADGET(ctk_box_gadget_get_type ()),
566 "node", node,
567 "owner", owner,
568 NULL((void*)0));
569}
570
571CtkCssGadget *
572ctk_box_gadget_new (const char *name,
573 CtkWidget *owner,
574 CtkCssGadget *parent,
575 CtkCssGadget *next_sibling)
576{
577 CtkCssNode *node;
578 CtkCssGadget *result;
579
580 node = ctk_css_node_new ();
581 ctk_css_node_set_name (node, g_intern_string (name));
582 if (parent)
583 ctk_css_node_insert_before (ctk_css_gadget_get_node (parent),
584 node,
585 next_sibling ? ctk_css_gadget_get_node (next_sibling) : NULL((void*)0));
586
587 result = ctk_box_gadget_new_for_node (node, owner);
588
589 g_object_unref (node);
590
591 return result;
592}
593
594void
595ctk_box_gadget_set_orientation (CtkBoxGadget *gadget,
596 CtkOrientation orientation)
597{
598 CtkBoxGadgetPrivate *priv = ctk_box_gadget_get_instance_private (gadget);
599
600 priv->orientation = orientation;
601}
602
603void
604ctk_box_gadget_set_draw_focus (CtkBoxGadget *gadget,
605 gboolean draw_focus)
606{
607 CtkBoxGadgetPrivate *priv = ctk_box_gadget_get_instance_private (gadget);
608
609 priv->draw_focus = draw_focus;
610}
611
612void
613ctk_box_gadget_set_draw_reverse (CtkBoxGadget *gadget,
614 gboolean draw_reverse)
615{
616 CtkBoxGadgetPrivate *priv = ctk_box_gadget_get_instance_private (gadget);
617
618 priv->draw_reverse = draw_reverse;
619}
620
621void
622ctk_box_gadget_set_allocate_reverse (CtkBoxGadget *gadget,
623 gboolean allocate_reverse)
624{
625 CtkBoxGadgetPrivate *priv = ctk_box_gadget_get_instance_private (gadget);
626
627 priv->allocate_reverse = allocate_reverse;
628}
629
630void
631ctk_box_gadget_set_align_reverse (CtkBoxGadget *gadget,
632 gboolean align_reverse)
633{
634 CtkBoxGadgetPrivate *priv = ctk_box_gadget_get_instance_private (gadget);
635
636 priv->align_reverse = align_reverse;
637}
638
639static CtkCssNode *
640get_css_node (GObject *child)
641{
642 if (CTK_IS_WIDGET (child)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(child)); GType __t = ((ctk_widget_get_type ())); gboolean __r
; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
643 return ctk_widget_get_css_node (CTK_WIDGET (child)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((child)), ((ctk_widget_get_type ()))))))
);
644 else
645 return ctk_css_gadget_get_node (CTK_CSS_GADGET (child)((((CtkCssGadget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (child), ((ctk_css_gadget_get_type ()))))))
);
646}
647
648static void
649ctk_box_gadget_insert_object (CtkBoxGadget *gadget,
650 int pos,
651 GObject *object,
652 gboolean expand,
653 CtkAlign align)
654{
655 CtkBoxGadgetPrivate *priv = ctk_box_gadget_get_instance_private (gadget);
656 CtkBoxGadgetChild child;
657
658 child.object = g_object_ref (object)((__typeof__ (object)) (g_object_ref) (object));
659 child.expand = expand;
660 child.align = align;
661
662 if (pos < 0 || pos >= priv->children->len)
663 {
664 g_array_append_val (priv->children, child)g_array_append_vals (priv->children, &(child), 1);
665 ctk_css_node_insert_before (ctk_css_gadget_get_node (CTK_CSS_GADGET (gadget)((((CtkCssGadget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (gadget), ((ctk_css_gadget_get_type ()))))))
),
666 get_css_node (object),
667 NULL((void*)0));
668 }
669 else
670 {
671 g_array_insert_val (priv->children, pos, child)g_array_insert_vals (priv->children, pos, &(child), 1);
672 ctk_css_node_insert_before (ctk_css_gadget_get_node (CTK_CSS_GADGET (gadget)((((CtkCssGadget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (gadget), ((ctk_css_gadget_get_type ()))))))
),
673 get_css_node (object),
674 get_css_node (g_array_index (priv->children, CtkBoxGadgetChild, pos + 1)(((CtkBoxGadgetChild*) (void *) (priv->children)->data)
[(pos + 1)])
.object));
675 }
676}
677
678void
679ctk_box_gadget_insert_widget (CtkBoxGadget *gadget,
680 int pos,
681 CtkWidget *widget)
682{
683 ctk_box_gadget_insert_object (gadget, pos, G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
, FALSE(0), CTK_ALIGN_FILL);
684}
685
686static CtkBoxGadgetChild *
687ctk_box_gadget_find_object (CtkBoxGadget *gadget,
688 GObject *object,
689 int *position)
690{
691 CtkBoxGadgetPrivate *priv = ctk_box_gadget_get_instance_private (gadget);
692 guint i;
693
694 for (i = 0; i < priv->children->len; i++)
695 {
696 CtkBoxGadgetChild *child = &g_array_index (priv->children, CtkBoxGadgetChild, i)(((CtkBoxGadgetChild*) (void *) (priv->children)->data)
[(i)])
;
697
698 if (child->object == object)
699 {
700 if (position)
701 *position = i;
702 return child;
703 }
704 }
705
706 return NULL((void*)0);
707}
708
709static void
710ctk_box_gadget_remove_object (CtkBoxGadget *gadget,
711 GObject *object)
712{
713 CtkBoxGadgetPrivate *priv = ctk_box_gadget_get_instance_private (gadget);
714 CtkBoxGadgetChild *child;
715 int position;
716
717 child = ctk_box_gadget_find_object (gadget, object, &position);
718 if (child)
719 {
720 ctk_css_node_set_parent (get_css_node (child->object), NULL((void*)0));
721 g_array_remove_index (priv->children, position);
722 }
723}
724
725void
726ctk_box_gadget_remove_widget (CtkBoxGadget *gadget,
727 CtkWidget *widget)
728{
729 ctk_box_gadget_remove_object (gadget, G_OBJECT (widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (((GType) ((20) << (2))))))))
);
730}
731
732void
733ctk_box_gadget_insert_gadget_before (CtkBoxGadget *gadget,
734 CtkCssGadget *sibling,
735 CtkCssGadget *cssgadget,
736 gboolean expand,
737 CtkAlign align)
738{
739 /* Insert at the end if no sibling specified */
740 int pos = -1;
741
742 if (sibling)
743 ctk_box_gadget_find_object (gadget, G_OBJECT (sibling)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((sibling)), (((GType) ((20) << (2))))))))
, &pos);
744
745 ctk_box_gadget_insert_gadget (gadget, pos, cssgadget, expand, align);
746}
747
748void
749ctk_box_gadget_insert_gadget_after (CtkBoxGadget *gadget,
750 CtkCssGadget *sibling,
751 CtkCssGadget *cssgadget,
752 gboolean expand,
753 CtkAlign align)
754{
755 /* Insert at the beginning if no sibling specified */
756 int pos = 0;
757
758 if (sibling && ctk_box_gadget_find_object (gadget, G_OBJECT (sibling)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((sibling)), (((GType) ((20) << (2))))))))
, &pos))
759 pos++;
760
761 ctk_box_gadget_insert_gadget (gadget, pos, cssgadget, expand, align);
762}
763
764void
765ctk_box_gadget_insert_gadget (CtkBoxGadget *gadget,
766 int pos,
767 CtkCssGadget *cssgadget,
768 gboolean expand,
769 CtkAlign align)
770{
771 ctk_box_gadget_insert_object (gadget, pos, G_OBJECT (cssgadget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((cssgadget)), (((GType) ((20) << (2))))))))
, expand, align);
772}
773
774void
775ctk_box_gadget_remove_gadget (CtkBoxGadget *gadget,
776 CtkCssGadget *cssgadget)
777{
778 ctk_box_gadget_remove_object (gadget, G_OBJECT (cssgadget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((cssgadget)), (((GType) ((20) << (2))))))))
);
779}
780
781void
782ctk_box_gadget_reverse_children (CtkBoxGadget *gadget)
783{
784 CtkBoxGadgetPrivate *priv = ctk_box_gadget_get_instance_private (CTK_BOX_GADGET (gadget)((((CtkBoxGadget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (gadget), ((ctk_box_gadget_get_type ()))))))
);
785 int i, j;
786
787 ctk_css_node_reverse_children (ctk_css_gadget_get_node (CTK_CSS_GADGET (gadget)((((CtkCssGadget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (gadget), ((ctk_css_gadget_get_type ()))))))
));
788
789 for (i = 0, j = priv->children->len - 1; i < j; i++, j--)
790 {
791 CtkBoxGadgetChild *child1 = &g_array_index (priv->children, CtkBoxGadgetChild, i)(((CtkBoxGadgetChild*) (void *) (priv->children)->data)
[(i)])
;
792 CtkBoxGadgetChild *child2 = &g_array_index (priv->children, CtkBoxGadgetChild, j)(((CtkBoxGadgetChild*) (void *) (priv->children)->data)
[(j)])
;
793 CtkBoxGadgetChild tmp;
794
795 tmp = *child1;
796 *child1 = *child2;
797 *child2 = tmp;
798 }
799}
800
801void
802ctk_box_gadget_set_gadget_expand (CtkBoxGadget *gadget,
803 GObject *object,
804 gboolean expand)
805{
806 CtkBoxGadgetChild *child;
807
808 child = ctk_box_gadget_find_object (gadget, object, NULL((void*)0));
809
810 if (!child)
811 return;
812
813 if (child->expand == expand)
814 return;
815
816 child->expand = expand;
817 ctk_css_gadget_queue_resize (CTK_CSS_GADGET (gadget)((((CtkCssGadget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (gadget), ((ctk_css_gadget_get_type ()))))))
);
818}
819
820void
821ctk_box_gadget_set_gadget_align (CtkBoxGadget *gadget,
822 GObject *object,
823 CtkAlign align)
824{
825 CtkBoxGadgetChild *child;
826
827 child = ctk_box_gadget_find_object (gadget, object, NULL((void*)0));
828
829 if (!child)
830 return;
831
832 if (child->align == align)
833 return;
834
835 child->align = align;
836 ctk_css_gadget_queue_resize (CTK_CSS_GADGET (gadget)((((CtkCssGadget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) (gadget), ((ctk_css_gadget_get_type ()))))))
);
837}