add recursive name fund func evas_object_name_child_find()

SVN revision: 66587
This commit is contained in:
Carsten Haitzler 2011-12-28 05:07:31 +00:00
parent 4f4639b81f
commit d72c60d269
3 changed files with 62 additions and 0 deletions

View File

@ -596,3 +596,7 @@
* 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()

View File

@ -5791,10 +5791,36 @@ 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

View 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);
}