summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLarry Jr <larry.olj@gmail.com>2015-02-03 20:03:21 -0200
committerLarry Jr <larry.olj@gmail.com>2015-03-19 15:34:51 -0300
commitb2494ef738f3ad8b1bd12a258ba8867cd574eef1 (patch)
tree81118324a6f3626e46f49b5ec91dc258464f3630
parent55a022d4ab2925ed8c30d1039bde889bd2c173bf (diff)
update to new emodel API and resolved treeview expand incorrect clear
-rw-r--r--src/examples/filemvc.c2
-rw-r--r--src/lib/elm_view_form.c32
-rw-r--r--src/lib/elm_view_form.eo1
-rw-r--r--src/lib/elm_view_list.c94
4 files changed, 66 insertions, 63 deletions
diff --git a/src/examples/filemvc.c b/src/examples/filemvc.c
index 47e969db5..580845275 100644
--- a/src/examples/filemvc.c
+++ b/src/examples/filemvc.c
@@ -156,7 +156,7 @@ elm_main(int argc, char **argv)
156 genlist = elm_genlist_add(win); 156 genlist = elm_genlist_add(win);
157 priv.fileview = eo_add(ELM_VIEW_LIST_CLASS, NULL, elm_view_list_constructor(genlist, ELM_GENLIST_ITEM_NONE, "double_label")); 157 priv.fileview = eo_add(ELM_VIEW_LIST_CLASS, NULL, elm_view_list_constructor(genlist, ELM_GENLIST_ITEM_NONE, "double_label"));
158 eo_do(priv.fileview, elm_view_list_property_connect("filename", "elm.text"), 158 eo_do(priv.fileview, elm_view_list_property_connect("filename", "elm.text"),
159 elm_view_list_property_connect("mtime", "elm.text.sub")); 159 elm_view_list_property_connect("size", "elm.text.sub"));
160 160
161 evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _cleanup_cb, &priv); 161 evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _cleanup_cb, &priv);
162 _widget_init(genlist); 162 _widget_init(genlist);
diff --git a/src/lib/elm_view_form.c b/src/lib/elm_view_form.c
index 24a33cebf..f08c00e8b 100644
--- a/src/lib/elm_view_form.c
+++ b/src/lib/elm_view_form.c
@@ -43,24 +43,24 @@ _emodel_properties_change_cb(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Des
43{ 43{
44 const Emodel_Property_Event *evt = event_info; 44 const Emodel_Property_Event *evt = event_info;
45 Elm_View_Form_Data *priv = data; 45 Elm_View_Form_Data *priv = data;
46 Emodel_Property_Pair *pair = NULL; 46 Eina_Value value;
47 Eina_List *l, *fe = NULL; 47 Eina_List *l = NULL;
48 Elm_View_Form_Widget *w = NULL; 48 Elm_View_Form_Widget *w = NULL;
49 49
50 EINA_SAFETY_ON_NULL_RETURN_VAL(priv, EINA_TRUE); 50 EINA_SAFETY_ON_NULL_RETURN_VAL(priv, EINA_TRUE);
51 EINA_SAFETY_ON_NULL_RETURN_VAL(evt, EINA_TRUE); 51 EINA_SAFETY_ON_NULL_RETURN_VAL(evt, EINA_TRUE);
52 52
53 //update all widgets with this property 53 if (evt->changed_properties && eina_value_type_get(evt->changed_properties) == EINA_VALUE_TYPE_STRUCT)
54 EINA_LIST_FOREACH(priv->l, l, w)
55 { 54 {
56 EINA_LIST_FOREACH(evt->changed_properties, fe, pair) 55 //update all widgets with this property
57 { 56 EINA_LIST_FOREACH(priv->l, l, w)
58 if(w->widget_propname == pair->property) 57 {
59 { 58 if (eina_value_struct_value_get(evt->changed_properties, w->widget_propname, &value) == EINA_TRUE)
60 w->widget_obj_set_cb(priv->model_obj, w->widget_obj, &pair->value, pair->property); 59 {
61 break; 60 w->widget_obj_set_cb(priv->model_obj, w->widget_obj, &value, w->widget_propname);
62 } 61 eina_value_flush(&value);
63 } 62 }
63 }
64 } 64 }
65 65
66 return EINA_TRUE; 66 return EINA_TRUE;
@@ -188,10 +188,9 @@ _elm_view_widget_add(Elm_View_Form_Data *priv, const char *propname, Evas_Object
188 * @brief constructor 188 * @brief constructor
189 */ 189 */
190static void 190static void
191_elm_view_form_constructor(Eo *obj, Elm_View_Form_Data *_pd, Eo *model) 191_elm_view_form_constructor(Eo *obj EINA_UNUSED, Elm_View_Form_Data *_pd, Eo *model)
192{ 192{
193 Elm_View_Form_Data *priv = (Elm_View_Form_Data *)_pd; 193 Elm_View_Form_Data *priv = (Elm_View_Form_Data *)_pd;
194 eo_do_super(obj, MY_CLASS, eo_constructor());
195 priv->model_obj = model; 194 priv->model_obj = model;
196 if (priv->model_obj != NULL) 195 if (priv->model_obj != NULL)
197 { 196 {
@@ -203,16 +202,13 @@ _elm_view_form_constructor(Eo *obj, Elm_View_Form_Data *_pd, Eo *model)
203static void 202static void
204_elm_view_form_eo_base_constructor(Eo *obj, Elm_View_Form_Data *_pd EINA_UNUSED) 203_elm_view_form_eo_base_constructor(Eo *obj, Elm_View_Form_Data *_pd EINA_UNUSED)
205{ 204{
206 eo_error_set(obj);
207 fprintf(stderr, "only custom constructor can be used with '%s' class", MY_CLASS_NAME);
208} 205}
209 206
210
211/** 207/**
212 * @brief destructor 208 * @brief destructor
213 */ 209 */
214static void 210static void
215_elm_view_form_eo_base_destructor(Eo *obj, Elm_View_Form_Data *priv) 211_elm_view_form_eo_base_destructor(Eo *obj EINA_UNUSED, Elm_View_Form_Data *priv)
216{ 212{
217 Elm_View_Form_Widget *w = NULL; 213 Elm_View_Form_Widget *w = NULL;
218 EINA_LIST_FREE(priv->l, w) 214 EINA_LIST_FREE(priv->l, w)
diff --git a/src/lib/elm_view_form.eo b/src/lib/elm_view_form.eo
index aa6528d85..6abd5fdf7 100644
--- a/src/lib/elm_view_form.eo
+++ b/src/lib/elm_view_form.eo
@@ -30,7 +30,6 @@ class Elm_View_Form (Eo.Base)
30 } 30 }
31 implements { 31 implements {
32 Eo.Base.destructor; 32 Eo.Base.destructor;
33 Eo.Base.constructor;
34 } 33 }
35 constructors { 34 constructors {
36 .constructor; 35 .constructor;
diff --git a/src/lib/elm_view_list.c b/src/lib/elm_view_list.c
index aeb6c4c5f..56b5df07b 100644
--- a/src/lib/elm_view_list.c
+++ b/src/lib/elm_view_list.c
@@ -57,16 +57,22 @@ static void
57_item_del(void *data, Evas_Object *obj EINA_UNUSED) 57_item_del(void *data, Evas_Object *obj EINA_UNUSED)
58{ 58{
59 View_List_ItemData *idata = data; 59 View_List_ItemData *idata = data;
60 if (idata) { 60 if (!idata)
61 eo_do(idata->model, eo_event_callback_del(EMODEL_EVENT_PROPERTIES_CHANGED, _emodel_properties_change_cb, idata)); 61 return;
62 eo_do(idata->model, eo_event_callback_del(EMODEL_EVENT_LOAD_STATUS, _emodel_load_status_change_cb, idata)); 62
63 eo_do(idata->model, eo_event_callback_del(EMODEL_EVENT_CHILDREN_COUNT_CHANGED, _emodel_children_count_change_cb, idata)); 63 eo_do(idata->model, eo_event_callback_del(EMODEL_EVENT_PROPERTIES_CHANGED,
64 eo_unref(idata->model); 64 _emodel_properties_change_cb, idata));
65 idata->model = NULL; 65 eo_do(idata->model, eo_event_callback_del(EMODEL_EVENT_LOAD_STATUS,
66 idata->item = NULL; 66 _emodel_load_status_change_cb, idata));
67 idata->parent = NULL; 67 eo_do(idata->model, eo_event_callback_del(EMODEL_EVENT_CHILDREN_COUNT_CHANGED,
68 idata->priv = NULL; 68 _emodel_children_count_change_cb, idata));
69 } 69
70 eo_unref(idata->model);
71 idata->model = NULL;
72 idata->item = NULL;
73 idata->parent = NULL;
74 idata->priv = NULL;
75
70 free(idata); 76 free(idata);
71} 77}
72 78
@@ -136,10 +142,7 @@ _item_text_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part)
136 142
137 eina_value_setup(&value, EINA_VALUE_TYPE_STRING); 143 eina_value_setup(&value, EINA_VALUE_TYPE_STRING);
138 eo_do(idata->model, emodel_property_get(prop, &value)); 144 eo_do(idata->model, emodel_property_get(prop, &value));
139 if (eina_value_type_get(&value) == EINA_VALUE_TYPE_STRING) 145 text = eina_value_to_string(&value);
140 {
141 text = eina_value_to_string(&value);
142 }
143 eina_value_flush(&value); 146 eina_value_flush(&value);
144 147
145 return text; 148 return text;
@@ -150,14 +153,19 @@ _expand_request_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e
150{ 153{
151 Elm_Object_Item *item = event_info; 154 Elm_Object_Item *item = event_info;
152 View_List_ItemData *idata = elm_object_item_data_get(item); 155 View_List_ItemData *idata = elm_object_item_data_get(item);
153 Emodel_Load_Status st; 156 Emodel_Load_Status st = EMODEL_LOAD_STATUS_ERROR;
157
158 EINA_SAFETY_ON_NULL_RETURN(idata);
154 159
155 eo_do(idata->model, st = emodel_load_status_get()); 160 eo_do(idata->model, st = emodel_load_status_get());
156 eo_do(idata->model, eo_event_callback_add(EMODEL_EVENT_LOAD_STATUS, _emodel_load_status_change_cb, idata)); 161 eo_do(idata->model, eo_event_callback_add(EMODEL_EVENT_LOAD_STATUS,
157 eo_do(idata->model, eo_event_callback_add(EMODEL_EVENT_CHILDREN_COUNT_CHANGED, _emodel_children_count_change_cb, idata)); 162 _emodel_load_status_change_cb, idata));
163 eo_do(idata->model, eo_event_callback_add(EMODEL_EVENT_CHILDREN_COUNT_CHANGED,
164 _emodel_children_count_change_cb, idata));
165
158 if (st & EMODEL_LOAD_STATUS_LOADED_CHILDREN) 166 if (st & EMODEL_LOAD_STATUS_LOADED_CHILDREN)
159 { 167 {
160 _emodel_load_children(idata); 168 _emodel_load_children(idata);
161 } 169 }
162 else 170 else
163 { 171 {
@@ -171,8 +179,10 @@ _contract_request_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
171 Elm_Object_Item *item = event_info; 179 Elm_Object_Item *item = event_info;
172 View_List_ItemData *idata = elm_object_item_data_get(item); 180 View_List_ItemData *idata = elm_object_item_data_get(item);
173 181
174 eo_do(idata->model, eo_event_callback_del(EMODEL_EVENT_LOAD_STATUS, _emodel_load_status_change_cb, idata)); 182 eo_do(idata->model, eo_event_callback_del(EMODEL_EVENT_LOAD_STATUS,
175 eo_do(idata->model, eo_event_callback_del(EMODEL_EVENT_CHILDREN_COUNT_CHANGED, _emodel_children_count_change_cb, idata)); 183 _emodel_load_status_change_cb, idata));
184 eo_do(idata->model, eo_event_callback_del(EMODEL_EVENT_CHILDREN_COUNT_CHANGED,
185 _emodel_children_count_change_cb, idata));
176 elm_genlist_item_expanded_set(item, EINA_FALSE); 186 elm_genlist_item_expanded_set(item, EINA_FALSE);
177} 187}
178 188
@@ -201,7 +211,8 @@ _genlist_deleted(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_
201 211
202/* --- Emodel Callbacks --- */ 212/* --- Emodel Callbacks --- */
203static Eina_Bool 213static Eina_Bool
204_emodel_properties_change_cb(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info) 214_emodel_properties_change_cb(void *data, Eo *obj EINA_UNUSED,
215 const Eo_Event_Description *desc EINA_UNUSED, void *event_info)
205{ 216{
206 View_List_ItemData *idata = data; 217 View_List_ItemData *idata = data;
207 Emodel_Property_Event *evt = event_info; 218 Emodel_Property_Event *evt = event_info;
@@ -210,7 +221,7 @@ _emodel_properties_change_cb(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Des
210 EINA_SAFETY_ON_NULL_RETURN_VAL(evt, EINA_TRUE); 221 EINA_SAFETY_ON_NULL_RETURN_VAL(evt, EINA_TRUE);
211 222
212 if (idata->item) 223 if (idata->item)
213 elm_genlist_item_update(idata->item); 224 elm_genlist_item_update(idata->item);
214 225
215 return EINA_TRUE; 226 return EINA_TRUE;
216} 227}
@@ -219,9 +230,11 @@ static void
219_emodel_load_children(View_List_ItemData *pdata) 230_emodel_load_children(View_List_ItemData *pdata)
220{ 231{
221 Eo *child; 232 Eo *child;
222 Eina_Accessor *accessor; 233 Eina_Accessor *accessor = NULL;
234 EINA_SAFETY_ON_NULL_RETURN(pdata);
235
223 Elm_View_List_Data *priv = pdata->priv; 236 Elm_View_List_Data *priv = pdata->priv;
224 unsigned int total, i; 237 unsigned int i, total = 0;
225 238
226 eo_do(pdata->model, emodel_children_count_get(&total)); 239 eo_do(pdata->model, emodel_children_count_get(&total));
227 if (total == 0) 240 if (total == 0)
@@ -240,27 +253,27 @@ _emodel_load_children(View_List_ItemData *pdata)
240 idata->parent = pdata; 253 idata->parent = pdata;
241 idata->model = child; 254 idata->model = child;
242 eo_ref(child); 255 eo_ref(child);
243 eo_do(child, eo_event_callback_add(EMODEL_EVENT_PROPERTIES_CHANGED, _emodel_properties_change_cb, idata)); 256 eo_do(child, eo_event_callback_add(EMODEL_EVENT_PROPERTIES_CHANGED,
257 _emodel_properties_change_cb, idata));
244 eo_do(child, emodel_properties_load()); 258 eo_do(child, emodel_properties_load());
245 idata->item = elm_genlist_item_append(priv->genlist, priv->itc, idata, pdata->item, 259 idata->item = elm_genlist_item_append(priv->genlist, priv->itc, idata, pdata->item,
246 priv->itype, _item_sel_cb, idata); 260 priv->itype, _item_sel_cb, idata);
247 } 261 }
248 262
249 if (pdata->item) 263 if (pdata->item)
250 { 264 elm_genlist_item_expanded_set(pdata->item, EINA_TRUE);
251 elm_genlist_item_expanded_set(pdata->item, EINA_TRUE);
252 }
253} 265}
254 266
255static Eina_Bool 267static Eina_Bool
256_emodel_children_count_change_cb(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) 268_emodel_children_count_change_cb(void *data, Eo *obj EINA_UNUSED,
269 const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
257{ 270{
258 View_List_ItemData *idata = data; 271 View_List_ItemData *idata = data;
259 EINA_SAFETY_ON_NULL_RETURN_VAL(idata, EINA_FALSE); 272 EINA_SAFETY_ON_NULL_RETURN_VAL(idata, EINA_FALSE);
260 EINA_SAFETY_ON_NULL_RETURN_VAL(idata->priv, EINA_FALSE); 273 EINA_SAFETY_ON_NULL_RETURN_VAL(idata->priv, EINA_FALSE);
261 EINA_SAFETY_ON_NULL_RETURN_VAL(idata->priv->genlist, EINA_FALSE); 274 EINA_SAFETY_ON_NULL_RETURN_VAL(idata->priv->genlist, EINA_FALSE);
262 275
263 eo_do(idata->priv->genlist, elm_obj_genlist_clear()); 276 elm_genlist_item_subitems_clear(idata->item);
264 277
265 _emodel_load_children(idata); 278 _emodel_load_children(idata);
266 279
@@ -268,18 +281,12 @@ _emodel_children_count_change_cb(void *data, Eo *obj EINA_UNUSED, const Eo_Event
268} 281}
269 282
270static Eina_Bool 283static Eina_Bool
271_emodel_load_status_change_cb(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info) 284_emodel_load_status_change_cb(void *data, Eo *obj EINA_UNUSED,
285 const Eo_Event_Description *desc EINA_UNUSED, void *event_info)
272{ 286{
273 View_List_ItemData *idata = data; 287 View_List_ItemData *idata = data;
274 Emodel_Load *load = event_info; 288 Emodel_Load *load = event_info;
275 289
276/* if ((load->status & EMODEL_LOAD_STATUS_LOADED_CHILDREN)
277 && !(data->status & EMODEL_LOAD_STATUS_LOADED_CHILDREN))
278 {
279 _emodel_load_children(idata);
280 }
281 else
282*/
283 if (load->status & EMODEL_LOAD_STATUS_UNLOADED) 290 if (load->status & EMODEL_LOAD_STATUS_UNLOADED)
284 { 291 {
285 if (idata->item) 292 if (idata->item)
@@ -328,10 +335,9 @@ _priv_model_set(Elm_View_List_Data *priv, Eo *model)
328 * @brief Elm View List Class impl. 335 * @brief Elm View List Class impl.
329 */ 336 */
330static void 337static void
331_elm_view_list_constructor(Eo *obj, Elm_View_List_Data *priv, Evas_Object *genlist, Elm_Genlist_Item_Type itype, const char *istyle) 338_elm_view_list_constructor(Eo *obj, Elm_View_List_Data *priv, Evas_Object *genlist,
339 Elm_Genlist_Item_Type itype, const char *istyle)
332{ 340{
333 eo_do_super(obj, MY_CLASS, eo_constructor());
334
335 priv->view = obj; 341 priv->view = obj;
336 priv->genlist = genlist; 342 priv->genlist = genlist;
337 priv->itype = itype; 343 priv->itype = itype;
@@ -342,7 +348,8 @@ _elm_view_list_constructor(Eo *obj, Elm_View_List_Data *priv, Evas_Object *genli
342 priv->rootdata->priv = priv; 348 priv->rootdata->priv = priv;
343 349
344 priv->itc = elm_genlist_item_class_new(); 350 priv->itc = elm_genlist_item_class_new();
345 priv->itc->item_style = strdup(istyle); 351 if (istyle)
352 priv->itc->item_style = strdup(istyle);
346 priv->itc->func.text_get = _item_text_get; 353 priv->itc->func.text_get = _item_text_get;
347 priv->itc->func.content_get = _item_content_get; 354 priv->itc->func.content_get = _item_content_get;
348 priv->itc->func.state_get = NULL; 355 priv->itc->func.state_get = NULL;
@@ -397,7 +404,8 @@ _elm_view_list_evas_object_get(Eo *obj, Elm_View_List_Data *priv, Evas_Object **
397} 404}
398 405
399static void 406static void
400_elm_view_list_property_connect(Eo *obj EINA_UNUSED, Elm_View_List_Data *priv, const char *property, const char *part) 407_elm_view_list_property_connect(Eo *obj EINA_UNUSED, Elm_View_List_Data *priv,
408 const char *property, const char *part)
401{ 409{
402 EINA_SAFETY_ON_NULL_RETURN(priv); 410 EINA_SAFETY_ON_NULL_RETURN(priv);
403 411