summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lib/edje/edje_util.c76
-rw-r--r--src/lib/edje/efl_canvas_layout.eo2
-rw-r--r--src/tests/edje/edje_test_swallow.c34
3 files changed, 112 insertions, 0 deletions
diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c
index f9fac775ee..4f27839066 100644
--- a/src/lib/edje/edje_util.c
+++ b/src/lib/edje/edje_util.c
@@ -3397,6 +3397,82 @@ _efl_canvas_layout_efl_container_content_remove(Eo *obj EINA_UNUSED, Edje *ed, E
3397 return EINA_TRUE; 3397 return EINA_TRUE;
3398} 3398}
3399 3399
3400typedef struct _Content_Part_Iterator Content_Part_Iterator;
3401struct _Content_Part_Iterator
3402{
3403 Eina_Iterator iterator;
3404 Eo *object;
3405 Edje *ed;
3406 unsigned index;
3407};
3408
3409static Eina_Bool
3410_content_part_iterator_next(Content_Part_Iterator *it, void **data)
3411{
3412 for (; it->index < it->ed->table_parts_size; it->index++)
3413 {
3414 Edje_Real_Part *rp = it->ed->table_parts[it->index];
3415 if (rp->part && rp->part->type == EDJE_PART_TYPE_SWALLOW)
3416 {
3417 if (data) *data = (void*) rp->typedata.swallow->swallowed_object;
3418 it->index++;
3419 return EINA_TRUE;
3420 }
3421 }
3422
3423 return EINA_FALSE;
3424}
3425
3426static Eo *
3427_content_part_iterator_get_container(Content_Part_Iterator *it)
3428{
3429 return it->object;
3430}
3431
3432static void
3433_content_part_iterator_free(Content_Part_Iterator *it)
3434{
3435 free(it);
3436}
3437
3438EOLIAN Eina_Iterator*
3439_efl_canvas_layout_efl_container_content_iterate(Eo *obj, Edje *ed)
3440{
3441 Content_Part_Iterator *it;
3442
3443 it = calloc(1, sizeof(*it));
3444 if (!it) return NULL;
3445
3446 EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
3447
3448 it->iterator.version = EINA_ITERATOR_VERSION;
3449 it->iterator.next = FUNC_ITERATOR_NEXT(_content_part_iterator_next);
3450 it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_content_part_iterator_get_container);
3451 it->iterator.free = FUNC_ITERATOR_FREE(_content_part_iterator_free);
3452 it->object = obj;
3453 it->ed = ed;
3454 it->index = 0;
3455
3456 return &it->iterator;
3457}
3458
3459EOLIAN int
3460_efl_canvas_layout_efl_container_content_count(Eo *obj EINA_UNUSED, Edje *pd)
3461{
3462 Edje_Real_Part *rp;
3463 int result = 0;
3464
3465 for (int i = 0; i < pd->table_parts_size; ++i)
3466 {
3467 rp = pd->table_parts[i];
3468 if (rp->part && rp->part->type == EDJE_PART_TYPE_SWALLOW)
3469 result ++;
3470 }
3471
3472 return result;
3473}
3474
3475
3400Efl_Gfx_Entity * 3476Efl_Gfx_Entity *
3401_edje_efl_content_content_get(Edje *ed, const char *part) 3477_edje_efl_content_content_get(Edje *ed, const char *part)
3402{ 3478{
diff --git a/src/lib/edje/efl_canvas_layout.eo b/src/lib/edje/efl_canvas_layout.eo
index f607e81408..e4f4f6fa8d 100644
--- a/src/lib/edje/efl_canvas_layout.eo
+++ b/src/lib/edje/efl_canvas_layout.eo
@@ -116,6 +116,8 @@ class Efl.Canvas.Layout extends Efl.Canvas.Group implements Efl.File, Efl.Contai
116 Efl.File.load_error { get; } 116 Efl.File.load_error { get; }
117 Efl.File.mmap { get; set; } 117 Efl.File.mmap { get; set; }
118 Efl.Container.content_remove; 118 Efl.Container.content_remove;
119 Efl.Container.content_iterate;
120 Efl.Container.content_count;
119 Efl.Part.part_get; [[Returns @Efl.Canvas.Layout_Part]] 121 Efl.Part.part_get; [[Returns @Efl.Canvas.Layout_Part]]
120 Efl.Observer.update; 122 Efl.Observer.update;
121 Efl.Player.playable { get; } 123 Efl.Player.playable { get; }
diff --git a/src/tests/edje/edje_test_swallow.c b/src/tests/edje/edje_test_swallow.c
index bce0989399..0d08951fcd 100644
--- a/src/tests/edje/edje_test_swallow.c
+++ b/src/tests/edje/edje_test_swallow.c
@@ -123,6 +123,39 @@ EFL_START_TEST(edje_test_swallows_eoapi)
123} 123}
124EFL_END_TEST 124EFL_END_TEST
125 125
126EFL_START_TEST(edje_test_swallows_container_api)
127{
128 Evas *evas = _setup_evas();
129 Evas_Object *ly, *o1;
130
131 ly = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas);
132 fail_unless(edje_object_file_set(ly, test_layout_get("test_swallows.edj"), "test_group"));
133
134 fail_unless(edje_object_part_exists(ly, "swallow"));
135
136 o1 = efl_add(EFL_CANVAS_LAYOUT_CLASS, ly);
137 fail_if(!efl_content_set(efl_part(ly, "swallow"), o1));
138
139 ck_assert_int_eq(efl_content_count(ly), 1);
140
141 {
142 Eina_Array *arr = eina_array_new(1);
143 Eina_Iterator *iter = efl_content_iterate(ly);
144 Eo *content;
145
146 EINA_ITERATOR_FOREACH(iter, content)
147 {
148 eina_array_push(arr, content);
149 }
150
151 ck_assert_int_eq(eina_array_count(arr), 1);
152 ck_assert_ptr_eq(eina_array_data_get(arr, 0), o1);
153 eina_array_free(arr);
154 }
155
156 evas_free(evas);
157}
158EFL_END_TEST
126 159
127void edje_test_swallow(TCase *tc) 160void edje_test_swallow(TCase *tc)
128{ 161{
@@ -130,4 +163,5 @@ void edje_test_swallow(TCase *tc)
130 tcase_add_test(tc, edje_test_swallows_lifetime); 163 tcase_add_test(tc, edje_test_swallows_lifetime);
131 tcase_add_test(tc, edje_test_swallows_invalidate); 164 tcase_add_test(tc, edje_test_swallows_invalidate);
132 tcase_add_test(tc, edje_test_swallows_eoapi); 165 tcase_add_test(tc, edje_test_swallows_eoapi);
166 tcase_add_test(tc, edje_test_swallows_container_api);
133} 167}