summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2019-08-15 20:45:09 -0700
committerCedric BAIL <cedric.bail@free.fr>2019-08-21 11:18:34 -0700
commit0248d504b34f5f4324102ae406b848c2c8fe28c4 (patch)
treea022986ba9a4b0f17bcb41ae4fff04ca52413762 /src
parentb8bf5b31e847194446838d32565a4c654823024b (diff)
elementary: switch Efl.Ui.Factory API to a batch API and update all class using it.
Reviewed-by: Lauro Neto <Lauro Moura <lauromoura@expertisesolutions.com.br>> Differential Revision: https://phab.enlightenment.org/D9579
Diffstat (limited to '')
-rw-r--r--src/lib/efl/Efl.h4
-rw-r--r--src/lib/efl/interfaces/efl_interfaces_main.c15
-rw-r--r--src/lib/efl/interfaces/efl_ui_factory.eo2
-rw-r--r--src/lib/elementary/efl_ui_caching_factory.c171
-rw-r--r--src/lib/elementary/efl_ui_image_factory.c15
-rw-r--r--src/lib/elementary/efl_ui_layout.c29
-rw-r--r--src/lib/elementary/efl_ui_layout_factory.c26
-rw-r--r--src/lib/elementary/efl_ui_list_view.c11
-rw-r--r--src/lib/elementary/efl_ui_widget_factory.c107
9 files changed, 266 insertions, 114 deletions
diff --git a/src/lib/efl/Efl.h b/src/lib/efl/Efl.h
index a75b683..e1cfe41 100644
--- a/src/lib/efl/Efl.h
+++ b/src/lib/efl/Efl.h
@@ -211,13 +211,13 @@ EAPI Efl_Object *efl_part(const Eo *obj, const char *name);
211 * @param[in] parent The parent of the newly created item 211 * @param[in] parent The parent of the newly created item
212 * @return A future that will resolve with the newly created item. 212 * @return A future that will resolve with the newly created item.
213 * 213 *
214 * @since 1.22 214 * @since 1.23
215 * @note This exists as we always want to trigger the event once all the logic 215 * @note This exists as we always want to trigger the event once all the logic
216 * of every factory in the chain has done what it planned to do. Basically we 216 * of every factory in the chain has done what it planned to do. Basically we
217 * want the inverse of inheritance call like efl_super. So we do setup the future 217 * want the inverse of inheritance call like efl_super. So we do setup the future
218 * in this way. 218 * in this way.
219 */ 219 */
220EAPI Eina_Future *efl_ui_view_factory_create_with_event(Efl_Ui_Factory *factory, Efl_Model *model, Efl_Gfx_Entity *parent); 220EAPI Eina_Future *efl_ui_view_factory_create_with_event(Efl_Ui_Factory *factory, Eina_Iterator *models, Efl_Gfx_Entity *parent);
221 221
222#else 222#else
223 223
diff --git a/src/lib/efl/interfaces/efl_interfaces_main.c b/src/lib/efl/interfaces/efl_interfaces_main.c
index 47c143c..4e85ab6 100644
--- a/src/lib/efl/interfaces/efl_interfaces_main.c
+++ b/src/lib/efl/interfaces/efl_interfaces_main.c
@@ -119,19 +119,22 @@ static Eina_Value
119_efl_ui_view_factory_item_created(Eo *factory, void *data EINA_UNUSED, const Eina_Value v) 119_efl_ui_view_factory_item_created(Eo *factory, void *data EINA_UNUSED, const Eina_Value v)
120{ 120{
121 Efl_Ui_Factory_Item_Created_Event event = { NULL, NULL }; 121 Efl_Ui_Factory_Item_Created_Event event = { NULL, NULL };
122 int len, i;
122 123
123 eina_value_pget(&v, &event.item); 124 EINA_VALUE_ARRAY_FOREACH(&v, len, i, event.item)
124 event.model = efl_ui_view_model_get(event.item); 125 {
126 event.model = efl_ui_view_model_get(event.item);
125 127
126 efl_event_callback_call(factory, EFL_UI_FACTORY_EVENT_CREATED, &event); 128 efl_event_callback_call(factory, EFL_UI_FACTORY_EVENT_CREATED, &event);
129 }
127 130
128 return v; 131 return v;
129} 132}
130 133
131EAPI Eina_Future * 134EAPI Eina_Future *
132efl_ui_view_factory_create_with_event(Efl_Ui_Factory *factory, Efl_Model *model, Efl_Gfx_Entity *parent) 135efl_ui_view_factory_create_with_event(Efl_Ui_Factory *factory, Eina_Iterator *models, Efl_Gfx_Entity *parent)
133{ 136{
134 return efl_future_then(factory, efl_ui_factory_create(factory, model, parent), 137 return efl_future_then(factory, efl_ui_factory_create(factory, models, parent),
135 .success_type = EINA_VALUE_TYPE_OBJECT, 138 .success_type = EINA_VALUE_TYPE_ARRAY,
136 .success = _efl_ui_view_factory_item_created); 139 .success = _efl_ui_view_factory_item_created);
137} 140}
diff --git a/src/lib/efl/interfaces/efl_ui_factory.eo b/src/lib/efl/interfaces/efl_ui_factory.eo
index e2c2ae3..38bb514 100644
--- a/src/lib/efl/interfaces/efl_ui_factory.eo
+++ b/src/lib/efl/interfaces/efl_ui_factory.eo
@@ -11,7 +11,7 @@ interface @beta Efl.Ui.Factory extends Efl.Ui.Property_Bind, Efl.Ui.Factory_Bind
11 create { 11 create {
12 [[Create a UI object from the necessary properties in the specified model.]] 12 [[Create a UI object from the necessary properties in the specified model.]]
13 params { 13 params {
14 model: Efl.Model; [[Efl model]] 14 models: iterator<Efl.Model>; [[Efl iterator providing the model to be associated to the new item. It should remain valid until the end of the function call.]]
15 parent: Efl.Gfx.Entity; [[Efl canvas]] 15 parent: Efl.Gfx.Entity; [[Efl canvas]]
16 } 16 }
17 return: future<Efl.Gfx.Entity>; [[Created UI object]] 17 return: future<Efl.Gfx.Entity>; [[Created UI object]]
diff --git a/src/lib/elementary/efl_ui_caching_factory.c b/src/lib/elementary/efl_ui_caching_factory.c
index bea7a33..a7fb277 100644
--- a/src/lib/elementary/efl_ui_caching_factory.c
+++ b/src/lib/elementary/efl_ui_caching_factory.c
@@ -7,6 +7,7 @@
7 7
8typedef struct _Efl_Ui_Caching_Factory_Data Efl_Ui_Caching_Factory_Data; 8typedef struct _Efl_Ui_Caching_Factory_Data Efl_Ui_Caching_Factory_Data;
9typedef struct _Efl_Ui_Caching_Factory_Request Efl_Ui_Caching_Factory_Request; 9typedef struct _Efl_Ui_Caching_Factory_Request Efl_Ui_Caching_Factory_Request;
10typedef struct _Efl_Ui_Caching_Factory_Group_Request Efl_Ui_Caching_Factory_Group_Request;
10 11
11struct _Efl_Ui_Caching_Factory_Data 12struct _Efl_Ui_Caching_Factory_Data
12{ 13{
@@ -31,8 +32,13 @@ struct _Efl_Ui_Caching_Factory_Request
31{ 32{
32 Efl_Ui_Caching_Factory_Data *pd; 33 Efl_Ui_Caching_Factory_Data *pd;
33 34
35 Efl_Ui_Caching_Factory *factory;
34 Eo *parent; 36 Eo *parent;
35 Efl_Model *model; 37};
38
39struct _Efl_Ui_Caching_Factory_Group_Request
40{
41 Eina_Value done;
36}; 42};
37 43
38// Clear the cache until it meet the constraint 44// Clear the cache until it meet the constraint
@@ -84,88 +90,179 @@ _efl_ui_caching_factory_flush(Eo *obj, Efl_Ui_Caching_Factory_Data *pd)
84} 90}
85 91
86static Eina_Value 92static Eina_Value
87_efl_ui_caching_factory_create_then(Eo *obj EINA_UNUSED, void *data, const Eina_Value v) 93_efl_ui_caching_factory_uncap_then(Eo *model EINA_UNUSED,
94 void *data EINA_UNUSED,
95 const Eina_Value v)
96{
97 Efl_Ui_Widget *widget = NULL;
98
99 if (eina_value_array_count(&v) != 1) return eina_value_error_init(EINVAL);
100
101 eina_value_array_get(&v, 0, &widget);
102
103 return eina_value_object_init(widget);
104}
105
106static Eina_Value
107_efl_ui_caching_factory_create_then(Eo *model, void *data, const Eina_Value v)
88{ 108{
89 Efl_Ui_Caching_Factory_Request *r = data; 109 Efl_Ui_Caching_Factory_Request *r = data;
90 Efl_Ui_Widget *w; 110 Efl_Ui_Widget *w;
91 const char *string = NULL; 111 const char *style = NULL;
92 112
93 if (!eina_value_string_get(&v, &string)) 113 if (!eina_value_string_get(&v, &style))
94 return eina_value_error_init(EFL_MODEL_ERROR_NOT_SUPPORTED); 114 return eina_value_error_init(EFL_MODEL_ERROR_NOT_SUPPORTED);
95 115
96 w = eina_hash_find(r->pd->lookup, string); 116 w = eina_hash_find(r->pd->lookup, style);
97 if (!w) 117 if (!w)
98 { 118 {
99 Eina_Future *f; 119 Eina_Future *f;
120 Eo *models[1] = { model };
100 121
101 // No object of that style in the cache, need to create a new one 122 // No object of that style in the cache, need to create a new one
102 f = efl_ui_factory_create(efl_super(obj, EFL_UI_CACHING_FACTORY_CLASS), 123 // This is not ideal, we would want to gather all the request in one swoop here,
103 r->model, r->parent); 124 // left for later improvement.
125 f = efl_ui_factory_create(efl_super(r->factory, EFL_UI_CACHING_FACTORY_CLASS),
126 EINA_C_ARRAY_ITERATOR_NEW(models), r->parent);
127 f = efl_future_then(r->factory, f,
128 .success = _efl_ui_caching_factory_uncap_then,
129 .success_type = EINA_VALUE_TYPE_ARRAY);
104 return eina_future_as_value(f); 130 return eina_future_as_value(f);
105 } 131 }
106 132
107 eina_hash_del(r->pd->lookup, string, w); 133 eina_hash_del(r->pd->lookup, style, w);
108 _efl_ui_caching_factory_remove(r->pd, r->pd->cache, w); 134 _efl_ui_caching_factory_remove(r->pd, eina_list_data_find(r->pd->cache, w), w);
109 135
110 efl_parent_set(w, r->parent); 136 efl_parent_set(w, r->parent);
111 efl_ui_view_model_set(w, r->model); 137 efl_ui_view_model_set(w, model);
112 138
113 return eina_value_object_init(w); 139 return eina_value_object_init(w);
114} 140}
115 141
116static void 142static void
117_efl_ui_caching_factory_create_cleanup(Eo *o EINA_UNUSED, void *data, const Eina_Future *dead_future EINA_UNUSED) 143_efl_ui_caching_factory_cleanup(Eo *o EINA_UNUSED, void *data, const Eina_Future *dead_future EINA_UNUSED)
118{ 144{
119 Efl_Ui_Caching_Factory_Request *r = data; 145 Efl_Ui_Caching_Factory_Request *r = data;
120 146
121 efl_unref(r->model); 147 efl_unref(r->factory);
122 efl_unref(r->parent); 148 efl_unref(r->parent);
123 free(r); 149 free(r);
124} 150}
125 151
152static Eina_Value
153_efl_ui_caching_factory_group_create_then(Eo *obj EINA_UNUSED,
154 void *data,
155 const Eina_Value v)
156{
157 Efl_Ui_Caching_Factory_Group_Request *gr = data;
158 int len, i;
159 Efl_Ui_Widget *widget;
160
161 EINA_VALUE_ARRAY_FOREACH(&v, len, i, widget)
162 eina_value_array_append(&gr->done, widget);
163
164 return eina_value_reference_copy(&gr->done);
165}
166
167static void
168_efl_ui_caching_factory_group_cleanup(Eo *o EINA_UNUSED, void *data, const Eina_Future *dead_future EINA_UNUSED)
169{
170 Efl_Ui_Caching_Factory_Group_Request *gr = data;
171
172 eina_value_flush(&gr->done);
173 free(gr);
174}
175
126static Eina_Future * 176static Eina_Future *
127_efl_ui_caching_factory_efl_ui_factory_create(Eo *obj, 177_efl_ui_caching_factory_efl_ui_factory_create(Eo *obj,
128 Efl_Ui_Caching_Factory_Data *pd, 178 Efl_Ui_Caching_Factory_Data *pd,
129 Efl_Model *model, Efl_Gfx_Entity *parent) 179 Eina_Iterator *models, Efl_Gfx_Entity *parent)
130{ 180{
181 Efl_Ui_Caching_Factory_Group_Request *gr;
131 Efl_Gfx_Entity *w = NULL; 182 Efl_Gfx_Entity *w = NULL;
183 Efl_Model *model;
184 Eina_Future *f;
132 185
133 if (pd->cache) 186 if (pd->cache && pd->style && !pd->klass)
134 { 187 {
135 if (pd->style && !pd->klass) 188 Efl_Ui_Caching_Factory_Request *r;
136 { 189 Eina_Future **all;
137 Efl_Ui_Caching_Factory_Request *r; 190 int count = 0;
138 191
139 r = calloc(1, sizeof (Efl_Ui_Caching_Factory_Request)); 192 r = calloc(1, sizeof (Efl_Ui_Caching_Factory_Request));
140 if (!r) return efl_loop_future_rejected(obj, ENOMEM); 193 if (!r) return efl_loop_future_rejected(obj, ENOMEM);
141 194
142 r->pd = pd; 195 r->pd = pd;
143 r->parent = efl_ref(parent); 196 r->parent = efl_ref(parent);
144 r->model = efl_ref(model); 197 r->factory = efl_ref(obj);
145 198
146 return efl_future_then(obj, efl_model_property_ready_get(obj, pd->style), 199 all = calloc(1, sizeof (Eina_Future *));
147 .success = _efl_ui_caching_factory_create_then, 200 if (!all) return efl_loop_future_rejected(obj, ENOMEM);
148 .data = r,
149 .free = _efl_ui_caching_factory_create_cleanup);
150 }
151 201
152 w = eina_list_data_get(pd->cache); 202 EINA_ITERATOR_FOREACH(models, model)
203 {
204 all[count++] = efl_future_then(model,
205 efl_model_property_ready_get(model, pd->style),
206 .success = _efl_ui_caching_factory_create_then,
207 .data = r);
153 208
154 _efl_ui_caching_factory_remove(pd, pd->cache, w); 209 all = realloc(all, (count + 1) * sizeof (Eina_Future *));
210 if (!all) return efl_loop_future_rejected(obj, ENOMEM);
211 }
212 eina_iterator_free(models);
155 213
156 efl_parent_set(w, parent); 214 all[count] = EINA_FUTURE_SENTINEL;
215
216 return efl_future_then(obj, eina_future_all_array(all),
217 .data = r,
218 .free = _efl_ui_caching_factory_cleanup);
157 } 219 }
158 220
159 if (!w) 221 gr = calloc(1, sizeof (Efl_Ui_Caching_Factory_Group_Request));
222 if (!gr) return efl_loop_future_rejected(obj, ENOMEM);
223
224 eina_value_array_setup(&gr->done, EINA_VALUE_TYPE_OBJECT, 4);
225
226 // First get as much object from the cache as possible
227 if (pd->cache)
228 EINA_ITERATOR_FOREACH(models, model)
229 {
230 w = eina_list_data_get(pd->cache);
231 _efl_ui_caching_factory_remove(pd, pd->cache, w);
232 efl_parent_set(w, parent);
233
234 efl_ui_view_model_set(w, model);
235
236 eina_value_array_append(&gr->done, w);
237
238 if (!pd->cache) break;
239 }
240
241 // Now create object on the fly that are missing from the cache
242 if (pd->klass)
160 { 243 {
161 if (pd->klass) w = efl_add(pd->klass, parent); 244 EINA_ITERATOR_FOREACH(models, model)
162 else return efl_ui_factory_create(efl_super(obj, EFL_UI_CACHING_FACTORY_CLASS), 245 {
163 model, parent); 246 w = efl_add(pd->klass, parent,
164 } 247 efl_ui_view_model_set(efl_added, model));
248 eina_value_array_append(&gr->done, w);
249 }
165 250
166 efl_ui_view_model_set(w, model); 251 f = efl_loop_future_resolved(obj, gr->done);
252
253 eina_value_flush(&gr->done);
254 free(gr);
255
256 return f;
257 }
167 258
168 return efl_loop_future_resolved(obj, eina_value_object_init(w)); 259 f = efl_ui_factory_create(efl_super(obj, EFL_UI_CACHING_FACTORY_CLASS),
260 models, parent);
261 return efl_future_then(obj, f,
262 .success = _efl_ui_caching_factory_group_create_then,
263 .success_type = EINA_VALUE_TYPE_ARRAY,
264 .data = gr,
265 .free = _efl_ui_caching_factory_group_cleanup);
169} 266}
170 267
171static void 268static void
diff --git a/src/lib/elementary/efl_ui_image_factory.c b/src/lib/elementary/efl_ui_image_factory.c
index 9bf9f39..4ea556e 100644
--- a/src/lib/elementary/efl_ui_image_factory.c
+++ b/src/lib/elementary/efl_ui_image_factory.c
@@ -36,28 +36,29 @@ _efl_ui_image_factory_efl_object_destructor(Eo *obj EINA_UNUSED, Efl_Ui_Image_Fa
36static Eina_Value 36static Eina_Value
37_efl_ui_image_factory_bind(Eo *obj EINA_UNUSED, void *data, const Eina_Value value) 37_efl_ui_image_factory_bind(Eo *obj EINA_UNUSED, void *data, const Eina_Value value)
38{ 38{
39 Efl_Gfx_Entity *entity = NULL;
40 Efl_Ui_Image_Factory_Data *pd = data; 39 Efl_Ui_Image_Factory_Data *pd = data;
40 Efl_Gfx_Entity *entity;
41 int len, i;
41 42
42 eina_value_pget(&value, &entity); 43 EINA_VALUE_ARRAY_FOREACH(&value, len, i, entity)
43 44 efl_ui_property_bind(entity, "filename", pd->property);
44 efl_ui_property_bind(entity, "filename", pd->property);
45 45
46 return value; 46 return value;
47} 47}
48 48
49EOLIAN static Eina_Future * 49EOLIAN static Eina_Future *
50_efl_ui_image_factory_efl_ui_factory_create(Eo *obj, Efl_Ui_Image_Factory_Data *pd, Efl_Model *model, Efl_Gfx_Entity *parent) 50_efl_ui_image_factory_efl_ui_factory_create(Eo *obj, Efl_Ui_Image_Factory_Data *pd,
51 Eina_Iterator *models, Efl_Gfx_Entity *parent)
51{ 52{
52 Eina_Future *f; 53 Eina_Future *f;
53 54
54 if (!parent) return efl_loop_future_rejected(obj, EFL_FACTORY_ERROR_NOT_SUPPORTED); 55 if (!parent) return efl_loop_future_rejected(obj, EFL_FACTORY_ERROR_NOT_SUPPORTED);
55 if (!pd->property) return efl_loop_future_rejected(obj, EFL_FACTORY_ERROR_NOT_SUPPORTED); 56 if (!pd->property) return efl_loop_future_rejected(obj, EFL_FACTORY_ERROR_NOT_SUPPORTED);
56 57
57 f = efl_ui_factory_create(efl_super(obj, EFL_UI_IMAGE_FACTORY_CLASS), model, parent); 58 f = efl_ui_factory_create(efl_super(obj, EFL_UI_IMAGE_FACTORY_CLASS), models, parent);
58 59
59 return efl_future_then(obj, f, 60 return efl_future_then(obj, f,
60 .success_type = EINA_VALUE_TYPE_OBJECT, 61 .success_type = EINA_VALUE_TYPE_ARRAY,
61 .success = _efl_ui_image_factory_bind, 62 .success = _efl_ui_image_factory_bind,
62 .data = pd); 63 .data = pd);
63} 64}
diff --git a/src/lib/elementary/efl_ui_layout.c b/src/lib/elementary/efl_ui_layout.c
index 224ca32..5ae0403 100644
--- a/src/lib/elementary/efl_ui_layout.c
+++ b/src/lib/elementary/efl_ui_layout.c
@@ -2184,15 +2184,17 @@ _content_created(Eo *obj, void *data, const Eina_Value value)
2184 Efl_Ui_Layout_Factory_Request *request = data; 2184 Efl_Ui_Layout_Factory_Request *request = data;
2185 Efl_Gfx_Entity *content = NULL; 2185 Efl_Gfx_Entity *content = NULL;
2186 Efl_Gfx_Entity *old_content; 2186 Efl_Gfx_Entity *old_content;
2187 int len, i;
2187 2188
2188 eina_value_get(&value, &content); 2189 EINA_VALUE_ARRAY_FOREACH(&value, len, i, content)
2189 2190 {
2190 // Recycle old content 2191 // Recycle old content
2191 old_content = efl_content_get(efl_part(obj, request->key)); 2192 old_content = efl_content_get(efl_part(obj, request->key));
2192 if (old_content) efl_ui_factory_release(request->factory, old_content); 2193 if (old_content) efl_ui_factory_release(request->factory, old_content);
2193 2194
2194 // Set new content 2195 // Set new content
2195 efl_content_set(efl_part(obj, request->key), content); 2196 efl_content_set(efl_part(obj, request->key), content);
2197 }
2196 2198
2197 return value; 2199 return value;
2198} 2200}
@@ -2211,10 +2213,11 @@ _clean_request(Eo *obj EINA_UNUSED, void *data, const Eina_Future *dead_future E
2211static void 2213static void
2212_efl_ui_layout_view_model_content_update(Efl_Ui_Layout_Data *pd, Efl_Ui_Layout_Factory_Tracking *tracking, const char *key) 2214_efl_ui_layout_view_model_content_update(Efl_Ui_Layout_Data *pd, Efl_Ui_Layout_Factory_Tracking *tracking, const char *key)
2213{ 2215{
2214 Efl_Ui_Layout_Factory_Request *request = calloc(1, sizeof (Efl_Ui_Layout_Factory_Request)); 2216 Efl_Ui_Layout_Factory_Request *request;
2215 Eina_Future *f; 2217 Eina_Future *f;
2216 Efl_Model *model; 2218 Efl_Model *models[1];
2217 2219
2220 request = calloc(1, sizeof (Efl_Ui_Layout_Factory_Request));
2218 if (!request) return ; 2221 if (!request) return ;
2219 2222
2220 if (tracking->in_flight) eina_future_cancel(tracking->in_flight); 2223 if (tracking->in_flight) eina_future_cancel(tracking->in_flight);
@@ -2224,11 +2227,13 @@ _efl_ui_layout_view_model_content_update(Efl_Ui_Layout_Data *pd, Efl_Ui_Layout_F
2224 request->factory = efl_ref(tracking->factory); 2227 request->factory = efl_ref(tracking->factory);
2225 request->tracking = tracking; 2228 request->tracking = tracking;
2226 2229
2227 model = efl_ui_view_model_get(pd->obj); 2230 models[0] = efl_ui_view_model_get(pd->obj);
2228 f = efl_ui_view_factory_create_with_event(tracking->factory, model, pd->obj); 2231 f = efl_ui_view_factory_create_with_event(tracking->factory,
2232 EINA_C_ARRAY_ITERATOR_NEW(models),
2233 pd->obj);
2229 f = efl_future_then(pd->obj, f, 2234 f = efl_future_then(pd->obj, f,
2230 .success = _content_created, 2235 .success = _content_created,
2231 .success_type = EINA_VALUE_TYPE_OBJECT, 2236 .success_type = EINA_VALUE_TYPE_ARRAY,
2232 .data = request, 2237 .data = request,
2233 .free = _clean_request); 2238 .free = _clean_request);
2234} 2239}
diff --git a/src/lib/elementary/efl_ui_layout_factory.c b/src/lib/elementary/efl_ui_layout_factory.c
index 310bc52..4ab6d19 100644
--- a/src/lib/elementary/efl_ui_layout_factory.c
+++ b/src/lib/elementary/efl_ui_layout_factory.c
@@ -73,30 +73,32 @@ _efl_ui_layout_factory_bind(Eo *obj EINA_UNUSED, void *data, const Eina_Value va
73{ 73{
74 Efl_Ui_Layout_Factory_Data *pd = data; 74 Efl_Ui_Layout_Factory_Data *pd = data;
75 Efl_Gfx_Entity *layout; 75 Efl_Gfx_Entity *layout;
76 int len, i;
76 77
77 eina_value_pget(&value, &layout); 78 EINA_VALUE_ARRAY_FOREACH(&value, len, i, layout)
78 79 {
79 efl_ui_layout_theme_set(layout, pd->klass, pd->group, pd->style); 80 efl_ui_layout_theme_set(layout, pd->klass, pd->group, pd->style);
80 81
81 eina_hash_foreach(pd->bind.properties, _property_bind, layout); 82 eina_hash_foreach(pd->bind.properties, _property_bind, layout);
82 eina_hash_foreach(pd->bind.factories, _factory_bind, layout); 83 eina_hash_foreach(pd->bind.factories, _factory_bind, layout);
83 84
84 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, 0); 85 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, 0);
85 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); 86 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
87 }
86 88
87 return value; 89 return value;
88} 90}
89 91
90EOLIAN static Eina_Future * 92EOLIAN static Eina_Future *
91_efl_ui_layout_factory_efl_ui_factory_create(Eo *obj, Efl_Ui_Layout_Factory_Data *pd, 93_efl_ui_layout_factory_efl_ui_factory_create(Eo *obj, Efl_Ui_Layout_Factory_Data *pd,
92 Efl_Model *model, Efl_Gfx_Entity *parent) 94 Eina_Iterator *models, Efl_Gfx_Entity *parent)
93{ 95{
94 Eina_Future *f; 96 Eina_Future *f;
95 97
96 f = efl_ui_factory_create(efl_super(obj, EFL_UI_LAYOUT_FACTORY_CLASS), model, parent); 98 f = efl_ui_factory_create(efl_super(obj, EFL_UI_LAYOUT_FACTORY_CLASS), models, parent);
97 99
98 return efl_future_then(obj, f, 100 return efl_future_then(obj, f,
99 .success_type = EINA_VALUE_TYPE_OBJECT, 101 .success_type = EINA_VALUE_TYPE_ARRAY,
100 .success = _efl_ui_layout_factory_bind, 102 .success = _efl_ui_layout_factory_bind,
101 .data = pd); 103 .data = pd);
102} 104}
@@ -148,8 +150,8 @@ _efl_ui_layout_factory_efl_ui_property_bind_property_bind(Eo *obj EINA_UNUSED, E
148} 150}
149 151
150EOLIAN static void 152EOLIAN static void
151_efl_ui_layout_factory_theme_config(Eo *obj EINA_UNUSED, Efl_Ui_Layout_Factory_Data *pd 153_efl_ui_layout_factory_theme_config(Eo *obj EINA_UNUSED, Efl_Ui_Layout_Factory_Data *pd,
152 , const char *klass, const char *group, const char *style) 154 const char *klass, const char *group, const char *style)
153{ 155{
154 eina_stringshare_replace(&pd->klass, klass); 156 eina_stringshare_replace(&pd->klass, klass);
155 eina_stringshare_replace(&pd->group, group); 157 eina_stringshare_replace(&pd->group, group);
diff --git a/src/lib/elementary/efl_ui_list_view.c b/src/lib/elementary/efl_ui_list_view.c
index 7881285..4f8495f 100644
--- a/src/lib/elementary/efl_ui_list_view.c
+++ b/src/lib/elementary/efl_ui_list_view.c
@@ -904,7 +904,8 @@ _content_created(Eo *obj, void *data, const Eina_Value value)
904 Efl_Ui_List_View_Layout_Item *item = tracking->item; 904 Efl_Ui_List_View_Layout_Item *item = tracking->item;
905 Efl_Ui_List_View_Item_Event evt; 905 Efl_Ui_List_View_Item_Event evt;
906 906
907 eina_value_pget(&value, &item->layout); 907 if (eina_value_array_count(&value) != 1) return eina_value_error_init(EINVAL);
908 eina_value_array_get(&value, 0, &item->layout);
908 909
909 evas_object_smart_member_add(item->layout, tracking->pd->pan_obj); 910 evas_object_smart_member_add(item->layout, tracking->pd->pan_obj);
910 evas_object_event_callback_add(item->layout, EVAS_CALLBACK_MOUSE_UP, _on_item_mouse_up, item); 911 evas_object_event_callback_add(item->layout, EVAS_CALLBACK_MOUSE_UP, _on_item_mouse_up, item);
@@ -942,6 +943,7 @@ EOLIAN static Efl_Ui_List_View_Layout_Item *
942_efl_ui_list_view_efl_ui_list_view_model_realize(Eo *obj, Efl_Ui_List_View_Data *pd, Efl_Ui_List_View_Layout_Item *item) 943_efl_ui_list_view_efl_ui_list_view_model_realize(Eo *obj, Efl_Ui_List_View_Data *pd, Efl_Ui_List_View_Layout_Item *item)
943{ 944{
944 Efl_Ui_List_View_Layout_Item_Tracking *tracking; 945 Efl_Ui_List_View_Layout_Item_Tracking *tracking;
946 Efl_Model *childrens[1];
945 EINA_SAFETY_ON_NULL_RETURN_VAL(item->children, item); 947 EINA_SAFETY_ON_NULL_RETURN_VAL(item->children, item);
946 948
947 if (!item->children) return item; 949 if (!item->children) return item;
@@ -953,11 +955,14 @@ _efl_ui_list_view_efl_ui_list_view_model_realize(Eo *obj, Efl_Ui_List_View_Data
953 955
954 tracking->item = item; 956 tracking->item = item;
955 tracking->pd = pd; 957 tracking->pd = pd;
958 childrens[0] = item->children;
956 959
957 item->layout_request = efl_ui_view_factory_create_with_event(pd->factory, item->children, obj); 960 item->layout_request = efl_ui_view_factory_create_with_event(pd->factory,
961 EINA_C_ARRAY_ITERATOR_NEW(childrens),
962 obj);
958 item->layout_request = efl_future_then(obj, item->layout_request, 963 item->layout_request = efl_future_then(obj, item->layout_request,
959 .success = _content_created, 964 .success = _content_created,
960 .success_type = EINA_VALUE_TYPE_OBJECT, 965 .success_type = EINA_VALUE_TYPE_ARRAY,
961 .data = tracking, 966 .data = tracking,
962 .free = _clean_request); 967 .free = _clean_request);
963 968
diff --git a/src/lib/elementary/efl_ui_widget_factory.c b/src/lib/elementary/efl_ui_widget_factory.c
index 371b819..1ae33b2 100644
--- a/src/lib/elementary/efl_ui_widget_factory.c
+++ b/src/lib/elementary/efl_ui_widget_factory.c
@@ -40,7 +40,6 @@ struct _Efl_Ui_Widget_Factory_Request
40{ 40{
41 Efl_Ui_Widget_Factory_Data *pd; 41 Efl_Ui_Widget_Factory_Data *pd;
42 Eo *parent; 42 Eo *parent;
43 Efl_Model *model;
44}; 43};
45 44
46static void 45static void
@@ -67,58 +66,74 @@ _efl_ui_widget_factory_item_class_get(const Eo *obj EINA_UNUSED,
67 return pd->klass; 66 return pd->klass;
68} 67}
69 68
70static Eina_Value 69static Efl_Ui_Widget *
71_efl_ui_widget_factory_create_then(Eo *obj EINA_UNUSED, void *data, const Eina_Value v) 70_efl_ui_widget_create(const Efl_Class *klass, Eo *parent,
71 const char *style, Efl_Model *model,
72 const Eina_Hash *parts)
72{ 73{
73 Efl_Ui_Widget_Factory_Request *r = data; 74 Efl_Ui_Bind_Part_Data *bpd;
75 Eina_Iterator *it;
74 Efl_Ui_Widget *w; 76 Efl_Ui_Widget *w;
75 const char *string = NULL;
76 77
77 if (!eina_value_string_get(&v, &string)) 78 w = efl_add(klass, parent,
78 return eina_value_error_init(EFL_MODEL_ERROR_NOT_SUPPORTED); 79 style ? efl_ui_widget_style_set(efl_added, style) : (void) 0,
79 80 efl_ui_view_model_set(efl_added, model));
80 w = efl_add(r->pd->klass, r->parent, 81 if (!parts) return w;
81 efl_ui_widget_style_set(efl_added, string),
82 efl_ui_view_model_set(efl_added, r->model));
83 82
84 if (r->pd->parts) 83 it = eina_hash_iterator_data_new(parts);
84 EINA_ITERATOR_FOREACH(it, bpd)
85 { 85 {
86 Efl_Ui_Bind_Part_Data *bpd; 86 Efl_Ui_Property_Bind_Data *bppd;
87 Eina_Iterator *it; 87 Eina_List *l;
88 88
89 it = eina_hash_iterator_data_new(r->pd->parts); 89 EINA_LIST_FOREACH(bpd->properties, l, bppd)
90 efl_ui_property_bind(efl_part(w, bpd->part),
91 bppd->part_property,
92 bppd->model_property);
93 }
94 eina_iterator_free(it);
90 95
91 EINA_ITERATOR_FOREACH(it, bpd) 96 return w;
92 { 97}
93 Efl_Ui_Property_Bind_Data *bppd;
94 Eina_List *l;
95 98
96 EINA_LIST_FOREACH(bpd->properties, l, bppd) 99static Eina_Value
97 efl_ui_property_bind(efl_part(w, bpd->part), 100_efl_ui_widget_factory_create_then(Eo *model, void *data, const Eina_Value v)
98 bppd->part_property, 101{
99 bppd->model_property); 102 Efl_Ui_Widget_Factory_Request *r = data;
100 } 103 Efl_Ui_Widget *w;
101 eina_iterator_free(it); 104 const char *string = NULL;
102 }
103 105
106 if (!eina_value_string_get(&v, &string))
107 return eina_value_error_init(EFL_MODEL_ERROR_NOT_SUPPORTED);
108
109 w = _efl_ui_widget_create(r->pd->klass, r->parent, string, model, r->pd->parts);
110 if (!w) return eina_value_error_init(ENOMEM);
104 return eina_value_object_init(w); 111 return eina_value_object_init(w);
105} 112}
106 113
107static void 114static void
115_efl_ui_widget_factory_single_cleanup(Eo *model, void *data EINA_UNUSED, const Eina_Future *dead_future EINA_UNUSED)
116{
117 efl_unref(model);
118}
119
120static void
108_efl_ui_widget_factory_create_cleanup(Eo *o EINA_UNUSED, void *data, const Eina_Future *dead_future EINA_UNUSED) 121_efl_ui_widget_factory_create_cleanup(Eo *o EINA_UNUSED, void *data, const Eina_Future *dead_future EINA_UNUSED)
109{ 122{
110 Efl_Ui_Widget_Factory_Request *r = data; 123 Efl_Ui_Widget_Factory_Request *r = data;
111 124
112 efl_unref(r->model);
113 efl_unref(r->parent); 125 efl_unref(r->parent);
114 free(r); 126 free(r);
115} 127}
116 128
117static Eina_Future * 129static Eina_Future *
118_efl_ui_widget_factory_efl_ui_factory_create(Eo *obj, Efl_Ui_Widget_Factory_Data *pd, 130_efl_ui_widget_factory_efl_ui_factory_create(Eo *obj, Efl_Ui_Widget_Factory_Data *pd,
119 Efl_Model *model, Efl_Gfx_Entity *parent) 131 Eina_Iterator *models, Efl_Gfx_Entity *parent)
120{ 132{
121 Efl_Ui_Widget_Factory_Request *r; 133 Efl_Ui_Widget_Factory_Request *r;
134 Eina_Future **f;
135 Efl_Model *model;
136 int count = 0;
122 137
123 if (!pd->klass) 138 if (!pd->klass)
124 return efl_loop_future_rejected(obj, EFL_MODEL_ERROR_INCORRECT_VALUE); 139 return efl_loop_future_rejected(obj, EFL_MODEL_ERROR_INCORRECT_VALUE);
@@ -126,10 +141,20 @@ _efl_ui_widget_factory_efl_ui_factory_create(Eo *obj, Efl_Ui_Widget_Factory_Data
126 if (!pd->style) 141 if (!pd->style)
127 { 142 {
128 Efl_Ui_Widget *w; 143 Efl_Ui_Widget *w;
144 Eina_Value r;
145
146 eina_value_array_setup(&r, EINA_VALUE_TYPE_OBJECT, 4);
147
148 EINA_ITERATOR_FOREACH(models, model)
149 {
150 w = _efl_ui_widget_create(pd->klass, parent, NULL, model, pd->parts);
151
152 if (!w) return efl_loop_future_rejected(obj, ENOMEM);
153 eina_value_array_append(&r, w);
154 }
155 eina_iterator_free(models);
129 156
130 w = efl_add(pd->klass, parent, 157 return efl_loop_future_resolved(obj, r);
131 efl_ui_view_model_set(efl_added, model));
132 return efl_loop_future_resolved(obj, eina_value_object_init(w));
133 } 158 }
134 159
135 r = calloc(1, sizeof (Efl_Ui_Widget_Factory_Request)); 160 r = calloc(1, sizeof (Efl_Ui_Widget_Factory_Request));
@@ -137,10 +162,24 @@ _efl_ui_widget_factory_efl_ui_factory_create(Eo *obj, Efl_Ui_Widget_Factory_Data
137 162
138 r->pd = pd; 163 r->pd = pd;
139 r->parent = efl_ref(parent); 164 r->parent = efl_ref(parent);
140 r->model = efl_ref(model);
141 165
142 return efl_future_then(obj, efl_model_property_ready_get(obj, pd->style), 166 f = calloc(count + 1, sizeof (Eina_Future *));
143 .success = _efl_ui_widget_factory_create_then, 167 if (!f) return efl_loop_future_rejected(obj, ENOMEM);
168
169 EINA_ITERATOR_FOREACH(models, model)
170 {
171 f[count++] = efl_future_then(efl_ref(model), efl_model_property_ready_get(model, pd->style),
172 .success = _efl_ui_widget_factory_create_then,
173 .free = _efl_ui_widget_factory_single_cleanup);
174
175 f = realloc(f, (count + 1) * sizeof (Eina_Future *));
176 if (!f) return efl_loop_future_rejected(obj, ENOMEM);
177 }
178 eina_iterator_free(models);
179
180 f[count] = EINA_FUTURE_SENTINEL;
181
182 return efl_future_then(obj, eina_future_all_array(f),
144 .data = r, 183 .data = r,
145 .free = _efl_ui_widget_factory_create_cleanup); 184 .free = _efl_ui_widget_factory_create_cleanup);
146} 185}