add recursie object find function - it will only look at elm children

not go into edje objects et.c and hunt their children too. should be
more efficient than evas's recursive name finder.



SVN revision: 66591
This commit is contained in:
Carsten Haitzler 2011-12-28 06:01:31 +00:00
parent b8d342e49e
commit 1713de6106
4 changed files with 15 additions and 15 deletions

View File

@ -1257,7 +1257,7 @@ extern "C" {
* *
* @param obj The parent object whose children to look at * @param obj The parent object whose children to look at
* @param name The name of the child to find * @param name The name of the child to find
* @param recurse Set to EINA_TRUE if you should recurse into children of children * @param recurse Set to thge maximum number of levels to recurse (0 == none, 1 is only look at 1 level of children etc.)
* @return The found object of that name, or NULL if none is found * @return The found object of that name, or NULL if none is found
* *
* This function searches the children (or recursively children of * This function searches the children (or recursively children of
@ -1265,13 +1265,14 @@ extern "C" {
* the name of @p name. If the child is found the object is returned, or * the name of @p name. If the child is found the object is returned, or
* NULL is returned. You can set the name of an object with * NULL is returned. You can set the name of an object with
* evas_object_name_set(). If the name is not unique within the child * evas_object_name_set(). If the name is not unique within the child
* objects (or the tree is @p recurse is set to EINA_TRUE) then it is * objects (or the tree is @p recurse is greater than 0) then it is
* undefined as to which child of that name is returned, so ensure the name * undefined as to which child of that name is returned, so ensure the name
* is unique amongst children. * is unique amongst children. If recurse is set to -1 it will recurse
* without limit.
* *
* @ingroup General * @ingroup General
*/ */
EAPI Evas_Object *elm_object_name_find(const Evas_Object *obj, const char *name, Eina_Bool recurse); EAPI Evas_Object *elm_object_name_find(const Evas_Object *obj, const char *name, int recurse);
/** /**
* Get the widget object's handle which contains a given item * Get the widget object's handle which contains a given item

View File

@ -2090,7 +2090,7 @@ elm_object_access_info_set(Evas_Object *obj, const char *txt)
} }
EAPI Evas_Object * EAPI Evas_Object *
elm_object_name_find(const Evas_Object *obj, const char *name, Eina_Bool recurse) elm_object_name_find(const Evas_Object *obj, const char *name, int recurse)
{ {
return elm_widget_name_find(obj, name, recurse); return elm_widget_name_find(obj, name, recurse);
} }

View File

@ -2638,44 +2638,43 @@ elm_widget_type_check(const Evas_Object *obj,
} }
static Evas_Object * static Evas_Object *
_widget_name_find(const Evas_Object *obj, const char *name, Eina_Bool recurse) _widget_name_find(const Evas_Object *obj, const char *name, int recurse)
{ {
Eina_List *l; Eina_List *l;
Evas_Object *child; Evas_Object *child;
const char *s; const char *s;
INTERNAL_ENTRY NULL; INTERNAL_ENTRY NULL;
void **childlist = NULL;
if (!_elm_widget_is(obj)) return NULL; if (!_elm_widget_is(obj)) return NULL;
if (sd->resize_obj) if (sd->resize_obj)
{ {
s = evas_object_name_get(sd->resize_obj); s = evas_object_name_get(sd->resize_obj);
if ((s) && (!strcmp(s, name))) return sd->resize_obj; if ((s) && (!strcmp(s, name))) return sd->resize_obj;
if ((recurse) && if ((recurse != 0) &&
((child = _widget_name_find(sd->resize_obj, name, recurse)))) ((child = _widget_name_find(sd->resize_obj, name, recurse - 1))))
return child; return child;
} }
EINA_LIST_FOREACH(sd->subobjs, l, child) EINA_LIST_FOREACH(sd->subobjs, l, child)
{ {
s = evas_object_name_get(child); s = evas_object_name_get(child);
if ((s) && (!strcmp(s, name))) return child; if ((s) && (!strcmp(s, name))) return child;
if ((recurse) && if ((recurse != 0) &&
((child = _widget_name_find(child, name, recurse)))) ((child = _widget_name_find(child, name, recurse - 1))))
return child; return child;
} }
if (sd->hover_obj) if (sd->hover_obj)
{ {
s = evas_object_name_get(sd->hover_obj); s = evas_object_name_get(sd->hover_obj);
if ((s) && (!strcmp(s, name))) return sd->hover_obj; if ((s) && (!strcmp(s, name))) return sd->hover_obj;
if ((recurse) && if ((recurse != 0) &&
((child = _widget_name_find(sd->hover_obj, name, recurse)))) ((child = _widget_name_find(sd->hover_obj, name, recurse - 1))))
return child; return child;
} }
return NULL; return NULL;
} }
EAPI Evas_Object * EAPI Evas_Object *
elm_widget_name_find(const Evas_Object *obj, const char *name, Eina_Bool recurse) elm_widget_name_find(const Evas_Object *obj, const char *name, int recurse)
{ {
API_ENTRY return NULL; API_ENTRY return NULL;
if (!name) return NULL; if (!name) return NULL;

View File

@ -412,7 +412,7 @@ EAPI void elm_widget_type_register(const char **ptr);
EAPI void elm_widget_type_unregister(const char **ptr); EAPI void elm_widget_type_unregister(const char **ptr);
EAPI Eina_Bool elm_widget_is_check(const Evas_Object *obj); EAPI Eina_Bool elm_widget_is_check(const Evas_Object *obj);
EAPI Eina_Bool elm_widget_type_check(const Evas_Object *obj, const char *type, const char *func); EAPI Eina_Bool elm_widget_type_check(const Evas_Object *obj, const char *type, const char *func);
EAPI Evas_Object *elm_widget_name_find(const Evas_Object *obj, const char *name, Eina_Bool recurse); EAPI Evas_Object *elm_widget_name_find(const Evas_Object *obj, const char *name, int recurse);
EAPI Eina_List *elm_widget_stringlist_get(const char *str); EAPI Eina_List *elm_widget_stringlist_get(const char *str);
EAPI void elm_widget_stringlist_free(Eina_List *list); EAPI void elm_widget_stringlist_free(Eina_List *list);
EAPI void elm_widget_focus_hide_handle(Evas_Object *obj); EAPI void elm_widget_focus_hide_handle(Evas_Object *obj);