[clutter/wip/apocalypses/apocalypse-1: 35/92] actor: Provide more children methods



commit e76ba718d91a4d7e826986106365ec11feb4eb65
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Tue Dec 6 16:00:08 2011 +0000

    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.

 clutter/clutter-actor-private.h |    1 -
 clutter/clutter-actor.c         |   36 +++++++++++++++++++++++++++++++++++-
 clutter/clutter-actor.h         |    5 ++++-
 3 files changed, 39 insertions(+), 3 deletions(-)
---
diff --git a/clutter/clutter-actor-private.h b/clutter/clutter-actor-private.h
index ec9433c..fc37412 100644
--- a/clutter/clutter-actor-private.h
+++ b/clutter/clutter-actor-private.h
@@ -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);
diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c
index ae8f436..6802439 100644
--- a/clutter/clutter-actor.c
+++ b/clutter/clutter-actor.c
@@ -13985,12 +13985,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
diff --git a/clutter/clutter-actor.h b/clutter/clutter-actor.h
index 9b73c51..3e58a9c 100644
--- a/clutter/clutter-actor.h
+++ b/clutter/clutter-actor.h
@@ -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);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]