clutter: Mark BoxLayout as derivable

As it is subclassed in GNOME Shell

Fixes: 23d921080 ("box-layout: Use macros for subclassing boilerplate")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3509>
This commit is contained in:
Bilal Elmoussaoui 2024-01-10 11:52:32 +01:00
parent 8e04168fb2
commit 38fd27b528
2 changed files with 113 additions and 71 deletions

View File

@ -59,10 +59,8 @@
#include "clutter/clutter-private.h" #include "clutter/clutter-private.h"
#include "clutter/clutter-types.h" #include "clutter/clutter-types.h"
struct _ClutterBoxLayout typedef struct _ClutterBoxLayoutPrivate
{ {
ClutterLayoutManager parent_instance;
ClutterActor *container; ClutterActor *container;
guint spacing; guint spacing;
@ -73,7 +71,7 @@ struct _ClutterBoxLayout
ClutterOrientation orientation; ClutterOrientation orientation;
guint is_homogeneous : 1; guint is_homogeneous : 1;
}; } ClutterBoxLayoutPrivate;
enum enum
{ {
@ -88,7 +86,7 @@ enum
static GParamSpec *obj_props[PROP_LAST] = { NULL, }; static GParamSpec *obj_props[PROP_LAST] = { NULL, };
G_DEFINE_FINAL_TYPE (ClutterBoxLayout, G_DEFINE_TYPE_WITH_PRIVATE (ClutterBoxLayout,
clutter_box_layout, clutter_box_layout,
CLUTTER_TYPE_LAYOUT_MANAGER) CLUTTER_TYPE_LAYOUT_MANAGER)
@ -114,21 +112,23 @@ clutter_box_layout_set_container (ClutterLayoutManager *layout,
ClutterActor *container) ClutterActor *container)
{ {
ClutterBoxLayout *self = CLUTTER_BOX_LAYOUT (layout); ClutterBoxLayout *self = CLUTTER_BOX_LAYOUT (layout);
ClutterBoxLayoutPrivate *priv =
clutter_box_layout_get_instance_private (self);
ClutterLayoutManagerClass *parent_class; ClutterLayoutManagerClass *parent_class;
self->container = container; priv->container = container;
if (self->container != NULL) if (priv->container != NULL)
{ {
ClutterRequestMode request_mode; ClutterRequestMode request_mode;
/* we need to change the :request-mode of the container /* we need to change the :request-mode of the container
* to match the orientation * to match the orientation
*/ */
request_mode = self->orientation == CLUTTER_ORIENTATION_VERTICAL request_mode = priv->orientation == CLUTTER_ORIENTATION_VERTICAL
? CLUTTER_REQUEST_HEIGHT_FOR_WIDTH ? CLUTTER_REQUEST_HEIGHT_FOR_WIDTH
: CLUTTER_REQUEST_WIDTH_FOR_HEIGHT; : CLUTTER_REQUEST_WIDTH_FOR_HEIGHT;
clutter_actor_set_request_mode (CLUTTER_ACTOR (self->container), clutter_actor_set_request_mode (CLUTTER_ACTOR (priv->container),
request_mode); request_mode);
} }
@ -157,6 +157,8 @@ get_preferred_size_for_orientation (ClutterBoxLayout *self,
gfloat *min_size_p, gfloat *min_size_p,
gfloat *natural_size_p) gfloat *natural_size_p)
{ {
ClutterBoxLayoutPrivate *priv =
clutter_box_layout_get_instance_private (self);
ClutterActorIter iter; ClutterActorIter iter;
ClutterActor *child; ClutterActor *child;
gint n_children = 0; gint n_children = 0;
@ -176,10 +178,10 @@ get_preferred_size_for_orientation (ClutterBoxLayout *self,
n_children++; n_children++;
get_child_size (child, self->orientation, get_child_size (child, priv->orientation,
for_size, &child_min, &child_nat); for_size, &child_min, &child_nat);
if (self->is_homogeneous) if (priv->is_homogeneous)
{ {
largest_min_size = MAX (largest_min_size, child_min); largest_min_size = MAX (largest_min_size, child_min);
largest_nat_size = MAX (largest_nat_size, child_nat); largest_nat_size = MAX (largest_nat_size, child_nat);
@ -191,7 +193,7 @@ get_preferred_size_for_orientation (ClutterBoxLayout *self,
} }
} }
if (self->is_homogeneous) if (priv->is_homogeneous)
{ {
minimum = largest_min_size * n_children; minimum = largest_min_size * n_children;
natural = largest_nat_size * n_children; natural = largest_nat_size * n_children;
@ -199,8 +201,8 @@ get_preferred_size_for_orientation (ClutterBoxLayout *self,
if (n_children > 1) if (n_children > 1)
{ {
minimum += self->spacing * (n_children - 1); minimum += priv->spacing * (n_children - 1);
natural += self->spacing * (n_children - 1); natural += priv->spacing * (n_children - 1);
} }
if (min_size_p) if (min_size_p)
@ -216,12 +218,14 @@ get_base_size_for_opposite_orientation (ClutterBoxLayout *self,
gfloat *min_size_p, gfloat *min_size_p,
gfloat *natural_size_p) gfloat *natural_size_p)
{ {
ClutterBoxLayoutPrivate *priv =
clutter_box_layout_get_instance_private (self);
ClutterActorIter iter; ClutterActorIter iter;
ClutterActor *child; ClutterActor *child;
gint n_children = 0; gint n_children = 0;
gfloat minimum, natural; gfloat minimum, natural;
ClutterOrientation opposite_orientation = ClutterOrientation opposite_orientation =
self->orientation == CLUTTER_ORIENTATION_HORIZONTAL priv->orientation == CLUTTER_ORIENTATION_HORIZONTAL
? CLUTTER_ORIENTATION_VERTICAL ? CLUTTER_ORIENTATION_VERTICAL
: CLUTTER_ORIENTATION_HORIZONTAL; : CLUTTER_ORIENTATION_HORIZONTAL;
@ -268,6 +272,8 @@ get_preferred_size_for_opposite_orientation (ClutterBoxLayout *self,
gfloat *natural_size_p) gfloat *natural_size_p)
{ {
ClutterLayoutManager *layout = CLUTTER_LAYOUT_MANAGER (self); ClutterLayoutManager *layout = CLUTTER_LAYOUT_MANAGER (self);
ClutterBoxLayoutPrivate *priv =
clutter_box_layout_get_instance_private (self);
ClutterActor *child; ClutterActor *child;
ClutterActorIter iter; ClutterActorIter iter;
gint nvis_children = 0, n_extra_widgets = 0; gint nvis_children = 0, n_extra_widgets = 0;
@ -275,7 +281,7 @@ get_preferred_size_for_opposite_orientation (ClutterBoxLayout *self,
RequestedSize *sizes; RequestedSize *sizes;
gfloat minimum, natural, size, extra = 0; gfloat minimum, natural, size, extra = 0;
ClutterOrientation opposite_orientation = ClutterOrientation opposite_orientation =
self->orientation == CLUTTER_ORIENTATION_HORIZONTAL priv->orientation == CLUTTER_ORIENTATION_HORIZONTAL
? CLUTTER_ORIENTATION_VERTICAL ? CLUTTER_ORIENTATION_VERTICAL
: CLUTTER_ORIENTATION_HORIZONTAL; : CLUTTER_ORIENTATION_HORIZONTAL;
@ -305,7 +311,7 @@ get_preferred_size_for_opposite_orientation (ClutterBoxLayout *self,
if (!clutter_actor_is_visible (child)) if (!clutter_actor_is_visible (child))
continue; continue;
get_child_size (child, self->orientation, -1, get_child_size (child, priv->orientation, -1,
&sizes[i].minimum_size, &sizes[i].minimum_size,
&sizes[i].natural_size); &sizes[i].natural_size);
@ -313,15 +319,15 @@ get_preferred_size_for_opposite_orientation (ClutterBoxLayout *self,
i++; i++;
} }
if (self->is_homogeneous) if (priv->is_homogeneous)
{ {
size = for_size - (nvis_children - 1) * self->spacing; size = for_size - (nvis_children - 1) * priv->spacing;
extra = size / nvis_children; extra = size / nvis_children;
n_extra_widgets = ((gint)size) % nvis_children; n_extra_widgets = ((gint)size) % nvis_children;
} }
else else
{ {
size -= (nvis_children - 1) * self->spacing; size -= (nvis_children - 1) * priv->spacing;
/* Bring children up to size first */ /* Bring children up to size first */
if (isnormal (size) || size == 0) if (isnormal (size) || size == 0)
@ -357,7 +363,7 @@ get_preferred_size_for_opposite_orientation (ClutterBoxLayout *self,
if (!clutter_actor_is_visible (child)) if (!clutter_actor_is_visible (child))
continue; continue;
if (self->is_homogeneous) if (priv->is_homogeneous)
{ {
sizes[i].minimum_size = extra; sizes[i].minimum_size = extra;
@ -369,7 +375,7 @@ get_preferred_size_for_opposite_orientation (ClutterBoxLayout *self,
} }
else else
{ {
if (clutter_actor_needs_expand (child, self->orientation)) if (clutter_actor_needs_expand (child, priv->orientation))
{ {
sizes[i].minimum_size += extra; sizes[i].minimum_size += extra;
@ -434,8 +440,10 @@ clutter_box_layout_get_preferred_width (ClutterLayoutManager *layout,
gfloat *natural_width_p) gfloat *natural_width_p)
{ {
ClutterBoxLayout *self = CLUTTER_BOX_LAYOUT (layout); ClutterBoxLayout *self = CLUTTER_BOX_LAYOUT (layout);
ClutterBoxLayoutPrivate *priv =
clutter_box_layout_get_instance_private (self);
if (self->orientation == CLUTTER_ORIENTATION_VERTICAL) if (priv->orientation == CLUTTER_ORIENTATION_VERTICAL)
{ {
if (for_height < 0) if (for_height < 0)
get_base_size_for_opposite_orientation (self, CLUTTER_ACTOR (container), get_base_size_for_opposite_orientation (self, CLUTTER_ACTOR (container),
@ -457,8 +465,10 @@ clutter_box_layout_get_preferred_height (ClutterLayoutManager *layout,
gfloat *natural_height_p) gfloat *natural_height_p)
{ {
ClutterBoxLayout *self = CLUTTER_BOX_LAYOUT (layout); ClutterBoxLayout *self = CLUTTER_BOX_LAYOUT (layout);
ClutterBoxLayoutPrivate *priv =
clutter_box_layout_get_instance_private (self);
if (self->orientation == CLUTTER_ORIENTATION_HORIZONTAL) if (priv->orientation == CLUTTER_ORIENTATION_HORIZONTAL)
{ {
if (for_width < 0) if (for_width < 0)
get_base_size_for_opposite_orientation (self, CLUTTER_ACTOR (container), get_base_size_for_opposite_orientation (self, CLUTTER_ACTOR (container),
@ -479,6 +489,8 @@ count_expand_children (ClutterLayoutManager *layout,
gint *expand_children) gint *expand_children)
{ {
ClutterBoxLayout *self = CLUTTER_BOX_LAYOUT (layout); ClutterBoxLayout *self = CLUTTER_BOX_LAYOUT (layout);
ClutterBoxLayoutPrivate *priv =
clutter_box_layout_get_instance_private (self);
ClutterActor *child; ClutterActor *child;
ClutterActorIter iter; ClutterActorIter iter;
@ -491,7 +503,7 @@ count_expand_children (ClutterLayoutManager *layout,
{ {
*visible_children += 1; *visible_children += 1;
if (clutter_actor_needs_expand (child, self->orientation)) if (clutter_actor_needs_expand (child, priv->orientation))
*expand_children += 1; *expand_children += 1;
} }
} }
@ -611,6 +623,8 @@ clutter_box_layout_allocate (ClutterLayoutManager *layout,
const ClutterActorBox *box) const ClutterActorBox *box)
{ {
ClutterBoxLayout *self = CLUTTER_BOX_LAYOUT (layout); ClutterBoxLayout *self = CLUTTER_BOX_LAYOUT (layout);
ClutterBoxLayoutPrivate *priv =
clutter_box_layout_get_instance_private (self);
ClutterActor *actor, *child; ClutterActor *actor, *child;
gint nvis_children; gint nvis_children;
gint nexpand_children; gint nexpand_children;
@ -639,10 +653,10 @@ clutter_box_layout_allocate (ClutterLayoutManager *layout,
sizes = g_newa (RequestedSize, nvis_children); sizes = g_newa (RequestedSize, nvis_children);
if (self->orientation == CLUTTER_ORIENTATION_VERTICAL) if (priv->orientation == CLUTTER_ORIENTATION_VERTICAL)
size = box->y2 - box->y1 - (nvis_children - 1) * self->spacing; size = box->y2 - box->y1 - (nvis_children - 1) * priv->spacing;
else else
size = box->x2 - box->x1 - (nvis_children - 1) * self->spacing; size = box->x2 - box->x1 - (nvis_children - 1) * priv->spacing;
actor = CLUTTER_ACTOR (container); actor = CLUTTER_ACTOR (container);
@ -654,7 +668,7 @@ clutter_box_layout_allocate (ClutterLayoutManager *layout,
if (!clutter_actor_is_visible (child)) if (!clutter_actor_is_visible (child))
continue; continue;
if (self->orientation == CLUTTER_ORIENTATION_VERTICAL) if (priv->orientation == CLUTTER_ORIENTATION_VERTICAL)
clutter_actor_get_preferred_height (child, clutter_actor_get_preferred_height (child,
box->x2 - box->x1, box->x2 - box->x1,
&sizes[i].minimum_size, &sizes[i].minimum_size,
@ -670,29 +684,29 @@ clutter_box_layout_allocate (ClutterLayoutManager *layout,
if (sizes[i].minimum_size < 0) if (sizes[i].minimum_size < 0)
g_error ("ClutterBoxLayout child %s minimum %s: %f < 0 for %s %f", g_error ("ClutterBoxLayout child %s minimum %s: %f < 0 for %s %f",
_clutter_actor_get_debug_name (child), _clutter_actor_get_debug_name (child),
self->orientation == CLUTTER_ORIENTATION_VERTICAL priv->orientation == CLUTTER_ORIENTATION_VERTICAL
? "height" ? "height"
: "width", : "width",
sizes[i].minimum_size, sizes[i].minimum_size,
self->orientation == CLUTTER_ORIENTATION_VERTICAL priv->orientation == CLUTTER_ORIENTATION_VERTICAL
? "width" ? "width"
: "height", : "height",
self->orientation == CLUTTER_ORIENTATION_VERTICAL priv->orientation == CLUTTER_ORIENTATION_VERTICAL
? box->x2 - box->x1 ? box->x2 - box->x1
: box->y2 - box->y1); : box->y2 - box->y1);
if (sizes[i].natural_size < sizes[i].minimum_size) if (sizes[i].natural_size < sizes[i].minimum_size)
g_error ("ClutterBoxLayout child %s natural %s: %f < minimum %f for %s %f", g_error ("ClutterBoxLayout child %s natural %s: %f < minimum %f for %s %f",
_clutter_actor_get_debug_name (child), _clutter_actor_get_debug_name (child),
self->orientation == CLUTTER_ORIENTATION_VERTICAL priv->orientation == CLUTTER_ORIENTATION_VERTICAL
? "height" ? "height"
: "width", : "width",
sizes[i].natural_size, sizes[i].natural_size,
sizes[i].minimum_size, sizes[i].minimum_size,
self->orientation == CLUTTER_ORIENTATION_VERTICAL priv->orientation == CLUTTER_ORIENTATION_VERTICAL
? "width" ? "width"
: "height", : "height",
self->orientation == CLUTTER_ORIENTATION_VERTICAL priv->orientation == CLUTTER_ORIENTATION_VERTICAL
? box->x2 - box->x1 ? box->x2 - box->x1
: box->y2 - box->y1); : box->y2 - box->y1);
@ -703,15 +717,15 @@ clutter_box_layout_allocate (ClutterLayoutManager *layout,
i += 1; i += 1;
} }
if (self->is_homogeneous) if (priv->is_homogeneous)
{ {
/* If were homogeneous we still need to run the above loop to get the /* If were homogeneous we still need to run the above loop to get the
* minimum sizes for children that are not going to fill * minimum sizes for children that are not going to fill
*/ */
if (self->orientation == CLUTTER_ORIENTATION_VERTICAL) if (priv->orientation == CLUTTER_ORIENTATION_VERTICAL)
size = box->y2 - box->y1 - (nvis_children - 1) * self->spacing; size = box->y2 - box->y1 - (nvis_children - 1) * priv->spacing;
else else
size = box->x2 - box->x1 - (nvis_children - 1) * self->spacing; size = box->x2 - box->x1 - (nvis_children - 1) * priv->spacing;
extra = size / nvis_children; extra = size / nvis_children;
n_extra_widgets = size % nvis_children; n_extra_widgets = size % nvis_children;
@ -735,7 +749,7 @@ clutter_box_layout_allocate (ClutterLayoutManager *layout,
extra = 0; extra = 0;
} }
if (self->orientation == CLUTTER_ORIENTATION_HORIZONTAL) if (priv->orientation == CLUTTER_ORIENTATION_HORIZONTAL)
{ {
ClutterTextDirection text_dir; ClutterTextDirection text_dir;
@ -746,7 +760,7 @@ clutter_box_layout_allocate (ClutterLayoutManager *layout,
is_rtl = FALSE; is_rtl = FALSE;
/* Allocate child positions. */ /* Allocate child positions. */
if (self->orientation == CLUTTER_ORIENTATION_VERTICAL) if (priv->orientation == CLUTTER_ORIENTATION_VERTICAL)
{ {
child_allocation.x1 = box->x1; child_allocation.x1 = box->x1;
child_allocation.x2 = MAX (1.0, box->x2); child_allocation.x2 = MAX (1.0, box->x2);
@ -768,7 +782,7 @@ clutter_box_layout_allocate (ClutterLayoutManager *layout,
continue; continue;
/* Assign the child's size. */ /* Assign the child's size. */
if (self->is_homogeneous) if (priv->is_homogeneous)
{ {
child_size = extra; child_size = extra;
@ -782,7 +796,7 @@ clutter_box_layout_allocate (ClutterLayoutManager *layout,
{ {
child_size = sizes[i].minimum_size; child_size = sizes[i].minimum_size;
if (clutter_actor_needs_expand (child, self->orientation)) if (clutter_actor_needs_expand (child, priv->orientation))
{ {
child_size += extra; child_size += extra;
@ -795,9 +809,9 @@ clutter_box_layout_allocate (ClutterLayoutManager *layout,
} }
/* Assign the child's position. */ /* Assign the child's position. */
if (self->orientation == CLUTTER_ORIENTATION_VERTICAL) if (priv->orientation == CLUTTER_ORIENTATION_VERTICAL)
{ {
if (clutter_actor_needs_expand (child, self->orientation)) if (clutter_actor_needs_expand (child, priv->orientation))
{ {
child_allocation.y1 = y; child_allocation.y1 = y;
child_allocation.y2 = child_allocation.y1 + MAX (1.0, child_size); child_allocation.y2 = child_allocation.y1 + MAX (1.0, child_size);
@ -808,11 +822,11 @@ clutter_box_layout_allocate (ClutterLayoutManager *layout,
child_allocation.y2 = child_allocation.y1 + sizes[i].minimum_size; child_allocation.y2 = child_allocation.y1 + sizes[i].minimum_size;
} }
y += child_size + self->spacing; y += child_size + priv->spacing;
} }
else /* CLUTTER_ORIENTATION_HORIZONTAL */ else /* CLUTTER_ORIENTATION_HORIZONTAL */
{ {
if (clutter_actor_needs_expand (child, self->orientation)) if (clutter_actor_needs_expand (child, priv->orientation))
{ {
child_allocation.x1 = x; child_allocation.x1 = x;
child_allocation.x2 = child_allocation.x1 + MAX (1.0, child_size); child_allocation.x2 = child_allocation.x1 + MAX (1.0, child_size);
@ -823,7 +837,7 @@ clutter_box_layout_allocate (ClutterLayoutManager *layout,
child_allocation.x2 = child_allocation.x1 + sizes[i].minimum_size; child_allocation.x2 = child_allocation.x1 + sizes[i].minimum_size;
} }
x += child_size + self->spacing; x += child_size + priv->spacing;
if (is_rtl) if (is_rtl)
{ {
@ -879,19 +893,21 @@ clutter_box_layout_get_property (GObject *gobject,
GParamSpec *pspec) GParamSpec *pspec)
{ {
ClutterBoxLayout *self = CLUTTER_BOX_LAYOUT (gobject); ClutterBoxLayout *self = CLUTTER_BOX_LAYOUT (gobject);
ClutterBoxLayoutPrivate *priv =
clutter_box_layout_get_instance_private (self);
switch (prop_id) switch (prop_id)
{ {
case PROP_ORIENTATION: case PROP_ORIENTATION:
g_value_set_enum (value, self->orientation); g_value_set_enum (value, priv->orientation);
break; break;
case PROP_HOMOGENEOUS: case PROP_HOMOGENEOUS:
g_value_set_boolean (value, self->is_homogeneous); g_value_set_boolean (value, priv->is_homogeneous);
break; break;
case PROP_SPACING: case PROP_SPACING:
g_value_set_uint (value, self->spacing); g_value_set_uint (value, priv->spacing);
break; break;
default: default:
@ -957,12 +973,15 @@ clutter_box_layout_class_init (ClutterBoxLayoutClass *klass)
static void static void
clutter_box_layout_init (ClutterBoxLayout *self) clutter_box_layout_init (ClutterBoxLayout *self)
{ {
self->orientation = CLUTTER_ORIENTATION_HORIZONTAL; ClutterBoxLayoutPrivate *priv =
self->is_homogeneous = FALSE; clutter_box_layout_get_instance_private (self);
self->spacing = 0;
self->easing_mode = CLUTTER_EASE_OUT_CUBIC; priv->orientation = CLUTTER_ORIENTATION_HORIZONTAL;
self->easing_duration = 500; priv->is_homogeneous = FALSE;
priv->spacing = 0;
priv->easing_mode = CLUTTER_EASE_OUT_CUBIC;
priv->easing_duration = 500;
} }
/** /**
@ -989,13 +1008,16 @@ void
clutter_box_layout_set_spacing (ClutterBoxLayout *layout, clutter_box_layout_set_spacing (ClutterBoxLayout *layout,
guint spacing) guint spacing)
{ {
ClutterBoxLayoutPrivate *priv;
g_return_if_fail (CLUTTER_IS_BOX_LAYOUT (layout)); g_return_if_fail (CLUTTER_IS_BOX_LAYOUT (layout));
if (layout->spacing != spacing) priv = clutter_box_layout_get_instance_private (layout);
if (priv->spacing != spacing)
{ {
ClutterLayoutManager *manager; ClutterLayoutManager *manager;
layout->spacing = spacing; priv->spacing = spacing;
manager = CLUTTER_LAYOUT_MANAGER (layout); manager = CLUTTER_LAYOUT_MANAGER (layout);
@ -1016,9 +1038,12 @@ clutter_box_layout_set_spacing (ClutterBoxLayout *layout,
guint guint
clutter_box_layout_get_spacing (ClutterBoxLayout *layout) clutter_box_layout_get_spacing (ClutterBoxLayout *layout)
{ {
ClutterBoxLayoutPrivate *priv;
g_return_val_if_fail (CLUTTER_IS_BOX_LAYOUT (layout), 0); g_return_val_if_fail (CLUTTER_IS_BOX_LAYOUT (layout), 0);
return layout->spacing; priv = clutter_box_layout_get_instance_private (layout);
return priv->spacing;
} }
/** /**
@ -1033,13 +1058,15 @@ clutter_box_layout_set_orientation (ClutterBoxLayout *layout,
ClutterOrientation orientation) ClutterOrientation orientation)
{ {
ClutterLayoutManager *manager; ClutterLayoutManager *manager;
ClutterBoxLayoutPrivate *priv;
g_return_if_fail (CLUTTER_IS_BOX_LAYOUT (layout)); g_return_if_fail (CLUTTER_IS_BOX_LAYOUT (layout));
if (layout->orientation == orientation) priv = clutter_box_layout_get_instance_private (layout);
if (priv->orientation == orientation)
return; return;
layout->orientation = orientation; priv->orientation = orientation;
manager = CLUTTER_LAYOUT_MANAGER (layout); manager = CLUTTER_LAYOUT_MANAGER (layout);
@ -1059,10 +1086,13 @@ clutter_box_layout_set_orientation (ClutterBoxLayout *layout,
ClutterOrientation ClutterOrientation
clutter_box_layout_get_orientation (ClutterBoxLayout *layout) clutter_box_layout_get_orientation (ClutterBoxLayout *layout)
{ {
ClutterBoxLayoutPrivate *priv;
g_return_val_if_fail (CLUTTER_IS_BOX_LAYOUT (layout), g_return_val_if_fail (CLUTTER_IS_BOX_LAYOUT (layout),
CLUTTER_ORIENTATION_HORIZONTAL); CLUTTER_ORIENTATION_HORIZONTAL);
return layout->orientation; priv = clutter_box_layout_get_instance_private (layout);
return priv->orientation;
} }
/** /**
@ -1077,13 +1107,16 @@ void
clutter_box_layout_set_homogeneous (ClutterBoxLayout *layout, clutter_box_layout_set_homogeneous (ClutterBoxLayout *layout,
gboolean homogeneous) gboolean homogeneous)
{ {
ClutterBoxLayoutPrivate *priv;
g_return_if_fail (CLUTTER_IS_BOX_LAYOUT (layout)); g_return_if_fail (CLUTTER_IS_BOX_LAYOUT (layout));
if (layout->is_homogeneous != homogeneous) priv = clutter_box_layout_get_instance_private (layout);
if (priv->is_homogeneous != homogeneous)
{ {
ClutterLayoutManager *manager; ClutterLayoutManager *manager;
layout->is_homogeneous = !!homogeneous; priv->is_homogeneous = !!homogeneous;
manager = CLUTTER_LAYOUT_MANAGER (layout); manager = CLUTTER_LAYOUT_MANAGER (layout);
@ -1105,8 +1138,11 @@ clutter_box_layout_set_homogeneous (ClutterBoxLayout *layout,
gboolean gboolean
clutter_box_layout_get_homogeneous (ClutterBoxLayout *layout) clutter_box_layout_get_homogeneous (ClutterBoxLayout *layout)
{ {
ClutterBoxLayoutPrivate *priv;
g_return_val_if_fail (CLUTTER_IS_BOX_LAYOUT (layout), FALSE); g_return_val_if_fail (CLUTTER_IS_BOX_LAYOUT (layout), FALSE);
return layout->is_homogeneous; priv = clutter_box_layout_get_instance_private (layout);
return priv->is_homogeneous;
} }

View File

@ -38,11 +38,17 @@ G_BEGIN_DECLS
#define CLUTTER_TYPE_BOX_LAYOUT (clutter_box_layout_get_type ()) #define CLUTTER_TYPE_BOX_LAYOUT (clutter_box_layout_get_type ())
CLUTTER_EXPORT CLUTTER_EXPORT
G_DECLARE_FINAL_TYPE (ClutterBoxLayout, G_DECLARE_DERIVABLE_TYPE (ClutterBoxLayout,
clutter_box_layout, clutter_box_layout,
CLUTTER, BOX_LAYOUT, CLUTTER, BOX_LAYOUT,
ClutterLayoutManager) ClutterLayoutManager)
struct _ClutterBoxLayoutClass
{
/*< private >*/
ClutterLayoutManagerClass parent_class;
};
CLUTTER_EXPORT CLUTTER_EXPORT
ClutterLayoutManager * clutter_box_layout_new (void); ClutterLayoutManager * clutter_box_layout_new (void);