From 3c8abc0a8599a604011c6315aaf0b750521c7bc1 Mon Sep 17 00:00:00 2001 From: seoz Date: Tue, 6 Dec 2011 01:19:12 +0000 Subject: [PATCH] elm genlist/gengrid: Refactoring. Moved global function pointers to widget data. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@65930 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/elm_gengrid.c | 12 +++++------- src/lib/elm_genlist.c | 14 ++++++-------- src/lib/elm_genlist.h | 2 ++ 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/lib/elm_gengrid.c b/src/lib/elm_gengrid.c index 3a40dfe..e0d16e7 100644 --- a/src/lib/elm_gengrid.c +++ b/src/lib/elm_gengrid.c @@ -158,9 +158,6 @@ static const Evas_Smart_Cb_Description _signals[] = { {NULL, NULL} }; -static Eina_Compare_Cb _elm_gengrid_item_compare_cb; -static Eina_Compare_Cb _elm_gengrid_item_compare_data_cb; - static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, @@ -1823,7 +1820,7 @@ _elm_gengrid_item_compare_data(const void *data, const void *data1) const Elm_Gen_Item *it = data; const Elm_Gen_Item *item1 = data1; - return _elm_gengrid_item_compare_data_cb(it->base.data, item1->base.data); + return it->wd->item_compare_data_cb(it->base.data, item1->base.data); } static int @@ -1832,7 +1829,7 @@ _elm_gengrid_item_compare(const void *data, const void *data1) Elm_Gen_Item *it, *item1; it = ELM_GEN_ITEM_FROM_INLIST(data); item1 = ELM_GEN_ITEM_FROM_INLIST(data1); - return _elm_gengrid_item_compare_cb(it, item1); + return it->wd->item_compare_cb(it, item1); } static Elm_Gen_Item * @@ -2154,7 +2151,7 @@ elm_gengrid_item_direct_sorted_insert(Evas_Object *obj, if (!wd->state) wd->state = eina_inlist_sorted_state_new(); - _elm_gengrid_item_compare_cb = comp; + wd->item_compare_cb = comp; wd->items = eina_inlist_sorted_state_insert(wd->items, EINA_INLIST_GET(it), _elm_gengrid_item_compare, wd->state); if (wd->calc_job) ecore_job_del(wd->calc_job); @@ -2171,7 +2168,8 @@ elm_gengrid_item_sorted_insert(Evas_Object *obj, Evas_Smart_Cb func, const void *func_data) { - _elm_gengrid_item_compare_data_cb = comp; + Widget_Data *wd = elm_widget_data_get(obj); + wd->item_compare_data_cb = comp; return elm_gengrid_item_direct_sorted_insert(obj, itc, data, _elm_gengrid_item_compare_data, func, func_data); } diff --git a/src/lib/elm_genlist.c b/src/lib/elm_genlist.c index 80b0634..d3e4bd9 100644 --- a/src/lib/elm_genlist.c +++ b/src/lib/elm_genlist.c @@ -209,9 +209,6 @@ static const Evas_Smart_Cb_Description _signals[] = { {NULL, NULL} }; -static Eina_Compare_Cb _elm_genlist_item_compare_cb; -static Eina_Compare_Cb _elm_genlist_item_compare_data_cb; - /* TEMPORARY */ #undef ELM_CHECK_WIDTYPE #define ELM_CHECK_WIDTYPE(obj, widtype) \ @@ -3514,7 +3511,7 @@ _elm_genlist_item_compare_data(const void *data, const void *data1) const Elm_Gen_Item *it = data; const Elm_Gen_Item *item1 = data1; - return _elm_genlist_item_compare_data_cb(it->base.data, item1->base.data); + return it->wd->item_compare_data_cb(it->base.data, item1->base.data); } static int @@ -3523,7 +3520,7 @@ _elm_genlist_item_compare(const void *data, const void *data1) const Elm_Gen_Item *it, *item1; it = ELM_GEN_ITEM_FROM_INLIST(data); item1 = ELM_GEN_ITEM_FROM_INLIST(data1); - return _elm_genlist_item_compare_cb(it, item1); + return it->wd->item_compare_cb(it, item1); } static int @@ -3531,7 +3528,7 @@ _elm_genlist_item_list_compare(const void *data, const void *data1) { const Elm_Gen_Item *it = data; const Elm_Gen_Item *item1 = data1; - return _elm_genlist_item_compare_cb(it, item1); + return it->wd->item_compare_cb(it, item1); } static void @@ -3750,7 +3747,7 @@ elm_genlist_item_direct_sorted_insert(Evas_Object *obj, func_data); if (!it) return NULL; - _elm_genlist_item_compare_cb = comp; + wd->item_compare_cb = comp; if (it->parent) { @@ -3826,7 +3823,8 @@ elm_genlist_item_sorted_insert(Evas_Object *obj, Evas_Smart_Cb func, const void *func_data) { - _elm_genlist_item_compare_data_cb = comp; + Widget_Data *wd = elm_widget_data_get(obj); + wd->item_compare_data_cb = comp; return elm_genlist_item_direct_sorted_insert(obj, itc, data, parent, flags, _elm_genlist_item_compare_data, func, func_data); diff --git a/src/lib/elm_genlist.h b/src/lib/elm_genlist.h index b57930b..e8432d9 100644 --- a/src/lib/elm_genlist.h +++ b/src/lib/elm_genlist.h @@ -145,6 +145,8 @@ struct _Widget_Data double longpress_timeout; /* longpress timeout. this value comes from _elm_config by default. this can be changed by elm_genlist_longpress_timeout_set() */ int generation; /* a generation of genlist. when genlist is cleared, this value will be increased and a new generation will start */ + Eina_Compare_Cb item_compare_cb; + Eina_Compare_Cb item_compare_data_cb; Eina_Bool requeue : 1; /* The stuff below directly come from gengrid without any thinking */ -- 2.7.4