actor: Add replace_child() method

A simple method that atomically replaces a child actor with another one.
This commit is contained in:
Emmanuele Bassi 2011-12-18 22:14:36 +00:00
parent 238a6eb03d
commit bd58694678
2 changed files with 33 additions and 0 deletions

View File

@ -10015,6 +10015,36 @@ clutter_actor_remove_child (ClutterActor *self,
clutter_actor_remove_child_internal (self, child, TRUE, TRUE); clutter_actor_remove_child_internal (self, child, TRUE, TRUE);
} }
/**
* clutter_actor_replace_child:
* @self: a #ClutterActor
* @old_child: the child of @self to replace
* @new_child: the #ClutterActor to replace @old_child
*
* Replaces @old_child with @new_child in the list of children of @self.
*
* Since: 1.10
*/
void
clutter_actor_replace_child (ClutterActor *self,
ClutterActor *old_child,
ClutterActor *new_child)
{
g_return_if_fail (CLUTTER_IS_ACTOR (self));
g_return_if_fail (CLUTTER_IS_ACTOR (old_child));
g_return_if_fail (old_child->priv->parent == self);
g_return_if_fail (CLUTTER_IS_ACTOR (new_child));
g_return_if_fail (old_child != new_child);
g_return_if_fail (new_child != self);
g_return_if_fail (new_child->priv->parent == NULL);
clutter_actor_add_child_internal (self, new_child,
insert_child_above,
old_child,
TRUE, TRUE);
clutter_actor_remove_child_internal (self, old_child, TRUE, TRUE);
}
/** /**
* clutter_actor_unparent: * clutter_actor_unparent:
* @self: a #ClutterActor * @self: a #ClutterActor

View File

@ -461,6 +461,9 @@ void clutter_actor_insert_child_above (ClutterActor
void clutter_actor_insert_child_below (ClutterActor *self, void clutter_actor_insert_child_below (ClutterActor *self,
ClutterActor *child, ClutterActor *child,
ClutterActor *sibling); ClutterActor *sibling);
void clutter_actor_replace_child (ClutterActor *self,
ClutterActor *old_child,
ClutterActor *new_child);
void clutter_actor_remove_child (ClutterActor *self, void clutter_actor_remove_child (ClutterActor *self,
ClutterActor *child); ClutterActor *child);
GList * clutter_actor_get_children (ClutterActor *self); GList * clutter_actor_get_children (ClutterActor *self);