Add evas_object_smart_callback_del_full API

Patch by Raphael Kubo Costas (rakuco)


SVN revision: 67246
This commit is contained in:
Iván Briano 2012-01-16 17:25:40 +00:00
parent 544dfc53b3
commit 11d67f493d
4 changed files with 64 additions and 0 deletions

View File

@ -633,4 +633,8 @@
can cause issues if new configs are added. Now we have evas allocate it can cause issues if new configs are added. Now we have evas allocate it
for you. 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.

View File

@ -7,6 +7,7 @@ Additions:
* Textblock now supports self-closing tags, i.e <br/>. Those should be used instead of the old <br> way. * Textblock now supports self-closing tags, i.e <br/>. Those should be used instead of the old <br> way.
* Shm engine for drawing in Wayland. * Shm engine for drawing in Wayland.
* evas_object_smart_callback_del_full API.
Improvements: Improvements:

View File

@ -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); 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 <b>the first</b> 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. * Call a given smart callback on the smart object @p obj.
* *

View File

@ -402,6 +402,37 @@ evas_object_smart_callback_del(Evas_Object *obj, const char *event, Evas_Smart_C
return NULL; 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 EAPI void
evas_object_smart_callback_call(Evas_Object *obj, const char *event, void *event_info) evas_object_smart_callback_call(Evas_Object *obj, const char *event, void *event_info)
{ {