summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLarry Jr <larry.olj@gmail.com>2015-07-01 19:27:30 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2015-07-01 20:03:27 -0300
commit595c4b8e5ec503d9dfe6c22c570399bccf114e2e (patch)
tree957693a5013ec1e2456c1e0332137e8424f24fdf
parentef8b20372b7bc1eb2b401d6e7a79e76496418f5c (diff)
EFL Model List View for MVC design
Elementary views that show an EFL.model and keep them synchronized asynchronously. The elm_view_list show a tree data structure using a genlist. Each property is seen as a different data column. There is an example defined in fileviewlist.c. @feature
-rw-r--r--configure.ac2
-rw-r--r--src/examples/.gitignore1
-rw-r--r--src/examples/Makefile.am2
-rw-r--r--src/examples/fileviewlist.c77
-rw-r--r--src/lib/Elementary.h.in1
-rw-r--r--src/lib/Makefile.am3
-rw-r--r--src/lib/elm_view_list.c442
-rw-r--r--src/lib/elm_view_list.eo77
-rw-r--r--src/lib/elm_view_list.h10
9 files changed, 615 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 919ccb14d..19ec753f9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -270,6 +270,7 @@ if test "x${HAVE_CXX11}" = "x1" -a "x${want_cxx11}" = "xyes"; then
270 eo-cxx >= efl_version 270 eo-cxx >= efl_version
271 eina-cxx >= efl_version 271 eina-cxx >= efl_version
272 evas-cxx >= efl_version 272 evas-cxx >= efl_version
273 eio-cxx >= efl_version
273 ], 274 ],
274 [ 275 [
275 requirement_elm_pc="${requirement_elm_pc} \ 276 requirement_elm_pc="${requirement_elm_pc} \
@@ -277,6 +278,7 @@ if test "x${HAVE_CXX11}" = "x1" -a "x${want_cxx11}" = "xyes"; then
277 eo-cxx >= efl_version \ 278 eo-cxx >= efl_version \
278 eina-cxx >= efl_version \ 279 eina-cxx >= efl_version \
279 evas-cxx >= efl_version \ 280 evas-cxx >= efl_version \
281 eio-cxx >= efl_version \
280 " 282 "
281 have_cxx11="yes" 283 have_cxx11="yes"
282 LDFLAGS="${LDFLAGS} -fPIC -DPIC" 284 LDFLAGS="${LDFLAGS} -fPIC -DPIC"
diff --git a/src/examples/.gitignore b/src/examples/.gitignore
index fd9fc399b..7c9b93b9d 100644
--- a/src/examples/.gitignore
+++ b/src/examples/.gitignore
@@ -32,6 +32,7 @@
32/fileselector_button_example 32/fileselector_button_example
33/fileselector_entry_example 33/fileselector_entry_example
34/fileselector_example 34/fileselector_example
35/fileviewlist
35/flip_example_01 36/flip_example_01
36/flipselector_example 37/flipselector_example
37/frame_example_01 38/frame_example_01
diff --git a/src/examples/Makefile.am b/src/examples/Makefile.am
index dc100db38..3835b5f3e 100644
--- a/src/examples/Makefile.am
+++ b/src/examples/Makefile.am
@@ -68,6 +68,7 @@ entry_example.c \
68fileselector_button_example.c \ 68fileselector_button_example.c \
69fileselector_entry_example.c \ 69fileselector_entry_example.c \
70fileselector_example.c \ 70fileselector_example.c \
71fileviewlist.c \
71flip_example_01.c \ 72flip_example_01.c \
72flipselector_example.c \ 73flipselector_example.c \
73frame_example_01.c \ 74frame_example_01.c \
@@ -220,6 +221,7 @@ entry_example \
220fileselector_button_example \ 221fileselector_button_example \
221fileselector_entry_example \ 222fileselector_entry_example \
222fileselector_example \ 223fileselector_example \
224fileviewlist \
223flip_example_01 \ 225flip_example_01 \
224flipselector_example \ 226flipselector_example \
225frame_example_01 \ 227frame_example_01 \
diff --git a/src/examples/fileviewlist.c b/src/examples/fileviewlist.c
new file mode 100644
index 000000000..0b683566c
--- /dev/null
+++ b/src/examples/fileviewlist.c
@@ -0,0 +1,77 @@
1//Compile with:
2// gcc -o fileviewlist fileviewlist.c `pkg-config --cflags --libs emodel`
3
4//#ifdef HAVE_CONFIG_H
5# include "../../elementary_config.h"
6//#endif
7
8#include <Elementary.h>
9#include <Efl.h>
10#include <Eio.h>
11#include <eio_model.eo.h>
12#include <stdio.h>
13
14#define EFL_MODEL_TEST_FILENAME_PATH "/tmp"
15
16struct _Efl_Model_Test_Fileview_Data
17{
18 Eo *filemodel;
19 Eo *fileview;
20};
21typedef struct _Efl_Model_Test_Fileview_Data Efl_Model_Test_Fileview_Data;
22
23static void
24_cleanup_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
25{
26 Efl_Model_Test_Fileview_Data *priv = (Efl_Model_Test_Fileview_Data *)data;
27 eo_unref(priv->fileview);
28 eo_unref(priv->filemodel);
29}
30
31EAPI_MAIN int
32elm_main(int argc, char **argv)
33{
34 Efl_Model_Test_Fileview_Data priv;
35 Evas_Object *win = NULL;
36 Evas_Object *genlist = NULL;
37 char *dirname;
38
39 memset(&priv, 0, sizeof(Efl_Model_Test_Fileview_Data));
40
41 ecore_init();
42 eio_init();
43
44 if(argv[1] != NULL) dirname = argv[1];
45 else dirname = EFL_MODEL_TEST_FILENAME_PATH;
46
47 win = elm_win_util_standard_add("viewlist", "Viewlist");
48 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
49 elm_win_autodel_set(win, EINA_TRUE);
50
51 genlist = elm_genlist_add(win);
52 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
53 evas_object_show(genlist);
54
55 priv.filemodel = eo_add(EIO_MODEL_CLASS, NULL, eio_model_path_set(dirname));
56 priv.fileview = eo_add(ELM_VIEW_LIST_CLASS, NULL,
57 elm_view_list_genlist_set(genlist, ELM_GENLIST_ITEM_TREE, "double_label"));
58 eo_do(priv.fileview, elm_view_list_model_set(priv.filemodel));
59 eo_do(priv.filemodel, efl_model_load());
60 evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _cleanup_cb, &priv);
61
62 eo_do(priv.fileview, elm_view_list_property_connect("filename", "elm.text"),
63 elm_view_list_property_connect("mtime", "elm.text.sub"));
64
65 evas_object_resize(win, 320, 520);
66 elm_win_resize_object_add(win, genlist);
67 evas_object_show(win);
68
69 elm_run();
70
71 elm_shutdown();
72 ecore_shutdown();
73
74 return 0;
75}
76ELM_MAIN()
77
diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in
index 2dacb1a44..61cb53ea0 100644
--- a/src/lib/Elementary.h.in
+++ b/src/lib/Elementary.h.in
@@ -260,6 +260,7 @@ EAPI extern Elm_Version *elm_version;
260#include <elm_toolbar.h> 260#include <elm_toolbar.h>
261#include <elm_transit.h> 261#include <elm_transit.h>
262#include <elm_video.h> 262#include <elm_video.h>
263#include <elm_view_list.h>
263#include <elm_web.h> 264#include <elm_web.h>
264#include <elm_win.h> 265#include <elm_win.h>
265#include <elm_win_standard.h> 266#include <elm_win_standard.h>
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index bcfc36ea9..547576709 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -376,6 +376,7 @@ elm_transit.h \
376elm_video.h \ 376elm_video.h \
377elm_video_eo.h \ 377elm_video_eo.h \
378elm_video_legacy.h \ 378elm_video_legacy.h \
379elm_view_list.h \
379elm_web.h \ 380elm_web.h \
380elm_web_common.h \ 381elm_web_common.h \
381elm_web_eo.h \ 382elm_web_eo.h \
@@ -500,6 +501,7 @@ elm_transit.c \
500elm_util.c \ 501elm_util.c \
501elm_url.c \ 502elm_url.c \
502elm_video.c \ 503elm_video.c \
504elm_view_list.c \
503elm_web2.c \ 505elm_web2.c \
504elm_widget.c \ 506elm_widget.c \
505elm_win.c \ 507elm_win.c \
@@ -619,6 +621,7 @@ elm_table.eo \
619elm_thumb.eo \ 621elm_thumb.eo \
620elm_toolbar.eo \ 622elm_toolbar.eo \
621elm_video.eo \ 623elm_video.eo \
624elm_view_list.eo \
622elm_web.eo \ 625elm_web.eo \
623elm_widget.eo \ 626elm_widget.eo \
624elm_win.eo \ 627elm_win.eo \
diff --git a/src/lib/elm_view_list.c b/src/lib/elm_view_list.c
new file mode 100644
index 000000000..5773b2a1c
--- /dev/null
+++ b/src/lib/elm_view_list.c
@@ -0,0 +1,442 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4#include <Eo.h>
5#include <Efl.h>
6#include <Elementary.h>
7
8#include "elm_priv.h"
9#include <assert.h>
10
11#define MY_CLASS ELM_VIEW_LIST_CLASS
12#define MY_CLASS_NAME "View List"
13
14struct _Elm_View_List_Data;
15typedef struct _Elm_View_List_Data Elm_View_List_Data;
16
17struct _View_List_ItemData;
18typedef struct _View_List_ItemData View_List_ItemData;
19
20struct _Elm_View_List_Data
21{
22 Eo *view;
23 Evas_Object *genlist;
24 View_List_ItemData *rootdata;
25 Elm_Genlist_Item_Class *itc;
26 Elm_Genlist_Item_Type itype;
27 Eina_Hash *prop_con;
28 Eo *model;
29};
30
31struct _View_List_ItemData
32{
33 Elm_View_List_Data *priv;
34 Elm_Object_Item *item;
35 Eo *model;
36 View_List_ItemData *parent;
37 Efl_Model_Load_Status status;
38};
39
40static void _efl_model_load_children(View_List_ItemData *);
41static Eina_Bool _efl_model_load_status_change_cb(void *, Eo *, const Eo_Event_Description *, void *);
42static Eina_Bool _efl_model_children_count_change_cb(void *, Eo *, const Eo_Event_Description *, void *);
43static Eina_Bool _efl_model_properties_change_cb(void *, Eo *, const Eo_Event_Description *, void *);
44
45/* --- Genlist Callbacks --- */
46static void
47_item_sel_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
48{
49 View_List_ItemData *idata = data;
50
51 EINA_SAFETY_ON_NULL_RETURN(data);
52
53 eo_do(idata->priv->view, eo_event_callback_call(ELM_VIEW_LIST_EVENT_MODEL_SELECTED, idata->model));
54}
55
56static void
57_item_del(void *data, Evas_Object *obj EINA_UNUSED)
58{
59 View_List_ItemData *idata = data;
60 if (!idata)
61 return;
62
63 eo_do(idata->model, eo_event_callback_del(EFL_MODEL_BASE_EVENT_PROPERTIES_CHANGED,
64 _efl_model_properties_change_cb, idata));
65 eo_do(idata->model, eo_event_callback_del(EFL_MODEL_BASE_EVENT_LOAD_STATUS,
66 _efl_model_load_status_change_cb, idata));
67 eo_do(idata->model, eo_event_callback_del(EFL_MODEL_BASE_EVENT_CHILDREN_COUNT_CHANGED,
68 _efl_model_children_count_change_cb, idata));
69
70 eo_unref(idata->model);
71 idata->model = NULL;
72 idata->item = NULL;
73 idata->parent = NULL;
74 idata->priv = NULL;
75
76 free(idata);
77}
78
79static Evas_Object *
80_item_content_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part)
81{
82 const Eina_Value *value = NULL;
83 const Eina_Value_Type *vtype;
84 Evas_Object *content = NULL;
85 View_List_ItemData *idata = data;
86 EINA_SAFETY_ON_NULL_RETURN_VAL(data, NULL);
87 EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
88 Elm_View_List_Data *priv = idata->priv;
89
90 const char *prop = eina_hash_find(priv->prop_con, part);
91 if (prop == NULL) prop = part;
92
93 eo_do(idata->model, efl_model_property_get(prop, &value));
94 if (value == NULL)
95 return content;
96
97 vtype = eina_value_type_get(value);
98 if (vtype == EINA_VALUE_TYPE_STRING || vtype == EINA_VALUE_TYPE_STRINGSHARE)
99 {
100 char *content_s = NULL;
101 content_s = eina_value_to_string(value);
102 content = elm_icon_add(obj);
103 if (elm_icon_standard_set(content, content_s))
104 {
105 evas_object_size_hint_aspect_set(content, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
106 }
107 else
108 {
109 evas_object_del(content);
110 content = NULL;
111 }
112 free(content_s);
113 }
114 else if (vtype == EINA_VALUE_TYPE_BLOB)
115 {
116 Eina_Value_Blob out;
117 eina_value_get(value, &out);
118 if (out.memory != NULL)
119 {
120 content = elm_image_add(obj);
121
122 //XXX: need copy memory??
123 elm_image_memfile_set(content, out.memory, out.size, NULL, NULL);
124 }
125 }
126
127 return content;
128}
129
130static char *
131_item_text_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part)
132{
133 const Eina_Value *value = NULL;
134 char *text = NULL;
135 View_List_ItemData *idata = data;
136
137 EINA_SAFETY_ON_NULL_RETURN_VAL(data, NULL);
138 EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
139 Elm_View_List_Data *priv = idata->priv;
140 EINA_SAFETY_ON_NULL_RETURN_VAL(idata->model, NULL);
141
142 const char *prop = eina_hash_find(priv->prop_con, part);
143 if (prop == NULL) prop = part;
144
145 eo_do(idata->model, efl_model_property_get(prop, &value));
146 if (value)
147 text = eina_value_to_string(value);
148
149 return text;
150}
151
152static void
153_expand_request_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
154{
155 Elm_Object_Item *item = event_info;
156 View_List_ItemData *idata = elm_object_item_data_get(item);
157 Efl_Model_Load_Status st = EFL_MODEL_LOAD_STATUS_ERROR;
158
159 EINA_SAFETY_ON_NULL_RETURN(idata);
160
161 eo_do(idata->model, st = efl_model_load_status_get());
162 eo_do(idata->model, eo_event_callback_add(EFL_MODEL_BASE_EVENT_LOAD_STATUS,
163 _efl_model_load_status_change_cb, idata));
164 eo_do(idata->model, eo_event_callback_add(EFL_MODEL_BASE_EVENT_CHILDREN_COUNT_CHANGED,
165 _efl_model_children_count_change_cb, idata));
166
167 if (st & EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN)
168 {
169 _efl_model_load_children(idata);
170 }
171 else
172 {
173 eo_do(idata->model, efl_model_children_load());
174 }
175}
176
177static void
178_contract_request_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
179{
180 Elm_Object_Item *item = event_info;
181 View_List_ItemData *idata = elm_object_item_data_get(item);
182
183 eo_do(idata->model, eo_event_callback_del(EFL_MODEL_BASE_EVENT_LOAD_STATUS,
184 _efl_model_load_status_change_cb, idata));
185 eo_do(idata->model, eo_event_callback_del(EFL_MODEL_BASE_EVENT_CHILDREN_COUNT_CHANGED,
186 _efl_model_children_count_change_cb, idata));
187 elm_genlist_item_expanded_set(item, EINA_FALSE);
188}
189
190static void
191_contracted_cb(void *data EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event_info)
192{
193 Elm_Object_Item *glit = event_info;
194 elm_genlist_item_subitems_clear(glit);
195}
196
197static void
198_genlist_deleted(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
199{
200 Elm_View_List_Data *priv = data;
201
202 if (priv && priv->genlist && priv->genlist == obj)
203 {
204 evas_object_smart_callback_del(priv->genlist, "expand,request", _expand_request_cb);
205 evas_object_smart_callback_del(priv->genlist, "contract,request", _contract_request_cb);
206 evas_object_smart_callback_del(priv->genlist, "contracted", _contracted_cb);
207 eo_unref(priv->genlist);
208 priv->genlist = NULL;
209 }
210}
211
212
213/* --- Efl_Model Callbacks --- */
214static Eina_Bool
215_efl_model_properties_change_cb(void *data, Eo *obj EINA_UNUSED,
216 const Eo_Event_Description *desc EINA_UNUSED, void *event_info)
217{
218 View_List_ItemData *idata = data;
219 Efl_Model_Property_Event *evt = event_info;
220
221 EINA_SAFETY_ON_NULL_RETURN_VAL(idata, EINA_TRUE);
222 EINA_SAFETY_ON_NULL_RETURN_VAL(evt, EINA_TRUE);
223
224 if (idata->item)
225 elm_genlist_item_update(idata->item);
226
227 return EINA_TRUE;
228}
229
230static void
231_efl_model_load_children(View_List_ItemData *pdata)
232{
233 Eo *child;
234 Eina_Accessor *accessor = NULL;
235 EINA_SAFETY_ON_NULL_RETURN(pdata);
236
237 Elm_View_List_Data *priv = pdata->priv;
238 unsigned int i, total = 0;
239
240 eo_do(pdata->model, efl_model_children_count_get(&total));
241 if (total == 0)
242 return;
243
244 eo_do(pdata->model, efl_model_children_slice_get(0 ,0 ,(Eina_Accessor **)&accessor));
245
246 EINA_SAFETY_ON_NULL_RETURN(accessor);
247
248 EINA_ACCESSOR_FOREACH(accessor, i, child)
249 {
250 View_List_ItemData *idata = malloc(sizeof(View_List_ItemData));
251 memset(idata, 0, sizeof(View_List_ItemData));
252 EINA_SAFETY_ON_NULL_RETURN(idata);
253 idata->priv = priv;
254 idata->parent = pdata;
255 idata->model = child;
256 eo_ref(child);
257 eo_do(child, eo_event_callback_add(EFL_MODEL_BASE_EVENT_PROPERTIES_CHANGED,
258 _efl_model_properties_change_cb, idata));
259 eo_do(child, efl_model_properties_load());
260 idata->item = elm_genlist_item_append(priv->genlist, priv->itc, idata, pdata->item,
261 priv->itype, _item_sel_cb, idata);
262 }
263
264 if (pdata->item)
265 elm_genlist_item_expanded_set(pdata->item, EINA_TRUE);
266}
267
268static Eina_Bool
269_efl_model_children_count_change_cb(void *data, Eo *obj EINA_UNUSED,
270 const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
271{
272 View_List_ItemData *idata = data;
273 EINA_SAFETY_ON_NULL_RETURN_VAL(idata, EINA_FALSE);
274 EINA_SAFETY_ON_NULL_RETURN_VAL(idata->priv, EINA_FALSE);
275 EINA_SAFETY_ON_NULL_RETURN_VAL(idata->priv->genlist, EINA_FALSE);
276
277 elm_genlist_item_subitems_clear(idata->item);
278
279 _efl_model_load_children(idata);
280
281 return EINA_TRUE;
282}
283
284static Eina_Bool
285_efl_model_load_status_change_cb(void *data, Eo *obj EINA_UNUSED,
286 const Eo_Event_Description *desc EINA_UNUSED, void *event_info)
287{
288 View_List_ItemData *idata = data;
289 Efl_Model_Load *load = event_info;
290
291 if (load->status & EFL_MODEL_LOAD_STATUS_UNLOADED)
292 {
293 if (idata->item)
294 elm_genlist_item_expanded_set(idata->item, EINA_FALSE);
295 }
296
297 idata->status = load->status;
298 return EINA_TRUE;
299}
300
301static void
302_priv_model_set(Elm_View_List_Data *priv, Eo *model)
303{
304 Efl_Model_Load_Status load_st;
305
306 if (priv->model != NULL)
307 {
308 eo_do(priv->model, eo_event_callback_del(EFL_MODEL_BASE_EVENT_LOAD_STATUS,
309 _efl_model_load_status_change_cb, priv->rootdata));
310 eo_do(priv->model, eo_event_callback_del(EFL_MODEL_BASE_EVENT_CHILDREN_COUNT_CHANGED,
311 _efl_model_children_count_change_cb, priv->rootdata));
312 eo_do(priv->genlist, elm_obj_genlist_clear());
313 eo_unref(priv->model);
314 priv->model = NULL;
315 }
316
317 if (model == NULL)
318 return;
319
320 priv->model = model;
321 priv->rootdata->model = priv->model;
322 eo_ref(priv->model);
323
324 eo_do(priv->model, eo_event_callback_add(EFL_MODEL_BASE_EVENT_LOAD_STATUS,
325 _efl_model_load_status_change_cb, priv->rootdata));
326 eo_do(priv->model, eo_event_callback_add(EFL_MODEL_BASE_EVENT_CHILDREN_COUNT_CHANGED,
327 _efl_model_children_count_change_cb, priv->rootdata));
328 eo_do(priv->model, load_st = efl_model_load_status_get());
329 if (load_st & EFL_MODEL_LOAD_STATUS_LOADED_CHILDREN)
330 {
331 _efl_model_load_children(priv->rootdata);
332 }
333}
334
335/**
336 * @brief Elm View List Class impl.
337 */
338static void
339_elm_view_list_genlist_set(Eo *obj, Elm_View_List_Data *priv, Evas_Object *genlist,
340 Elm_Genlist_Item_Type itype, const char *istyle)
341{
342 priv->view = obj;
343 priv->genlist = genlist;
344 priv->itype = itype;
345 EINA_SAFETY_ON_NULL_RETURN(priv->genlist);
346 eo_ref(priv->genlist);
347
348 priv->rootdata = calloc(1, sizeof(View_List_ItemData));
349 priv->rootdata->priv = priv;
350
351 priv->itc = elm_genlist_item_class_new();
352 if (istyle)
353 priv->itc->item_style = strdup(istyle);
354 priv->itc->func.text_get = _item_text_get;
355 priv->itc->func.content_get = _item_content_get;
356 priv->itc->func.state_get = NULL;
357 priv->itc->func.del = _item_del;
358 priv->prop_con = eina_hash_string_superfast_new(free);
359
360 evas_object_smart_callback_add(priv->genlist, "expand,request", _expand_request_cb, priv);
361 evas_object_smart_callback_add(priv->genlist, "contract,request", _contract_request_cb, priv);
362 evas_object_smart_callback_add(priv->genlist, "contracted", _contracted_cb, priv);
363 evas_object_event_callback_add(priv->genlist, EVAS_CALLBACK_DEL, _genlist_deleted, priv);
364}
365
366
367static void
368_elm_view_list_eo_base_destructor(Eo *obj, Elm_View_List_Data *priv)
369{
370 EINA_SAFETY_ON_NULL_RETURN(priv);
371 EINA_SAFETY_ON_NULL_RETURN(obj);
372
373 eo_do(priv->model, eo_event_callback_del(EFL_MODEL_BASE_EVENT_LOAD_STATUS,
374 _efl_model_load_status_change_cb, priv->rootdata));
375 eo_do(priv->model, eo_event_callback_del(EFL_MODEL_BASE_EVENT_CHILDREN_COUNT_CHANGED,
376 _efl_model_children_count_change_cb, priv->rootdata));
377
378 eo_do(priv->genlist, elm_obj_genlist_clear());
379 elm_genlist_item_class_free(priv->itc);
380
381 eina_hash_free(priv->prop_con);
382 free(priv->rootdata);
383 priv->rootdata = NULL;
384 if (priv->genlist) {
385 evas_object_event_callback_del(priv->genlist, EVAS_CALLBACK_DEL, _genlist_deleted);
386 evas_object_smart_callback_del(priv->genlist, "expand,request", _expand_request_cb);
387 evas_object_smart_callback_del(priv->genlist, "contract,request", _contract_request_cb);
388 evas_object_smart_callback_del(priv->genlist, "contracted", _contracted_cb);
389 eo_unref(priv->genlist);
390 }
391
392 eo_unref(priv->model);
393
394 eo_do_super(obj, MY_CLASS, eo_destructor());
395}
396
397static void
398_elm_view_list_evas_object_get(Eo *obj, Elm_View_List_Data *priv, Evas_Object **widget)
399{
400 EINA_SAFETY_ON_NULL_RETURN(priv);
401 EINA_SAFETY_ON_NULL_RETURN(obj);
402 EINA_SAFETY_ON_NULL_RETURN(widget);
403
404 *widget = priv->genlist;
405}
406
407static void
408_elm_view_list_property_connect(Eo *obj EINA_UNUSED, Elm_View_List_Data *priv,
409 const char *property, const char *part)
410{
411 EINA_SAFETY_ON_NULL_RETURN(priv);
412
413 EINA_SAFETY_ON_NULL_RETURN(priv->prop_con);
414 EINA_SAFETY_ON_NULL_RETURN(property);
415 EINA_SAFETY_ON_NULL_RETURN(part);
416
417 free(eina_hash_set(priv->prop_con, part, strdup(property)));
418}
419
420static void
421_elm_view_list_model_set(Eo *obj EINA_UNUSED, Elm_View_List_Data *priv, Efl_Model_Base *model)
422{
423 EINA_SAFETY_ON_NULL_RETURN(priv);
424 EINA_SAFETY_ON_NULL_RETURN(model);
425 _priv_model_set(priv, model);
426}
427
428static void
429_elm_view_list_model_unset(Eo *obj EINA_UNUSED, Elm_View_List_Data *priv)
430{
431 EINA_SAFETY_ON_NULL_RETURN(priv);
432 _priv_model_set(priv, NULL);
433}
434
435static void
436_elm_view_list_model_get(Eo *obj EINA_UNUSED, Elm_View_List_Data *priv, Eo **model)
437{
438 EINA_SAFETY_ON_NULL_RETURN(priv);
439 EINA_SAFETY_ON_NULL_RETURN(model);
440 *model = priv->model;
441}
442#include "elm_view_list.eo.c"
diff --git a/src/lib/elm_view_list.eo b/src/lib/elm_view_list.eo
new file mode 100644
index 000000000..b1e48a552
--- /dev/null
+++ b/src/lib/elm_view_list.eo
@@ -0,0 +1,77 @@
1class Elm_View_List (Eo.Base)
2{
3 legacy_prefix: null;
4 methods {
5 genlist_set {
6 /*@ Constructor wrapper
7 *
8 * @def elm_view_list_constructor
9 * @since 1.11
10 */
11 params {
12 @in genlist: Evas_Object*; /*@ Genlist object */
13 @in item_type: Elm_Genlist_Item_Type; /*@ Item type */
14 @in item_style: const(char)*; /*@ The current item style name. @c NULL would be default. */
15 }
16 }
17 evas_object_get {
18 /*@ Return evas object
19 *
20 * @def elm_view_list_evas_object_get
21 * @since 1.11
22 */
23 params {
24 @out widget: Evas_Object*; /*@ Returned widget */
25 }
26 }
27 property_connect {
28 /*@ Connect property
29 *
30 * @def elm_view_list_property_connect
31 * @since 1.11
32 */
33 params {
34 @in property: const(char)*; /*@ Property name */
35 @in part: const(char)*; /*@ Edje's theme part */
36 }
37 }
38 model_set {
39 /*@ Set model
40 *
41 * @def elm_view_list_model_set
42 * @since 1.11
43 */
44 params {
45 @in model: Efl.Model.Base *; /*@ New Emodel to set */
46 }
47 }
48 model_unset {
49 /*@ Unset model
50 *
51 * @def elm_view_list_model_unset
52 * @since 1.11
53 */
54 }
55 model_get {
56 /*@ Get model
57 *
58 * @def elm_view_list_model_get
59 * @since 1.11
60 */
61 params {
62 @out model: Eo *; /*@ Returned Emodel */
63 }
64 }
65 }
66 /* For some reason the following comment after the event doesn't work: Event dispatch when a model is selected */
67 events {
68 model,selected;
69 }
70
71 implements {
72 Eo.Base.destructor;
73 }
74 constructors {
75 .genlist_set;
76 }
77}
diff --git a/src/lib/elm_view_list.h b/src/lib/elm_view_list.h
new file mode 100644
index 000000000..7d9823e81
--- /dev/null
+++ b/src/lib/elm_view_list.h
@@ -0,0 +1,10 @@
1
2#ifdef EFL_EO_API_SUPPORT
3#ifndef ELM_VIEW_LIST_H
4#define ELM_VIEW_LIST_H
5
6#include <Efl.h>
7#include <elm_view_list.eo.h>
8
9#endif
10#endif // ELM_VIEW_LIST_H