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

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