From 11d67f493ddd7b57c46dd3ef7122a7af9fb6cb12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Briano?= Date: Mon, 16 Jan 2012 17:25:40 +0000 Subject: [PATCH] Add evas_object_smart_callback_del_full API Patch by Raphael Kubo Costas (rakuco) SVN revision: 67246 --- legacy/evas/ChangeLog | 4 +++ legacy/evas/NEWS | 1 + legacy/evas/src/lib/Evas.h | 28 +++++++++++++++++ .../evas/src/lib/canvas/evas_object_smart.c | 31 +++++++++++++++++++ 4 files changed, 64 insertions(+) diff --git a/legacy/evas/ChangeLog b/legacy/evas/ChangeLog index f95e796755..6e7e747788 100644 --- a/legacy/evas/ChangeLog +++ b/legacy/evas/ChangeLog @@ -633,4 +633,8 @@ can cause issues if new configs are added. Now we have evas allocate it for you. +2012-01-16 Raphael Kubo da Costa (rakuco) + * Add evas_object_smart_callback_del_full() to allow users to + unregister a specific smart event callback instead of all + callbacks matching a given type and function pointer. diff --git a/legacy/evas/NEWS b/legacy/evas/NEWS index 33026c0b56..945fd96cff 100644 --- a/legacy/evas/NEWS +++ b/legacy/evas/NEWS @@ -7,6 +7,7 @@ Additions: * Textblock now supports self-closing tags, i.e
. Those should be used instead of the old
way. * Shm engine for drawing in Wayland. + * evas_object_smart_callback_del_full API. Improvements: diff --git a/legacy/evas/src/lib/Evas.h b/legacy/evas/src/lib/Evas.h index 1a8d377a58..1854aee7b8 100644 --- a/legacy/evas/src/lib/Evas.h +++ b/legacy/evas/src/lib/Evas.h @@ -9846,6 +9846,34 @@ EAPI void evas_object_smart_callback_priority_add(Evas_Object *obj, */ EAPI void *evas_object_smart_callback_del (Evas_Object *obj, const char *event, Evas_Smart_Cb func) EINA_ARG_NONNULL(1, 2, 3); +/** + * Delete (unregister) a callback function from the smart event + * specified by @p event on the smart object @p obj. + * + * @param obj a smart object + * @param event the event's name string + * @param func the callback function + * @param data the data pointer that was passed to the callback + * @return the data pointer + * + * This function removes the first added smart callback on the + * object @p obj matching the event name @p event, the registered + * function pointer @p func and the callback data pointer @p data. If + * the removal is successful it will also return the data pointer that + * was passed to evas_object_smart_callback_add() (that will be the same + * as the parameter) when the callback(s) was(were) added to the canvas. + * If not successful @c NULL will be returned. A common use would be to + * remove an exact match of a callback + * + * @see evas_object_smart_callback_add() for more details. + * @since 1.2.0 + * @ingroup Evas_Smart_Object_Group + * + * @note To delete all smart event callbacks which match @p type and @p func, + * use evas_object_smart_callback_del(). + */ +EAPI void *evas_object_smart_callback_del_full(Evas_Object *obj, const char *event, Evas_Smart_Cb func, const void *data) EINA_ARG_NONNULL(1, 2, 3); + /** * Call a given smart callback on the smart object @p obj. * diff --git a/legacy/evas/src/lib/canvas/evas_object_smart.c b/legacy/evas/src/lib/canvas/evas_object_smart.c index a7dfcdf796..cca7201569 100644 --- a/legacy/evas/src/lib/canvas/evas_object_smart.c +++ b/legacy/evas/src/lib/canvas/evas_object_smart.c @@ -402,6 +402,37 @@ evas_object_smart_callback_del(Evas_Object *obj, const char *event, Evas_Smart_C return NULL; } +EAPI void * +evas_object_smart_callback_del_full(Evas_Object *obj, const char *event, Evas_Smart_Cb func, const void *data) +{ + Evas_Object_Smart *o; + Eina_List *l; + Evas_Smart_Callback *cb; + + MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ); + return NULL; + MAGIC_CHECK_END(); + o = (Evas_Object_Smart *)(obj->object_data); + MAGIC_CHECK(o, Evas_Object_Smart, MAGIC_OBJ_SMART); + return NULL; + MAGIC_CHECK_END(); + if (!event) return NULL; + EINA_LIST_FOREACH(o->callbacks, l, cb) + { + if ((!strcmp(cb->event, event)) && (cb->func == func) && (cb->func_data == data)) + { + void *data; + + data = cb->func_data; + cb->delete_me = 1; + o->deletions_waiting = 1; + evas_object_smart_callbacks_clear(obj); + return data; + } + } + return NULL; +} + EAPI void evas_object_smart_callback_call(Evas_Object *obj, const char *event, void *event_info) {