From 57c0be73cd1148206730936ae9f48468fda8b264 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 13 Aug 2007 17:00:47 +0000 Subject: [PATCH] Implement ClutterContainer::find_child_by_id() in ClutterBox Iterate (recursively) on the children of a box to find the one with the given unique id. --- clutter/clutter-box.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/clutter/clutter-box.c b/clutter/clutter-box.c index 937728cda..7b9648982 100644 --- a/clutter/clutter-box.c +++ b/clutter/clutter-box.c @@ -126,12 +126,47 @@ clutter_box_foreach (ClutterContainer *container, } } +static ClutterActor * +clutter_box_find_child_by_id (ClutterContainer *container, + guint child_id) +{ + ClutterBox *self = CLUTTER_BOX (container); + ClutterActor *actor = NULL; + GList *l; + + if (clutter_actor_get_id (CLUTTER_ACTOR (self)) == child_id) + return CLUTTER_ACTOR (self); + + for (l = self->children; l; l = l->next) + { + ClutterBoxChild *child = l->data; + + if (clutter_actor_get_id (child->actor) == child_id) + { + actor = child->actor; + break; + } + + if (CLUTTER_IS_CONTAINER (child->actor)) + { + ClutterContainer *c = CLUTTER_CONTAINER (child->actor); + + actor = clutter_container_find_child_by_id (c, child_id); + if (actor) + break; + } + } + + return actor; +} + static void clutter_container_iface_init (ClutterContainerIface *iface) { iface->add = clutter_box_add; iface->remove = clutter_box_remove; iface->foreach = clutter_box_foreach; + iface->find_child_by_id = clutter_box_find_child_by_id; } static void