2007-09-28 Øyvind Kolås <pippin@openedhand.com>
authorØyvind Kolås <pippin@openedhand.com>
Fri, 28 Sep 2007 14:52:54 +0000 (14:52 +0000)
committerØyvind Kolås <pippin@openedhand.com>
Fri, 28 Sep 2007 14:52:54 +0000 (14:52 +0000)
* clutter/clutter-container.[ch]: added
clutter_container_find_child_by_name.

ChangeLog
clutter/clutter-container.c
clutter/clutter-container.h

index c4f4efe..9926fc5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2007-09-28  Øyvind Kolås  <pippin@openedhand.com>
 
+       * clutter/clutter-container.[ch]: added
+       clutter_container_find_child_by_name.
+
+2007-09-28  Øyvind Kolås  <pippin@openedhand.com>
+
        * clutter/glx/clutter-stage-glx.c: (clutter_stage_glx_realize):
        removed unused variable perspective.
        * tests/test-events.c: (main): added CLUTTER_STAGE() cast.
index f9ee905..17c1674 100644 (file)
@@ -504,3 +504,55 @@ clutter_container_sort_depth_order (ClutterContainer *container)
 
   CLUTTER_CONTAINER_GET_IFACE (container)->sort_depth_order (container);
 }
+
+/**
+ * clutter_container_find_child_by_name:
+ * @container: a #ClutterContainer
+ * @child_name: the name of the requested child. 
+ *
+ * Finds a child actor of a container by its name. Search recurses
+ * into any child container.
+ *
+ * Return value: The child actor with the requested name, or %NULL if no
+ *   actor with that name was found.
+ *
+ * Since: 0.6
+ */
+ClutterActor *
+clutter_container_find_child_by_name (ClutterContainer *container,
+                                      const gchar      *child_name)
+{
+  GList        *children;
+  GList        *iter;
+  ClutterActor *actor = NULL;
+
+  g_return_val_if_fail (CLUTTER_IS_CONTAINER (container), NULL);
+
+  children = clutter_container_get_children (container);
+
+  for (iter=children; iter; iter = g_list_next (iter))
+    {
+      ClutterActor *a;
+      const gchar  *iter_name;
+
+      a = CLUTTER_ACTOR (iter->data);
+      iter_name = clutter_actor_get_name (a);
+
+      if (iter_name && !strcmp (iter_name, child_name))
+        {
+          actor = a;
+          break;
+        }
+
+      if (CLUTTER_IS_CONTAINER (a))
+        {
+          ClutterContainer *c = CLUTTER_CONTAINER (a);
+
+          actor = clutter_container_find_child_by_name (c, child_name);
+          if (actor)
+            break;
+       }
+    }
+  g_list_free (children);
+  return actor;
+}
index 00378dd..9934162 100644 (file)
@@ -114,6 +114,8 @@ void          clutter_container_foreach          (ClutterContainer *container,
                                                   gpointer          user_data);
 ClutterActor *clutter_container_find_child_by_id (ClutterContainer *container,
                                                   guint             child_id);
+ClutterActor *clutter_container_find_child_by_name(ClutterContainer *container,
+                                                  const gchar      *child_name);
 void          clutter_container_raise_child      (ClutterContainer *container,
                                                   ClutterActor     *actor,
                                                   ClutterActor     *sibling);