summaryrefslogtreecommitdiff
path: root/src
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 /src
parent0091e8b5b6269259185179542b85380838b1a546 (diff)
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
Diffstat (limited to 'src')
-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
22 Evas_Object *entry; 22 Evas_Object *entry;
23 Evas_Object *img; 23 Evas_Object *img;
24 Evas_Object *bt; 24 Evas_Object *bt;
25 Evas_Object *bxr;
25}; 26};
26typedef struct _Layout_Model_Data Layout_Model_Data; 27typedef struct _Layout_Model_Data Layout_Model_Data;
27 28
29static Eina_Value
30_wait_for_image(Eo *o EINA_UNUSED, void *data, const Eina_Value v)
31{
32 Layout_Model_Data *priv = data;
33
34 priv->img = eina_value_object_get(&v);
35 elm_box_pack_end(priv->bxr, priv->img);
36 evas_object_size_hint_weight_set(priv->img, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
37 evas_object_size_hint_align_set(priv->img, EVAS_HINT_FILL, EVAS_HINT_FILL);
38 evas_object_show(priv->img);
39
40 return v;
41}
42
28static void 43static void
29_cleanup_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 44_cleanup_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
30{ 45{
@@ -46,7 +61,6 @@ _list_selected_cb(void *data EINA_UNUSED, const Efl_Event *event)
46 efl_ui_view_model_set(priv->bt, child); 61 efl_ui_view_model_set(priv->bt, child);
47} 62}
48 63
49
50static void 64static void
51_update_cb(void *data, Evas_Object *obj EINA_UNUSED, void *ev EINA_UNUSED) 65_update_cb(void *data, Evas_Object *obj EINA_UNUSED, void *ev EINA_UNUSED)
52{ 66{
@@ -78,7 +92,6 @@ _label_init(Evas_Object *win, Evas_Object *box, const char *text)
78 return widget; 92 return widget;
79} 93}
80 94
81
82static void 95static void
83_signal_cb(void *data EINA_UNUSED, 96_signal_cb(void *data EINA_UNUSED,
84 Evas_Object *obj EINA_UNUSED, 97 Evas_Object *obj EINA_UNUSED,
@@ -111,10 +124,10 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
111 if (argv[1] != NULL) dirname = argv[1]; 124 if (argv[1] != NULL) dirname = argv[1];
112 else dirname = EFL_MODEL_TEST_FILENAME_PATH; 125 else dirname = EFL_MODEL_TEST_FILENAME_PATH;
113 126
114 priv->model = efl_add(EFL_IO_MODEL_CLASS, win, efl_io_model_path_set(efl_added, dirname)); 127 priv->model = efl_add_ref(EFL_IO_MODEL_CLASS, win, efl_io_model_path_set(efl_added, dirname));
115 128
116 genlist = elm_genlist_add(win); 129 genlist = elm_genlist_add(win);
117 priv->fileview = efl_add(ELM_VIEW_LIST_CLASS, win, elm_view_list_genlist_set(efl_added, genlist, ELM_GENLIST_ITEM_NONE, NULL)); 130 priv->fileview = efl_add_ref(ELM_VIEW_LIST_CLASS, win, elm_view_list_genlist_set(efl_added, genlist, ELM_GENLIST_ITEM_NONE, NULL));
118 elm_view_list_property_connect(priv->fileview, "filename", "elm.text"); 131 elm_view_list_property_connect(priv->fileview, "filename", "elm.text");
119 elm_view_list_model_set(priv->fileview, priv->model); 132 elm_view_list_model_set(priv->fileview, priv->model);
120 _widget_init(genlist); 133 _widget_init(genlist);
@@ -123,6 +136,7 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
123 efl_event_callback_add(priv->fileview, ELM_VIEW_LIST_EVENT_MODEL_SELECTED, _list_selected_cb, priv); 136 efl_event_callback_add(priv->fileview, ELM_VIEW_LIST_EVENT_MODEL_SELECTED, _list_selected_cb, priv);
124 137
125 bxr = elm_box_add(win); 138 bxr = elm_box_add(win);
139 priv->bxr = bxr;
126 _widget_init(bxr); 140 _widget_init(bxr);
127 elm_object_part_content_set(panes, "right", bxr); 141 elm_object_part_content_set(panes, "right", bxr);
128 142
@@ -154,11 +168,9 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
154 efl_ui_property_bind(img_factory, "", "path"); //connect to "path" property 168 efl_ui_property_bind(img_factory, "", "path"); //connect to "path" property
155 efl_ui_factory_bind(priv->bt, "icon", img_factory); 169 efl_ui_factory_bind(priv->bt, "icon", img_factory);
156 170
157 priv->img = efl_ui_factory_create(img_factory, NULL, win); 171 efl_future_then(win, efl_ui_factory_create(img_factory, NULL, win),
158 elm_box_pack_end(bxr, priv->img); 172 .success = _wait_for_image,
159 evas_object_size_hint_weight_set(priv->img, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 173 .data = priv);
160 evas_object_size_hint_align_set(priv->img, EVAS_HINT_FILL, EVAS_HINT_FILL);
161 evas_object_show(priv->img);
162 174
163 evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _cleanup_cb, priv); 175 evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _cleanup_cb, priv);
164 //showall 176 //showall
@@ -167,8 +179,8 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
167 evas_object_show(win); 179 evas_object_show(win);
168 180
169 elm_run(); 181 elm_run();
182
170 elm_shutdown(); 183 elm_shutdown();
171 ecore_shutdown();
172 184
173 return 0; 185 return 0;
174} 186}