actor: Provide more children methods

Add a getter for the number of children, as well as a method to retrieve
the child at a given index.
This commit is contained in:
Emmanuele Bassi 2011-12-06 16:00:08 +00:00 committed by Emmanuele Bassi
parent b86cf3e2f3
commit 4acf8de8b4
3 changed files with 39 additions and 3 deletions

View File

@ -149,7 +149,6 @@ struct _ClutterLayoutInfo
const ClutterLayoutInfo * _clutter_actor_get_layout_info_or_defaults (ClutterActor *self);
ClutterLayoutInfo * _clutter_actor_get_layout_info (ClutterActor *self);
gint _clutter_actor_get_n_children (ClutterActor *self);
gboolean _clutter_actor_foreach_child (ClutterActor *self,
ClutterForeachCallback callback,
gpointer user_data);

View File

@ -13978,12 +13978,46 @@ clutter_actor_has_actions (ClutterActor *self)
return self->priv->actions != NULL;
}
/**
* clutter_actor_get_n_children:
* @self: a #ClutterActor
*
* Retrieves the number of children of @self.
*
* Return value: the number of children of an actor
*
* Since: 1.10
*/
gint
_clutter_actor_get_n_children (ClutterActor *self)
clutter_actor_get_n_children (ClutterActor *self)
{
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0);
return self->priv->n_children;
}
/**
* clutter_actor_get_child_at_index:
* @self: a #ClutterActor
* @index_: the position in the list of children
*
* Retrieves the actor at the given @index_ inside the list of
* children of @self.
*
* Return value: (transfer none): a pointer to a #ClutterActor, or %NULL
*
* Since: 1.10
*/
ClutterActor *
clutter_actor_get_child_at_index (ClutterActor *self,
gint index_)
{
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), NULL);
g_return_val_if_fail (index_ <= self->priv->n_children, NULL);
return g_list_nth_data (self->priv->children, index_);
}
/* _clutter_actor_foreach_child:
* @actor: The actor whos children you want to iterate
* @callback: The function to call for each child

View File

@ -462,6 +462,9 @@ void clutter_actor_insert_child_below (ClutterActor
void clutter_actor_remove_child (ClutterActor *self,
ClutterActor *child);
GList * clutter_actor_get_children (ClutterActor *self);
gint clutter_actor_get_n_children (ClutterActor *self);
ClutterActor * clutter_actor_get_child_at_index (ClutterActor *self,
gint index_);
void clutter_actor_set_parent (ClutterActor *self,
ClutterActor *parent);
ClutterActor * clutter_actor_get_parent (ClutterActor *self);
@ -477,10 +480,10 @@ void clutter_actor_lower (ClutterActor
ClutterActor *above);
void clutter_actor_raise_top (ClutterActor *self);
void clutter_actor_lower_bottom (ClutterActor *self);
void clutter_actor_push_internal (ClutterActor *self);
void clutter_actor_pop_internal (ClutterActor *self);
/* Transformations */
gboolean clutter_actor_is_rotated (ClutterActor *self);
gboolean clutter_actor_is_scaled (ClutterActor *self);