aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2019-02-28 16:14:42 -0800
committerCedric BAIL <cedric.bail@free.fr>2019-03-01 17:10:44 -0800
commit6d61ca915195a5ff4c5dc24c271d37fa22d64314 (patch)
tree8de9c93673f28f122ce6f4e5320732585f37c611
parentelementary: Efl.Ui.Layout should use the new API efl_content to control objec... (diff)
downloadefl-6d61ca915195a5ff4c5dc24c271d37fa22d64314.tar.gz
elementary: update MVVM example to use asynchronous factory API.
This also fix a bunch of other error regarding object lifecycle and library initialization. Reviewed-by: Vitor Sousa da Silva <vitorsousa@expertisesolutions.com.br> Differential Revision: https://phab.enlightenment.org/D8079
-rw-r--r--src/examples/elementary/layout_property_bind.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/examples/elementary/layout_property_bind.c b/src/examples/elementary/layout_property_bind.c
index b5915ae62c..a06e383b33 100644
--- a/src/examples/elementary/layout_property_bind.c
+++ b/src/examples/elementary/layout_property_bind.c
@@ -22,9 +22,24 @@ struct _Layout_Model_Data
Evas_Object *entry;
Evas_Object *img;
Evas_Object *bt;
+ Evas_Object *bxr;
};
typedef struct _Layout_Model_Data Layout_Model_Data;
+static Eina_Value
+_wait_for_image(Eo *o EINA_UNUSED, void *data, const Eina_Value v)
+{
+ Layout_Model_Data *priv = data;
+
+ priv->img = eina_value_object_get(&v);
+ elm_box_pack_end(priv->bxr, priv->img);
+ evas_object_size_hint_weight_set(priv->img, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(priv->img, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_show(priv->img);
+
+ return v;
+}
+
static void
_cleanup_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
@@ -46,7 +61,6 @@ _list_selected_cb(void *data EINA_UNUSED, const Efl_Event *event)
efl_ui_view_model_set(priv->bt, child);
}
-
static void
_update_cb(void *data, Evas_Object *obj EINA_UNUSED, void *ev EINA_UNUSED)
{
@@ -78,7 +92,6 @@ _label_init(Evas_Object *win, Evas_Object *box, const char *text)
return widget;
}
-
static void
_signal_cb(void *data EINA_UNUSED,
Evas_Object *obj EINA_UNUSED,
@@ -111,10 +124,10 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
if (argv[1] != NULL) dirname = argv[1];
else dirname = EFL_MODEL_TEST_FILENAME_PATH;
- priv->model = efl_add(EFL_IO_MODEL_CLASS, win, efl_io_model_path_set(efl_added, dirname));
+ priv->model = efl_add_ref(EFL_IO_MODEL_CLASS, win, efl_io_model_path_set(efl_added, dirname));
genlist = elm_genlist_add(win);
- priv->fileview = efl_add(ELM_VIEW_LIST_CLASS, win, elm_view_list_genlist_set(efl_added, genlist, ELM_GENLIST_ITEM_NONE, NULL));
+ priv->fileview = efl_add_ref(ELM_VIEW_LIST_CLASS, win, elm_view_list_genlist_set(efl_added, genlist, ELM_GENLIST_ITEM_NONE, NULL));
elm_view_list_property_connect(priv->fileview, "filename", "elm.text");
elm_view_list_model_set(priv->fileview, priv->model);
_widget_init(genlist);
@@ -123,6 +136,7 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
efl_event_callback_add(priv->fileview, ELM_VIEW_LIST_EVENT_MODEL_SELECTED, _list_selected_cb, priv);
bxr = elm_box_add(win);
+ priv->bxr = bxr;
_widget_init(bxr);
elm_object_part_content_set(panes, "right", bxr);
@@ -154,11 +168,9 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
efl_ui_property_bind(img_factory, "", "path"); //connect to "path" property
efl_ui_factory_bind(priv->bt, "icon", img_factory);
- priv->img = efl_ui_factory_create(img_factory, NULL, win);
- elm_box_pack_end(bxr, priv->img);
- evas_object_size_hint_weight_set(priv->img, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(priv->img, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_show(priv->img);
+ efl_future_then(win, efl_ui_factory_create(img_factory, NULL, win),
+ .success = _wait_for_image,
+ .data = priv);
evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _cleanup_cb, priv);
//showall
@@ -167,8 +179,8 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
evas_object_show(win);
elm_run();
+
elm_shutdown();
- ecore_shutdown();
return 0;
}