From fd909fc341730f5db7554e03d8466310001de845 Mon Sep 17 00:00:00 2001 From: ChunEon Park Date: Mon, 30 Jan 2012 06:06:03 +0000 Subject: [PATCH] elementary/list - deprecated elm_list_item_del() please use elm_object_item_del(). SVN revision: 67598 --- legacy/elementary/doc/examples.dox | 2 +- legacy/elementary/src/bin/test_index.c | 4 +- legacy/elementary/src/bin/test_list.c | 2 +- .../src/examples/index_example_01.c | 2 +- .../elementary/src/examples/list_example_03.c | 4 +- legacy/elementary/src/lib/elm_deprecated.h | 17 ++++ legacy/elementary/src/lib/elm_list.c | 84 +++++++++++-------- legacy/elementary/src/lib/elm_list.h | 45 +++------- 8 files changed, 83 insertions(+), 77 deletions(-) diff --git a/legacy/elementary/doc/examples.dox b/legacy/elementary/doc/examples.dox index 0b9cc1879d..c2e8f30c21 100644 --- a/legacy/elementary/doc/examples.dox +++ b/legacy/elementary/doc/examples.dox @@ -2464,7 +2464,7 @@ * @skipline _del_cb( * @until } * - * To delete an item we simple need to call elm_list_item_del() with + * To delete an item we simple need to call elm_object_item_del() with * a pointer for such item. * * If you need, you can get selected item with diff --git a/legacy/elementary/src/bin/test_index.c b/legacy/elementary/src/bin/test_index.c index d13c17399c..2fd0e510db 100644 --- a/legacy/elementary/src/bin/test_index.c +++ b/legacy/elementary/src/bin/test_index.c @@ -170,7 +170,7 @@ test_index2_it_del(void *data, Evas_Object *obj, void *event_info __UNUSED__) { iit = elm_index_item_find(gui->id, list_it); if (iit) elm_object_item_del(iit); - elm_list_item_del(list_it); + elm_object_item_del(list_it); return; } @@ -183,7 +183,7 @@ test_index2_it_del(void *data, Evas_Object *obj, void *event_info __UNUSED__) else elm_object_item_del(iit); - elm_list_item_del(list_it); + elm_object_item_del(list_it); } void diff --git a/legacy/elementary/src/bin/test_list.c b/legacy/elementary/src/bin/test_list.c index 5a7b757974..868fc57021 100644 --- a/legacy/elementary/src/bin/test_list.c +++ b/legacy/elementary/src/bin/test_list.c @@ -740,7 +740,7 @@ test_list5_item_del(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - elm_list_item_del(data); + elm_object_item_del(data); } static void diff --git a/legacy/elementary/src/examples/index_example_01.c b/legacy/elementary/src/examples/index_example_01.c index a4dffa4bce..4c669fef55 100644 --- a/legacy/elementary/src/examples/index_example_01.c +++ b/legacy/elementary/src/examples/index_example_01.c @@ -40,7 +40,7 @@ _index_item_del(void *data, data == elm_index_item_data_get(event_info) ? "OK" : "FAIL, something went wrong"); - elm_list_item_del(data); + elm_object_item_del(data); } /* delete an index item */ diff --git a/legacy/elementary/src/examples/list_example_03.c b/legacy/elementary/src/examples/list_example_03.c index 1814a4820a..23ffb84786 100644 --- a/legacy/elementary/src/examples/list_example_03.c +++ b/legacy/elementary/src/examples/list_example_03.c @@ -119,7 +119,7 @@ _add_data_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED_ printf("Error adding item\n"); return; } - elm_list_item_del_cb_set(list_it, _free_data); + elm_object_item_del_cb_set(list_it, _free_data); } static void @@ -129,7 +129,7 @@ _del_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) Evas_Object *li = data; selected_item = elm_list_selected_item_get(li); - elm_list_item_del(selected_item); + elm_object_item_del(selected_item); } static void diff --git a/legacy/elementary/src/lib/elm_deprecated.h b/legacy/elementary/src/lib/elm_deprecated.h index b54a8a1fa1..894ea73595 100644 --- a/legacy/elementary/src/lib/elm_deprecated.h +++ b/legacy/elementary/src/lib/elm_deprecated.h @@ -3719,6 +3719,23 @@ EINA_DEPRECATED EAPI void elm_list_item_cursor_engine_on */ EINA_DEPRECATED EAPI Eina_Bool elm_list_item_cursor_engine_only_get(const Elm_Object_Item *it); +/** + * Delete the item from the list. + * + * @param it The item of list to be deleted. + * + * If deleting all list items is required, elm_list_clear() + * should be used instead of getting items list and deleting each one. + * + * @see elm_list_clear() + * @see elm_list_item_append() + * @see elm_widget_item_del_cb_set() + * @deprecated Use elm_object_item_del() instead + * + * @ingroup List + */ +EINA_DEPRECATED EAPI void elm_list_item_del(Elm_Object_Item *it); + /** * Set the shrink state of toolbar @p obj. * diff --git a/legacy/elementary/src/lib/elm_list.c b/legacy/elementary/src/lib/elm_list.c index 8d03ae4e49..0c38ddd06f 100644 --- a/legacy/elementary/src/lib/elm_list.c +++ b/legacy/elementary/src/lib/elm_list.c @@ -135,8 +135,6 @@ _elm_list_item_free(Elm_List_Item *it) if (it->long_timer) ecore_timer_del(it->long_timer); if (it->icon) evas_object_del(it->icon); if (it->end) evas_object_del(it->end); - - elm_widget_item_del(it); } static Eina_Bool @@ -399,10 +397,9 @@ _elm_list_process_deletions(Widget_Data *wd) EINA_LIST_FREE(wd->to_delete, it) { - elm_widget_item_pre_notify_del(it); - wd->items = eina_list_remove_list(wd->items, it->node); _elm_list_item_free(it); + elm_widget_item_free(it); } wd->walking--; @@ -474,7 +471,11 @@ _del_hook(Evas_Object *obj) if (wd->to_delete) ERR("ERROR: leaking nodes!\n"); - EINA_LIST_FREE(wd->items, it) _elm_list_item_free(it); + EINA_LIST_FREE(wd->items, it) + { + _elm_list_item_free(it); + elm_widget_item_free(it); + } eina_list_free(wd->selected); free(wd); } @@ -1130,6 +1131,39 @@ _item_text_get(const Elm_Object_Item *it, const char *part) return ((Elm_List_Item *) it)->label; } +static Eina_Bool +_item_del_pre_hook(Elm_Object_Item *it) +{ + ELM_LIST_ITEM_CHECK_DELETED_RETURN(it, EINA_FALSE); + + Evas_Object *obj = WIDGET(it); + Elm_List_Item *item = (Elm_List_Item *) it; + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return EINA_FALSE; + + if (item->selected) _item_unselect(item); + + if (wd->walking > 0) + { + if (item->deleted) return EINA_FALSE; + item->deleted = EINA_TRUE; + wd->to_delete = eina_list_append(wd->to_delete, item); + return EINA_FALSE; + } + + wd->items = eina_list_remove_list(wd->items, item->node); + + evas_object_ref(obj); + _elm_list_walk(wd); + + _elm_list_item_free(item); + + _elm_list_unwalk(wd); + evas_object_unref(obj); + + return EINA_TRUE; +} + static Elm_List_Item * _item_new(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *end, Evas_Smart_Cb func, const void *data) { @@ -1172,6 +1206,7 @@ _item_new(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *e elm_widget_item_content_unset_hook_set(it, _item_content_unset); elm_widget_item_text_set_hook_set(it, _item_text_set); elm_widget_item_text_get_hook_set(it, _item_text_get); + elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook); return it; } @@ -1684,8 +1719,8 @@ elm_list_clear(Evas_Object *obj) EINA_LIST_FREE(wd->items, it) { - elm_widget_item_pre_notify_del(it); _elm_list_item_free(it); + elm_widget_item_free(it); } _elm_list_unwalk(wd); @@ -1903,37 +1938,6 @@ elm_list_item_bring_in(Elm_Object_Item *it) if (wd->scr) elm_smart_scroller_region_bring_in(wd->scr, x, y, w, h); } -EAPI void -elm_list_item_del(Elm_Object_Item *it) -{ - ELM_LIST_ITEM_CHECK_DELETED_RETURN(it); - Evas_Object *obj = WIDGET(it); - Elm_List_Item *item = (Elm_List_Item *) it; - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - - if (item->selected) _item_unselect(item); - - if (wd->walking > 0) - { - if (item->deleted) return; - item->deleted = EINA_TRUE; - wd->to_delete = eina_list_append(wd->to_delete, item); - return; - } - - wd->items = eina_list_remove_list(wd->items, item->node); - - evas_object_ref(obj); - _elm_list_walk(wd); - - elm_widget_item_pre_notify_del(item); - _elm_list_item_free(item); - - _elm_list_unwalk(wd); - evas_object_unref(obj); -} - EAPI Evas_Object * elm_list_item_object_get(const Elm_Object_Item *it) { @@ -1959,6 +1963,12 @@ elm_list_item_next(const Elm_Object_Item *it) else return NULL; } +EINA_DEPRECATED EAPI void +elm_list_item_del(Elm_Object_Item *it) +{ + elm_object_item_del(it); +} + EINA_DEPRECATED EAPI Evas_Object * elm_list_item_base_get(const Elm_Object_Item *it) { diff --git a/legacy/elementary/src/lib/elm_list.h b/legacy/elementary/src/lib/elm_list.h index 20927d3871..2ed3635e27 100644 --- a/legacy/elementary/src/lib/elm_list.h +++ b/legacy/elementary/src/lib/elm_list.h @@ -346,8 +346,7 @@ EAPI void elm_list_scroller_policy_get(const Evas_Object * A new item will be created and appended to the list, i.e., will * be set as @b last item. * - * Items created with this method can be deleted with - * elm_list_item_del(). + * Items created with this method can be deleted with elm_object_item_del(). * * Associated @p data can be properly freed when item is deleted if a * callback function is set with elm_widget_item_del_cb_set(). @@ -371,7 +370,7 @@ EAPI void elm_list_scroller_policy_get(const Evas_Object * @endcode * * @see elm_list_always_select_mode_set() - * @see elm_list_item_del() + * @see elm_object_item_del() * @see elm_widget_item_del_cb_set() * @see elm_list_clear() * @see elm_icon_add() @@ -398,8 +397,7 @@ EAPI Elm_Object_Item *elm_list_item_append(Evas_Object *obj, const * A new item will be created and prepended to the list, i.e., will * be set as @b first item. * - * Items created with this method can be deleted with - * elm_list_item_del(). + * Items created with this method can be deleted with elm_object_item_del(). * * Associated @p data can be properly freed when item is deleted if a * callback function is set with elm_widget_item_del_cb_set(). @@ -413,7 +411,7 @@ EAPI Elm_Object_Item *elm_list_item_append(Evas_Object *obj, const * * @see elm_list_item_append() for a simple code example. * @see elm_list_always_select_mode_set() - * @see elm_list_item_del() + * @see elm_object_item_del() * @see elm_widget_item_del_cb_set() * @see elm_list_clear() * @see elm_icon_add() @@ -441,8 +439,7 @@ EAPI Elm_Object_Item *elm_list_item_prepend(Evas_Object *obj, cons * A new item will be created and added to the list. Its position in * this list will be just before item @p before. * - * Items created with this method can be deleted with - * elm_list_item_del(). + * Items created with this method can be deleted with elm_object_item_del(). * * Associated @p data can be properly freed when item is deleted if a * callback function is set with elm_widget_item_del_cb_set(). @@ -456,7 +453,7 @@ EAPI Elm_Object_Item *elm_list_item_prepend(Evas_Object *obj, cons * * @see elm_list_item_append() for a simple code example. * @see elm_list_always_select_mode_set() - * @see elm_list_item_del() + * @see elm_object_item_del() * @see elm_widget_item_del_cb_set() * @see elm_list_clear() * @see elm_icon_add() @@ -484,8 +481,7 @@ EAPI Elm_Object_Item *elm_list_item_insert_before(Evas_Object *obj * A new item will be created and added to the list. Its position in * this list will be just after item @p after. * - * Items created with this method can be deleted with - * elm_list_item_del(). + * Items created with this method can be deleted with elm_object_item_del(). * * Associated @p data can be properly freed when item is deleted if a * callback function is set with elm_widget_item_del_cb_set(). @@ -499,7 +495,7 @@ EAPI Elm_Object_Item *elm_list_item_insert_before(Evas_Object *obj * * @see elm_list_item_append() for a simple code example. * @see elm_list_always_select_mode_set() - * @see elm_list_item_del() + * @see elm_object_item_del() * @see elm_widget_item_del_cb_set() * @see elm_list_clear() * @see elm_icon_add() @@ -535,8 +531,7 @@ EAPI Elm_Object_Item *elm_list_item_insert_after(Evas_Object *obj, * this list will be found comparing the new item with previously inserted * items using function @p cmp_func. * - * Items created with this method can be deleted with - * elm_list_item_del(). + * Items created with this method can be deleted with elm_object_item_del(). * * Associated @p data can be properly freed when item is deleted if a * callback function is set with elm_widget_item_del_cb_set(). @@ -550,7 +545,7 @@ EAPI Elm_Object_Item *elm_list_item_insert_after(Evas_Object *obj, * * @see elm_list_item_append() for a simple code example. * @see elm_list_always_select_mode_set() - * @see elm_list_item_del() + * @see elm_object_item_del() * @see elm_widget_item_del_cb_set() * @see elm_list_clear() * @see elm_icon_add() @@ -564,7 +559,7 @@ EAPI Elm_Object_Item *elm_list_item_sorted_insert(Evas_Object *obj * * @param obj The list object * - * @see elm_list_item_del() + * @see elm_object_item_del() * @see elm_list_item_append() * * @ingroup List @@ -579,7 +574,7 @@ EAPI void elm_list_clear(Evas_Object *obj); * or @c NULL on failure. * * @see elm_list_item_append() - * @see elm_list_item_del() + * @see elm_object_item_del() * @see elm_list_clear() * * @ingroup List @@ -717,22 +712,6 @@ EAPI void elm_list_item_show(Elm_Object_Item *it); */ EAPI void elm_list_item_bring_in(Elm_Object_Item *it); -/** - * Delete the item from the list. - * - * @param it The item of list to be deleted. - * - * If deleting all list items is required, elm_list_clear() - * should be used instead of getting items list and deleting each one. - * - * @see elm_list_clear() - * @see elm_list_item_append() - * @see elm_widget_item_del_cb_set() - * - * @ingroup List - */ -EAPI void elm_list_item_del(Elm_Object_Item *it); - /** * Gets the base object of the item. *