Bug Summary

File:ctk/ctkbox.c
Warning:line 1020, column 40
Assigned value is garbage or undefined

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 ctkbox.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 ctkbox.c
1/* CTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
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 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
18/*
19 * Modified by the CTK+ Team and others 1997-2000. See the AUTHORS
20 * file for a list of people on the CTK+ Team. See the ChangeLog
21 * files for a list of changes. These files are distributed with
22 * CTK+ at ftp://ftp.ctk.org/pub/ctk/.
23 */
24
25/**
26 * SECTION:ctkbox
27 * @Short_description: A container for packing widgets in a single row or column
28 * @Title: CtkBox
29 * @See_also: #CtkGrid
30 *
31 * The CtkBox widget arranges child widgets into a single row or column,
32 * depending upon the value of its #CtkOrientable:orientation property. Within
33 * the other dimension, all children are allocated the same size. Of course,
34 * the #CtkWidget:halign and #CtkWidget:valign properties can be used on
35 * the children to influence their allocation.
36 *
37 * CtkBox uses a notion of packing. Packing refers
38 * to adding widgets with reference to a particular position in a
39 * #CtkContainer. For a CtkBox, there are two reference positions: the
40 * start and the end of the box.
41 * For a vertical #CtkBox, the start is defined as the top of the box and
42 * the end is defined as the bottom. For a horizontal #CtkBox the start
43 * is defined as the left side and the end is defined as the right side.
44 *
45 * Use repeated calls to ctk_box_pack_start() to pack widgets into a
46 * CtkBox from start to end. Use ctk_box_pack_end() to add widgets from
47 * end to start. You may intersperse these calls and add widgets from
48 * both ends of the same CtkBox.
49 *
50 * Because CtkBox is a #CtkContainer, you may also use ctk_container_add()
51 * to insert widgets into the box, and they will be packed with the default
52 * values for expand and fill child properties. Use ctk_container_remove()
53 * to remove widgets from the CtkBox.
54 *
55 * Use ctk_box_set_homogeneous() to specify whether or not all children
56 * of the CtkBox are forced to get the same amount of space.
57 *
58 * Use ctk_box_set_spacing() to determine how much space will be
59 * minimally placed between all children in the CtkBox. Note that
60 * spacing is added between the children, while
61 * padding added by ctk_box_pack_start() or ctk_box_pack_end() is added
62 * on either side of the widget it belongs to.
63 *
64 * Use ctk_box_reorder_child() to move a CtkBox child to a different
65 * place in the box.
66 *
67 * Use ctk_box_set_child_packing() to reset the expand,
68 * fill and padding child properties.
69 * Use ctk_box_query_child_packing() to query these fields.
70 *
71 * # CSS nodes
72 *
73 * CtkBox uses a single CSS node with name box.
74 *
75 * In horizontal orientation, the nodes of the children are always arranged
76 * from left to right. So :first-child will always select the leftmost child,
77 * regardless of text direction.
78 */
79
80#include "config.h"
81
82#include "ctkbox.h"
83#include "ctkboxprivate.h"
84#include "ctkcontainerprivate.h"
85#include "ctkcsscustomgadgetprivate.h"
86#include "ctkcssnodeprivate.h"
87#include "ctkintl.h"
88#include "ctkorientable.h"
89#include "ctkorientableprivate.h"
90#include "ctkprivate.h"
91#include "ctktypebuiltins.h"
92#include "ctksizerequest.h"
93#include "ctkwidgetpath.h"
94#include "ctkwidgetprivate.h"
95#include "a11y/ctkcontaineraccessible.h"
96
97
98enum {
99 PROP_0,
100 PROP_SPACING,
101 PROP_HOMOGENEOUS,
102 PROP_BASELINE_POSITION,
103
104 /* orientable */
105 PROP_ORIENTATION,
106 LAST_PROP = PROP_ORIENTATION
107};
108
109enum {
110 CHILD_PROP_0,
111 CHILD_PROP_EXPAND,
112 CHILD_PROP_FILL,
113 CHILD_PROP_PADDING,
114 CHILD_PROP_PACK_TYPE,
115 CHILD_PROP_POSITION,
116 LAST_CHILD_PROP
117};
118
119typedef struct _CtkBoxChild CtkBoxChild;
120
121struct _CtkBoxPrivate
122{
123 GList *children;
124 CtkBoxChild *center;
125 CtkCssGadget *gadget;
126
127 CtkOrientation orientation;
128 gint16 spacing;
129
130 guint default_expand : 1;
131 guint homogeneous : 1;
132 guint spacing_set : 1;
133 guint baseline_pos : 2;
134};
135
136static GParamSpec *props[LAST_PROP] = { NULL((void*)0), };
137static GParamSpec *child_props[LAST_CHILD_PROP] = { NULL((void*)0), };
138
139/*
140 * CtkBoxChild:
141 * @widget: the child widget, packed into the CtkBox.
142 * @padding: the number of extra pixels to put between this child and its
143 * neighbors, set when packed, zero by default.
144 * @expand: flag indicates whether extra space should be given to this child.
145 * Any extra space given to the parent CtkBox is divided up among all children
146 * with this attribute set to %TRUE; set when packed, %TRUE by default.
147 * @fill: flag indicates whether any extra space given to this child due to its
148 * @expand attribute being set is actually allocated to the child, rather than
149 * being used as padding around the widget; set when packed, %TRUE by default.
150 * @pack: one of #CtkPackType indicating whether the child is packed with
151 * reference to the start (top/left) or end (bottom/right) of the CtkBox.
152 */
153struct _CtkBoxChild
154{
155 CtkWidget *widget;
156
157 guint16 padding;
158
159 guint expand : 1;
160 guint fill : 1;
161 guint pack : 1;
162};
163
164static void ctk_box_size_allocate (CtkWidget *widget,
165 CtkAllocation *allocation);
166static gboolean ctk_box_draw (CtkWidget *widget,
167 cairo_t *cr);
168
169static void ctk_box_direction_changed (CtkWidget *widget,
170 CtkTextDirection previous_direction);
171
172static void ctk_box_set_property (GObject *object,
173 guint prop_id,
174 const GValue *value,
175 GParamSpec *pspec);
176static void ctk_box_get_property (GObject *object,
177 guint prop_id,
178 GValue *value,
179 GParamSpec *pspec);
180static void ctk_box_add (CtkContainer *container,
181 CtkWidget *widget);
182static void ctk_box_remove (CtkContainer *container,
183 CtkWidget *widget);
184static void ctk_box_forall (CtkContainer *container,
185 gboolean include_internals,
186 CtkCallback callback,
187 gpointer callback_data);
188static void ctk_box_set_child_property (CtkContainer *container,
189 CtkWidget *child,
190 guint property_id,
191 const GValue *value,
192 GParamSpec *pspec);
193static void ctk_box_get_child_property (CtkContainer *container,
194 CtkWidget *child,
195 guint property_id,
196 GValue *value,
197 GParamSpec *pspec);
198static GType ctk_box_child_type (CtkContainer *container);
199static CtkWidgetPath * ctk_box_get_path_for_child
200 (CtkContainer *container,
201 CtkWidget *child);
202
203
204static void ctk_box_get_preferred_width (CtkWidget *widget,
205 gint *minimum_size,
206 gint *natural_size);
207static void ctk_box_get_preferred_height (CtkWidget *widget,
208 gint *minimum_size,
209 gint *natural_size);
210static void ctk_box_get_preferred_width_for_height (CtkWidget *widget,
211 gint height,
212 gint *minimum_width,
213 gint *natural_width);
214static void ctk_box_get_preferred_height_for_width (CtkWidget *widget,
215 gint width,
216 gint *minimum_height,
217 gint *natural_height);
218static void ctk_box_get_preferred_height_and_baseline_for_width (CtkWidget *widget,
219 gint width,
220 gint *minimum_height,
221 gint *natural_height,
222 gint *minimum_baseline,
223 gint *natural_baseline);
224
225static void ctk_box_buildable_init (CtkBuildableIface *iface);
226
227G_DEFINE_TYPE_WITH_CODE (CtkBox, ctk_box, CTK_TYPE_CONTAINER,static void ctk_box_init (CtkBox *self); static void ctk_box_class_init
(CtkBoxClass *klass); static GType ctk_box_get_type_once (void
); static gpointer ctk_box_parent_class = ((void*)0); static gint
CtkBox_private_offset; static void ctk_box_class_intern_init
(gpointer klass) { ctk_box_parent_class = g_type_class_peek_parent
(klass); if (CtkBox_private_offset != 0) g_type_class_adjust_private_offset
(klass, &CtkBox_private_offset); ctk_box_class_init ((CtkBoxClass
*) klass); } __attribute__ ((__unused__)) static inline gpointer
ctk_box_get_instance_private (CtkBox *self) { return (((gpointer
) ((guint8*) (self) + (glong) (CtkBox_private_offset)))); } GType
ctk_box_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_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_get_type_once (void) { GType
g_define_type_id = g_type_register_static_simple ((ctk_container_get_type
()), g_intern_static_string ("CtkBox"), sizeof (CtkBoxClass)
, (GClassInitFunc)(void (*)(void)) ctk_box_class_intern_init,
sizeof (CtkBox), (GInstanceInitFunc)(void (*)(void)) ctk_box_init
, (GTypeFlags) 0); { {{ CtkBox_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (CtkBoxPrivate)); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) ((void*)0), ((void*)0), ((void*)0) }; g_type_add_interface_static
(g_define_type_id, (ctk_orientable_get_type ()), &g_implement_interface_info
); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc
)(void (*)(void)) ctk_box_buildable_init, ((void*)0), ((void*
)0) }; g_type_add_interface_static (g_define_type_id, (ctk_buildable_get_type
()), &g_implement_interface_info); };} } return g_define_type_id
; }
228 G_ADD_PRIVATE (CtkBox)static void ctk_box_init (CtkBox *self); static void ctk_box_class_init
(CtkBoxClass *klass); static GType ctk_box_get_type_once (void
); static gpointer ctk_box_parent_class = ((void*)0); static gint
CtkBox_private_offset; static void ctk_box_class_intern_init
(gpointer klass) { ctk_box_parent_class = g_type_class_peek_parent
(klass); if (CtkBox_private_offset != 0) g_type_class_adjust_private_offset
(klass, &CtkBox_private_offset); ctk_box_class_init ((CtkBoxClass
*) klass); } __attribute__ ((__unused__)) static inline gpointer
ctk_box_get_instance_private (CtkBox *self) { return (((gpointer
) ((guint8*) (self) + (glong) (CtkBox_private_offset)))); } GType
ctk_box_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_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_get_type_once (void) { GType
g_define_type_id = g_type_register_static_simple ((ctk_container_get_type
()), g_intern_static_string ("CtkBox"), sizeof (CtkBoxClass)
, (GClassInitFunc)(void (*)(void)) ctk_box_class_intern_init,
sizeof (CtkBox), (GInstanceInitFunc)(void (*)(void)) ctk_box_init
, (GTypeFlags) 0); { {{ CtkBox_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (CtkBoxPrivate)); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) ((void*)0), ((void*)0), ((void*)0) }; g_type_add_interface_static
(g_define_type_id, (ctk_orientable_get_type ()), &g_implement_interface_info
); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc
)(void (*)(void)) ctk_box_buildable_init, ((void*)0), ((void*
)0) }; g_type_add_interface_static (g_define_type_id, (ctk_buildable_get_type
()), &g_implement_interface_info); };} } return g_define_type_id
; }
229 G_IMPLEMENT_INTERFACE (CTK_TYPE_ORIENTABLE, NULL)static void ctk_box_init (CtkBox *self); static void ctk_box_class_init
(CtkBoxClass *klass); static GType ctk_box_get_type_once (void
); static gpointer ctk_box_parent_class = ((void*)0); static gint
CtkBox_private_offset; static void ctk_box_class_intern_init
(gpointer klass) { ctk_box_parent_class = g_type_class_peek_parent
(klass); if (CtkBox_private_offset != 0) g_type_class_adjust_private_offset
(klass, &CtkBox_private_offset); ctk_box_class_init ((CtkBoxClass
*) klass); } __attribute__ ((__unused__)) static inline gpointer
ctk_box_get_instance_private (CtkBox *self) { return (((gpointer
) ((guint8*) (self) + (glong) (CtkBox_private_offset)))); } GType
ctk_box_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_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_get_type_once (void) { GType
g_define_type_id = g_type_register_static_simple ((ctk_container_get_type
()), g_intern_static_string ("CtkBox"), sizeof (CtkBoxClass)
, (GClassInitFunc)(void (*)(void)) ctk_box_class_intern_init,
sizeof (CtkBox), (GInstanceInitFunc)(void (*)(void)) ctk_box_init
, (GTypeFlags) 0); { {{ CtkBox_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (CtkBoxPrivate)); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) ((void*)0), ((void*)0), ((void*)0) }; g_type_add_interface_static
(g_define_type_id, (ctk_orientable_get_type ()), &g_implement_interface_info
); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc
)(void (*)(void)) ctk_box_buildable_init, ((void*)0), ((void*
)0) }; g_type_add_interface_static (g_define_type_id, (ctk_buildable_get_type
()), &g_implement_interface_info); };} } return g_define_type_id
; }
230 G_IMPLEMENT_INTERFACE (CTK_TYPE_BUILDABLE, ctk_box_buildable_init))static void ctk_box_init (CtkBox *self); static void ctk_box_class_init
(CtkBoxClass *klass); static GType ctk_box_get_type_once (void
); static gpointer ctk_box_parent_class = ((void*)0); static gint
CtkBox_private_offset; static void ctk_box_class_intern_init
(gpointer klass) { ctk_box_parent_class = g_type_class_peek_parent
(klass); if (CtkBox_private_offset != 0) g_type_class_adjust_private_offset
(klass, &CtkBox_private_offset); ctk_box_class_init ((CtkBoxClass
*) klass); } __attribute__ ((__unused__)) static inline gpointer
ctk_box_get_instance_private (CtkBox *self) { return (((gpointer
) ((guint8*) (self) + (glong) (CtkBox_private_offset)))); } GType
ctk_box_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_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_get_type_once (void) { GType
g_define_type_id = g_type_register_static_simple ((ctk_container_get_type
()), g_intern_static_string ("CtkBox"), sizeof (CtkBoxClass)
, (GClassInitFunc)(void (*)(void)) ctk_box_class_intern_init,
sizeof (CtkBox), (GInstanceInitFunc)(void (*)(void)) ctk_box_init
, (GTypeFlags) 0); { {{ CtkBox_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (CtkBoxPrivate)); } { const GInterfaceInfo
g_implement_interface_info = { (GInterfaceInitFunc)(void (*)
(void)) ((void*)0), ((void*)0), ((void*)0) }; g_type_add_interface_static
(g_define_type_id, (ctk_orientable_get_type ()), &g_implement_interface_info
); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc
)(void (*)(void)) ctk_box_buildable_init, ((void*)0), ((void*
)0) }; g_type_add_interface_static (g_define_type_id, (ctk_buildable_get_type
()), &g_implement_interface_info); };} } return g_define_type_id
; }
231
232static void
233ctk_box_dispose (GObject *object)
234{
235 CtkBox *box = CTK_BOX (object)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((ctk_box_get_type ()))))))
;
236 CtkBoxPrivate *priv = box->priv;
237
238 g_clear_object (&priv->gadget)do { _Static_assert (sizeof *((&priv->gadget)) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ (((
&priv->gadget))) _pp = ((&priv->gadget)); __typeof__
(*((&priv->gadget))) _ptr = *_pp; *_pp = ((void*)0); if
(_ptr) (g_object_unref) (_ptr); } while (0)
;
239
240 G_OBJECT_CLASS (ctk_box_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((ctk_box_parent_class)), (((GType) ((20) << (2)))))
)))
->dispose (object);
241}
242
243static void
244ctk_box_class_init (CtkBoxClass *class)
245{
246 GObjectClass *object_class = G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), (((GType) ((20) << (2))))))))
;
247 CtkWidgetClass *widget_class = CTK_WIDGET_CLASS (class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), ((ctk_widget_get_type ()))))))
;
248 CtkContainerClass *container_class = CTK_CONTAINER_CLASS (class)((((CtkContainerClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), ((ctk_container_get_type ()))))))
;
249
250 object_class->set_property = ctk_box_set_property;
251 object_class->get_property = ctk_box_get_property;
252 object_class->dispose = ctk_box_dispose;
253
254 widget_class->draw = ctk_box_draw;
255 widget_class->size_allocate = ctk_box_size_allocate;
256 widget_class->get_preferred_width = ctk_box_get_preferred_width;
257 widget_class->get_preferred_height = ctk_box_get_preferred_height;
258 widget_class->get_preferred_height_for_width = ctk_box_get_preferred_height_for_width;
259 widget_class->get_preferred_height_and_baseline_for_width = ctk_box_get_preferred_height_and_baseline_for_width;
260 widget_class->get_preferred_width_for_height = ctk_box_get_preferred_width_for_height;
261 widget_class->direction_changed = ctk_box_direction_changed;
262
263 container_class->add = ctk_box_add;
264 container_class->remove = ctk_box_remove;
265 container_class->forall = ctk_box_forall;
266 container_class->child_type = ctk_box_child_type;
267 container_class->set_child_property = ctk_box_set_child_property;
268 container_class->get_child_property = ctk_box_get_child_property;
269 container_class->get_path_for_child = ctk_box_get_path_for_child;
270 ctk_container_class_handle_border_width (container_class);
271
272 g_object_class_override_property (object_class,
273 PROP_ORIENTATION,
274 "orientation");
275
276 props[PROP_SPACING] =
277 g_param_spec_int ("spacing",
278 P_("Spacing")g_dgettext("ctk30" "-properties","Spacing"),
279 P_("The amount of space between children")g_dgettext("ctk30" "-properties","The amount of space between children"
)
,
280 0, G_MAXINT2147483647, 0,
281 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY);
282
283 props[PROP_HOMOGENEOUS] =
284 g_param_spec_boolean ("homogeneous",
285 P_("Homogeneous")g_dgettext("ctk30" "-properties","Homogeneous"),
286 P_("Whether the children should all be the same size")g_dgettext("ctk30" "-properties","Whether the children should all be the same size"
)
,
287 FALSE(0),
288 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY);
289
290 props[PROP_BASELINE_POSITION] =
291 g_param_spec_enum ("baseline-position",
292 P_("Baseline position")g_dgettext("ctk30" "-properties","Baseline position"),
293 P_("The position of the baseline aligned widgets if extra space is available")g_dgettext("ctk30" "-properties","The position of the baseline aligned widgets if extra space is available"
)
,
294 CTK_TYPE_BASELINE_POSITION(ctk_baseline_position_get_type ()),
295 CTK_BASELINE_POSITION_CENTER,
296 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB|G_PARAM_EXPLICIT_NOTIFY);
297
298 g_object_class_install_properties (object_class, LAST_PROP, props);
299
300 /**
301 * CtkBox:expand:
302 *
303 * Whether the child should receive extra space when the parent grows.
304 *
305 * Note that the default value for this property is %FALSE for CtkBox,
306 * but #CtkHBox, #CtkVBox and other subclasses use the old default
307 * of %TRUE.
308 *
309 * Note: The #CtkWidget:hexpand or #CtkWidget:vexpand properties are the
310 * preferred way to influence whether the child receives extra space, by
311 * setting the child’s expand property corresponding to the box’s orientation.
312 *
313 * In contrast to #CtkWidget:hexpand, the expand child property does
314 * not cause the box to expand itself.
315 */
316 child_props[CHILD_PROP_EXPAND] =
317 g_param_spec_boolean ("expand",
318 P_("Expand")g_dgettext("ctk30" "-properties","Expand"),
319 P_("Whether the child should receive extra space when the parent grows")g_dgettext("ctk30" "-properties","Whether the child should receive extra space when the parent grows"
)
,
320 FALSE(0),
321 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB);
322
323 /**
324 * CtkBox:fill:
325 *
326 * Whether the child should fill extra space or use it as padding.
327 *
328 * Note: The #CtkWidget:halign or #CtkWidget:valign properties are the
329 * preferred way to influence whether the child fills available space, by
330 * setting the child’s align property corresponding to the box’s orientation
331 * to %CTK_ALIGN_FILL to fill, or to something else to refrain from filling.
332 */
333 child_props[CHILD_PROP_FILL] =
334 g_param_spec_boolean ("fill",
335 P_("Fill")g_dgettext("ctk30" "-properties","Fill"),
336 P_("Whether extra space given to the child should be allocated to the child or used as padding")g_dgettext("ctk30" "-properties","Whether extra space given to the child should be allocated to the child or used as padding"
)
,
337 TRUE(!(0)),
338 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB);
339
340 /**
341 * CtkBox:padding:
342 *
343 * Extra space to put between the child and its neighbors, in pixels.
344 *
345 * Note: The CSS padding properties are the preferred way to add space among
346 * widgets, by setting the paddings corresponding to the box’s orientation.
347 */
348 child_props[CHILD_PROP_PADDING] =
349 g_param_spec_uint ("padding",
350 P_("Padding")g_dgettext("ctk30" "-properties","Padding"),
351 P_("Extra space to put between the child and its neighbors, in pixels")g_dgettext("ctk30" "-properties","Extra space to put between the child and its neighbors, in pixels"
)
,
352 0, G_MAXINT2147483647,
353 0,
354 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB);
355
356 child_props[CHILD_PROP_PACK_TYPE] =
357 g_param_spec_enum ("pack-type",
358 P_("Pack type")g_dgettext("ctk30" "-properties","Pack type"),
359 P_("A CtkPackType indicating whether the child is packed with reference to the start or end of the parent")g_dgettext("ctk30" "-properties","A CtkPackType indicating whether the child is packed with reference to the start or end of the parent"
)
,
360 CTK_TYPE_PACK_TYPE(ctk_pack_type_get_type ()), CTK_PACK_START,
361 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB);
362
363 child_props[CHILD_PROP_POSITION] =
364 g_param_spec_int ("position",
365 P_("Position")g_dgettext("ctk30" "-properties","Position"),
366 P_("The index of the child in the parent")g_dgettext("ctk30" "-properties","The index of the child in the parent"
)
,
367 -1, G_MAXINT2147483647,
368 0,
369 CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB);
370
371 ctk_container_class_install_child_properties (container_class, LAST_CHILD_PROP, child_props);
372
373 ctk_widget_class_set_accessible_role (widget_class, ATK_ROLE_FILLER);
374 ctk_widget_class_set_css_name (widget_class, "box");
375}
376
377static void
378ctk_box_set_property (GObject *object,
379 guint prop_id,
380 const GValue *value,
381 GParamSpec *pspec)
382{
383 CtkBox *box = CTK_BOX (object)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((ctk_box_get_type ()))))))
;
384 CtkBoxPrivate *private = box->priv;
385
386 switch (prop_id)
387 {
388 case PROP_ORIENTATION:
389 {
390 CtkOrientation orientation = g_value_get_enum (value);
391 if (private->orientation != orientation)
392 {
393 private->orientation = orientation;
394 _ctk_orientable_set_style_classes (CTK_ORIENTABLE (box)((((CtkOrientable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_orientable_get_type ()))))))
);
395 ctk_widget_queue_resize (CTK_WIDGET (box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_widget_get_type ()))))))
);
396 g_object_notify (object, "orientation");
397 }
398 }
399 break;
400 case PROP_SPACING:
401 ctk_box_set_spacing (box, g_value_get_int (value));
402 break;
403 case PROP_BASELINE_POSITION:
404 ctk_box_set_baseline_position (box, g_value_get_enum (value));
405 break;
406 case PROP_HOMOGENEOUS:
407 ctk_box_set_homogeneous (box, g_value_get_boolean (value));
408 break;
409 default:
410 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "ctkbox.c", 410, ("property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
411 break;
412 }
413}
414
415static void
416ctk_box_get_property (GObject *object,
417 guint prop_id,
418 GValue *value,
419 GParamSpec *pspec)
420{
421 CtkBox *box = CTK_BOX (object)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((ctk_box_get_type ()))))))
;
422 CtkBoxPrivate *private = box->priv;
423
424 switch (prop_id)
425 {
426 case PROP_ORIENTATION:
427 g_value_set_enum (value, private->orientation);
428 break;
429 case PROP_SPACING:
430 g_value_set_int (value, private->spacing);
431 break;
432 case PROP_BASELINE_POSITION:
433 g_value_set_enum (value, private->baseline_pos);
434 break;
435 case PROP_HOMOGENEOUS:
436 g_value_set_boolean (value, private->homogeneous);
437 break;
438 default:
439 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "ctkbox.c", 439, ("property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
440 break;
441 }
442}
443
444static gboolean
445ctk_box_draw_contents (CtkCssGadget *gadget,
446 cairo_t *cr,
447 int x G_GNUC_UNUSED__attribute__ ((__unused__)),
448 int y G_GNUC_UNUSED__attribute__ ((__unused__)),
449 int width G_GNUC_UNUSED__attribute__ ((__unused__)),
450 int height G_GNUC_UNUSED__attribute__ ((__unused__)),
451 gpointer unused G_GNUC_UNUSED__attribute__ ((__unused__)))
452{
453 CTK_WIDGET_CLASS (ctk_box_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((ctk_box_parent_class)), ((ctk_widget_get_type ()))))))
->draw (ctk_css_gadget_get_owner (gadget), cr);
454
455 return FALSE(0);
456}
457
458static gboolean
459ctk_box_draw (CtkWidget *widget,
460 cairo_t *cr)
461{
462 ctk_css_gadget_draw (CTK_BOX (widget)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_box_get_type ()))))))
->priv->gadget, cr);
463
464 return FALSE(0);
465}
466
467
468static void
469count_expand_children (CtkBox *box,
470 gint *visible_children,
471 gint *expand_children)
472{
473 CtkBoxPrivate *private = box->priv;
474 GList *children;
475 CtkBoxChild *child;
476
477 *visible_children = *expand_children = 0;
478
479 for (children = private->children; children; children = children->next)
480 {
481 child = children->data;
482
483 if (_ctk_widget_get_visible (child->widget))
484 {
485 *visible_children += 1;
486 if (child->expand || ctk_widget_compute_expand (child->widget, private->orientation))
487 *expand_children += 1;
488 }
489 }
490}
491
492static void
493ctk_box_size_allocate_no_center (CtkWidget *widget,
494 const CtkAllocation *allocation)
495{
496 CtkBox *box = CTK_BOX (widget)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_box_get_type ()))))))
;
497 CtkBoxPrivate *private = box->priv;
498 CtkBoxChild *child;
499 GList *children;
500 gint nvis_children;
501 gint nexpand_children;
502
503 CtkTextDirection direction;
504 CtkAllocation child_allocation;
505 CtkRequestedSize *sizes;
506 gint child_minimum_baseline, child_natural_baseline;
507 gint minimum_above, natural_above;
508 gint minimum_below, natural_below;
509 gboolean have_baseline;
510 gint baseline;
511
512 CtkPackType packing;
513
514 gint size;
515 gint extra;
516 gint n_extra_widgets = 0; /* Number of widgets that receive 1 extra px */
517 gint x = 0, y = 0, i;
518 gint child_size;
519
520
521 count_expand_children (box, &nvis_children, &nexpand_children);
522
523 /* If there is no visible child, simply return. */
524 if (nvis_children <= 0)
525 return;
526
527 direction = ctk_widget_get_direction (widget);
528 sizes = g_newa (CtkRequestedSize, nvis_children)((CtkRequestedSize*) __builtin_alloca (sizeof (CtkRequestedSize
) * (gsize) (nvis_children)))
;
529 memset (sizes, 0, nvis_children * sizeof (CtkRequestedSize));
530
531 if (private->orientation == CTK_ORIENTATION_HORIZONTAL)
532 size = allocation->width - (nvis_children - 1) * private->spacing;
533 else
534 size = allocation->height - (nvis_children - 1) * private->spacing;
535
536 have_baseline = FALSE(0);
537 minimum_above = natural_above = 0;
538 minimum_below = natural_below = 0;
539
540 /* Retrieve desired size for visible children. */
541 for (i = 0, children = private->children; children; children = children->next)
542 {
543 child = children->data;
544
545 if (!_ctk_widget_get_visible (child->widget))
546 continue;
547
548 if (private->orientation == CTK_ORIENTATION_HORIZONTAL)
549 ctk_widget_get_preferred_width_for_height (child->widget,
550 allocation->height,
551 &sizes[i].minimum_size,
552 &sizes[i].natural_size);
553 else
554 ctk_widget_get_preferred_height_and_baseline_for_width (child->widget,
555 allocation->width,
556 &sizes[i].minimum_size,
557 &sizes[i].natural_size,
558 NULL((void*)0), NULL((void*)0));
559
560 /* Assert the api is working properly */
561 if (sizes[i].minimum_size < 0)
562 g_error ("CtkBox child %s minimum %s: %d < 0 for %s %d",
563 ctk_widget_get_name (CTK_WIDGET (child->widget)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((child->widget)), ((ctk_widget_get_type ()))))))
),
564 (private->orientation == CTK_ORIENTATION_HORIZONTAL) ? "width" : "height",
565 sizes[i].minimum_size,
566 (private->orientation == CTK_ORIENTATION_HORIZONTAL) ? "height" : "width",
567 (private->orientation == CTK_ORIENTATION_HORIZONTAL) ? allocation->height : allocation->width);
568
569 if (sizes[i].natural_size < sizes[i].minimum_size)
570 g_error ("CtkBox child %s natural %s: %d < minimum %d for %s %d",
571 ctk_widget_get_name (CTK_WIDGET (child->widget)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((child->widget)), ((ctk_widget_get_type ()))))))
),
572 (private->orientation == CTK_ORIENTATION_HORIZONTAL) ? "width" : "height",
573 sizes[i].natural_size,
574 sizes[i].minimum_size,
575 (private->orientation == CTK_ORIENTATION_HORIZONTAL) ? "height" : "width",
576 (private->orientation == CTK_ORIENTATION_HORIZONTAL) ? allocation->height : allocation->width);
577
578 size -= sizes[i].minimum_size;
579 size -= child->padding * 2;
580
581 sizes[i].data = child;
582
583 i++;
584 }
585
586 if (private->homogeneous)
587 {
588 /* If were homogenous we still need to run the above loop to get the
589 * minimum sizes for children that are not going to fill
590 */
591 if (private->orientation == CTK_ORIENTATION_HORIZONTAL)
592 size = allocation->width - (nvis_children - 1) * private->spacing;
593 else
594 size = allocation->height - (nvis_children - 1) * private->spacing;
595
596 extra = size / nvis_children;
597 n_extra_widgets = size % nvis_children;
598 }
599 else
600 {
601 /* Bring children up to size first */
602 size = ctk_distribute_natural_allocation (MAX (0, size)(((0) > (size)) ? (0) : (size)), nvis_children, sizes);
603
604 /* Calculate space which hasn't distributed yet,
605 * and is available for expanding children.
606 */
607 if (nexpand_children > 0)
608 {
609 extra = size / nexpand_children;
610 n_extra_widgets = size % nexpand_children;
611 }
612 else
613 extra = 0;
614 }
615
616 /* Allocate child sizes. */
617 for (packing = CTK_PACK_START; packing <= CTK_PACK_END; ++packing)
618 {
619 for (i = 0, children = private->children;
620 children;
621 children = children->next)
622 {
623 child = children->data;
624
625 /* If widget is not visible, skip it. */
626 if (!_ctk_widget_get_visible (child->widget))
627 continue;
628
629 /* If widget is packed differently skip it, but still increment i,
630 * since widget is visible and will be handled in next loop iteration.
631 */
632 if (child->pack != packing)
633 {
634 i++;
635 continue;
636 }
637
638 /* Assign the child's size. */
639 if (private->homogeneous)
640 {
641 child_size = extra;
642
643 if (n_extra_widgets > 0)
644 {
645 child_size++;
646 n_extra_widgets--;
647 }
648 }
649 else
650 {
651 child_size = sizes[i].minimum_size + child->padding * 2;
652
653 if (child->expand || ctk_widget_compute_expand (child->widget, private->orientation))
654 {
655 child_size += extra;
656
657 if (n_extra_widgets > 0)
658 {
659 child_size++;
660 n_extra_widgets--;
661 }
662 }
663 }
664
665 sizes[i].natural_size = child_size;
666
667 if (private->orientation == CTK_ORIENTATION_HORIZONTAL &&
668 ctk_widget_get_valign_with_baseline (child->widget) == CTK_ALIGN_BASELINE)
669 {
670 int child_allocation_width;
671 int child_minimum_height, child_natural_height;
672
673 if (child->fill)
674 child_allocation_width = MAX (1, child_size - child->padding * 2)(((1) > (child_size - child->padding * 2)) ? (1) : (child_size
- child->padding * 2))
;
675 else
676 child_allocation_width = sizes[i].minimum_size;
677
678 child_minimum_baseline = -1;
679 child_natural_baseline = -1;
680 ctk_widget_get_preferred_height_and_baseline_for_width (child->widget,
681 child_allocation_width,
682 &child_minimum_height, &child_natural_height,
683 &child_minimum_baseline, &child_natural_baseline);
684
685 if (child_minimum_baseline >= 0)
686 {
687 have_baseline = TRUE(!(0));
688 minimum_below = MAX (minimum_below, child_minimum_height - child_minimum_baseline)(((minimum_below) > (child_minimum_height - child_minimum_baseline
)) ? (minimum_below) : (child_minimum_height - child_minimum_baseline
))
;
689 natural_below = MAX (natural_below, child_natural_height - child_natural_baseline)(((natural_below) > (child_natural_height - child_natural_baseline
)) ? (natural_below) : (child_natural_height - child_natural_baseline
))
;
690 minimum_above = MAX (minimum_above, child_minimum_baseline)(((minimum_above) > (child_minimum_baseline)) ? (minimum_above
) : (child_minimum_baseline))
;
691 natural_above = MAX (natural_above, child_natural_baseline)(((natural_above) > (child_natural_baseline)) ? (natural_above
) : (child_natural_baseline))
;
692 }
693 }
694
695 i++;
696 }
697 }
698
699 baseline = ctk_widget_get_allocated_baseline (widget);
700 if (baseline == -1 && have_baseline)
701 {
702 gint height = MAX (1, allocation->height)(((1) > (allocation->height)) ? (1) : (allocation->height
))
;
703
704 /* TODO: This is purely based on the minimum baseline, when things fit we should
705 use the natural one? */
706
707 switch (private->baseline_pos)
708 {
709 case CTK_BASELINE_POSITION_TOP:
710 baseline = minimum_above;
711 break;
712 case CTK_BASELINE_POSITION_CENTER:
713 baseline = minimum_above + (height - (minimum_above + minimum_below)) / 2;
714 break;
715 case CTK_BASELINE_POSITION_BOTTOM:
716 baseline = height - minimum_below;
717 break;
718 }
719 }
720
721 /* Allocate child positions. */
722 for (packing = CTK_PACK_START; packing <= CTK_PACK_END; ++packing)
723 {
724 if (private->orientation == CTK_ORIENTATION_HORIZONTAL)
725 {
726 child_allocation.y = allocation->y;
727 child_allocation.height = MAX (1, allocation->height)(((1) > (allocation->height)) ? (1) : (allocation->height
))
;
728 if (packing == CTK_PACK_START)
729 x = allocation->x;
730 else
731 x = allocation->x + allocation->width;
732 }
733 else
734 {
735 child_allocation.x = allocation->x;
736 child_allocation.width = MAX (1, allocation->width)(((1) > (allocation->width)) ? (1) : (allocation->width
))
;
737 if (packing == CTK_PACK_START)
738 y = allocation->y;
739 else
740 y = allocation->y + allocation->height;
741 }
742
743 for (i = 0, children = private->children;
744 children;
745 children = children->next)
746 {
747 child = children->data;
748
749 /* If widget is not visible, skip it. */
750 if (!_ctk_widget_get_visible (child->widget))
751 continue;
752
753 /* If widget is packed differently skip it, but still increment i,
754 * since widget is visible and will be handled in next loop iteration.
755 */
756 if (child->pack != packing)
757 {
758 i++;
759 continue;
760 }
761
762 child_size = sizes[i].natural_size;
763
764 /* Assign the child's position. */
765 if (private->orientation == CTK_ORIENTATION_HORIZONTAL)
766 {
767 if (child->fill)
768 {
769 child_allocation.width = MAX (1, child_size - child->padding * 2)(((1) > (child_size - child->padding * 2)) ? (1) : (child_size
- child->padding * 2))
;
770 child_allocation.x = x + child->padding;
771 }
772 else
773 {
774 child_allocation.width = sizes[i].minimum_size;
775 child_allocation.x = x + (child_size - child_allocation.width) / 2;
776 }
777
778 if (packing == CTK_PACK_START)
779 {
780 x += child_size + private->spacing;
781 }
782 else
783 {
784 x -= child_size + private->spacing;
785
786 child_allocation.x -= child_size;
787 }
788
789 if (direction == CTK_TEXT_DIR_RTL)
790 child_allocation.x = allocation->x + allocation->width - (child_allocation.x - allocation->x) - child_allocation.width;
791
792 }
793 else /* (private->orientation == CTK_ORIENTATION_VERTICAL) */
794 {
795 if (child->fill)
796 {
797 child_allocation.height = MAX (1, child_size - child->padding * 2)(((1) > (child_size - child->padding * 2)) ? (1) : (child_size
- child->padding * 2))
;
798 child_allocation.y = y + child->padding;
799 }
800 else
801 {
802 child_allocation.height = sizes[i].minimum_size;
803 child_allocation.y = y + (child_size - child_allocation.height) / 2;
804 }
805
806 if (packing == CTK_PACK_START)
807 {
808 y += child_size + private->spacing;
809 }
810 else
811 {
812 y -= child_size + private->spacing;
813
814 child_allocation.y -= child_size;
815 }
816 }
817 ctk_widget_size_allocate_with_baseline (child->widget, &child_allocation, baseline);
818
819 i++;
820 }
821 }
822
823 _ctk_widget_set_simple_clip (widget, NULL((void*)0));
824}
825
826static void
827ctk_box_size_allocate_with_center (CtkWidget *widget,
828 const CtkAllocation *allocation)
829{
830 CtkBox *box = CTK_BOX (widget)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_box_get_type ()))))))
;
831 CtkBoxPrivate *priv = box->priv;
832 CtkBoxChild *child;
833 GList *children;
834 gint nvis[2];
835 gint nexp[2];
836 CtkTextDirection direction;
837 CtkAllocation child_allocation;
838 CtkRequestedSize *sizes[2];
839 CtkRequestedSize center_req = {.minimum_size = 0, .natural_size = 0};
840 gint child_minimum_baseline, child_natural_baseline;
841 gint minimum_above, natural_above;
842 gint minimum_below, natural_below;
843 gboolean have_baseline;
844 gint baseline;
845 gint idx[2];
846 gint center_pos;
847 gint center_size;
848 gint box_size;
849 gint side[2];
850 CtkPackType packing;
851 gint min_size[2];
852 gint nat_size[2];
853 gint extra[2];
854 gint n_extra_widgets[2];
855 gint x = 0, y = 0, i;
856 gint child_size;
857
858 nvis[0] = nvis[1] = 0;
859 nexp[0] = nexp[1] = 0;
860 for (children = priv->children; children; children = children->next)
1
Loop condition is true. Entering loop body
8
Loop condition is false. Execution continues on line 873
861 {
862 child = children->data;
863
864 if (child != priv->center &&
2
Assuming 'child' is not equal to field 'center'
4
Taking true branch
865 _ctk_widget_get_visible (child->widget))
3
Assuming the condition is true
866 {
867 nvis[child->pack] += 1;
868 if (child->expand || ctk_widget_compute_expand (child->widget, priv->orientation))
5
Assuming field 'expand' is 0
6
Assuming the condition is false
7
Taking false branch
869 nexp[child->pack] += 1;
870 }
871 }
872
873 direction = ctk_widget_get_direction (widget);
874 sizes[0] = g_newa (CtkRequestedSize, nvis[0])((CtkRequestedSize*) __builtin_alloca (sizeof (CtkRequestedSize
) * (gsize) (nvis[0])))
;
875 sizes[1] = g_newa (CtkRequestedSize, nvis[1])((CtkRequestedSize*) __builtin_alloca (sizeof (CtkRequestedSize
) * (gsize) (nvis[1])))
;
876
877 if (priv->orientation == CTK_ORIENTATION_HORIZONTAL)
9
Assuming field 'orientation' is equal to CTK_ORIENTATION_HORIZONTAL
10
Taking true branch
878 box_size = allocation->width;
879 else
880 box_size = allocation->height;
881
882 have_baseline = FALSE(0);
883 minimum_above = natural_above = 0;
884 minimum_below = natural_below = 0;
885
886 min_size[0] = nat_size[0] = nvis[0] * priv->spacing;
887 min_size[1] = nat_size[1] = nvis[1] * priv->spacing;
888
889 /* Retrieve desired size for visible children. */
890 idx[0] = idx[1] = 0;
891 for (children = priv->children; children; children = children->next)
11
Loop condition is true. Entering loop body
17
Loop condition is false. Execution continues on line 929
892 {
893 CtkRequestedSize *req;
894
895 child = children->data;
896
897 if (!_ctk_widget_get_visible (child->widget))
12
Assuming the condition is false
13
Taking false branch
898 continue;
899
900 if (child
13.1
'child' is not equal to field 'center'
== priv->center)
14
Taking false branch
901 req = &center_req;
902 else
903 req = &(sizes[child->pack][idx[child->pack]]);
904
905 if (priv->orientation
14.1
Field 'orientation' is equal to CTK_ORIENTATION_HORIZONTAL
== CTK_ORIENTATION_HORIZONTAL)
15
Taking true branch
906 ctk_widget_get_preferred_width_for_height (child->widget,
907 allocation->height,
908 &req->minimum_size,
909 &req->natural_size);
910 else
911 ctk_widget_get_preferred_height_and_baseline_for_width (child->widget,
912 allocation->width,
913 &req->minimum_size,
914 &req->natural_size,
915 NULL((void*)0), NULL((void*)0));
916
917 if (child
15.1
'child' is not equal to field 'center'
!= priv->center)
16
Taking true branch
918 {
919 min_size[child->pack] += req->minimum_size + 2 * child->padding;
920 nat_size[child->pack] += req->natural_size + 2 * child->padding;
921
922 idx[child->pack] += 1;
923 }
924
925 req->data = child;
926 }
927
928 /* Determine size of center */
929 if (priv->center->expand)
18
Assuming field 'expand' is not equal to 0
930 center_size = MAX (box_size - 2 * MAX (nat_size[0], nat_size[1]), center_req.minimum_size)(((box_size - 2 * (((nat_size[0]) > (nat_size[1])) ? (nat_size
[0]) : (nat_size[1]))) > (center_req.minimum_size)) ? (box_size
- 2 * (((nat_size[0]) > (nat_size[1])) ? (nat_size[0]) : (
nat_size[1]))) : (center_req.minimum_size))
;
19
Taking true branch
20
Assuming the condition is false
21
'?' condition is false
22
Assuming the condition is false
23
'?' condition is false
931 else
932 center_size = MAX (MIN (center_req.natural_size, box_size - min_size[0] - min_size[1]), center_req.minimum_size)((((((center_req.natural_size) < (box_size - min_size[0] -
min_size[1])) ? (center_req.natural_size) : (box_size - min_size
[0] - min_size[1]))) > (center_req.minimum_size)) ? ((((center_req
.natural_size) < (box_size - min_size[0] - min_size[1])) ?
(center_req.natural_size) : (box_size - min_size[0] - min_size
[1]))) : (center_req.minimum_size))
;
933
934 if (priv->homogeneous)
24
Assuming field 'homogeneous' is not equal to 0
935 {
936 extra[0] = nvis[0] ? ((box_size - center_size) / 2 - nvis[0] * priv->spacing) / nvis[0] : 0;
25
Taking true branch
26
Assuming the condition is true
27
'?' condition is true
937 extra[1] = nvis[1] ? ((box_size - center_size) / 2 - nvis[1] * priv->spacing) / nvis[1] : 0;
28
Assuming the condition is true
29
'?' condition is true
938 extra[0] = MIN (extra[0], extra[1])(((extra[0]) < (extra[1])) ? (extra[0]) : (extra[1]));
30
Assuming the condition is false
31
'?' condition is false
939 n_extra_widgets[0] = 0;
940 }
941 else
942 {
943 for (packing = CTK_PACK_START; packing <= CTK_PACK_END; packing++)
944 {
945 gint s;
946 /* Distribute the remainder naturally on each side */
947 s = MIN ((box_size - center_size) / 2 - min_size[packing], box_size - center_size - min_size[0] - min_size[1])((((box_size - center_size) / 2 - min_size[packing]) < (box_size
- center_size - min_size[0] - min_size[1])) ? ((box_size - center_size
) / 2 - min_size[packing]) : (box_size - center_size - min_size
[0] - min_size[1]))
;
948 s = ctk_distribute_natural_allocation (MAX (0, s)(((0) > (s)) ? (0) : (s)), nvis[packing], sizes[packing]);
949
950 /* Calculate space which hasn't distributed yet,
951 * and is available for expanding children.
952 */
953 if (nexp[packing] > 0)
954 {
955 extra[packing] = s / nexp[packing];
956 n_extra_widgets[packing] = s % nexp[packing];
957 }
958 else
959 extra[packing] = 0;
960 }
961 }
962
963 /* Allocate child sizes. */
964 for (packing = CTK_PACK_START; packing <= CTK_PACK_END; ++packing)
32
Loop condition is true. Entering loop body
965 {
966 for (i = 0, children = priv->children; children; children = children->next)
33
Loop condition is true. Entering loop body
967 {
968 child = children->data;
969
970 /* If widget is not visible, skip it. */
971 if (!_ctk_widget_get_visible (child->widget))
34
Assuming the condition is false
35
Taking false branch
972 continue;
973
974 /* Skip the center widget */
975 if (child
35.1
'child' is not equal to field 'center'
== priv->center)
36
Taking false branch
976 continue;
977
978 /* If widget is packed differently, skip it. */
979 if (child->pack != packing)
37
Assuming 'packing' is equal to field 'pack'
38
Taking false branch
980 continue;
981
982 /* Assign the child's size. */
983 if (priv->homogeneous
38.1
Field 'homogeneous' is not equal to 0
)
39
Taking true branch
984 {
985 child_size = extra[0];
986
987 if (n_extra_widgets[0] > 0)
40
Taking false branch
988 {
989 child_size++;
990 n_extra_widgets[0]--;
991 }
992 }
993 else
994 {
995 child_size = sizes[packing][i].minimum_size + child->padding * 2;
996
997 if (child->expand || ctk_widget_compute_expand (child->widget, priv->orientation))
998 {
999 child_size += extra[packing];
1000
1001 if (n_extra_widgets[packing] > 0)
1002 {
1003 child_size++;
1004 n_extra_widgets[packing]--;
1005 }
1006 }
1007 }
1008
1009 sizes[packing][i].natural_size = child_size;
1010
1011 if (priv->orientation
40.1
Field 'orientation' is equal to CTK_ORIENTATION_HORIZONTAL
== CTK_ORIENTATION_HORIZONTAL &&
42
Taking true branch
1012 ctk_widget_get_valign_with_baseline (child->widget) == CTK_ALIGN_BASELINE)
41
Assuming the condition is true
1013 {
1014 gint child_allocation_width;
1015 gint child_minimum_height, child_natural_height;
1016
1017 if (child->fill)
43
Assuming field 'fill' is 0
44
Taking false branch
1018 child_allocation_width = MAX (1, child_size - child->padding * 2)(((1) > (child_size - child->padding * 2)) ? (1) : (child_size
- child->padding * 2))
;
1019 else
1020 child_allocation_width = sizes[packing][i].minimum_size;
45
Assigned value is garbage or undefined
1021
1022 child_minimum_baseline = -1;
1023 child_natural_baseline = -1;
1024 ctk_widget_get_preferred_height_and_baseline_for_width (child->widget,
1025 child_allocation_width,
1026 &child_minimum_height, &child_natural_height,
1027 &child_minimum_baseline, &child_natural_baseline);
1028
1029 if (child_minimum_baseline >= 0)
1030 {
1031 have_baseline = TRUE(!(0));
1032 minimum_below = MAX (minimum_below, child_minimum_height - child_minimum_baseline)(((minimum_below) > (child_minimum_height - child_minimum_baseline
)) ? (minimum_below) : (child_minimum_height - child_minimum_baseline
))
;
1033 natural_below = MAX (natural_below, child_natural_height - child_natural_baseline)(((natural_below) > (child_natural_height - child_natural_baseline
)) ? (natural_below) : (child_natural_height - child_natural_baseline
))
;
1034 minimum_above = MAX (minimum_above, child_minimum_baseline)(((minimum_above) > (child_minimum_baseline)) ? (minimum_above
) : (child_minimum_baseline))
;
1035 natural_above = MAX (natural_above, child_natural_baseline)(((natural_above) > (child_natural_baseline)) ? (natural_above
) : (child_natural_baseline))
;
1036 }
1037 }
1038
1039 i++;
1040 }
1041 }
1042
1043 baseline = ctk_widget_get_allocated_baseline (widget);
1044 if (baseline == -1 && have_baseline)
1045 {
1046 gint height = MAX (1, allocation->height)(((1) > (allocation->height)) ? (1) : (allocation->height
))
;
1047
1048 /* TODO: This is purely based on the minimum baseline, when things fit we should
1049 * use the natural one?
1050 */
1051 switch (priv->baseline_pos)
1052 {
1053 case CTK_BASELINE_POSITION_TOP:
1054 baseline = minimum_above;
1055 break;
1056 case CTK_BASELINE_POSITION_CENTER:
1057 baseline = minimum_above + (height - (minimum_above + minimum_below)) / 2;
1058 break;
1059 case CTK_BASELINE_POSITION_BOTTOM:
1060 baseline = height - minimum_below;
1061 break;
1062 }
1063 }
1064
1065 /* Allocate child positions. */
1066 for (packing = CTK_PACK_START; packing <= CTK_PACK_END; ++packing)
1067 {
1068 if (priv->orientation == CTK_ORIENTATION_HORIZONTAL)
1069 {
1070 child_allocation.y = allocation->y;
1071 child_allocation.height = MAX (1, allocation->height)(((1) > (allocation->height)) ? (1) : (allocation->height
))
;
1072 if ((packing == CTK_PACK_START && direction == CTK_TEXT_DIR_LTR) ||
1073 (packing == CTK_PACK_END && direction == CTK_TEXT_DIR_RTL))
1074 x = allocation->x;
1075 else
1076 x = allocation->x + allocation->width;
1077 }
1078 else
1079 {
1080 child_allocation.x = allocation->x;
1081 child_allocation.width = MAX (1, allocation->width)(((1) > (allocation->width)) ? (1) : (allocation->width
))
;
1082 if (packing == CTK_PACK_START)
1083 y = allocation->y;
1084 else
1085 y = allocation->y + allocation->height;
1086 }
1087
1088 for (i = 0, children = priv->children; children; children = children->next)
1089 {
1090 child = children->data;
1091
1092 /* If widget is not visible, skip it. */
1093 if (!_ctk_widget_get_visible (child->widget))
1094 continue;
1095
1096 /* Skip the center widget */
1097 if (child == priv->center)
1098 continue;
1099
1100 /* If widget is packed differently, skip it. */
1101 if (child->pack != packing)
1102 continue;
1103
1104 child_size = sizes[packing][i].natural_size;
1105
1106 /* Assign the child's position. */
1107 if (priv->orientation == CTK_ORIENTATION_HORIZONTAL)
1108 {
1109 if (child->fill)
1110 {
1111 child_allocation.width = MAX (1, child_size - child->padding * 2)(((1) > (child_size - child->padding * 2)) ? (1) : (child_size
- child->padding * 2))
;
1112 child_allocation.x = x + child->padding;
1113 }
1114 else
1115 {
1116 child_allocation.width = sizes[packing][i].minimum_size;
1117 child_allocation.x = x + (child_size - child_allocation.width) / 2;
1118 }
1119
1120 if ((packing == CTK_PACK_START && direction == CTK_TEXT_DIR_LTR) ||
1121 (packing == CTK_PACK_END && direction == CTK_TEXT_DIR_RTL))
1122 {
1123 x += child_size + priv->spacing;
1124 }
1125 else
1126 {
1127 x -= child_size + priv->spacing;
1128 child_allocation.x -= child_size;
1129 }
1130 }
1131 else /* (private->orientation == CTK_ORIENTATION_VERTICAL) */
1132 {
1133 if (child->fill)
1134 {
1135 child_allocation.height = MAX (1, child_size - child->padding * 2)(((1) > (child_size - child->padding * 2)) ? (1) : (child_size
- child->padding * 2))
;
1136 child_allocation.y = y + child->padding;
1137 }
1138 else
1139 {
1140 child_allocation.height = sizes[packing][i].minimum_size;
1141 child_allocation.y = y + (child_size - child_allocation.height) / 2;
1142 }
1143
1144 if (packing == CTK_PACK_START)
1145 {
1146 y += child_size + priv->spacing;
1147 }
1148 else
1149 {
1150 y -= child_size + priv->spacing;
1151 child_allocation.y -= child_size;
1152 }
1153 }
1154 ctk_widget_size_allocate_with_baseline (child->widget, &child_allocation, baseline);
1155
1156 i++;
1157 }
1158
1159 if (priv->orientation == CTK_ORIENTATION_HORIZONTAL)
1160 side[packing] = x;
1161 else
1162 side[packing] = y;
1163 }
1164
1165 /* Allocate the center widget */
1166 if (priv->orientation == CTK_ORIENTATION_HORIZONTAL)
1167 center_pos = allocation->x + (box_size - center_size) / 2;
1168 else
1169 center_pos = allocation->y + (box_size - center_size) / 2;
1170
1171 if (priv->orientation == CTK_ORIENTATION_HORIZONTAL &&
1172 direction == CTK_TEXT_DIR_RTL)
1173 packing = CTK_PACK_END;
1174 else
1175 packing = CTK_PACK_START;
1176
1177 if (center_pos < side[packing])
1178 center_pos = side[packing];
1179 else if (center_pos + center_size > side[1 - packing])
1180 center_pos = side[1 - packing] - center_size;
1181
1182 if (priv->orientation == CTK_ORIENTATION_HORIZONTAL)
1183 {
1184 child_allocation.x = center_pos;
1185 child_allocation.width = center_size;
1186 }
1187 else
1188 {
1189 child_allocation.y = center_pos;
1190 child_allocation.height = center_size;
1191 }
1192 ctk_widget_size_allocate_with_baseline (priv->center->widget, &child_allocation, baseline);
1193
1194 _ctk_widget_set_simple_clip (widget, NULL((void*)0));
1195}
1196
1197static void
1198ctk_box_allocate_contents (CtkCssGadget *gadget,
1199 const CtkAllocation *allocation,
1200 int baseline G_GNUC_UNUSED__attribute__ ((__unused__)),
1201 CtkAllocation *out_clip,
1202 gpointer unused G_GNUC_UNUSED__attribute__ ((__unused__)))
1203{
1204 CtkWidget *widget = ctk_css_gadget_get_owner (gadget);
1205 CtkBox *box = CTK_BOX (widget)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_box_get_type ()))))))
;
1206
1207 if (box->priv->center &&
1208 _ctk_widget_get_visible (box->priv->center->widget))
1209 ctk_box_size_allocate_with_center (widget, allocation);
1210 else
1211 ctk_box_size_allocate_no_center (widget, allocation);
1212
1213 ctk_container_get_children_clip (CTK_CONTAINER (box)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_container_get_type ()))))))
, out_clip);
1214}
1215
1216static void
1217ctk_box_size_allocate (CtkWidget *widget,
1218 CtkAllocation *allocation)
1219{
1220 CtkBoxPrivate *priv = CTK_BOX (widget)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_box_get_type ()))))))
->priv;
1221 CtkAllocation clip;
1222
1223 ctk_widget_set_allocation (widget, allocation);
1224
1225 ctk_css_gadget_allocate (priv->gadget,
1226 allocation,
1227 ctk_widget_get_allocated_baseline (widget),
1228 &clip);
1229
1230 ctk_widget_set_clip (widget, &clip);
1231}
1232
1233static GType
1234ctk_box_child_type (CtkContainer *container G_GNUC_UNUSED__attribute__ ((__unused__)))
1235{
1236 return CTK_TYPE_WIDGET(ctk_widget_get_type ());
1237}
1238
1239static void
1240ctk_box_set_child_property (CtkContainer *container,
1241 CtkWidget *child,
1242 guint property_id,
1243 const GValue *value,
1244 GParamSpec *pspec)
1245{
1246 gboolean expand = 0;
1247 gboolean fill = 0;
1248 guint padding = 0;
1249 CtkPackType pack_type = 0;
1250
1251 if (property_id != CHILD_PROP_POSITION)
1252 ctk_box_query_child_packing (CTK_BOX (container)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((container)), ((ctk_box_get_type ()))))))
,
1253 child,
1254 &expand,
1255 &fill,
1256 &padding,
1257 &pack_type);
1258 switch (property_id)
1259 {
1260 case CHILD_PROP_EXPAND:
1261 ctk_box_set_child_packing (CTK_BOX (container)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((container)), ((ctk_box_get_type ()))))))
,
1262 child,
1263 g_value_get_boolean (value),
1264 fill,
1265 padding,
1266 pack_type);
1267 break;
1268 case CHILD_PROP_FILL:
1269 ctk_box_set_child_packing (CTK_BOX (container)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((container)), ((ctk_box_get_type ()))))))
,
1270 child,
1271 expand,
1272 g_value_get_boolean (value),
1273 padding,
1274 pack_type);
1275 break;
1276 case CHILD_PROP_PADDING:
1277 ctk_box_set_child_packing (CTK_BOX (container)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((container)), ((ctk_box_get_type ()))))))
,
1278 child,
1279 expand,
1280 fill,
1281 g_value_get_uint (value),
1282 pack_type);
1283 break;
1284 case CHILD_PROP_PACK_TYPE:
1285 ctk_box_set_child_packing (CTK_BOX (container)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((container)), ((ctk_box_get_type ()))))))
,
1286 child,
1287 expand,
1288 fill,
1289 padding,
1290 g_value_get_enum (value));
1291 break;
1292 case CHILD_PROP_POSITION:
1293 ctk_box_reorder_child (CTK_BOX (container)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((container)), ((ctk_box_get_type ()))))))
,
1294 child,
1295 g_value_get_int (value));
1296 break;
1297 default:
1298 CTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec)do { GObject *_glib__object = (GObject*) ((container)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((property_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "ctkbox.c", 1298, ("child property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
1299 break;
1300 }
1301}
1302
1303static void
1304ctk_box_get_child_property (CtkContainer *container,
1305 CtkWidget *child,
1306 guint property_id,
1307 GValue *value,
1308 GParamSpec *pspec)
1309{
1310 gboolean expand = FALSE(0);
1311 gboolean fill = FALSE(0);
1312 guint padding = 0;
1313 CtkPackType pack_type = 0;
1314 GList *list;
1315
1316 if (property_id != CHILD_PROP_POSITION)
1317 ctk_box_query_child_packing (CTK_BOX (container)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((container)), ((ctk_box_get_type ()))))))
,
1318 child,
1319 &expand,
1320 &fill,
1321 &padding,
1322 &pack_type);
1323 switch (property_id)
1324 {
1325 guint i;
1326 case CHILD_PROP_EXPAND:
1327 g_value_set_boolean (value, expand);
1328 break;
1329 case CHILD_PROP_FILL:
1330 g_value_set_boolean (value, fill);
1331 break;
1332 case CHILD_PROP_PADDING:
1333 g_value_set_uint (value, padding);
1334 break;
1335 case CHILD_PROP_PACK_TYPE:
1336 g_value_set_enum (value, pack_type);
1337 break;
1338 case CHILD_PROP_POSITION:
1339 i = 0;
1340 for (list = CTK_BOX (container)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((container)), ((ctk_box_get_type ()))))))
->priv->children; list; list = list->next)
1341 {
1342 CtkBoxChild *child_entry;
1343
1344 child_entry = list->data;
1345 if (child_entry->widget == child)
1346 break;
1347 i++;
1348 }
1349 g_value_set_int (value, list ? i : -1);
1350 break;
1351 default:
1352 CTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec)do { GObject *_glib__object = (GObject*) ((container)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((property_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "ctkbox.c", 1352, ("child property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
1353 break;
1354 }
1355}
1356
1357typedef struct _CountingData CountingData;
1358struct _CountingData {
1359 CtkWidget *widget;
1360 gboolean found;
1361 guint before;
1362 guint after;
1363};
1364
1365static void
1366count_widget_position (CtkWidget *widget,
1367 gpointer data)
1368{
1369 CountingData *count = data;
1370
1371 if (!_ctk_widget_get_visible (widget))
1372 return;
1373
1374 if (count->widget == widget)
1375 count->found = TRUE(!(0));
1376 else if (count->found)
1377 count->after++;
1378 else
1379 count->before++;
1380}
1381
1382static gint
1383ctk_box_get_visible_position (CtkBox *box,
1384 CtkWidget *child)
1385{
1386 CountingData count = { child, FALSE(0), 0, 0 };
1387
1388 /* foreach iterates in visible order */
1389 ctk_container_foreach (CTK_CONTAINER (box)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_container_get_type ()))))))
,
1390 count_widget_position,
1391 &count);
1392
1393 /* the child wasn't found, it's likely an internal child of some
1394 * subclass, return -1 to indicate that there is no sibling relation
1395 * to the regular box children
1396 */
1397 if (!count.found)
1398 return -1;
1399
1400 if (box->priv->orientation == CTK_ORIENTATION_HORIZONTAL &&
1401 ctk_widget_get_direction (CTK_WIDGET (box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_widget_get_type ()))))))
) == CTK_TEXT_DIR_RTL)
1402 return count.after;
1403 else
1404 return count.before;
1405}
1406
1407static CtkWidgetPath *
1408ctk_box_get_path_for_child (CtkContainer *container,
1409 CtkWidget *child)
1410{
1411 CtkWidgetPath *path, *sibling_path;
1412 CtkBox *box;
1413 CtkBoxPrivate *private;
1414 GList *list, *children;
1415
1416 box = CTK_BOX (container)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((container)), ((ctk_box_get_type ()))))))
;
1417 private = box->priv;
1418
1419 path = _ctk_widget_create_path (CTK_WIDGET (container)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((container)), ((ctk_widget_get_type ()))))))
);
1420
1421 if (_ctk_widget_get_visible (child))
1422 {
1423 gint position;
1424
1425 sibling_path = ctk_widget_path_new ();
1426
1427 /* get_children works in visible order */
1428 children = ctk_container_get_children (container);
1429 if (private->orientation == CTK_ORIENTATION_HORIZONTAL &&
1430 ctk_widget_get_direction (CTK_WIDGET (box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_widget_get_type ()))))))
) == CTK_TEXT_DIR_RTL)
1431 children = g_list_reverse (children);
1432
1433 for (list = children; list; list = list->next)
1434 {
1435 if (!_ctk_widget_get_visible (list->data))
1436 continue;
1437
1438 ctk_widget_path_append_for_widget (sibling_path, list->data);
1439 }
1440
1441 g_list_free (children);
1442
1443 position = ctk_box_get_visible_position (box, child);
1444
1445 if (position >= 0)
1446 ctk_widget_path_append_with_siblings (path, sibling_path, position);
1447 else
1448 ctk_widget_path_append_for_widget (path, child);
1449
1450 ctk_widget_path_unref (sibling_path);
1451 }
1452 else
1453 ctk_widget_path_append_for_widget (path, child);
1454
1455 return path;
1456}
1457
1458static void
1459ctk_box_buildable_add_child (CtkBuildable *buildable,
1460 CtkBuilder *builder G_GNUC_UNUSED__attribute__ ((__unused__)),
1461 GObject *child,
1462 const gchar *type)
1463{
1464 if (type && strcmp (type, "center") == 0)
1465 ctk_box_set_center_widget (CTK_BOX (buildable)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((buildable)), ((ctk_box_get_type ()))))))
, CTK_WIDGET (child)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((child)), ((ctk_widget_get_type ()))))))
);
1466 else if (!type)
1467 ctk_container_add (CTK_CONTAINER (buildable)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((buildable)), ((ctk_container_get_type ()))))))
, CTK_WIDGET (child)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((child)), ((ctk_widget_get_type ()))))))
);
1468 else
1469 CTK_BUILDER_WARN_INVALID_CHILD_TYPE (CTK_BOX (buildable), type)g_warning ("'%s' is not a valid child type of '%s'", type, g_type_name
((((((GTypeClass*) (((GTypeInstance*) (((((CtkBox*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((buildable)), (
(ctk_box_get_type ()))))))))->g_class))->g_type)))))
;
1470}
1471
1472static void
1473ctk_box_buildable_init (CtkBuildableIface *iface)
1474{
1475 iface->add_child = ctk_box_buildable_add_child;
1476}
1477
1478static void
1479ctk_box_update_child_css_position (CtkBox *box,
1480 CtkBoxChild *child_info)
1481{
1482 CtkBoxPrivate *priv = box->priv;
1483 CtkBoxChild *prev;
1484 gboolean reverse;
1485 GList *l;
1486
1487 prev = NULL((void*)0);
1488 for (l = priv->children; l->data != child_info; l = l->next)
1489 {
1490 CtkBoxChild *cur = l->data;
1491
1492 if (cur->pack == child_info->pack)
1493 prev = cur;
1494 }
1495
1496 reverse = child_info->pack == CTK_PACK_END;
1497 if (box->priv->orientation == CTK_ORIENTATION_HORIZONTAL &&
1498 ctk_widget_get_direction (CTK_WIDGET (box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_widget_get_type ()))))))
) == CTK_TEXT_DIR_RTL)
1499 reverse = !reverse;
1500
1501 if (reverse)
1502 ctk_css_node_insert_before (ctk_widget_get_css_node (CTK_WIDGET (box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_widget_get_type ()))))))
),
1503 ctk_widget_get_css_node (child_info->widget),
1504 prev ? ctk_widget_get_css_node (prev->widget) : NULL((void*)0));
1505 else
1506 ctk_css_node_insert_after (ctk_widget_get_css_node (CTK_WIDGET (box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_widget_get_type ()))))))
),
1507 ctk_widget_get_css_node (child_info->widget),
1508 prev ? ctk_widget_get_css_node (prev->widget) : NULL((void*)0));
1509}
1510
1511static void
1512ctk_box_direction_changed (CtkWidget *widget,
1513 CtkTextDirection previous_direction G_GNUC_UNUSED__attribute__ ((__unused__)))
1514{
1515 CtkBox *box = CTK_BOX (widget)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_box_get_type ()))))))
;
1516
1517 if (box->priv->orientation == CTK_ORIENTATION_HORIZONTAL)
1518 ctk_css_node_reverse_children (ctk_widget_get_css_node (widget));
1519}
1520
1521static CtkBoxChild *
1522ctk_box_pack (CtkBox *box,
1523 CtkWidget *child,
1524 gboolean expand,
1525 gboolean fill,
1526 guint padding,
1527 CtkPackType pack_type)
1528{
1529 CtkContainer *container = CTK_CONTAINER (box)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_container_get_type ()))))))
;
1530 CtkBoxPrivate *private = box->priv;
1531 CtkBoxChild *child_info;
1532
1533 g_return_val_if_fail (CTK_IS_BOX (box), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((box)); GType __t = ((ctk_box_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; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_BOX (box)"); return (((void*)0)); } } while (0)
;
1534 g_return_val_if_fail (CTK_IS_WIDGET (child), NULL)do { if (((((__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; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (child)"); return (((void*)0)); } } while (
0)
;
1535 g_return_val_if_fail (_ctk_widget_get_parent (child) == NULL, NULL)do { if ((_ctk_widget_get_parent (child) == ((void*)0))) { } else
{ g_return_if_fail_warning ("Ctk", ((const char*) (__func__)
), "_ctk_widget_get_parent (child) == NULL"); return (((void*
)0)); } } while (0)
;
1536
1537 child_info = g_new (CtkBoxChild, 1)((CtkBoxChild *) g_malloc_n ((1), sizeof (CtkBoxChild)));
1538 child_info->widget = child;
1539 child_info->padding = padding;
1540 child_info->expand = expand ? TRUE(!(0)) : FALSE(0);
1541 child_info->fill = fill ? TRUE(!(0)) : FALSE(0);
1542 child_info->pack = pack_type;
1543
1544 private->children = g_list_append (private->children, child_info);
1545 ctk_box_update_child_css_position (box, child_info);
1546
1547 ctk_widget_freeze_child_notify (child);
1548
1549 ctk_widget_set_parent (child, CTK_WIDGET (box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_widget_get_type ()))))))
);
1550
1551 if (expand)
1552 ctk_container_child_notify_by_pspec (container, child, child_props[CHILD_PROP_EXPAND]);
1553 if (!fill)
1554 ctk_container_child_notify_by_pspec (container, child, child_props[CHILD_PROP_FILL]);
1555 if (padding != 0)
1556 ctk_container_child_notify_by_pspec (container, child, child_props[CHILD_PROP_PADDING]);
1557 if (pack_type != CTK_PACK_START)
1558 ctk_container_child_notify_by_pspec (container, child, child_props[CHILD_PROP_PACK_TYPE]);
1559 ctk_container_child_notify_by_pspec (container, child, child_props[CHILD_PROP_POSITION]);
1560
1561 ctk_widget_thaw_child_notify (child);
1562
1563 return child_info;
1564}
1565
1566static void
1567ctk_box_get_size (CtkWidget *widget,
1568 CtkOrientation orientation,
1569 gint *minimum_size,
1570 gint *natural_size,
1571 gint *minimum_baseline,
1572 gint *natural_baseline)
1573{
1574 CtkBox *box;
1575 CtkBoxPrivate *private;
1576 GList *children;
1577 gint nvis_children;
1578 gint minimum, natural;
1579 gint minimum_above, natural_above;
1580 gint minimum_below, natural_below;
1581 gboolean have_baseline;
1582 gint min_baseline, nat_baseline;
1583 gint center_min, center_nat;
1584
1585 box = CTK_BOX (widget)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_box_get_type ()))))))
;
1586 private = box->priv;
1587
1588 have_baseline = FALSE(0);
1589 minimum = natural = 0;
1590 minimum_above = natural_above = 0;
1591 minimum_below = natural_below = 0;
1592 min_baseline = nat_baseline = -1;
1593
1594 nvis_children = 0;
1595
1596 center_min = center_nat = 0;
1597
1598 for (children = private->children; children; children = children->next)
1599 {
1600 CtkBoxChild *child = children->data;
1601
1602 if (_ctk_widget_get_visible (child->widget))
1603 {
1604 gint child_minimum, child_natural;
1605 gint child_minimum_baseline = -1, child_natural_baseline = -1;
1606
1607 if (orientation == CTK_ORIENTATION_HORIZONTAL)
1608 ctk_widget_get_preferred_width (child->widget,
1609 &child_minimum, &child_natural);
1610 else
1611 ctk_widget_get_preferred_height_and_baseline_for_width (child->widget, -1,
1612 &child_minimum, &child_natural,
1613 &child_minimum_baseline, &child_natural_baseline);
1614
1615 if (private->orientation == orientation)
1616 {
1617 if (private->homogeneous)
1618 {
1619 if (child == private->center)
1620 {
1621 center_min = child_minimum + child->padding * 2;
1622 center_nat = child_natural + child->padding * 2;
1623 }
1624 else
1625 {
1626 gint largest;
1627
1628 largest = child_minimum + child->padding * 2;
1629 minimum = MAX (minimum, largest)(((minimum) > (largest)) ? (minimum) : (largest));
1630
1631 largest = child_natural + child->padding * 2;
1632 natural = MAX (natural, largest)(((natural) > (largest)) ? (natural) : (largest));
1633 }
1634 }
1635 else
1636 {
1637 minimum += child_minimum + child->padding * 2;
1638 natural += child_natural + child->padding * 2;
1639 }
1640 }
1641 else
1642 {
1643 if (child_minimum_baseline >= 0)
1644 {
1645 have_baseline = TRUE(!(0));
1646 minimum_below = MAX (minimum_below, child_minimum - child_minimum_baseline)(((minimum_below) > (child_minimum - child_minimum_baseline
)) ? (minimum_below) : (child_minimum - child_minimum_baseline
))
;
1647 natural_below = MAX (natural_below, child_natural - child_natural_baseline)(((natural_below) > (child_natural - child_natural_baseline
)) ? (natural_below) : (child_natural - child_natural_baseline
))
;
1648 minimum_above = MAX (minimum_above, child_minimum_baseline)(((minimum_above) > (child_minimum_baseline)) ? (minimum_above
) : (child_minimum_baseline))
;
1649 natural_above = MAX (natural_above, child_natural_baseline)(((natural_above) > (child_natural_baseline)) ? (natural_above
) : (child_natural_baseline))
;
1650 }
1651 else
1652 {
1653 /* The biggest mins and naturals in the opposing orientation */
1654 minimum = MAX (minimum, child_minimum)(((minimum) > (child_minimum)) ? (minimum) : (child_minimum
))
;
1655 natural = MAX (natural, child_natural)(((natural) > (child_natural)) ? (natural) : (child_natural
))
;
1656 }
1657 }
1658
1659 nvis_children += 1;
1660 }
1661 }
1662
1663 if (nvis_children > 0 && private->orientation == orientation)
1664 {
1665 if (private->homogeneous)
1666 {
1667 if (center_min > 0)
1668 {
1669 minimum = minimum * (nvis_children - 1) + center_min;
1670 natural = natural * (nvis_children - 1) + center_nat;
1671 }
1672 else
1673 {
1674 minimum *= nvis_children;
1675 natural *= nvis_children;
1676 }
1677 }
1678 minimum += (nvis_children - 1) * private->spacing;
1679 natural += (nvis_children - 1) * private->spacing;
1680 }
1681
1682 minimum = MAX (minimum, minimum_below + minimum_above)(((minimum) > (minimum_below + minimum_above)) ? (minimum)
: (minimum_below + minimum_above))
;
1683 natural = MAX (natural, natural_below + natural_above)(((natural) > (natural_below + natural_above)) ? (natural)
: (natural_below + natural_above))
;
1684
1685 if (have_baseline)
1686 {
1687 switch (private->baseline_pos)
1688 {
1689 case CTK_BASELINE_POSITION_TOP:
1690 min_baseline = minimum_above;
1691 nat_baseline = natural_above;
1692 break;
1693 case CTK_BASELINE_POSITION_CENTER:
1694 min_baseline = minimum_above + (minimum - (minimum_above + minimum_below)) / 2;
1695 nat_baseline = natural_above + (natural - (natural_above + natural_below)) / 2;
1696 break;
1697 case CTK_BASELINE_POSITION_BOTTOM:
1698 min_baseline = minimum - minimum_below;
1699 nat_baseline = natural - natural_below;
1700 break;
1701 }
1702 }
1703
1704 if (minimum_size)
1705 *minimum_size = minimum;
1706
1707 if (natural_size)
1708 *natural_size = natural;
1709
1710 if (minimum_baseline)
1711 *minimum_baseline = min_baseline;
1712
1713 if (natural_baseline)
1714 *natural_baseline = nat_baseline;
1715}
1716
1717static void
1718ctk_box_get_preferred_width (CtkWidget *widget,
1719 gint *minimum,
1720 gint *natural)
1721{
1722 ctk_css_gadget_get_preferred_size (CTK_BOX (widget)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_box_get_type ()))))))
->priv->gadget,
1723 CTK_ORIENTATION_HORIZONTAL,
1724 -1,
1725 minimum, natural,
1726 NULL((void*)0), NULL((void*)0));
1727}
1728
1729static void
1730ctk_box_get_preferred_height (CtkWidget *widget,
1731 gint *minimum,
1732 gint *natural)
1733{
1734 ctk_css_gadget_get_preferred_size (CTK_BOX (widget)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_box_get_type ()))))))
->priv->gadget,
1735 CTK_ORIENTATION_VERTICAL,
1736 -1,
1737 minimum, natural,
1738 NULL((void*)0), NULL((void*)0));
1739}
1740
1741static void
1742ctk_box_compute_size_for_opposing_orientation (CtkBox *box,
1743 gint avail_size,
1744 gint *minimum_size,
1745 gint *natural_size,
1746 gint *minimum_baseline,
1747 gint *natural_baseline)
1748{
1749 CtkBoxPrivate *private = box->priv;
1750 CtkBoxChild *child;
1751 GList *children;
1752 gint nvis_children;
1753 gint nexpand_children;
1754 gint computed_minimum = 0, computed_natural = 0;
1755 gint computed_minimum_above = 0, computed_natural_above = 0;
1756 gint computed_minimum_below = 0, computed_natural_below = 0;
1757 gint computed_minimum_baseline = -1, computed_natural_baseline = -1;
1758 CtkRequestedSize *sizes;
1759 CtkPackType packing;
1760 gint size, extra, i;
1761 gint child_size, child_minimum, child_natural;
1762 gint child_minimum_baseline, child_natural_baseline;
1763 gint n_extra_widgets = 0;
1764 gboolean have_baseline;
1765
1766 count_expand_children (box, &nvis_children, &nexpand_children);
1767
1768 if (nvis_children <= 0)
1769 return;
1770
1771 sizes = g_newa (CtkRequestedSize, nvis_children)((CtkRequestedSize*) __builtin_alloca (sizeof (CtkRequestedSize
) * (gsize) (nvis_children)))
;
1772 memset (sizes, 0, nvis_children * sizeof (CtkRequestedSize));
1773 size = avail_size - (nvis_children - 1) * private->spacing;
1774
1775 /* Retrieve desired size for visible children */
1776 for (i = 0, children = private->children; children; children = children->next)
1777 {
1778 child = children->data;
1779
1780 if (_ctk_widget_get_visible (child->widget))
1781 {
1782 if (private->orientation == CTK_ORIENTATION_HORIZONTAL)
1783 ctk_widget_get_preferred_width (child->widget,
1784 &sizes[i].minimum_size,
1785 &sizes[i].natural_size);
1786 else
1787 ctk_widget_get_preferred_height (child->widget,
1788 &sizes[i].minimum_size,
1789 &sizes[i].natural_size);
1790
1791 /* Assert the api is working properly */
1792 if (sizes[i].minimum_size < 0)
1793 g_error ("CtkBox child %s minimum %s: %d < 0",
1794 ctk_widget_get_name (CTK_WIDGET (child->widget)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((child->widget)), ((ctk_widget_get_type ()))))))
),
1795 (private->orientation == CTK_ORIENTATION_HORIZONTAL) ? "width" : "height",
1796 sizes[i].minimum_size);
1797
1798 if (sizes[i].natural_size < sizes[i].minimum_size)
1799 g_error ("CtkBox child %s natural %s: %d < minimum %d",
1800 ctk_widget_get_name (CTK_WIDGET (child->widget)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((child->widget)), ((ctk_widget_get_type ()))))))
),
1801 (private->orientation == CTK_ORIENTATION_HORIZONTAL) ? "width" : "height",
1802 sizes[i].natural_size,
1803 sizes[i].minimum_size);
1804
1805 size -= sizes[i].minimum_size;
1806 size -= child->padding * 2;
1807
1808 sizes[i].data = child;
1809
1810 i += 1;
1811 }
1812 }
1813
1814 if (private->homogeneous)
1815 {
1816 /* If were homogenous we still need to run the above loop to get the
1817 * minimum sizes for children that are not going to fill
1818 */
1819 size = avail_size - (nvis_children - 1) * private->spacing;
1820 extra = size / nvis_children;
1821 n_extra_widgets = size % nvis_children;
1822 }
1823 else
1824 {
1825 /* Bring children up to size first */
1826 size = ctk_distribute_natural_allocation (MAX (0, size)(((0) > (size)) ? (0) : (size)), nvis_children, sizes);
1827
1828 /* Calculate space which hasn't distributed yet,
1829 * and is available for expanding children.
1830 */
1831 if (nexpand_children > 0)
1832 {
1833 extra = size / nexpand_children;
1834 n_extra_widgets = size % nexpand_children;
1835 }
1836 else
1837 extra = 0;
1838 }
1839
1840 have_baseline = FALSE(0);
1841 /* Allocate child positions. */
1842 for (packing = CTK_PACK_START; packing <= CTK_PACK_END; ++packing)
1843 {
1844 for (i = 0, children = private->children;
1845 children;
1846 children = children->next)
1847 {
1848 child = children->data;
1849
1850 /* If widget is not visible, skip it. */
1851 if (!_ctk_widget_get_visible (child->widget))
1852 continue;
1853
1854 /* If widget is packed differently skip it, but still increment i,
1855 * since widget is visible and will be handled in next loop iteration.
1856 */
1857 if (child->pack != packing)
1858 {
1859 i++;
1860 continue;
1861 }
1862
1863 if (child->pack == packing)
1864 {
1865 /* Assign the child's size. */
1866 if (private->homogeneous)
1867 {
1868 child_size = extra;
1869
1870 if (n_extra_widgets > 0)
1871 {
1872 child_size++;
1873 n_extra_widgets--;
1874 }
1875 }
1876 else
1877 {
1878 child_size = sizes[i].minimum_size + child->padding * 2;
1879
1880 if (child->expand || ctk_widget_compute_expand (child->widget, private->orientation))
1881 {
1882 child_size += extra;
1883
1884 if (n_extra_widgets > 0)
1885 {
1886 child_size++;
1887 n_extra_widgets--;
1888 }
1889 }
1890 }
1891
1892 if (child->fill)
1893 {
1894 child_size = MAX (1, child_size - child->padding * 2)(((1) > (child_size - child->padding * 2)) ? (1) : (child_size
- child->padding * 2))
;
1895 }
1896 else
1897 {
1898 child_size = sizes[i].minimum_size;
1899 }
1900
1901
1902 child_minimum_baseline = child_natural_baseline = -1;
1903 /* Assign the child's position. */
1904 if (private->orientation == CTK_ORIENTATION_HORIZONTAL)
1905 ctk_widget_get_preferred_height_and_baseline_for_width (child->widget, child_size,
1906 &child_minimum, &child_natural,
1907 &child_minimum_baseline, &child_natural_baseline);
1908 else /* (private->orientation == CTK_ORIENTATION_VERTICAL) */
1909 ctk_widget_get_preferred_width_for_height (child->widget,
1910 child_size, &child_minimum, &child_natural);
1911
1912 if (child_minimum_baseline >= 0)
1913 {
1914 have_baseline = TRUE(!(0));
1915 computed_minimum_below = MAX (computed_minimum_below, child_minimum - child_minimum_baseline)(((computed_minimum_below) > (child_minimum - child_minimum_baseline
)) ? (computed_minimum_below) : (child_minimum - child_minimum_baseline
))
;
1916 computed_natural_below = MAX (computed_natural_below, child_natural - child_natural_baseline)(((computed_natural_below) > (child_natural - child_natural_baseline
)) ? (computed_natural_below) : (child_natural - child_natural_baseline
))
;
1917 computed_minimum_above = MAX (computed_minimum_above, child_minimum_baseline)(((computed_minimum_above) > (child_minimum_baseline)) ? (
computed_minimum_above) : (child_minimum_baseline))
;
1918 computed_natural_above = MAX (computed_natural_above, child_natural_baseline)(((computed_natural_above) > (child_natural_baseline)) ? (
computed_natural_above) : (child_natural_baseline))
;
1919 }
1920 else
1921 {
1922 computed_minimum = MAX (computed_minimum, child_minimum)(((computed_minimum) > (child_minimum)) ? (computed_minimum
) : (child_minimum))
;
1923 computed_natural = MAX (computed_natural, child_natural)(((computed_natural) > (child_natural)) ? (computed_natural
) : (child_natural))
;
1924 }
1925 }
1926 i += 1;
1927 }
1928 }
1929
1930 if (have_baseline)
1931 {
1932 computed_minimum = MAX (computed_minimum, computed_minimum_below + computed_minimum_above)(((computed_minimum) > (computed_minimum_below + computed_minimum_above
)) ? (computed_minimum) : (computed_minimum_below + computed_minimum_above
))
;
1933 computed_natural = MAX (computed_natural, computed_natural_below + computed_natural_above)(((computed_natural) > (computed_natural_below + computed_natural_above
)) ? (computed_natural) : (computed_natural_below + computed_natural_above
))
;
1934 switch (private->baseline_pos)
1935 {
1936 case CTK_BASELINE_POSITION_TOP:
1937 computed_minimum_baseline = computed_minimum_above;
1938 computed_natural_baseline = computed_natural_above;
1939 break;
1940 case CTK_BASELINE_POSITION_CENTER:
1941 computed_minimum_baseline = computed_minimum_above + MAX((computed_minimum - (computed_minimum_above + computed_minimum_below)) / 2, 0)((((computed_minimum - (computed_minimum_above + computed_minimum_below
)) / 2) > (0)) ? ((computed_minimum - (computed_minimum_above
+ computed_minimum_below)) / 2) : (0))
;
1942 computed_natural_baseline = computed_natural_above + MAX((computed_natural - (computed_natural_above + computed_natural_below)) / 2, 0)((((computed_natural - (computed_natural_above + computed_natural_below
)) / 2) > (0)) ? ((computed_natural - (computed_natural_above
+ computed_natural_below)) / 2) : (0))
;
1943 break;
1944 case CTK_BASELINE_POSITION_BOTTOM:
1945 computed_minimum_baseline = computed_minimum - computed_minimum_below;
1946 computed_natural_baseline = computed_natural - computed_natural_below;
1947 break;
1948 }
1949 }
1950
1951 if (minimum_baseline)
1952 *minimum_baseline = computed_minimum_baseline;
1953 if (natural_baseline)
1954 *natural_baseline = computed_natural_baseline;
1955
1956 if (minimum_size)
1957 *minimum_size = computed_minimum;
1958 if (natural_size)
1959 *natural_size = MAX (computed_natural, computed_natural_below + computed_natural_above)(((computed_natural) > (computed_natural_below + computed_natural_above
)) ? (computed_natural) : (computed_natural_below + computed_natural_above
))
;
1960}
1961
1962static void
1963ctk_box_compute_size_for_orientation (CtkBox *box,
1964 gint avail_size,
1965 gint *minimum_size,
1966 gint *natural_size)
1967{
1968 CtkBoxPrivate *private = box->priv;
1969 GList *children;
1970 gint nvis_children = 0;
1971 gint required_size = 0, required_natural = 0, child_size, child_natural;
1972 gint largest_child = 0, largest_natural = 0;
1973
1974 for (children = private->children; children != NULL((void*)0);
1975 children = children->next)
1976 {
1977 CtkBoxChild *child = children->data;
1978
1979 if (_ctk_widget_get_visible (child->widget))
1980 {
1981
1982 if (private->orientation == CTK_ORIENTATION_HORIZONTAL)
1983 ctk_widget_get_preferred_width_for_height (child->widget,
1984 avail_size, &child_size, &child_natural);
1985 else
1986 ctk_widget_get_preferred_height_for_width (child->widget,
1987 avail_size, &child_size, &child_natural);
1988
1989
1990 child_size += child->padding * 2;
1991 child_natural += child->padding * 2;
1992
1993 if (child_size > largest_child)
1994 largest_child = child_size;
1995
1996 if (child_natural > largest_natural)
1997 largest_natural = child_natural;
1998
1999 required_size += child_size;
2000 required_natural += child_natural;
2001
2002 nvis_children += 1;
2003 }
2004 }
2005
2006 if (nvis_children > 0)
2007 {
2008 if (private->homogeneous)
2009 {
2010 required_size = largest_child * nvis_children;
2011 required_natural = largest_natural * nvis_children;
2012 }
2013
2014 required_size += (nvis_children - 1) * private->spacing;
2015 required_natural += (nvis_children - 1) * private->spacing;
2016 }
2017
2018 if (minimum_size)
2019 *minimum_size = required_size;
2020
2021 if (natural_size)
2022 *natural_size = required_natural;
2023}
2024
2025static void
2026ctk_box_get_preferred_width_for_height (CtkWidget *widget,
2027 gint height,
2028 gint *minimum,
2029 gint *natural)
2030{
2031 ctk_css_gadget_get_preferred_size (CTK_BOX (widget)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_box_get_type ()))))))
->priv->gadget,
2032 CTK_ORIENTATION_HORIZONTAL,
2033 height,
2034 minimum, natural,
2035 NULL((void*)0), NULL((void*)0));
2036}
2037
2038static void
2039ctk_box_get_preferred_height_and_baseline_for_width (CtkWidget *widget,
2040 gint width,
2041 gint *minimum,
2042 gint *natural,
2043 gint *minimum_baseline,
2044 gint *natural_baseline)
2045{
2046 ctk_css_gadget_get_preferred_size (CTK_BOX (widget)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_box_get_type ()))))))
->priv->gadget,
2047 CTK_ORIENTATION_VERTICAL,
2048 width,
2049 minimum, natural,
2050 minimum_baseline, natural_baseline);
2051}
2052
2053static void
2054ctk_box_get_content_size (CtkCssGadget *gadget,
2055 CtkOrientation orientation,
2056 gint for_size,
2057 gint *minimum,
2058 gint *natural,
2059 gint *minimum_baseline,
2060 gint *natural_baseline,
2061 gpointer unused G_GNUC_UNUSED__attribute__ ((__unused__)))
2062{
2063 CtkWidget *widget = ctk_css_gadget_get_owner (gadget);
2064 CtkBox *box = CTK_BOX (widget)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_box_get_type ()))))))
;
2065 CtkBoxPrivate *private = box->priv;
2066
2067 if (for_size < 0)
2068 ctk_box_get_size (widget, orientation, minimum, natural, minimum_baseline, natural_baseline);
2069 else
2070 {
2071 if (private->orientation != orientation)
2072 ctk_box_compute_size_for_opposing_orientation (box, for_size, minimum, natural, minimum_baseline, natural_baseline);
2073 else
2074 {
2075 if (minimum_baseline)
2076 *minimum_baseline = -1;
2077 if (natural_baseline)
2078 *natural_baseline = -1;
2079 ctk_box_compute_size_for_orientation (box, for_size, minimum, natural);
2080 }
2081 }
2082}
2083
2084static void
2085ctk_box_get_preferred_height_for_width (CtkWidget *widget,
2086 gint width,
2087 gint *minimum_height,
2088 gint *natural_height)
2089{
2090 ctk_box_get_preferred_height_and_baseline_for_width (widget, width, minimum_height, natural_height, NULL((void*)0), NULL((void*)0));
2091}
2092
2093static void
2094ctk_box_init (CtkBox *box)
2095{
2096 CtkBoxPrivate *private;
2097
2098 box->priv = ctk_box_get_instance_private (box);
2099 private = box->priv;
2100
2101 ctk_widget_set_has_window (CTK_WIDGET (box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_widget_get_type ()))))))
, FALSE(0));
2102
2103 private->orientation = CTK_ORIENTATION_HORIZONTAL;
2104 private->children = NULL((void*)0);
2105
2106 private->default_expand = FALSE(0);
2107 private->homogeneous = FALSE(0);
2108 private->spacing = 0;
2109 private->spacing_set = FALSE(0);
2110 private->baseline_pos = CTK_BASELINE_POSITION_CENTER;
2111
2112 private->gadget = ctk_css_custom_gadget_new_for_node (ctk_widget_get_css_node (CTK_WIDGET (box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_widget_get_type ()))))))
),
2113 CTK_WIDGET (box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_widget_get_type ()))))))
,
2114 ctk_box_get_content_size,
2115 ctk_box_allocate_contents,
2116 ctk_box_draw_contents,
2117 NULL((void*)0),
2118 NULL((void*)0));
2119
2120 _ctk_orientable_set_style_classes (CTK_ORIENTABLE (box)((((CtkOrientable*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_orientable_get_type ()))))))
);
2121}
2122
2123CtkCssGadget *
2124ctk_box_get_gadget (CtkBox *box)
2125{
2126 return box->priv->gadget;
2127}
2128
2129/**
2130 * ctk_box_new:
2131 * @orientation: the box’s orientation.
2132 * @spacing: the number of pixels to place by default between children.
2133 *
2134 * Creates a new #CtkBox.
2135 *
2136 * Returns: a new #CtkBox.
2137 *
2138 * Since: 3.0
2139 **/
2140CtkWidget*
2141ctk_box_new (CtkOrientation orientation,
2142 gint spacing)
2143{
2144 return g_object_new (CTK_TYPE_BOX(ctk_box_get_type ()),
2145 "orientation", orientation,
2146 "spacing", spacing,
2147 NULL((void*)0));
2148}
2149
2150/**
2151 * ctk_box_pack_start:
2152 * @box: a #CtkBox
2153 * @child: the #CtkWidget to be added to @box
2154 * @expand: %TRUE if the new child is to be given extra space allocated
2155 * to @box. The extra space will be divided evenly between all children
2156 * that use this option
2157 * @fill: %TRUE if space given to @child by the @expand option is
2158 * actually allocated to @child, rather than just padding it. This
2159 * parameter has no effect if @expand is set to %FALSE. A child is
2160 * always allocated the full height of a horizontal #CtkBox and the full width
2161 * of a vertical #CtkBox. This option affects the other dimension
2162 * @padding: extra space in pixels to put between this child and its
2163 * neighbors, over and above the global amount specified by
2164 * #CtkBox:spacing property. If @child is a widget at one of the
2165 * reference ends of @box, then @padding pixels are also put between
2166 * @child and the reference edge of @box
2167 *
2168 * Adds @child to @box, packed with reference to the start of @box.
2169 * The @child is packed after any other child packed with reference
2170 * to the start of @box.
2171 */
2172void
2173ctk_box_pack_start (CtkBox *box,
2174 CtkWidget *child,
2175 gboolean expand,
2176 gboolean fill,
2177 guint padding)
2178{
2179 ctk_box_pack (box, child, expand, fill, padding, CTK_PACK_START);
2180}
2181
2182/**
2183 * ctk_box_pack_end:
2184 * @box: a #CtkBox
2185 * @child: the #CtkWidget to be added to @box
2186 * @expand: %TRUE if the new child is to be given extra space allocated
2187 * to @box. The extra space will be divided evenly between all children
2188 * of @box that use this option
2189 * @fill: %TRUE if space given to @child by the @expand option is
2190 * actually allocated to @child, rather than just padding it. This
2191 * parameter has no effect if @expand is set to %FALSE. A child is
2192 * always allocated the full height of a horizontal #CtkBox and the full width
2193 * of a vertical #CtkBox. This option affects the other dimension
2194 * @padding: extra space in pixels to put between this child and its
2195 * neighbors, over and above the global amount specified by
2196 * #CtkBox:spacing property. If @child is a widget at one of the
2197 * reference ends of @box, then @padding pixels are also put between
2198 * @child and the reference edge of @box
2199 *
2200 * Adds @child to @box, packed with reference to the end of @box.
2201 * The @child is packed after (away from end of) any other child
2202 * packed with reference to the end of @box.
2203 */
2204void
2205ctk_box_pack_end (CtkBox *box,
2206 CtkWidget *child,
2207 gboolean expand,
2208 gboolean fill,
2209 guint padding)
2210{
2211 ctk_box_pack (box, child, expand, fill, padding, CTK_PACK_END);
2212}
2213
2214/**
2215 * ctk_box_set_homogeneous:
2216 * @box: a #CtkBox
2217 * @homogeneous: a boolean value, %TRUE to create equal allotments,
2218 * %FALSE for variable allotments
2219 *
2220 * Sets the #CtkBox:homogeneous property of @box, controlling
2221 * whether or not all children of @box are given equal space
2222 * in the box.
2223 */
2224void
2225ctk_box_set_homogeneous (CtkBox *box,
2226 gboolean homogeneous)
2227{
2228 CtkBoxPrivate *private;
2229
2230 g_return_if_fail (CTK_IS_BOX (box))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((box)); GType __t = ((ctk_box_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; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_BOX (box)"); return; } } while (0)
;
2231
2232 private = box->priv;
2233
2234 homogeneous = homogeneous != FALSE(0);
2235
2236 if (private->homogeneous != homogeneous)
2237 {
2238 private->homogeneous = homogeneous;
2239 g_object_notify_by_pspec (G_OBJECT (box)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), (((GType) ((20) << (2))))))))
, props[PROP_HOMOGENEOUS]);
2240 ctk_widget_queue_resize (CTK_WIDGET (box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_widget_get_type ()))))))
);
2241 }
2242}
2243
2244/**
2245 * ctk_box_get_homogeneous:
2246 * @box: a #CtkBox
2247 *
2248 * Returns whether the box is homogeneous (all children are the
2249 * same size). See ctk_box_set_homogeneous().
2250 *
2251 * Returns: %TRUE if the box is homogeneous.
2252 **/
2253gboolean
2254ctk_box_get_homogeneous (CtkBox *box)
2255{
2256 g_return_val_if_fail (CTK_IS_BOX (box), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((box)); GType __t = ((ctk_box_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; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_BOX (box)"); return ((0)); } } while (0)
;
2257
2258 return box->priv->homogeneous;
2259}
2260
2261/**
2262 * ctk_box_set_spacing:
2263 * @box: a #CtkBox
2264 * @spacing: the number of pixels to put between children
2265 *
2266 * Sets the #CtkBox:spacing property of @box, which is the
2267 * number of pixels to place between children of @box.
2268 */
2269void
2270ctk_box_set_spacing (CtkBox *box,
2271 gint spacing)
2272{
2273 CtkBoxPrivate *private;
2274
2275 g_return_if_fail (CTK_IS_BOX (box))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((box)); GType __t = ((ctk_box_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; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_BOX (box)"); return; } } while (0)
;
2276
2277 private = box->priv;
2278
2279 if (private->spacing != spacing)
2280 {
2281 private->spacing = spacing;
2282 _ctk_box_set_spacing_set (box, TRUE(!(0)));
2283
2284 g_object_notify_by_pspec (G_OBJECT (box)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), (((GType) ((20) << (2))))))))
, props[PROP_SPACING]);
2285
2286 ctk_widget_queue_resize (CTK_WIDGET (box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_widget_get_type ()))))))
);
2287 }
2288}
2289
2290/**
2291 * ctk_box_get_spacing:
2292 * @box: a #CtkBox
2293 *
2294 * Gets the value set by ctk_box_set_spacing().
2295 *
2296 * Returns: spacing between children
2297 **/
2298gint
2299ctk_box_get_spacing (CtkBox *box)
2300{
2301 g_return_val_if_fail (CTK_IS_BOX (box), 0)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((box)); GType __t = ((ctk_box_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; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_BOX (box)"); return (0); } } while (0)
;
2302
2303 return box->priv->spacing;
2304}
2305
2306/**
2307 * ctk_box_set_baseline_position:
2308 * @box: a #CtkBox
2309 * @position: a #CtkBaselinePosition
2310 *
2311 * Sets the baseline position of a box. This affects
2312 * only horizontal boxes with at least one baseline aligned
2313 * child. If there is more vertical space available than requested,
2314 * and the baseline is not allocated by the parent then
2315 * @position is used to allocate the baseline wrt the
2316 * extra space available.
2317 *
2318 * Since: 3.10
2319 */
2320void
2321ctk_box_set_baseline_position (CtkBox *box,
2322 CtkBaselinePosition position)
2323{
2324 CtkBoxPrivate *private;
2325
2326 g_return_if_fail (CTK_IS_BOX (box))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((box)); GType __t = ((ctk_box_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; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_BOX (box)"); return; } } while (0)
;
2327
2328 private = box->priv;
2329
2330 if (private->baseline_pos != position)
2331 {
2332 private->baseline_pos = position;
2333
2334 g_object_notify_by_pspec (G_OBJECT (box)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), (((GType) ((20) << (2))))))))
, props[PROP_BASELINE_POSITION]);
2335
2336 ctk_widget_queue_resize (CTK_WIDGET (box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_widget_get_type ()))))))
);
2337 }
2338}
2339
2340/**
2341 * ctk_box_get_baseline_position:
2342 * @box: a #CtkBox
2343 *
2344 * Gets the value set by ctk_box_set_baseline_position().
2345 *
2346 * Returns: the baseline position
2347 *
2348 * Since: 3.10
2349 **/
2350CtkBaselinePosition
2351ctk_box_get_baseline_position (CtkBox *box)
2352{
2353 g_return_val_if_fail (CTK_IS_BOX (box), CTK_BASELINE_POSITION_CENTER)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((box)); GType __t = ((ctk_box_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; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_BOX (box)"); return (CTK_BASELINE_POSITION_CENTER
); } } while (0)
;
2354
2355 return box->priv->baseline_pos;
2356}
2357
2358
2359void
2360_ctk_box_set_spacing_set (CtkBox *box,
2361 gboolean spacing_set)
2362{
2363 CtkBoxPrivate *private;
2364
2365 g_return_if_fail (CTK_IS_BOX (box))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((box)); GType __t = ((ctk_box_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; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_BOX (box)"); return; } } while (0)
;
2366
2367 private = box->priv;
2368
2369 private->spacing_set = spacing_set ? TRUE(!(0)) : FALSE(0);
2370}
2371
2372gboolean
2373_ctk_box_get_spacing_set (CtkBox *box)
2374{
2375 CtkBoxPrivate *private;
2376
2377 g_return_val_if_fail (CTK_IS_BOX (box), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((box)); GType __t = ((ctk_box_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; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_BOX (box)"); return ((0)); } } while (0)
;
2378
2379 private = box->priv;
2380
2381 return private->spacing_set;
2382}
2383
2384/**
2385 * ctk_box_reorder_child:
2386 * @box: a #CtkBox
2387 * @child: the #CtkWidget to move
2388 * @position: the new position for @child in the list of children
2389 * of @box, starting from 0. If negative, indicates the end of
2390 * the list
2391 *
2392 * Moves @child to a new @position in the list of @box children.
2393 * The list contains widgets packed #CTK_PACK_START
2394 * as well as widgets packed #CTK_PACK_END, in the order that these
2395 * widgets were added to @box.
2396 *
2397 * A widget’s position in the @box children list determines where
2398 * the widget is packed into @box. A child widget at some position
2399 * in the list will be packed just after all other widgets of the
2400 * same packing type that appear earlier in the list.
2401 */
2402void
2403ctk_box_reorder_child (CtkBox *box,
2404 CtkWidget *child,
2405 gint position)
2406{
2407 CtkBoxPrivate *priv;
2408 GList *old_link;
2409 GList *new_link;
2410 CtkBoxChild *child_info = NULL((void*)0);
2411 gint old_position;
2412
2413 g_return_if_fail (CTK_IS_BOX (box))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((box)); GType __t = ((ctk_box_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; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_BOX (box)"); return; } } while (0)
;
2414 g_return_if_fail (CTK_IS_WIDGET (child))do { if (((((__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; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (child)"); return; } } while (0)
;
2415
2416 priv = box->priv;
2417
2418 old_link = priv->children;
2419 old_position = 0;
2420 while (old_link)
2421 {
2422 child_info = old_link->data;
2423 if (child_info->widget == child)
2424 break;
2425
2426 old_link = old_link->next;
2427 old_position++;
2428 }
2429
2430 g_return_if_fail (old_link != NULL)do { if ((old_link != ((void*)0))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "old_link != NULL"); return
; } } while (0)
;
2431
2432 if (position == old_position)
2433 return;
2434
2435 priv->children = g_list_delete_link (priv->children, old_link);
2436
2437 if (position < 0)
2438 new_link = NULL((void*)0);
2439 else
2440 new_link = g_list_nth (priv->children, position);
2441
2442 priv->children = g_list_insert_before (priv->children, new_link, child_info);
2443 ctk_box_update_child_css_position (box, child_info);
2444
2445 ctk_container_child_notify_by_pspec (CTK_CONTAINER (box)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_container_get_type ()))))))
, child, child_props[CHILD_PROP_POSITION]);
2446 if (_ctk_widget_get_visible (child) &&
2447 _ctk_widget_get_visible (CTK_WIDGET (box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_widget_get_type ()))))))
))
2448 {
2449 ctk_widget_queue_resize (child);
2450 }
2451}
2452
2453/**
2454 * ctk_box_query_child_packing:
2455 * @box: a #CtkBox
2456 * @child: the #CtkWidget of the child to query
2457 * @expand: (out): pointer to return location for expand child
2458 * property
2459 * @fill: (out): pointer to return location for fill child
2460 * property
2461 * @padding: (out): pointer to return location for padding
2462 * child property
2463 * @pack_type: (out): pointer to return location for pack-type
2464 * child property
2465 *
2466 * Obtains information about how @child is packed into @box.
2467 */
2468void
2469ctk_box_query_child_packing (CtkBox *box,
2470 CtkWidget *child,
2471 gboolean *expand,
2472 gboolean *fill,
2473 guint *padding,
2474 CtkPackType *pack_type)
2475{
2476 CtkBoxPrivate *private;
2477 GList *list;
2478 CtkBoxChild *child_info = NULL((void*)0);
2479
2480 g_return_if_fail (CTK_IS_BOX (box))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((box)); GType __t = ((ctk_box_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; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_BOX (box)"); return; } } while (0)
;
2481 g_return_if_fail (CTK_IS_WIDGET (child))do { if (((((__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; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (child)"); return; } } while (0)
;
2482
2483 private = box->priv;
2484
2485 list = private->children;
2486 while (list)
2487 {
2488 child_info = list->data;
2489 if (child_info->widget == child)
2490 break;
2491
2492 list = list->next;
2493 }
2494
2495 if (list)
2496 {
2497 if (expand)
2498 *expand = child_info->expand;
2499 if (fill)
2500 *fill = child_info->fill;
2501 if (padding)
2502 *padding = child_info->padding;
2503 if (pack_type)
2504 *pack_type = child_info->pack;
2505 }
2506}
2507
2508/**
2509 * ctk_box_set_child_packing:
2510 * @box: a #CtkBox
2511 * @child: the #CtkWidget of the child to set
2512 * @expand: the new value of the expand child property
2513 * @fill: the new value of the fill child property
2514 * @padding: the new value of the padding child property
2515 * @pack_type: the new value of the pack-type child property
2516 *
2517 * Sets the way @child is packed into @box.
2518 */
2519void
2520ctk_box_set_child_packing (CtkBox *box,
2521 CtkWidget *child,
2522 gboolean expand,
2523 gboolean fill,
2524 guint padding,
2525 CtkPackType pack_type)
2526{
2527 CtkBoxPrivate *private;
2528 GList *list;
2529 CtkBoxChild *child_info = NULL((void*)0);
2530
2531 g_return_if_fail (CTK_IS_BOX (box))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((box)); GType __t = ((ctk_box_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; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_BOX (box)"); return; } } while (0)
;
2532 g_return_if_fail (CTK_IS_WIDGET (child))do { if (((((__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; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_WIDGET (child)"); return; } } while (0)
;
2533
2534 private = box->priv;
2535
2536 list = private->children;
2537 while (list)
2538 {
2539 child_info = list->data;
2540 if (child_info->widget == child)
2541 break;
2542
2543 list = list->next;
2544 }
2545
2546 ctk_widget_freeze_child_notify (child);
2547 if (list)
2548 {
2549 expand = expand != FALSE(0);
2550
2551 if (child_info->expand != expand)
2552 {
2553 child_info->expand = expand;
2554 ctk_container_child_notify_by_pspec (CTK_CONTAINER (box)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_container_get_type ()))))))
, child, child_props[CHILD_PROP_EXPAND]);
2555 }
2556
2557 fill = fill != FALSE(0);
2558
2559 if (child_info->fill != fill)
2560 {
2561 child_info->fill = fill;
2562 ctk_container_child_notify_by_pspec (CTK_CONTAINER (box)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_container_get_type ()))))))
, child, child_props[CHILD_PROP_FILL]);
2563 }
2564
2565 if (child_info->padding != padding)
2566 {
2567 child_info->padding = padding;
2568 ctk_container_child_notify_by_pspec (CTK_CONTAINER (box)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_container_get_type ()))))))
, child, child_props[CHILD_PROP_PADDING]);
2569 }
2570
2571 if (pack_type != CTK_PACK_END)
2572 pack_type = CTK_PACK_START;
2573 if (child_info->pack != pack_type)
2574 {
2575 child_info->pack = pack_type;
2576 ctk_box_update_child_css_position (box, child_info);
2577 ctk_container_child_notify_by_pspec (CTK_CONTAINER (box)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_container_get_type ()))))))
, child, child_props[CHILD_PROP_PACK_TYPE]);
2578 }
2579
2580 if (_ctk_widget_get_visible (child) &&
2581 _ctk_widget_get_visible (CTK_WIDGET (box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_widget_get_type ()))))))
))
2582 ctk_widget_queue_resize (child);
2583 }
2584 ctk_widget_thaw_child_notify (child);
2585}
2586
2587void
2588_ctk_box_set_old_defaults (CtkBox *box)
2589{
2590 CtkBoxPrivate *private;
2591
2592 g_return_if_fail (CTK_IS_BOX (box))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((box)); GType __t = ((ctk_box_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; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_BOX (box)"); return; } } while (0)
;
2593
2594 private = box->priv;
2595
2596 private->default_expand = TRUE(!(0));
2597}
2598
2599static void
2600ctk_box_add (CtkContainer *container,
2601 CtkWidget *widget)
2602{
2603 CtkBoxPrivate *priv = CTK_BOX (container)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((container)), ((ctk_box_get_type ()))))))
->priv;
2604
2605 ctk_box_pack_start (CTK_BOX (container)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((container)), ((ctk_box_get_type ()))))))
, widget,
2606 priv->default_expand,
2607 TRUE(!(0)),
2608 0);
2609}
2610
2611static void
2612ctk_box_remove (CtkContainer *container,
2613 CtkWidget *widget)
2614{
2615 CtkBox *box = CTK_BOX (container)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((container)), ((ctk_box_get_type ()))))))
;
2616 CtkBoxPrivate *priv = box->priv;
2617 CtkBoxChild *child;
2618 GList *children;
2619
2620 children = priv->children;
2621 while (children)
2622 {
2623 child = children->data;
2624
2625 if (child->widget == widget)
2626 {
2627 gboolean was_visible;
2628
2629 if (priv->center == child)
2630 priv->center = NULL((void*)0);
2631
2632 was_visible = _ctk_widget_get_visible (widget);
2633 ctk_widget_unparent (widget);
2634
2635 priv->children = g_list_remove_link (priv->children, children);
2636 g_list_free (children);
2637 g_free (child);
2638
2639 /* queue resize regardless of ctk_widget_get_visible (container),
2640 * since that's what is needed by toplevels.
2641 */
2642 if (was_visible)
2643 {
2644 ctk_widget_queue_resize (CTK_WIDGET (container)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((container)), ((ctk_widget_get_type ()))))))
);
2645 }
2646
2647 break;
2648 }
2649
2650 children = children->next;
2651 }
2652}
2653
2654static void
2655ctk_box_forall (CtkContainer *container,
2656 gboolean include_internals G_GNUC_UNUSED__attribute__ ((__unused__)),
2657 CtkCallback callback,
2658 gpointer callback_data)
2659{
2660 CtkBox *box = CTK_BOX (container)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((container)), ((ctk_box_get_type ()))))))
;
2661 CtkBoxPrivate *priv = box->priv;
2662 CtkBoxChild *child;
2663 GList *children;
2664
2665 children = priv->children;
2666 while (children)
2667 {
2668 child = children->data;
2669 children = children->next;
2670
2671 if (child == priv->center)
2672 continue;
2673
2674 if (child->pack == CTK_PACK_START)
2675 (* callback) (child->widget, callback_data);
2676 }
2677
2678 if (priv->center)
2679 (* callback) (priv->center->widget, callback_data);
2680
2681 children = g_list_last (priv->children);
2682 while (children)
2683 {
2684 child = children->data;
2685 children = children->prev;
2686
2687 if (child == priv->center)
2688 continue;
2689
2690 if (child->pack == CTK_PACK_END)
2691 (* callback) (child->widget, callback_data);
2692 }
2693}
2694
2695GList *
2696_ctk_box_get_children (CtkBox *box)
2697{
2698 CtkBoxPrivate *priv;
2699 CtkBoxChild *child;
2700 GList *children;
2701 GList *retval = NULL((void*)0);
2702
2703 g_return_val_if_fail (CTK_IS_BOX (box), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((box)); GType __t = ((ctk_box_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; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_BOX (box)"); return (((void*)0)); } } while (0)
;
2704
2705 priv = box->priv;
2706
2707 children = priv->children;
2708 while (children)
2709 {
2710 child = children->data;
2711 children = children->next;
2712
2713 retval = g_list_prepend (retval, child->widget);
2714 }
2715
2716 return g_list_reverse (retval);
2717}
2718
2719/**
2720 * ctk_box_set_center_widget:
2721 * @box: a #CtkBox
2722 * @widget: (allow-none): the widget to center
2723 *
2724 * Sets a center widget; that is a child widget that will be
2725 * centered with respect to the full width of the box, even
2726 * if the children at either side take up different amounts
2727 * of space.
2728 *
2729 * Since: 3.12
2730 */
2731void
2732ctk_box_set_center_widget (CtkBox *box,
2733 CtkWidget *widget)
2734{
2735 CtkBoxPrivate *priv = box->priv;
2736 CtkWidget *old_center = NULL((void*)0);
2737
2738 g_return_if_fail (CTK_IS_BOX (box))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((box)); GType __t = ((ctk_box_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; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_BOX (box)"); return; } } while (0)
;
2739
2740 if (priv->center)
2741 {
2742 old_center = g_object_ref (priv->center->widget)((__typeof__ (priv->center->widget)) (g_object_ref) (priv
->center->widget))
;
2743 ctk_box_remove (CTK_CONTAINER (box)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((box)), ((ctk_container_get_type ()))))))
, priv->center->widget);
2744 priv->center = NULL((void*)0);
2745 }
2746
2747 if (widget)
2748 priv->center = ctk_box_pack (box, widget, FALSE(0), TRUE(!(0)), 0, CTK_PACK_START);
2749
2750 if (old_center)
2751 g_object_unref (old_center);
2752}
2753
2754/**
2755 * ctk_box_get_center_widget:
2756 * @box: a #CtkBox
2757 *
2758 * Retrieves the center widget of the box.
2759 *
2760 * Returns: (transfer none) (nullable): the center widget
2761 * or %NULL in case no center widget is set.
2762 *
2763 * Since: 3.12
2764 */
2765CtkWidget *
2766ctk_box_get_center_widget (CtkBox *box)
2767{
2768 CtkBoxPrivate *priv = box->priv;
2769
2770 g_return_val_if_fail (CTK_IS_BOX (box), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((box)); GType __t = ((ctk_box_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; })))))) { }
else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__
)), "CTK_IS_BOX (box)"); return (((void*)0)); } } while (0)
;
2771
2772 if (priv->center)
2773 return priv->center->widget;
2774
2775 return NULL((void*)0);
2776}