summaryrefslogtreecommitdiff
path: root/src/examples/elementary/filemvc.c
diff options
context:
space:
mode:
authorLarry Jr <larry.olj@gmail.com>2016-04-20 17:07:53 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2016-04-29 13:21:24 -0300
commit0c76f82a31b1ad06a4da4c12f1a02139e0d0c6fa (patch)
tree254f0542b8fc5ea1af14936da8e6806262f3f8a6 /src/examples/elementary/filemvc.c
parent42346e22f4c06634e180c44cf63924dbc50a5184 (diff)
Efl, Eio, Eldbus, Elementary: new model API use eina_promise
Efl - efl_model_base changed to use eina_promise Eio - eio_model use efl_model_base with promise Eldbus - elddbus models use promise now Elementary - elm_view_list and elm_view_form use new models with promise updated all related examples and tests
Diffstat (limited to 'src/examples/elementary/filemvc.c')
-rw-r--r--src/examples/elementary/filemvc.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/examples/elementary/filemvc.c b/src/examples/elementary/filemvc.c
index 3b4fe5a121..f33b2002eb 100644
--- a/src/examples/elementary/filemvc.c
+++ b/src/examples/elementary/filemvc.c
@@ -51,29 +51,41 @@ _list_selected_cb(void *data EINA_UNUSED, const Eo_Event *event)
51{ 51{
52 Efl_Model_Test_Filemvc_Data *priv = data; 52 Efl_Model_Test_Filemvc_Data *priv = data;
53 Eo *child = event->info; 53 Eo *child = event->info;
54 ethumb_client_file_free(elm_thumb_ethumb_client_get()); 54// ethumb_client_file_free(elm_thumb_ethumb_client_get());
55 55
56 printf("LIST selected model\n"); 56 printf("LIST selected model\n");
57 elm_view_form_model_set(priv->formview, child); 57 elm_view_form_model_set(priv->formview, child);
58 return EINA_TRUE; 58 return EINA_TRUE;
59} 59}
60 60
61static void
62_promise_then(void *data, void *value)
63{
64 Efl_Model_Test_Filemvc_Data *priv = data;
65 char *path;
66 Eo *model;
67
68 eina_value_get((Eina_Value *)value, &path);
69 model = eo_add(EIO_MODEL_CLASS, NULL, eio_model_path_set(eo_self, path));
70 elm_view_list_model_set(priv->fileview, model);
71}
72
73static void
74_promise_error(void *data, const Eina_Error *err)
75{
76}
77
61static Eina_Bool 78static Eina_Bool
62_tree_selected_cb(void *data, const Eo_Event *event) 79_tree_selected_cb(void *data, const Eo_Event *event)
63{ 80{
64 Efl_Model_Test_Filemvc_Data *priv = data; 81 Efl_Model_Test_Filemvc_Data *priv = data;
65 Eo *child = event->info; 82 Eo *child = event->info;
66 const Eina_Value *vpath; 83 Eina_Promise *promise;
67 Eo *model;
68 char *path;
69 84
70 printf("TREE selected model\n"); 85 printf("TREE selected model\n");
71 86
72 efl_model_property_get(child, "path", &vpath); 87 efl_model_property_get(child, "path", &promise);
73 eina_value_get(vpath, &path); 88 eina_promise_then(promise, &_promise_then, &_promise_error, priv);
74 model = eo_add(EIO_MODEL_CLASS, NULL, eio_model_path_set(eo_self, path));
75 efl_model_load(model);
76 elm_view_list_model_set(priv->fileview, model);
77 return EINA_TRUE; 89 return EINA_TRUE;
78} 90}
79 91
@@ -130,16 +142,12 @@ elm_main(int argc, char **argv)
130 evas_object_size_hint_weight_set(panes, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 142 evas_object_size_hint_weight_set(panes, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
131 elm_win_resize_object_add(win, panes); 143 elm_win_resize_object_add(win, panes);
132 144
133 ecore_init();
134 eio_init();
135
136 if(argv[1] != NULL) dirname = argv[1]; 145 if(argv[1] != NULL) dirname = argv[1];
137 else dirname = EFL_MODEL_TEST_FILENAME_PATH; 146 else dirname = EFL_MODEL_TEST_FILENAME_PATH;
138 147
139 //treemodel 148 //treemodel
140 priv.treemodel = eo_add(EIO_MODEL_CLASS, NULL, eio_model_path_set(eo_self, dirname)); 149 priv.treemodel = eo_add(EIO_MODEL_CLASS, NULL, eio_model_path_set(eo_self, dirname));
141 eio_model_children_filter_set(priv.treemodel, _filter_cb, NULL); 150 eio_model_children_filter_set(priv.treemodel, _filter_cb, NULL);
142 efl_model_load(priv.treemodel);
143 151
144 //treeview 152 //treeview
145 genlist = elm_genlist_add(win); 153 genlist = elm_genlist_add(win);
@@ -155,6 +163,7 @@ elm_main(int argc, char **argv)
155 _widget_init(vpanes); 163 _widget_init(vpanes);
156 elm_object_part_content_set(panes, "right", vpanes); 164 elm_object_part_content_set(panes, "right", vpanes);
157 eo_event_callback_add(priv.treeview, ELM_VIEW_LIST_EVENT_MODEL_SELECTED, _tree_selected_cb, &priv); 165 eo_event_callback_add(priv.treeview, ELM_VIEW_LIST_EVENT_MODEL_SELECTED, _tree_selected_cb, &priv);
166
158 //listview 167 //listview
159 genlist = elm_genlist_add(win); 168 genlist = elm_genlist_add(win);
160 priv.fileview = eo_add(ELM_VIEW_LIST_CLASS, NULL, elm_view_list_genlist_set(eo_self, genlist, ELM_GENLIST_ITEM_NONE, "double_label")); 169 priv.fileview = eo_add(ELM_VIEW_LIST_CLASS, NULL, elm_view_list_genlist_set(eo_self, genlist, ELM_GENLIST_ITEM_NONE, "double_label"));