forked from enlightenment/efl
eo base - add loop_get for base class
base class objects will ask their parent object to get the loop. this means it recurses all objects regardless of type until it finds an object that returns a proper loop object - eg a loop object returns itself, a window, gfx/ui object returns the mainloop object etc. etc. @feature
This commit is contained in:
parent
9551867c52
commit
26b5eb8a26
|
@ -137,6 +137,24 @@ abstract Eo.Base ()
|
|||
finalized: bool;
|
||||
}
|
||||
}
|
||||
@property loop {
|
||||
[[The owning loop object.
|
||||
|
||||
Objects that have anything to do with I/O, time based events
|
||||
or anything async should have an owining loop. They will ask
|
||||
their parent for the owning loop and iterate until the
|
||||
toplevel/root object. The root object should be a loop object
|
||||
which will return itself. Some objects may shortcut this
|
||||
and be fixed to live in only a single loop. Either way all
|
||||
you need to do is get the loop for an object and use that
|
||||
for I/O, timing etc. needs.
|
||||
]]
|
||||
get {
|
||||
}
|
||||
values {
|
||||
obj: Eo.Base *; [[ XXX: this should be Efl.Loop *; ]]
|
||||
}
|
||||
}
|
||||
constructor {
|
||||
[[Call the object's constructor.
|
||||
|
||||
|
|
|
@ -682,6 +682,14 @@ _eo_base_finalized_get(Eo *obj_id, Eo_Base_Data *pd EINA_UNUSED)
|
|||
return obj->finalized;
|
||||
}
|
||||
|
||||
// XXX: this should be Efl_Loop *;
|
||||
EOLIAN static Eo_Base *
|
||||
_eo_base_loop_get(Eo *obj EINA_UNUSED, Eo_Base_Data *pd)
|
||||
{
|
||||
if (!pd->parent) return eo_loop_get(pd->parent);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Children accessor */
|
||||
typedef struct _Eo_Children_Iterator Eo_Children_Iterator;
|
||||
struct _Eo_Children_Iterator
|
||||
|
|
|
@ -1139,6 +1139,23 @@ START_TEST(eo_comment)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(eo_loop)
|
||||
{
|
||||
eo_init();
|
||||
Eo *obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
Eo *obj2 = eo_add(SIMPLE_CLASS, NULL);
|
||||
Eo *objtmp;
|
||||
|
||||
eo_parent_set(obj2, obj);
|
||||
objtmp = eo_loop_get(obj2);
|
||||
fail_if(NULL != objtmp);
|
||||
|
||||
eo_del(obj);
|
||||
|
||||
eo_shutdown();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
void eo_test_general(TCase *tc)
|
||||
{
|
||||
tcase_add_test(tc, eo_simple);
|
||||
|
@ -1159,4 +1176,5 @@ void eo_test_general(TCase *tc)
|
|||
tcase_add_test(tc, eo_del_intercept);
|
||||
tcase_add_test(tc, eo_name);
|
||||
tcase_add_test(tc, eo_comment);
|
||||
tcase_add_test(tc, eo_loop);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue