Constant void data is pretty useless in item callback contexts.

the callbacks are supposed to freely modify their data, as it is their
context (ie: python/js object, row from database, etc.



SVN revision: 52372
This commit is contained in:
Gustavo Sverzut Barbieri 2010-09-17 16:21:34 +00:00
parent 6a9ba35610
commit c4d40c7183
4 changed files with 35 additions and 30 deletions

View File

@ -618,10 +618,10 @@ extern "C" {
typedef struct _Elm_Gengrid_Item_Class Elm_Gengrid_Item_Class; typedef struct _Elm_Gengrid_Item_Class Elm_Gengrid_Item_Class;
typedef struct _Elm_Gengrid_Item_Class_Func Elm_Gengrid_Item_Class_Func; typedef struct _Elm_Gengrid_Item_Class_Func Elm_Gengrid_Item_Class_Func;
typedef struct _Elm_Gengrid_Item Elm_Gengrid_Item; /**< Item of Elm_Gengrid. Sub-type of Elm_Widget_Item */ typedef struct _Elm_Gengrid_Item Elm_Gengrid_Item; /**< Item of Elm_Gengrid. Sub-type of Elm_Widget_Item */
typedef char *(*GridItemLabelGetFunc) (const void *data, Evas_Object *obj, const char *part); typedef char *(*GridItemLabelGetFunc) (void *data, Evas_Object *obj, const char *part);
typedef Evas_Object *(*GridItemIconGetFunc) (const void *data, Evas_Object *obj, const char *part); typedef Evas_Object *(*GridItemIconGetFunc) (void *data, Evas_Object *obj, const char *part);
typedef Eina_Bool (*GridItemStateGetFunc) (const void *data, Evas_Object *obj, const char *part); typedef Eina_Bool (*GridItemStateGetFunc) (void *data, Evas_Object *obj, const char *part);
typedef void (*GridItemDelFunc) (const void *data, Evas_Object *obj); typedef void (*GridItemDelFunc) (void *data, Evas_Object *obj);
struct _Elm_Gengrid_Item_Class struct _Elm_Gengrid_Item_Class
{ {
@ -1164,10 +1164,10 @@ extern "C" {
typedef struct _Elm_Genlist_Item_Class Elm_Genlist_Item_Class; typedef struct _Elm_Genlist_Item_Class Elm_Genlist_Item_Class;
typedef struct _Elm_Genlist_Item Elm_Genlist_Item; /**< Item of Elm_Genlist. Sub-type of Elm_Widget_Item */ typedef struct _Elm_Genlist_Item Elm_Genlist_Item; /**< Item of Elm_Genlist. Sub-type of Elm_Widget_Item */
typedef struct _Elm_Genlist_Item_Class_Func Elm_Genlist_Item_Class_Func; typedef struct _Elm_Genlist_Item_Class_Func Elm_Genlist_Item_Class_Func;
typedef char *(*GenlistItemLabelGetFunc) (const void *data, Evas_Object *obj, const char *part); typedef char *(*GenlistItemLabelGetFunc) (void *data, Evas_Object *obj, const char *part);
typedef Evas_Object *(*GenlistItemIconGetFunc) (const void *data, Evas_Object *obj, const char *part); typedef Evas_Object *(*GenlistItemIconGetFunc) (void *data, Evas_Object *obj, const char *part);
typedef Eina_Bool (*GenlistItemStateGetFunc) (const void *data, Evas_Object *obj, const char *part); typedef Eina_Bool (*GenlistItemStateGetFunc) (void *data, Evas_Object *obj, const char *part);
typedef void (*GenlistItemDelFunc) (const void *data, Evas_Object *obj); typedef void (*GenlistItemDelFunc) (void *data, Evas_Object *obj);
struct _Elm_Genlist_Item_Class struct _Elm_Genlist_Item_Class
{ {

View File

@ -100,14 +100,14 @@ _sizing_eval(Evas_Object *obj)
/*** GENLIST "MODEL" ***/ /*** GENLIST "MODEL" ***/
static char* static char*
_itc_label_get(const void *data, Evas_Object *obj __UNUSED__, const char *source __UNUSED__) _itc_label_get(void *data, Evas_Object *obj __UNUSED__, const char *source __UNUSED__)
{ {
//~ printf("LABEL_GET: %s\n", (char*) data); //~ printf("LABEL_GET: %s\n", (char*) data);
return strdup(ecore_file_file_get(data)); // NOTE this will be free() by the caller return strdup(ecore_file_file_get(data)); // NOTE this will be free() by the caller
} }
static Evas_Object* static Evas_Object*
_itc_icon_get(const void *data, Evas_Object *obj, const char *source) _itc_icon_get(void *data, Evas_Object *obj, const char *source)
{ {
Evas_Object *ic; Evas_Object *ic;
@ -127,13 +127,13 @@ _itc_icon_get(const void *data, Evas_Object *obj, const char *source)
} }
static Eina_Bool static Eina_Bool
_itc_state_get(const void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *source __UNUSED__) _itc_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *source __UNUSED__)
{ {
return EINA_FALSE; return EINA_FALSE;
} }
static void static void
_itc_del(const void *data, Evas_Object *obj __UNUSED__) _itc_del(void *data, Evas_Object *obj __UNUSED__)
{ {
//~ printf("DEL DATA [%s]\n", (char*)data); //~ printf("DEL DATA [%s]\n", (char*)data);
eina_stringshare_del(data); eina_stringshare_del(data);

View File

@ -477,8 +477,8 @@ _item_realize(Elm_Gengrid_Item *item)
"labels")); "labels"));
EINA_LIST_FOREACH(item->labels, l, key) EINA_LIST_FOREACH(item->labels, l, key)
{ {
char *s = item->gic->func.label_get(item->base.data, item->wd->self, char *s = item->gic->func.label_get
l->data); ((void *)item->base.data, item->wd->self, l->data);
if (s) if (s)
{ {
edje_object_part_text_set(item->base.view, l->data, s); edje_object_part_text_set(item->base.view, l->data, s);
@ -496,9 +496,8 @@ _item_realize(Elm_Gengrid_Item *item)
"icons")); "icons"));
EINA_LIST_FOREACH(item->icons, l, key) EINA_LIST_FOREACH(item->icons, l, key)
{ {
Evas_Object *ic = item->gic->func.icon_get(item->base.data, Evas_Object *ic = item->gic->func.icon_get
item->wd->self, ((void *)item->base.data, item->wd->self, l->data);
l->data);
if (ic) if (ic)
{ {
item->icon_objs = eina_list_append(item->icon_objs, ic); item->icon_objs = eina_list_append(item->icon_objs, ic);
@ -518,8 +517,8 @@ _item_realize(Elm_Gengrid_Item *item)
"states")); "states"));
EINA_LIST_FOREACH(item->states, l, key) EINA_LIST_FOREACH(item->states, l, key)
{ {
Eina_Bool on = item->gic->func.state_get(item->base.data, Eina_Bool on = item->gic->func.state_get
item->wd->self, l->data); ((void *)item->base.data, item->wd->self, l->data);
if (on) if (on)
{ {
snprintf(buf, sizeof(buf), "elm,state,%s,active", key); snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
@ -675,7 +674,7 @@ _item_del(Elm_Gengrid_Item *item)
item->wd->selected = eina_list_remove(item->wd->selected, item); item->wd->selected = eina_list_remove(item->wd->selected, item);
if (item->realized) _item_unrealize(item); if (item->realized) _item_unrealize(item);
if ((!item->delete_me) && (item->gic->func.del)) if ((!item->delete_me) && (item->gic->func.del))
item->gic->func.del(item->base.data, item->wd->self); item->gic->func.del((void *)item->base.data, item->wd->self);
item->delete_me = EINA_TRUE; item->delete_me = EINA_TRUE;
item->wd->items = eina_list_remove(item->wd->items, item); item->wd->items = eina_list_remove(item->wd->items, item);
if (item->long_timer) ecore_timer_del(item->long_timer); if (item->long_timer) ecore_timer_del(item->long_timer);
@ -1154,8 +1153,8 @@ elm_gengrid_item_del(Elm_Gengrid_Item *item)
elm_widget_item_pre_notify_del(item); elm_widget_item_pre_notify_del(item);
if (item->selected) if (item->selected)
item->wd->selected = eina_list_remove(item->wd->selected, item); item->wd->selected = eina_list_remove(item->wd->selected, item);
if (item->gic->func.del) if (item->gic->func.del)
item->gic->func.del(item->base.data, item->wd->self); item->gic->func.del((void *)item->base.data, item->wd->self);
return; return;
} }
@ -1219,7 +1218,8 @@ elm_gengrid_clear(Evas_Object *obj)
wd->items = eina_list_remove_list(wd->items, l); wd->items = eina_list_remove_list(wd->items, l);
elm_widget_item_pre_notify_del(item); elm_widget_item_pre_notify_del(item);
if (item->realized) _item_unrealize(item); if (item->realized) _item_unrealize(item);
if (item->gic->func.del) item->gic->func.del(item->base.data, wd->self); if (item->gic->func.del)
item->gic->func.del((void *)item->base.data, wd->self);
if (item->long_timer) ecore_timer_del(item->long_timer); if (item->long_timer) ecore_timer_del(item->long_timer);
elm_widget_item_del(item); elm_widget_item_del(item);
} }

View File

@ -517,8 +517,8 @@ _item_del(Elm_Genlist_Item *it)
if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it); if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
if (it->realized) _item_unrealize(it); if (it->realized) _item_unrealize(it);
if (it->block) _item_block_del(it); if (it->block) _item_block_del(it);
if ((!it->delete_me) && (it->itc->func.del)) if ((!it->delete_me) && (it->itc->func.del))
it->itc->func.del(it->base.data, it->base.widget); it->itc->func.del((void *)it->base.data, it->base.widget);
it->delete_me = EINA_TRUE; it->delete_me = EINA_TRUE;
if (it->queued) if (it->queued)
it->wd->queue = eina_list_remove(it->wd->queue, it); it->wd->queue = eina_list_remove(it->wd->queue, it);
@ -903,7 +903,8 @@ _item_realize(Elm_Genlist_Item *it, int in, int calc)
it->labels = elm_widget_stringlist_get(edje_object_data_get(it->base.view, "labels")); it->labels = elm_widget_stringlist_get(edje_object_data_get(it->base.view, "labels"));
EINA_LIST_FOREACH(it->labels, l, key) EINA_LIST_FOREACH(it->labels, l, key)
{ {
char *s = it->itc->func.label_get(it->base.data, it->base.widget, l->data); char *s = it->itc->func.label_get
((void *)it->base.data, it->base.widget, l->data);
if (s) if (s)
{ {
@ -920,7 +921,8 @@ _item_realize(Elm_Genlist_Item *it, int in, int calc)
it->icons = elm_widget_stringlist_get(edje_object_data_get(it->base.view, "icons")); it->icons = elm_widget_stringlist_get(edje_object_data_get(it->base.view, "icons"));
EINA_LIST_FOREACH(it->icons, l, key) EINA_LIST_FOREACH(it->icons, l, key)
{ {
Evas_Object *ic = it->itc->func.icon_get(it->base.data, it->base.widget, l->data); Evas_Object *ic = it->itc->func.icon_get
((void *)it->base.data, it->base.widget, l->data);
if (ic) if (ic)
{ {
@ -939,7 +941,8 @@ _item_realize(Elm_Genlist_Item *it, int in, int calc)
it->states = elm_widget_stringlist_get(edje_object_data_get(it->base.view, "states")); it->states = elm_widget_stringlist_get(edje_object_data_get(it->base.view, "states"));
EINA_LIST_FOREACH(it->states, l, key) EINA_LIST_FOREACH(it->states, l, key)
{ {
Eina_Bool on = it->itc->func.state_get(it->base.data, it->base.widget, l->data); Eina_Bool on = it->itc->func.state_get
((void *)it->base.data, it->base.widget, l->data);
if (on) if (on)
{ {
@ -1988,7 +1991,8 @@ elm_genlist_clear(Evas_Object *obj)
wd->items = eina_inlist_remove(wd->items, wd->items); wd->items = eina_inlist_remove(wd->items, wd->items);
elm_widget_item_pre_notify_del(it); elm_widget_item_pre_notify_del(it);
if (it->realized) _item_unrealize(it); if (it->realized) _item_unrealize(it);
if (it->itc->func.del) it->itc->func.del(it->base.data, it->base.widget); if (it->itc->func.del)
it->itc->func.del((void *)it->base.data, it->base.widget);
if (it->long_timer) ecore_timer_del(it->long_timer); if (it->long_timer) ecore_timer_del(it->long_timer);
elm_widget_item_del(it); elm_widget_item_del(it);
} }
@ -2805,7 +2809,8 @@ elm_genlist_item_del(Elm_Genlist_Item *it)
if (it->wd->calc_job) ecore_job_del(it->wd->calc_job); if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
it->wd->calc_job = ecore_job_add(_calc_job, it->wd); it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
} }
if (it->itc->func.del) it->itc->func.del(it->base.data, it->base.widget); if (it->itc->func.del)
it->itc->func.del((void *)it->base.data, it->base.widget);
return; return;
} }
_item_del(it); _item_del(it);