aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2018-12-07 14:42:09 -0800
committerCedric BAIL <cedric.bail@free.fr>2019-01-09 11:02:12 -0800
commit78ca66fb762ffaca3a1afd343a61cfd50982b309 (patch)
treecd3588b710895a90e7671ba8f97b02810cd62a55
parentelementary: add a factory that handle caching for you. (diff)
downloadefl-78ca66fb762ffaca3a1afd343a61cfd50982b309.tar.gz
elementary: enable caching for Efl.Ui.ImageFactory.
Differential Revision: https://phab.enlightenment.org/D7444
-rw-r--r--src/lib/elementary/efl_ui_image_factory.c35
-rw-r--r--src/lib/elementary/efl_ui_image_factory.eo3
2 files changed, 22 insertions, 16 deletions
diff --git a/src/lib/elementary/efl_ui_image_factory.c b/src/lib/elementary/efl_ui_image_factory.c
index 998c43f70d..30d222c8f1 100644
--- a/src/lib/elementary/efl_ui_image_factory.c
+++ b/src/lib/elementary/efl_ui_image_factory.c
@@ -17,6 +17,7 @@ EOLIAN static Eo *
_efl_ui_image_factory_efl_object_constructor(Eo *obj, Efl_Ui_Image_Factory_Data *pd)
{
obj = efl_constructor(efl_super(obj, MY_CLASS));
+ efl_ui_caching_factory_item_class_set(obj, EFL_UI_IMAGE_CLASS);
pd->property = NULL;
@@ -32,27 +33,33 @@ _efl_ui_image_factory_efl_object_destructor(Eo *obj EINA_UNUSED, Efl_Ui_Image_Fa
efl_destructor(efl_super(obj, MY_CLASS));
}
-EOLIAN static Eina_Future *
-_efl_ui_image_factory_efl_ui_factory_create(Eo *obj, Efl_Ui_Image_Factory_Data *pd, Efl_Model *model, Efl_Gfx_Entity *parent)
+static Eina_Value
+_efl_ui_image_factory_connect(Eo *obj, void *data, const Eina_Value value)
{
- Efl_Gfx_Entity *ui_view;
- Eina_Value r;
+ Efl_Gfx_Entity *entity = NULL;
+ Efl_Ui_Image_Factory_Data *pd = data;
- EINA_SAFETY_ON_NULL_RETURN_VAL(pd->property, NULL);
- EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
- ui_view = efl_add(EFL_UI_IMAGE_CLASS, parent);
- efl_ui_view_model_set(ui_view, model);
- efl_ui_model_connect(ui_view, "filename", pd->property);
+ eina_value_pget(&value, &entity);
- r = eina_value_object_init(ui_view);
+ efl_ui_model_connect(entity, "filename", pd->property);
- return eina_future_resolved(efl_loop_future_scheduler_get(obj), r);
+ return value;
}
-EOLIAN static void
-_efl_ui_image_factory_efl_ui_factory_release(Eo *obj EINA_UNUSED, Efl_Ui_Image_Factory_Data *pd EINA_UNUSED, Efl_Gfx_Entity *ui_view)
+EOLIAN static Eina_Future *
+_efl_ui_image_factory_efl_ui_factory_create(Eo *obj, Efl_Ui_Image_Factory_Data *pd, Efl_Model *model, Efl_Gfx_Entity *parent)
{
- efl_parent_set(ui_view, NULL);
+ Eina_Future *f;
+
+ if (!parent) return efl_loop_future_rejected(obj, EFL_FACTORY_ERROR_NOT_SUPPORTED);
+ if (!pd->property) return efl_loop_future_rejected(obj, EFL_FACTORY_ERROR_NOT_SUPPORTED);
+
+ f = efl_ui_factory_create(efl_super(obj, EFL_UI_IMAGE_FACTORY_CLASS), model, parent);
+
+ return efl_future_then(obj, f,
+ .success_type = EINA_VALUE_TYPE_OBJECT,
+ .success = _efl_ui_image_factory_connect,
+ .data = pd);
}
EOLIAN static void
diff --git a/src/lib/elementary/efl_ui_image_factory.eo b/src/lib/elementary/efl_ui_image_factory.eo
index a966d23ec2..66abdf4d23 100644
--- a/src/lib/elementary/efl_ui_image_factory.eo
+++ b/src/lib/elementary/efl_ui_image_factory.eo
@@ -1,11 +1,10 @@
-class Efl.Ui.Image_Factory (Efl.Object, Efl.Ui.Factory)
+class Efl.Ui.Image_Factory (Efl.Ui.Caching_Factory)
{
[[Efl UI image factory class]]
implements {
Efl.Object.constructor;
Efl.Object.destructor;
Efl.Ui.Factory.create;
- Efl.Ui.Factory.release;
Efl.Ui.Model.Connect.connect;
}
}