summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2018-12-07 15:51:09 -0800
committerCedric BAIL <cedric@osg.samsung.com>2018-12-20 10:44:41 -0800
commitb992cc479e35a398e15f73439eb802127cb45cc7 (patch)
tree2f0134c2704fca0461ab18e51e63be29769c5388
parent3ef87a251b0324e24accfc4ef6fc0e257d0d1944 (diff)
efl: add facility to generate an event when an item is created by the factory.
Reviewed-by: SangHyeon Jade Lee <sh10233.lee@samsung.com> Differential Revision: https://phab.enlightenment.org/D7446
-rw-r--r--src/lib/efl/Efl.h16
-rw-r--r--src/lib/efl/interfaces/efl_interfaces_main.c21
-rw-r--r--src/lib/efl/interfaces/efl_ui_factory.eo9
3 files changed, 46 insertions, 0 deletions
diff --git a/src/lib/efl/Efl.h b/src/lib/efl/Efl.h
index 8548ac95c8..fc56d4a0b8 100644
--- a/src/lib/efl/Efl.h
+++ b/src/lib/efl/Efl.h
@@ -197,6 +197,22 @@ typedef Efl_Gfx_Path_Command_Type Efl_Gfx_Path_Command;
197 */ 197 */
198EAPI Efl_Object *efl_part(const Eo *obj, const char *name); 198EAPI Efl_Object *efl_part(const Eo *obj, const char *name);
199 199
200/**
201 * @brief This triggers the create method of a factory and trigger the item created event.
202 *
203 * @param[in] factory The factory that will provide the item
204 * @param[in] model The model to use to fetch information from
205 * @param[in] parent The parent of the newly created item
206 * @return A future that will resolve with the newly created item.
207 *
208 * @since 1.22
209 * @note This exists as we always want to trigger the event once all the logic
210 * of every factory in the chain has done what it planned to do. Basically we
211 * want the inverse of inheritance call like efl_super. So we do setup the future
212 * in this way.
213 */
214EAPI Eina_Future *efl_ui_view_factory_create_with_event(Efl_Ui_Factory *factory, Efl_Model *model, Efl_Gfx_Entity *parent);
215
200#else 216#else
201 217
202#ifndef EFL_NOLEGACY_API_SUPPORT 218#ifndef EFL_NOLEGACY_API_SUPPORT
diff --git a/src/lib/efl/interfaces/efl_interfaces_main.c b/src/lib/efl/interfaces/efl_interfaces_main.c
index a21d7505aa..65c3234fd3 100644
--- a/src/lib/efl/interfaces/efl_interfaces_main.c
+++ b/src/lib/efl/interfaces/efl_interfaces_main.c
@@ -113,3 +113,24 @@ __efl_internal_init(void)
113{ 113{
114 efl_model_init(); 114 efl_model_init();
115} 115}
116
117static Eina_Value
118_efl_ui_view_factory_item_created(Eo *factory, void *data EINA_UNUSED, const Eina_Value v)
119{
120 Efl_Ui_Factory_Item_Created_Event event = { NULL, NULL };
121
122 eina_value_pget(&v, &event.item);
123 event.model = efl_ui_view_model_get(event.item);
124
125 efl_event_callback_call(factory, EFL_UI_FACTORY_EVENT_CREATED, &event);
126
127 return v;
128}
129
130EAPI Eina_Future *
131efl_ui_view_factory_create_with_event(Efl_Ui_Factory *factory, Efl_Model *model, Efl_Gfx_Entity *parent)
132{
133 return efl_future_then(efl_ui_factory_create(factory, model, parent), factory,
134 .success_type = EINA_VALUE_TYPE_OBJECT,
135 .success = _efl_ui_view_factory_item_created);
136}
diff --git a/src/lib/efl/interfaces/efl_ui_factory.eo b/src/lib/efl/interfaces/efl_ui_factory.eo
index adbd93bbd1..b7848744de 100644
--- a/src/lib/efl/interfaces/efl_ui_factory.eo
+++ b/src/lib/efl/interfaces/efl_ui_factory.eo
@@ -1,3 +1,9 @@
1struct Efl.Ui.Factory_Item_Created_Event {
2 [[EFL Ui Factory event structure provided when an item was just created.]]
3 model: Efl.Model; [[The model already set on the new item.]]
4 item: Efl.Gfx.Entity; [[The item that was just created.]]
5}
6
1interface Efl.Ui.Factory (Efl.Ui.Model.Connect) 7interface Efl.Ui.Factory (Efl.Ui.Model.Connect)
2{ 8{
3 [[Efl UI factory interface]] 9 [[Efl UI factory interface]]
@@ -24,4 +30,7 @@ interface Efl.Ui.Factory (Efl.Ui.Model.Connect)
24 } 30 }
25 } 31 }
26 } 32 }
33 events {
34 created: Efl.Ui.Factory_Item_Created_Event; [[Event triggered when an item has been successfully created.]]
35 }
27} 36}