From 5490acad83988fecea710a9f2059f9d7aac1337f Mon Sep 17 00:00:00 2001 From: hermet Date: Tue, 10 Jan 2012 00:02:58 +0000 Subject: [PATCH] elementary/widget - +del_pre_hook now elm_object_item_del is exposed to users, this callback is used for widgets to use internally. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@67004 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/elm_widget.c | 13 +++++++++++++ src/lib/elm_widget.h | 31 ++++++++++++++++++++++--------- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/lib/elm_widget.c b/src/lib/elm_widget.c index edaf1e2..c44f691 100644 --- a/src/lib/elm_widget.c +++ b/src/lib/elm_widget.c @@ -2829,6 +2829,9 @@ _elm_widget_item_del(Elm_Widget_Item *item) if (item->del_cb) item->del_cb((void *)item->data, item->widget, item); + if (item->on_del_pre_cb) + item->on_del_pre_cb((Elm_Object_Item *) item); + if (item->view) evas_object_del(item->view); @@ -2848,6 +2851,16 @@ _elm_widget_item_del(Elm_Widget_Item *item) free(item); } +EAPI void +_elm_widget_item_del_pre_hook_set(Elm_Widget_Item *item, Elm_Widget_Item_On_Del_Pre_Cb func) +{ + ELM_WIDGET_ITEM_CHECK_OR_RETURN(item); + if ((item->on_del_pre_cb) && (item->on_del_pre_cb != func)) + WRN("You're replacing a previously set del_pre_cb %p of item %p with %p", item->on_del_pre_cb, item, func); + item->on_del_pre_cb = func; +} + + /** * @internal * diff --git a/src/lib/elm_widget.h b/src/lib/elm_widget.h index a0906f7..8262cf0 100644 --- a/src/lib/elm_widget.h +++ b/src/lib/elm_widget.h @@ -202,6 +202,7 @@ typedef Evas_Object *(*Elm_Widget_On_Content_Get_Cb)(const void *data, typedef Evas_Object *(*Elm_Widget_On_Content_Unset_Cb)(const void *data, const char *part); typedef void (*Elm_Widget_On_Signal_Emit_Cb)(void *data, const char *emission, const char *source); typedef void (*Elm_Widget_On_Disable_Set_Cb)(void *data); +typedef void (*Elm_Widget_Item_On_Del_Pre_Cb)(Elm_Object_Item *it); #define ELM_ACCESS_TYPE 0 // when reading out widget or item this is read first #define ELM_ACCESS_INFO 1 // next read is info - this is normally label @@ -241,20 +242,28 @@ EAPI void _elm_access_object_register(Evas_Object *obj, Evas_Object EAPI void _elm_access_item_register(Elm_Widget_Item *item, Evas_Object *hoverobj); EAPI Eina_Bool _elm_access_2nd_click_timeout(Evas_Object *obj); -#define ELM_WIDGET_ITEM Elm_Widget_Item base /**< put this as the first member in your widget item struct */ +/**< put this as the first member in your widget item struct */ +#define ELM_WIDGET_ITEM Elm_Widget_Item base + struct _Elm_Widget_Item { - /* ef1 ~~ efl, el3 ~~ elm */ +/* ef1 ~~ efl, el3 ~~ elm */ #define ELM_WIDGET_ITEM_MAGIC 0xef1e1301 EINA_MAGIC; /* simple accessor macros */ #define VIEW(X) X->base.view #define WIDGET(X) X->base.widget - Evas_Object *widget; /**< the owner widget that owns this item */ - Evas_Object *view; /**< the base view object */ - const void *data; /**< item specific data */ - Evas_Smart_Cb del_cb; /**< used to notify the item is being deleted */ + /**< the owner widget that owns this item */ + Evas_Object *widget; + /**< the base view object */ + Evas_Object *view; + /**< item specific data */ + const void *data; + /**< used to notify the item is being deleted */ + Evas_Smart_Cb del_cb; + /**< don't expose this callback call */ + Elm_Widget_Item_On_Del_Pre_Cb on_del_pre_cb; Elm_Widget_On_Content_Set_Cb on_content_set_func; Elm_Widget_On_Content_Get_Cb on_content_get_func; Elm_Widget_On_Content_Unset_Cb on_content_unset_func; @@ -464,6 +473,7 @@ EAPI void _elm_widget_item_access_info_set(Elm_Widget_Item *item, co EAPI void _elm_widget_item_disabled_set(Elm_Widget_Item *item, Eina_Bool disabled); EAPI Eina_Bool _elm_widget_item_disabled_get(const Elm_Widget_Item *item); EAPI void _elm_widget_item_disable_set_hook_set(Elm_Widget_Item *item, Elm_Widget_On_Disable_Set_Cb func); +EAPI void _elm_widget_item_del_pre_hook_set(Elm_Widget_Item *item, Elm_Widget_Item_On_Del_Pre_Cb func); /* debug function. don't use it unless you are tracking parenting issues */ EAPI void elm_widget_tree_dump(const Evas_Object *top); @@ -637,15 +647,18 @@ EAPI void elm_widget_tree_dot_dump(const Evas_Object *top, FILE *out */ #define elm_widget_item_disabled_get(item) \ _elm_widget_item_disabled_get((Elm_Widget_Item *)item) - -EAPI Eina_Bool _elm_widget_item_disabled_get(const Elm_Widget_Item *item); - /** * Convenience function to query disable set hook. * @see _elm_widget_item_disable_set_hook_set() */ #define elm_widget_item_disable_set_hook_set(item, func) \ _elm_widget_item_disable_set_hook_set((Elm_Widget_Item *)item, (Elm_Widget_On_Disable_Set_Cb)func) +/** + * Convenience function to query del pre hook. + * @see _elm_widget_item_del_pre_hook_set() + */ +#define elm_widget_item_del_pre_hook_set(item, func) \ + _elm_widget_item_del_pre_hook_set((Elm_Widget_Item *)item, (Elm_Widget_Item_On_Del_Pre_Cb)func) #define ELM_WIDGET_ITEM_CHECK_OR_RETURN(item, ...) \ do { \ -- 2.7.4