From f290189336f36e73d1592d7bf689794469fcab2a Mon Sep 17 00:00:00 2001 From: sachiel 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) git-svn-id: http://svn.enlightenment.org/svn/e/trunk/evas@67246 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- ChangeLog | 4 ++++ NEWS | 1 + src/lib/Evas.h | 28 ++++++++++++++++++++++++++++ src/lib/canvas/evas_object_smart.c | 31 +++++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+) diff --git a/ChangeLog b/ChangeLog index f95e796..6e7e747 100644 --- a/ChangeLog +++ b/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/NEWS b/NEWS index 33026c0..945fd96 100644 --- a/NEWS +++ b/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/src/lib/Evas.h b/src/lib/Evas.h index 1a8d377..1854aee 100644 --- a/src/lib/Evas.h +++ b/src/lib/Evas.h @@ -9847,6 +9847,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. * * @param obj the smart object diff --git a/src/lib/canvas/evas_object_smart.c b/src/lib/canvas/evas_object_smart.c index a7dfcdf..cca7201 100644 --- a/src/lib/canvas/evas_object_smart.c +++ b/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) { -- 2.7.4