add recursive name fund func evas_object_name_child_find()
authorraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 28 Dec 2011 05:07:31 +0000 (05:07 +0000)
committerraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 28 Dec 2011 05:07:31 +0000 (05:07 +0000)
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/evas@66587 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

ChangeLog
src/lib/Evas.h
src/lib/canvas/evas_name.c

index d95ab7d..28d7f45 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
         * Add feature to get number of pressed devices (help fix
           ecore-evas bug).
 
+2011-12-28  Carsten Haitzler (The Rasterman)
+
+        * Add recursive name find function - evas_object_name_child_find()
+
index ae0584f..a0a29e5 100644 (file)
@@ -5791,11 +5791,37 @@ EAPI Evas_Object      *evas_focus_get                    (const Evas *e) EINA_WA
  * @param   name The given name.
  * @return  If successful, the Evas object with the given name.  Otherwise,
  *          @c NULL.
+ * 
+ * This looks for the evas object given a name by evas_object_name_set(). If
+ * the name is not unique canvas-wide, then which one of the many objects
+ * with that name is returned is undefined, so only use this if you can ensure
+ * the object name is unique.
+ * 
  * @ingroup Evas_Object_Group_Find
  */
 EAPI Evas_Object      *evas_object_name_find             (const Evas *e, const char *name) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_PURE;
 
 /**
+ * Retrieves the object from children of the given objec with the given name.
+ * @param   obj  The parent (smart) object whose children to search.
+ * @param   name The given name.
+ * @param   recurse set to EINA_TRUE if this is to recurse down child objects.
+ * @return  If successful, the Evas object with the given name.  Otherwise,
+ *          @c NULL.
+ * 
+ * This looks for the evas object given a name by evas_object_name_set(), but
+ * it ONLY looks at the children of the biecjt *p obj, and will only recurse
+ * into thsoe children if @p recurse is set to EINA_TRUE. If the name is not
+ * unique within immediate children (or the whole child tree) then it is not
+ * defined which child object will be returned.
+ * 
+ * @since 1.2
+ * 
+ * @ingroup Evas_Object_Group_Find
+ */
+EAPI Evas_Object      *evas_object_name_child_find        (const Evas_Object *obj, const char *name, Eina_Bool recurse) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_PURE;
+
+/**
  * Retrieve the Evas object stacked at the top of a given position in
  * a canvas
  *
index c42f941..2a74805 100644 (file)
@@ -38,3 +38,35 @@ evas_object_name_find(const Evas *e, const char *name)
    if (!name) return NULL;
    return (Evas_Object *)eina_hash_find(e->name_hash, name);
 }
+
+static Evas_Object *
+_evas_object_name_child_find(const Evas_Object *obj, const char *name, Eina_Bool recurse)
+{
+   const Eina_Inlist *lst;
+   Evas_Object *child;
+   
+   if (!obj->smart.smart) return NULL;
+   lst = evas_object_smart_members_get_direct(obj);
+   EINA_INLIST_FOREACH(lst, child)
+     {
+        if (child->delete_me) continue;
+        if (!child->name) continue;
+        if (!strcmp(name, child->name)) return child;
+        if (recurse)
+          {
+             if ((obj = _evas_object_name_child_find(child, name, recurse)))
+               return obj;
+          }
+     }
+   return NULL;
+}
+
+EAPI Evas_Object *
+evas_object_name_child_find(const Evas_Object *obj, const char *name, Eina_Bool recurse)
+{
+   MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
+   return NULL;
+   MAGIC_CHECK_END();
+   if (!name) return NULL;
+   return _evas_object_name_child_find(obj, name, recurse);
+}