summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2020-01-24 11:01:03 -0800
committerCedric BAIL <cedric.bail@free.fr>2020-01-31 10:11:39 -0800
commit2e41a13166789670602bc005a7e6a9f0815ecd77 (patch)
treed8fb7f39ce1eb441830e80a80bf704c24af00f54
parenteaeb96cc3d11b6f107aef822ef6f0fbae5ceaa03 (diff)
efl: add Efl.Model.Children_Index_Get.
This allow for fetching random children in a model. A simple fallback is provided by Efl.Loop_Model that will allow all model to provide this feature in a non optimized way. Later on this can be speeded up. Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D11185
-rw-r--r--src/lib/ecore/efl_loop_model.c36
-rw-r--r--src/lib/ecore/efl_loop_model.eo1
-rw-r--r--src/lib/efl/interfaces/efl_model.eo12
3 files changed, 49 insertions, 0 deletions
diff --git a/src/lib/ecore/efl_loop_model.c b/src/lib/ecore/efl_loop_model.c
index d3e52a63fb..88d8574285 100644
--- a/src/lib/ecore/efl_loop_model.c
+++ b/src/lib/ecore/efl_loop_model.c
@@ -108,6 +108,42 @@ _efl_loop_model_efl_model_property_ready_get(Eo *obj, void *pd EINA_UNUSED, cons
108 return efl_future_then(obj, f); 108 return efl_future_then(obj, f);
109} 109}
110 110
111static Eina_Value
112_unpack_from_array(void *data EINA_UNUSED, Eina_Value v, const Eina_Future *f EINA_UNUSED)
113{
114 Eo *object = NULL;
115
116 if (eina_value_type_get(&v) == EINA_VALUE_TYPE_ERROR) return v;
117 if (eina_value_type_get(&v) != EINA_VALUE_TYPE_ARRAY) return eina_value_error_init(EINVAL);
118 if (eina_value_array_count(&v) != 1) return eina_value_error_init(EINVAL);
119
120 eina_value_array_get(&v, 0, &object);
121
122 return eina_value_object_init(object);
123}
124
125static Eina_Future *
126_efl_loop_model_efl_model_children_index_get(Eo *obj, void *pd EINA_UNUSED, Eina_Iterator *indexes)
127{
128 Eina_Future *r;
129 Eina_Array futures;
130 unsigned int idx;
131
132 eina_array_step_set(&futures, sizeof (Eina_Array), 8);
133
134 EINA_ITERATOR_FOREACH(indexes, idx)
135 eina_array_push(&futures, eina_future_then(efl_model_children_slice_get(obj, idx, 1), _unpack_from_array, NULL));
136 eina_iterator_free(indexes);
137
138 r = efl_future_then(obj, eina_future_all_iterator(eina_array_iterator_new(&futures)),
139 .success = _efl_future_all_repack,
140 .success_type = EINA_VALUE_TYPE_ARRAY);
141
142 eina_array_flush(&futures);
143
144 return r;
145}
146
111static void 147static void
112_noref_death(void *data EINA_UNUSED, const Efl_Event *event) 148_noref_death(void *data EINA_UNUSED, const Efl_Event *event)
113{ 149{
diff --git a/src/lib/ecore/efl_loop_model.eo b/src/lib/ecore/efl_loop_model.eo
index 2285b56f1b..06af337ecf 100644
--- a/src/lib/ecore/efl_loop_model.eo
+++ b/src/lib/ecore/efl_loop_model.eo
@@ -20,5 +20,6 @@ abstract Efl.Loop_Model extends Efl.Loop_Consumer implements Efl.Model
20 Efl.Object.invalidate; 20 Efl.Object.invalidate;
21 Efl.Model.property_ready_get; 21 Efl.Model.property_ready_get;
22 Efl.Model.property { get; set; } 22 Efl.Model.property { get; set; }
23 Efl.Model.children_index_get;
23 } 24 }
24} 25}
diff --git a/src/lib/efl/interfaces/efl_model.eo b/src/lib/efl/interfaces/efl_model.eo
index ee04879f68..e669d50ade 100644
--- a/src/lib/efl/interfaces/efl_model.eo
+++ b/src/lib/efl/interfaces/efl_model.eo
@@ -141,6 +141,18 @@ interface Efl.Model
141 /* XXX: is this right? */ 141 /* XXX: is this right? */
142 return: future<array<Efl.Object>>; [[Array of children]] 142 return: future<array<Efl.Object>>; [[Array of children]]
143 } 143 }
144 children_index_get {
145 [[Get children as specified by iterator.
146
147 Provided index have to be between 0 and @.children_count.get.
148
149 This function might rely on @.children_slice_get as a fallback.
150 ]]
151 params {
152 @in indices: iterator<uint>; [[Indices of the requested children.]]
153 }
154 return: future<array<Efl.Object>>; [[Array of children]]
155 }
144 @property children_count { 156 @property children_count {
145 [[Number of children. 157 [[Number of children.
146 158