st-container: Remove st_container_get_children_list

Replace it with the new actor iteration APIs. This fixes a few
unintentional memory leaks - st_container_get_children_list
returns an internal list, and clutter_actor_get_children_list
allocates a new list.

https://bugzilla.gnome.org/show_bug.cgi?id=670034

https://bugzilla.gnome.org/show_bug.cgi?id=670910
This commit is contained in:
Jasper St. Pierre 2012-02-16 13:40:31 -05:00
parent 4005863e3d
commit d2aab9d6a6
7 changed files with 106 additions and 195 deletions

View File

@ -125,15 +125,14 @@ static void
shell_generic_container_paint (ClutterActor *actor) shell_generic_container_paint (ClutterActor *actor)
{ {
ShellGenericContainer *self = (ShellGenericContainer*) actor; ShellGenericContainer *self = (ShellGenericContainer*) actor;
GList *iter, *children; ClutterActor *child;
st_widget_paint_background (ST_WIDGET (actor)); st_widget_paint_background (ST_WIDGET (actor));
children = st_container_get_children_list (ST_CONTAINER (actor)); for (child = clutter_actor_get_first_child (actor);
for (iter = children; iter; iter = iter->next) child != NULL;
child = clutter_actor_get_next_sibling (child))
{ {
ClutterActor *child = iter->data;
if (g_hash_table_lookup (self->priv->skip_paint, child)) if (g_hash_table_lookup (self->priv->skip_paint, child))
continue; continue;
@ -146,15 +145,14 @@ shell_generic_container_pick (ClutterActor *actor,
const ClutterColor *color) const ClutterColor *color)
{ {
ShellGenericContainer *self = (ShellGenericContainer*) actor; ShellGenericContainer *self = (ShellGenericContainer*) actor;
GList *iter, *children; ClutterActor *child;
CLUTTER_ACTOR_CLASS (shell_generic_container_parent_class)->pick (actor, color); CLUTTER_ACTOR_CLASS (shell_generic_container_parent_class)->pick (actor, color);
children = st_container_get_children_list (ST_CONTAINER (actor)); for (child = clutter_actor_get_first_child (actor);
for (iter = children; iter; iter = iter->next) child != NULL;
child = clutter_actor_get_next_sibling (child))
{ {
ClutterActor *child = iter->data;
if (g_hash_table_lookup (self->priv->skip_paint, child)) if (g_hash_table_lookup (self->priv->skip_paint, child))
continue; continue;
@ -166,13 +164,14 @@ static GList *
shell_generic_container_get_focus_chain (StWidget *widget) shell_generic_container_get_focus_chain (StWidget *widget)
{ {
ShellGenericContainer *self = SHELL_GENERIC_CONTAINER (widget); ShellGenericContainer *self = SHELL_GENERIC_CONTAINER (widget);
GList *children, *focus_chain; ClutterActor *child;
GList *focus_chain;
focus_chain = NULL; focus_chain = NULL;
for (children = st_container_get_children_list (ST_CONTAINER (widget)); children; children = children->next) for (child = clutter_actor_get_first_child (CLUTTER_ACTOR (self));
child != NULL;
child = clutter_actor_get_next_sibling (child))
{ {
ClutterActor *child = children->data;
if (CLUTTER_ACTOR_IS_VISIBLE (child) && if (CLUTTER_ACTOR_IS_VISIBLE (child) &&
!shell_generic_container_get_skip_paint (self, child)) !shell_generic_container_get_skip_paint (self, child))
focus_chain = g_list_prepend (focus_chain, child); focus_chain = g_list_prepend (focus_chain, child);

View File

@ -27,18 +27,18 @@ shell_stack_allocate (ClutterActor *self,
{ {
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self)); StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self));
ClutterActorBox content_box; ClutterActorBox content_box;
GList *children, *iter; ClutterActor *child;
clutter_actor_set_allocation (self, box, flags); clutter_actor_set_allocation (self, box, flags);
st_theme_node_get_content_box (theme_node, box, &content_box); st_theme_node_get_content_box (theme_node, box, &content_box);
children = st_container_get_children_list (ST_CONTAINER (self)); for (child = clutter_actor_get_first_child (self);
for (iter = children; iter; iter = iter->next) child != NULL;
child = clutter_actor_get_next_sibling (child))
{ {
ClutterActor *actor = CLUTTER_ACTOR (iter->data);
ClutterActorBox child_box = content_box; ClutterActorBox child_box = content_box;
clutter_actor_allocate (actor, &child_box, flags); clutter_actor_allocate (child, &child_box, flags);
} }
} }
@ -48,20 +48,17 @@ shell_stack_get_preferred_height (ClutterActor *actor,
gfloat *min_height_p, gfloat *min_height_p,
gfloat *natural_height_p) gfloat *natural_height_p)
{ {
ShellStack *stack = SHELL_STACK (actor);
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor)); StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
gboolean first = TRUE; gboolean first = TRUE;
float min = 0, natural = 0; float min = 0, natural = 0;
GList *children; ClutterActor *child;
GList *iter;
st_theme_node_adjust_for_width (theme_node, &for_width); st_theme_node_adjust_for_width (theme_node, &for_width);
children = st_container_get_children_list (ST_CONTAINER (stack)); for (child = clutter_actor_get_first_child (actor);
child != NULL;
for (iter = children; iter; iter = iter->next) child = clutter_actor_get_next_sibling (child))
{ {
ClutterActor *child = iter->data;
float child_min, child_natural; float child_min, child_natural;
clutter_actor_get_preferred_height (child, clutter_actor_get_preferred_height (child,
@ -100,20 +97,17 @@ shell_stack_get_preferred_width (ClutterActor *actor,
gfloat *min_width_p, gfloat *min_width_p,
gfloat *natural_width_p) gfloat *natural_width_p)
{ {
ShellStack *stack = SHELL_STACK (actor);
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor)); StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
gboolean first = TRUE; gboolean first = TRUE;
float min = 0, natural = 0; float min = 0, natural = 0;
GList *iter; ClutterActor *child;
GList *children;
st_theme_node_adjust_for_height (theme_node, &for_height); st_theme_node_adjust_for_height (theme_node, &for_height);
children = st_container_get_children_list (ST_CONTAINER (stack)); for (child = clutter_actor_get_first_child (actor);
child != NULL;
for (iter = children; iter; iter = iter->next) child = clutter_actor_get_next_sibling (child))
{ {
ClutterActor *child = iter->data;
float child_min, child_natural; float child_min, child_natural;
clutter_actor_get_preferred_width (child, clutter_actor_get_preferred_width (child,
@ -152,7 +146,6 @@ shell_stack_navigate_focus (StWidget *widget,
GtkDirectionType direction) GtkDirectionType direction)
{ {
ClutterActor *top_actor; ClutterActor *top_actor;
GList *children;
/* If the stack is itself focusable, then focus into or out of /* If the stack is itself focusable, then focus into or out of
* it, as appropriate. * it, as appropriate.
@ -166,12 +159,7 @@ shell_stack_navigate_focus (StWidget *widget,
return TRUE; return TRUE;
} }
/* Otherwise, navigate into its top-most child only */ top_actor = clutter_actor_get_last_child (CLUTTER_ACTOR (widget));
children = st_container_get_children_list (ST_CONTAINER (widget));
if (!children)
return FALSE;
top_actor = g_list_last (children)->data;
if (ST_IS_WIDGET (top_actor)) if (ST_IS_WIDGET (top_actor))
return st_widget_navigate_focus (ST_WIDGET (top_actor), from, direction, FALSE); return st_widget_navigate_focus (ST_WIDGET (top_actor), from, direction, FALSE);
else else

View File

@ -287,16 +287,15 @@ get_content_preferred_width (StBoxLayout *self,
gint n_children = 0; gint n_children = 0;
gint n_fixed = 0; gint n_fixed = 0;
gfloat min_width, natural_width; gfloat min_width, natural_width;
GList *l, *children; ClutterActor *child;
min_width = 0; min_width = 0;
natural_width = 0; natural_width = 0;
children = st_container_get_children_list (ST_CONTAINER (self)); for (child = clutter_actor_get_first_child (CLUTTER_ACTOR (self));
child != NULL;
for (l = children; l; l = g_list_next (l)) child = clutter_actor_get_next_sibling (child))
{ {
ClutterActor *child = l->data;
gfloat child_min = 0, child_nat = 0; gfloat child_min = 0, child_nat = 0;
gboolean child_fill; gboolean child_fill;
@ -370,16 +369,15 @@ get_content_preferred_height (StBoxLayout *self,
gint n_children = 0; gint n_children = 0;
gint n_fixed = 0; gint n_fixed = 0;
gfloat min_height, natural_height; gfloat min_height, natural_height;
GList *l, *children; ClutterActor *child;
min_height = 0; min_height = 0;
natural_height = 0; natural_height = 0;
children = st_container_get_children_list (ST_CONTAINER (self)); for (child = clutter_actor_get_first_child (CLUTTER_ACTOR (self));
child != NULL;
for (l = children; l; l = g_list_next (l)) child = clutter_actor_get_next_sibling (child))
{ {
ClutterActor *child = l->data;
gfloat child_min = 0, child_nat = 0; gfloat child_min = 0, child_nat = 0;
gboolean child_fill = FALSE; gboolean child_fill = FALSE;
@ -490,14 +488,13 @@ compute_shrinks (StBoxLayout *self,
gfloat total_shrink) gfloat total_shrink)
{ {
StBoxLayoutPrivate *priv = self->priv; StBoxLayoutPrivate *priv = self->priv;
GList *children = st_container_get_children_list (ST_CONTAINER (self)); int n_children = clutter_actor_get_n_children (CLUTTER_ACTOR (self));
int n_children = g_list_length (children);
BoxChildShrink *shrinks = g_new0 (BoxChildShrink, n_children); BoxChildShrink *shrinks = g_new0 (BoxChildShrink, n_children);
gfloat shrink_so_far; gfloat shrink_so_far;
gfloat base_shrink = 0; /* the "= 0" is just to make gcc happy */ gfloat base_shrink = 0; /* the "= 0" is just to make gcc happy */
int n_shrink_children; int n_shrink_children;
GList *l; ClutterActor *child;
int i; int i = 0;
/* The effect that we want is that all the children get an equal chance /* The effect that we want is that all the children get an equal chance
* to expand from their minimum size up to the natural size. Or to put * to expand from their minimum size up to the natural size. Or to put
@ -508,14 +505,14 @@ compute_shrinks (StBoxLayout *self,
/* Find the amount of possible shrink for each child */ /* Find the amount of possible shrink for each child */
int n_possible_shrink_children = 0; int n_possible_shrink_children = 0;
for (l = children, i = 0; l; l = l->next, i++) for (child = clutter_actor_get_first_child (CLUTTER_ACTOR (self));
child != NULL;
child = clutter_actor_get_next_sibling (child))
{ {
ClutterActor *child = l->data;
gfloat child_min, child_nat; gfloat child_min, child_nat;
gboolean child_fill; gboolean child_fill;
gboolean fixed; gboolean fixed;
child = (ClutterActor*) l->data;
fixed = clutter_actor_get_fixed_position_set (child); fixed = clutter_actor_get_fixed_position_set (child);
shrinks[i].child_index = i; shrinks[i].child_index = i;
@ -547,6 +544,8 @@ compute_shrinks (StBoxLayout *self,
{ {
shrinks[i].shrink_amount = -1.; shrinks[i].shrink_amount = -1.;
} }
i++;
} }
/* We want to process children starting from the child with the maximum available /* We want to process children starting from the child with the maximum available
@ -609,19 +608,15 @@ st_box_layout_allocate (ClutterActor *actor,
ClutterActorBox content_box; ClutterActorBox content_box;
gfloat avail_width, avail_height, min_width, natural_width, min_height, natural_height; gfloat avail_width, avail_height, min_width, natural_width, min_height, natural_height;
gfloat position, next_position; gfloat position, next_position;
GList *l, *children;
gint n_expand_children = 0, i; gint n_expand_children = 0, i;
gfloat expand_amount, shrink_amount; gfloat expand_amount, shrink_amount;
BoxChildShrink *shrinks = NULL; BoxChildShrink *shrinks = NULL;
gboolean flip = (st_widget_get_direction (ST_WIDGET (actor)) == ST_TEXT_DIRECTION_RTL) gboolean flip = (st_widget_get_direction (ST_WIDGET (actor)) == ST_TEXT_DIRECTION_RTL)
&& (!priv->is_vertical); && (!priv->is_vertical);
ClutterActor *child;
clutter_actor_set_allocation (actor, box, flags); clutter_actor_set_allocation (actor, box, flags);
children = st_container_get_children_list (ST_CONTAINER (actor));
if (children == NULL)
return;
st_theme_node_get_content_box (theme_node, box, &content_box); st_theme_node_get_content_box (theme_node, box, &content_box);
avail_width = content_box.x2 - content_box.x1; avail_width = content_box.x2 - content_box.x1;
@ -693,9 +688,10 @@ st_box_layout_allocate (ClutterActor *actor,
{ {
/* count the number of children with expand set to TRUE */ /* count the number of children with expand set to TRUE */
n_expand_children = 0; n_expand_children = 0;
for (l = children; l; l = l->next) for (child = clutter_actor_get_first_child (actor);
child != NULL;
child = clutter_actor_get_next_sibling (child))
{ {
ClutterActor *child = l->data;
gboolean expand; gboolean expand;
if (!CLUTTER_ACTOR_IS_VISIBLE (child) || if (!CLUTTER_ACTOR_IS_VISIBLE (child) ||
@ -729,18 +725,17 @@ st_box_layout_allocate (ClutterActor *actor,
if (priv->is_pack_start) if (priv->is_pack_start)
{ {
l = g_list_last (children); child = clutter_actor_get_last_child (actor);
i = g_list_length (children); i = clutter_actor_get_n_children (actor);
} }
else else
{ {
l = children; child = clutter_actor_get_first_child (actor);
i = 0; i = 0;
} }
while (l) while (child != NULL)
{ {
ClutterActor *child = (ClutterActor*) l->data;
ClutterActorBox child_box; ClutterActorBox child_box;
gfloat child_min, child_nat, child_allocated; gfloat child_min, child_nat, child_allocated;
gboolean xfill, yfill, expand, fixed; gboolean xfill, yfill, expand, fixed;
@ -827,12 +822,12 @@ st_box_layout_allocate (ClutterActor *actor,
next_child: next_child:
if (priv->is_pack_start) if (priv->is_pack_start)
{ {
l = l->prev; child = clutter_actor_get_previous_sibling (child);
i--; i--;
} }
else else
{ {
l = l->next; child = clutter_actor_get_next_sibling (child);
i++; i++;
} }
} }
@ -890,10 +885,10 @@ st_box_layout_paint (ClutterActor *actor)
StBoxLayout *self = ST_BOX_LAYOUT (actor); StBoxLayout *self = ST_BOX_LAYOUT (actor);
StBoxLayoutPrivate *priv = self->priv; StBoxLayoutPrivate *priv = self->priv;
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor)); StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
GList *l, *children;
gdouble x, y; gdouble x, y;
ClutterActorBox allocation_box; ClutterActorBox allocation_box;
ClutterActorBox content_box; ClutterActorBox content_box;
ClutterActor *child;
get_border_paint_offsets (self, &x, &y); get_border_paint_offsets (self, &x, &y);
if (x != 0 || y != 0) if (x != 0 || y != 0)
@ -909,9 +904,7 @@ st_box_layout_paint (ClutterActor *actor)
cogl_pop_matrix (); cogl_pop_matrix ();
} }
children = st_container_get_children_list (ST_CONTAINER (actor)); if (clutter_actor_get_n_children (actor) == 0)
if (children == NULL)
return; return;
clutter_actor_get_allocation_box (actor, &allocation_box); clutter_actor_get_allocation_box (actor, &allocation_box);
@ -931,13 +924,10 @@ st_box_layout_paint (ClutterActor *actor)
(int)content_box.x2, (int)content_box.x2,
(int)content_box.y2); (int)content_box.y2);
for (l = children; l; l = g_list_next (l)) for (child = clutter_actor_get_first_child (actor);
{ child != NULL;
ClutterActor *child = (ClutterActor*) l->data; child = clutter_actor_get_next_sibling (child))
clutter_actor_paint (child);
if (CLUTTER_ACTOR_IS_VISIBLE (child))
clutter_actor_paint (child);
}
if (priv->hadjustment || priv->vadjustment) if (priv->hadjustment || priv->vadjustment)
cogl_clip_pop (); cogl_clip_pop ();
@ -950,10 +940,10 @@ st_box_layout_pick (ClutterActor *actor,
StBoxLayout *self = ST_BOX_LAYOUT (actor); StBoxLayout *self = ST_BOX_LAYOUT (actor);
StBoxLayoutPrivate *priv = self->priv; StBoxLayoutPrivate *priv = self->priv;
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor)); StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
GList *l, *children;
gdouble x, y; gdouble x, y;
ClutterActorBox allocation_box; ClutterActorBox allocation_box;
ClutterActorBox content_box; ClutterActorBox content_box;
ClutterActor *child;
get_border_paint_offsets (self, &x, &y); get_border_paint_offsets (self, &x, &y);
if (x != 0 || y != 0) if (x != 0 || y != 0)
@ -969,9 +959,7 @@ st_box_layout_pick (ClutterActor *actor,
cogl_pop_matrix (); cogl_pop_matrix ();
} }
children = st_container_get_children_list (ST_CONTAINER (actor)); if (clutter_actor_get_n_children (actor) == 0)
if (children == NULL)
return; return;
clutter_actor_get_allocation_box (actor, &allocation_box); clutter_actor_get_allocation_box (actor, &allocation_box);
@ -988,13 +976,10 @@ st_box_layout_pick (ClutterActor *actor,
(int)content_box.x2, (int)content_box.x2,
(int)content_box.y2); (int)content_box.y2);
for (l = children; l; l = g_list_next (l)) for (child = clutter_actor_get_first_child (actor);
{ child != NULL;
ClutterActor *child = (ClutterActor*) l->data; child = clutter_actor_get_next_sibling (child))
clutter_actor_paint (child);
if (CLUTTER_ACTOR_IS_VISIBLE (child))
clutter_actor_paint (child);
}
if (priv->hadjustment || priv->vadjustment) if (priv->hadjustment || priv->vadjustment)
cogl_clip_pop (); cogl_clip_pop ();

View File

@ -30,21 +30,6 @@
G_DEFINE_ABSTRACT_TYPE (StContainer, st_container, ST_TYPE_WIDGET); G_DEFINE_ABSTRACT_TYPE (StContainer, st_container, ST_TYPE_WIDGET);
/**
* st_container_get_children_list:
* @container: An #StContainer
*
* Get the internal list of @container's child actors. This function
* should only be used by subclasses of StContainer
*
* Returns: (element-type Clutter.Actor) (transfer none): list of @container's child actors
*/
GList *
st_container_get_children_list (StContainer *container)
{
return clutter_actor_get_children (CLUTTER_ACTOR (container));
}
static gboolean static gboolean
st_container_get_paint_volume (ClutterActor *actor, st_container_get_paint_volume (ClutterActor *actor,
ClutterPaintVolume *volume) ClutterPaintVolume *volume)

View File

@ -50,9 +50,6 @@ struct _StContainerClass {
GType st_container_get_type (void) G_GNUC_CONST; GType st_container_get_type (void) G_GNUC_CONST;
/* Only to be used by subclasses of StContainer */
GList * st_container_get_children_list (StContainer *container);
G_END_DECLS G_END_DECLS
#endif /* __ST_CONTAINER_H__ */ #endif /* __ST_CONTAINER_H__ */

View File

@ -61,7 +61,7 @@ st_group_get_preferred_width (ClutterActor *actor,
StThemeNode *node = st_widget_get_theme_node (ST_WIDGET (actor)); StThemeNode *node = st_widget_get_theme_node (ST_WIDGET (actor));
gdouble min_width, natural_width; gdouble min_width, natural_width;
gint css_width, css_min_width, css_max_width; gint css_width, css_min_width, css_max_width;
GList *l, *children; ClutterActor *child;
css_width = st_theme_node_get_width (node); css_width = st_theme_node_get_width (node);
css_min_width = st_theme_node_get_min_width (node); css_min_width = st_theme_node_get_min_width (node);
@ -73,11 +73,10 @@ st_group_get_preferred_width (ClutterActor *actor,
min_width = 0; min_width = 0;
natural_width = 0; natural_width = 0;
children = st_container_get_children_list (ST_CONTAINER (actor)); for (child = clutter_actor_get_first_child (actor);
child != NULL;
for (l = children; l != NULL; l = l->next) child = clutter_actor_get_next_sibling (child))
{ {
ClutterActor *child = l->data;
gfloat child_x, child_min, child_nat; gfloat child_x, child_min, child_nat;
child_x = clutter_actor_get_x (child); child_x = clutter_actor_get_x (child);
@ -122,7 +121,7 @@ st_group_get_preferred_height (ClutterActor *actor,
StThemeNode *node = st_widget_get_theme_node (ST_WIDGET (actor)); StThemeNode *node = st_widget_get_theme_node (ST_WIDGET (actor));
gdouble min_height, natural_height; gdouble min_height, natural_height;
gint css_height, css_min_height, css_max_height; gint css_height, css_min_height, css_max_height;
GList *l, *children; ClutterActor *child;
css_height = st_theme_node_get_height (node); css_height = st_theme_node_get_height (node);
css_min_height = st_theme_node_get_min_height (node); css_min_height = st_theme_node_get_min_height (node);
@ -134,11 +133,10 @@ st_group_get_preferred_height (ClutterActor *actor,
min_height = 0; min_height = 0;
natural_height = 0; natural_height = 0;
children = st_container_get_children_list (ST_CONTAINER (actor)); for (child = clutter_actor_get_first_child (actor);
child != NULL;
for (l = children; l != NULL; l = l->next) child = clutter_actor_get_next_sibling (child))
{ {
ClutterActor *child = l->data;
gfloat child_y, child_min, child_nat; gfloat child_y, child_min, child_nat;
child_y = clutter_actor_get_y (child); child_y = clutter_actor_get_y (child);
@ -179,16 +177,14 @@ st_group_allocate (ClutterActor *actor,
const ClutterActorBox *box, const ClutterActorBox *box,
ClutterAllocationFlags flags) ClutterAllocationFlags flags)
{ {
GList *l, *children; ClutterActor *child;
CLUTTER_ACTOR_CLASS (st_group_parent_class)->allocate (actor, box, flags); CLUTTER_ACTOR_CLASS (st_group_parent_class)->allocate (actor, box, flags);
children = st_container_get_children_list (ST_CONTAINER (actor)); for (child = clutter_actor_get_first_child (actor);
for (l = children; l != NULL; l = l->next) child != NULL;
{ child = clutter_actor_get_next_sibling (child))
ClutterActor *child = l->data; clutter_actor_allocate_preferred_size (child, flags);
clutter_actor_allocate_preferred_size (child, flags);
}
} }
static void static void

View File

@ -99,15 +99,15 @@ st_table_actor_removed (ClutterContainer *container,
ClutterActor *actor) ClutterActor *actor)
{ {
StTablePrivate *priv = ST_TABLE (container)->priv; StTablePrivate *priv = ST_TABLE (container)->priv;
GList *list, *children;
gint n_rows = 0; gint n_rows = 0;
gint n_cols = 0; gint n_cols = 0;
ClutterActor *child;
/* Calculate and update the number of rows / columns */ /* Calculate and update the number of rows / columns */
children = st_container_get_children_list (ST_CONTAINER (container)); for (child = clutter_actor_get_first_child (actor);
for (list = children; list; list = list->next) child != NULL;
child = clutter_actor_get_next_sibling (child))
{ {
ClutterActor *child = CLUTTER_ACTOR (list->data);
StTableChild *meta; StTableChild *meta;
if (child == actor) if (child == actor)
@ -221,11 +221,11 @@ st_table_homogeneous_allocate (ClutterActor *self,
const ClutterActorBox *content_box, const ClutterActorBox *content_box,
gboolean flags) gboolean flags)
{ {
GList *list, *children;
gfloat col_width, row_height; gfloat col_width, row_height;
gint row_spacing, col_spacing; gint row_spacing, col_spacing;
StTablePrivate *priv = ST_TABLE (self)->priv; StTablePrivate *priv = ST_TABLE (self)->priv;
gboolean ltr = st_widget_get_direction (ST_WIDGET (self)) == ST_TEXT_DIRECTION_LTR; gboolean ltr = st_widget_get_direction (ST_WIDGET (self)) == ST_TEXT_DIRECTION_LTR;
ClutterActor *child;
col_spacing = priv->col_spacing; col_spacing = priv->col_spacing;
row_spacing = priv->row_spacing; row_spacing = priv->row_spacing;
@ -237,18 +237,16 @@ st_table_homogeneous_allocate (ClutterActor *self,
- (row_spacing * (priv->n_rows - 1))) - (row_spacing * (priv->n_rows - 1)))
/ priv->n_rows + 0.5); / priv->n_rows + 0.5);
children = st_container_get_children_list (ST_CONTAINER (self)); for (child = clutter_actor_get_first_child (self);
for (list = children; list; list = list->next) child != NULL;
child = clutter_actor_get_next_sibling (child))
{ {
gint row, col, row_span, col_span; gint row, col, row_span, col_span;
StTableChild *meta; StTableChild *meta;
ClutterActor *child;
ClutterActorBox childbox; ClutterActorBox childbox;
StAlign x_align, y_align; StAlign x_align, y_align;
gboolean x_fill, y_fill; gboolean x_fill, y_fill;
child = CLUTTER_ACTOR (list->data);
meta = (StTableChild *) clutter_container_get_child_meta (CLUTTER_CONTAINER (self), child); meta = (StTableChild *) clutter_container_get_child_meta (CLUTTER_CONTAINER (self), child);
if (!meta->allocate_hidden && !CLUTTER_ACTOR_IS_VISIBLE (child)) if (!meta->allocate_hidden && !CLUTTER_ACTOR_IS_VISIBLE (child))
@ -296,7 +294,7 @@ st_table_calculate_col_widths (StTable *table,
gboolean *is_expand_col; gboolean *is_expand_col;
gint extra_col_width, n_expanded_cols = 0, expanded_cols = 0; gint extra_col_width, n_expanded_cols = 0, expanded_cols = 0;
gint *pref_widths, *min_widths; gint *pref_widths, *min_widths;
GList *list, *children; ClutterActor *child;
g_array_set_size (priv->is_expand_col, 0); g_array_set_size (priv->is_expand_col, 0);
g_array_set_size (priv->is_expand_col, priv->n_cols); g_array_set_size (priv->is_expand_col, priv->n_cols);
@ -310,19 +308,16 @@ st_table_calculate_col_widths (StTable *table,
g_array_set_size (priv->min_widths, priv->n_cols); g_array_set_size (priv->min_widths, priv->n_cols);
min_widths = (gint *) priv->min_widths->data; min_widths = (gint *) priv->min_widths->data;
children = st_container_get_children_list (ST_CONTAINER (table)); for (child = clutter_actor_get_first_child (CLUTTER_ACTOR (table));
child != NULL;
for (list = children; list; list = list->next) child = clutter_actor_get_next_sibling (child))
{ {
gint col; gint col;
gfloat w_min, w_pref; gfloat w_min, w_pref;
gboolean x_expand; gboolean x_expand;
StTableChild *meta; StTableChild *meta;
ClutterActor *child;
gint col_span; gint col_span;
child = CLUTTER_ACTOR (list->data);
meta = (StTableChild *) clutter_container_get_child_meta (CLUTTER_CONTAINER (table), child); meta = (StTableChild *) clutter_container_get_child_meta (CLUTTER_CONTAINER (table), child);
if (!meta->allocate_hidden && !CLUTTER_ACTOR_IS_VISIBLE (child)) if (!meta->allocate_hidden && !CLUTTER_ACTOR_IS_VISIBLE (child))
@ -398,11 +393,11 @@ st_table_calculate_row_heights (StTable *table,
gint * col_widths) gint * col_widths)
{ {
StTablePrivate *priv = ST_TABLE (table)->priv; StTablePrivate *priv = ST_TABLE (table)->priv;
GList *list, *children;
gint *is_expand_row, *min_heights, *pref_heights, *row_heights, extra_row_height; gint *is_expand_row, *min_heights, *pref_heights, *row_heights, extra_row_height;
gint i, total_min_height; gint i, total_min_height;
gint expanded_rows = 0; gint expanded_rows = 0;
gint n_expanded_rows = 0; gint n_expanded_rows = 0;
ClutterActor *child;
g_array_set_size (priv->row_heights, 0); g_array_set_size (priv->row_heights, 0);
g_array_set_size (priv->row_heights, priv->n_rows); g_array_set_size (priv->row_heights, priv->n_rows);
@ -420,18 +415,16 @@ st_table_calculate_row_heights (StTable *table,
g_array_set_size (priv->pref_heights, priv->n_rows); g_array_set_size (priv->pref_heights, priv->n_rows);
pref_heights = (gboolean *) priv->pref_heights->data; pref_heights = (gboolean *) priv->pref_heights->data;
children = st_container_get_children_list (ST_CONTAINER (table)); for (child = clutter_actor_get_first_child (CLUTTER_ACTOR (table));
for (list = children; list; list = list->next) child != NULL;
child = clutter_actor_get_next_sibling (child))
{ {
gint row, col, cell_width; gint row, col, cell_width;
gfloat h_min, h_pref; gfloat h_min, h_pref;
gboolean y_expand; gboolean y_expand;
StTableChild *meta; StTableChild *meta;
ClutterActor *child;
gint col_span, row_span; gint col_span, row_span;
child = CLUTTER_ACTOR (list->data);
meta = (StTableChild *) clutter_container_get_child_meta (CLUTTER_CONTAINER (table), child); meta = (StTableChild *) clutter_container_get_child_meta (CLUTTER_CONTAINER (table), child);
if (!meta->allocate_hidden && !CLUTTER_ACTOR_IS_VISIBLE (child)) if (!meta->allocate_hidden && !CLUTTER_ACTOR_IS_VISIBLE (child))
@ -571,13 +564,13 @@ st_table_preferred_allocate (ClutterActor *self,
const ClutterActorBox *content_box, const ClutterActorBox *content_box,
gboolean flags) gboolean flags)
{ {
GList *list, *children;
gint row_spacing, col_spacing; gint row_spacing, col_spacing;
gint i; gint i;
gint *col_widths, *row_heights; gint *col_widths, *row_heights;
StTable *table; StTable *table;
StTablePrivate *priv; StTablePrivate *priv;
gboolean ltr; gboolean ltr;
ClutterActor *child;
table = ST_TABLE (self); table = ST_TABLE (self);
priv = ST_TABLE (self)->priv; priv = ST_TABLE (self)->priv;
@ -596,20 +589,18 @@ st_table_preferred_allocate (ClutterActor *self,
ltr = (st_widget_get_direction (ST_WIDGET (self)) == ST_TEXT_DIRECTION_LTR); ltr = (st_widget_get_direction (ST_WIDGET (self)) == ST_TEXT_DIRECTION_LTR);
children = st_container_get_children_list (ST_CONTAINER (self)); for (child = clutter_actor_get_first_child (self);
for (list = children; list; list = list->next) child != NULL;
child = clutter_actor_get_next_sibling (child))
{ {
gint row, col, row_span, col_span; gint row, col, row_span, col_span;
gint col_width, row_height; gint col_width, row_height;
StTableChild *meta; StTableChild *meta;
ClutterActor *child;
ClutterActorBox childbox; ClutterActorBox childbox;
gint child_x, child_y; gint child_x, child_y;
StAlign x_align, y_align; StAlign x_align, y_align;
gboolean x_fill, y_fill; gboolean x_fill, y_fill;
child = CLUTTER_ACTOR (list->data);
meta = (StTableChild *) clutter_container_get_child_meta (CLUTTER_CONTAINER (self), child); meta = (StTableChild *) clutter_container_get_child_meta (CLUTTER_CONTAINER (self), child);
if (!meta->allocate_hidden && !CLUTTER_ACTOR_IS_VISIBLE (child)) if (!meta->allocate_hidden && !CLUTTER_ACTOR_IS_VISIBLE (child))
@ -740,8 +731,8 @@ st_table_get_preferred_width (ClutterActor *self,
gfloat total_min_width, total_pref_width; gfloat total_min_width, total_pref_width;
StTablePrivate *priv = ST_TABLE (self)->priv; StTablePrivate *priv = ST_TABLE (self)->priv;
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self)); StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self));
GList *list, *children;
gint i; gint i;
ClutterActor *child;
if (priv->n_cols < 1) if (priv->n_cols < 1)
{ {
@ -762,15 +753,13 @@ st_table_get_preferred_width (ClutterActor *self,
pref_widths = (gint *) priv->pref_widths->data; pref_widths = (gint *) priv->pref_widths->data;
/* calculate minimum row widths */ /* calculate minimum row widths */
children = st_container_get_children_list (ST_CONTAINER (self)); for (child = clutter_actor_get_first_child (self);
for (list = children; list; list = list->next) child != NULL;
child = clutter_actor_get_next_sibling (child))
{ {
gint col, col_span; gint col, col_span;
gfloat w_min, w_pref; gfloat w_min, w_pref;
StTableChild *meta; StTableChild *meta;
ClutterActor *child;
child = CLUTTER_ACTOR (list->data);
meta = (StTableChild *) clutter_container_get_child_meta (CLUTTER_CONTAINER (self), child); meta = (StTableChild *) clutter_container_get_child_meta (CLUTTER_CONTAINER (self), child);
@ -824,9 +813,9 @@ st_table_get_preferred_height (ClutterActor *self,
gfloat total_min_height, total_pref_height; gfloat total_min_height, total_pref_height;
StTablePrivate *priv = ST_TABLE (self)->priv; StTablePrivate *priv = ST_TABLE (self)->priv;
StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self)); StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self));
GList *list, *children;
gint i; gint i;
gint *min_widths; gint *min_widths;
ClutterActor *child;
/* We only support height-for-width allocation. So if we are called /* We only support height-for-width allocation. So if we are called
* width-for-height, calculate heights based on our natural width * width-for-height, calculate heights based on our natural width
@ -863,15 +852,13 @@ st_table_get_preferred_height (ClutterActor *self,
pref_heights = (gint *) priv->pref_heights->data; pref_heights = (gint *) priv->pref_heights->data;
/* calculate minimum row heights */ /* calculate minimum row heights */
children = st_container_get_children_list (ST_CONTAINER (self)); for (child = clutter_actor_get_first_child (self);
for (list = children; list; list = list->next) child != NULL;
child = clutter_actor_get_next_sibling (child))
{ {
gint row, col, col_span, cell_width, row_span; gint row, col, col_span, cell_width, row_span;
gfloat min, pref; gfloat min, pref;
StTableChild *meta; StTableChild *meta;
ClutterActor *child;
child = CLUTTER_ACTOR (list->data);
meta = (StTableChild *) clutter_container_get_child_meta (CLUTTER_CONTAINER (self), child); meta = (StTableChild *) clutter_container_get_child_meta (CLUTTER_CONTAINER (self), child);
@ -915,30 +902,6 @@ st_table_get_preferred_height (ClutterActor *self,
st_theme_node_adjust_preferred_height (theme_node, min_height_p, natural_height_p); st_theme_node_adjust_preferred_height (theme_node, min_height_p, natural_height_p);
} }
static void
st_table_show_all (ClutterActor *table)
{
GList *l, *children;
children = st_container_get_children_list (ST_CONTAINER (table));
for (l = children; l; l = l->next)
clutter_actor_show_all (CLUTTER_ACTOR (l->data));
clutter_actor_show (table);
}
static void
st_table_hide_all (ClutterActor *table)
{
GList *l, *children;
clutter_actor_hide (table);
children = st_container_get_children_list (ST_CONTAINER (table));
for (l = children; l; l = l->next)
clutter_actor_hide_all (CLUTTER_ACTOR (l->data));
}
static void static void
st_table_style_changed (StWidget *self) st_table_style_changed (StWidget *self)
{ {
@ -978,8 +941,6 @@ st_table_class_init (StTableClass *klass)
actor_class->allocate = st_table_allocate; actor_class->allocate = st_table_allocate;
actor_class->get_preferred_width = st_table_get_preferred_width; actor_class->get_preferred_width = st_table_get_preferred_width;
actor_class->get_preferred_height = st_table_get_preferred_height; actor_class->get_preferred_height = st_table_get_preferred_height;
actor_class->show_all = st_table_show_all;
actor_class->hide_all = st_table_hide_all;
widget_class->style_changed = st_table_style_changed; widget_class->style_changed = st_table_style_changed;