From 2f416b0bbdc487e71e1a4754a2fef08609dee3fa Mon Sep 17 00:00:00 2001 From: hermet Date: Wed, 27 Jul 2011 09:49:14 +0000 Subject: [PATCH] elementary - added common APIs elm_object_content_set/get/unset Now need to widgets use them. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@61802 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/Elementary.h.in | 45 ++++++++++++++++++++++++++++++++++++ src/lib/elm_main.c | 21 +++++++++++++++++ src/lib/elm_widget.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++ src/lib/elm_widget.h | 7 +++++- 4 files changed, 133 insertions(+), 1 deletion(-) diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index 064f4a5..d8f7fce 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -711,6 +711,51 @@ extern "C" { #define elm_object_text_get(obj) elm_object_text_part_get((obj), NULL) /** + * Set a content of an object + * + * @param obj The Elementary object + * @param item The content id to set (NULL for the default content) + * @param content The new content of the object + * + * @note Elementary objects may have many contents + * + * @ingroup General + */ + EAPI void elm_object_content_part_set(Evas_Object *obj, const char *item, Evas_Object *content); + +#define elm_object_content_set(obj, content) elm_object_content_part_set((obj), NULL, (content)) + + /** + * Get a content of an object + * + * @param obj The Elementary object + * @param item The content id to get (NULL for the default content) + * @return content of the object or + * NULL for any error + * + * @note Elementary objects may have many contents + * + * @ingroup General + */ + EAPI Evas_Object *elm_object_content_part_get(const Evas_Object *obj, const char *item); + +#define elm_object_content_get(obj) elm_object_content_part_get((obj), NULL) + + /** + * Unset a content of an object + * + * @param obj The Elementary object + * @param item The content id to unset (NULL for the default content) + * + * @note Elementary objects may have many contents + * + * @ingroup General + */ + EAPI Evas_Object *elm_object_content_part_unset(Evas_Object *obj, const char *item); + +#define elm_object_content_unset(obj) elm_object_content_part_unset((obj), NULL) + + /** * @} */ diff --git a/src/lib/elm_main.c b/src/lib/elm_main.c index 983b528..e8ad7a8 100644 --- a/src/lib/elm_main.c +++ b/src/lib/elm_main.c @@ -1214,6 +1214,27 @@ elm_object_text_part_get(const Evas_Object *obj, const char *item) return elm_widget_text_part_get(obj, item); } +EAPI void +elm_object_content_part_set(Evas_Object *obj, const char *item, Evas_Object *content) +{ + EINA_SAFETY_ON_NULL_RETURN(obj); + elm_widget_content_part_set(obj, item, content); +} + +EAPI Evas_Object * +elm_object_content_part_get(const Evas_Object *obj, const char *item) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL); + return elm_widget_content_part_get(obj, item); +} + +EAPI Evas_Object * +elm_object_content_part_unset(Evas_Object *obj, const char *item) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL); + return elm_widget_content_part_unset(obj, item); +} + /** * Get the global scaling factor * diff --git a/src/lib/elm_widget.c b/src/lib/elm_widget.c index 9f321e4..7ee7279 100644 --- a/src/lib/elm_widget.c +++ b/src/lib/elm_widget.c @@ -75,6 +75,13 @@ struct _Smart_Data const char *text); const char *(*on_text_get_func)(const Evas_Object *obj, const char *item); + void (*on_content_set_func)(Evas_Object *obj, + const char *item, + Evas_Object *content); + Evas_Object *(*on_content_get_func)(const Evas_Object *obj, + const char *item); + Evas_Object *(*on_content_unset_func)(Evas_Object *obj, + const char *item); void *data; Evas_Coord rx, ry, rw, rh; int scroll_hold; @@ -502,6 +509,33 @@ elm_widget_text_get_hook_set(Evas_Object *obj, } EAPI void +elm_widget_content_set_hook_set(Evas_Object *obj, + void (*func)(Evas_Object *obj, + const char *item, + Evas_Object *content)) +{ + API_ENTRY return; + sd->on_content_set_func = func; +} + +EAPI void +elm_widget_content_get_hook_set(Evas_Object *obj, + Evas_Object *(*func)(const Evas_Object *obj, const char *item)) +{ + API_ENTRY return; + sd->on_content_get_func = func; +} + +EAPI void +elm_widget_content_unset_hook_set(Evas_Object *obj, + Evas_Object *(*func)(Evas_Object *obj, + const char *item)) +{ + API_ENTRY return; + sd->on_content_unset_func = func; +} + +EAPI void elm_widget_changed_hook_set(Evas_Object *obj, void (*func)(Evas_Object *obj)) { @@ -2042,6 +2076,33 @@ elm_widget_text_part_get(const Evas_Object *obj, const char *item) return sd->on_text_get_func(obj, item); } +EAPI void +elm_widget_content_part_set(Evas_Object *obj, const char *item, Evas_Object *content) +{ + API_ENTRY return; + + if (!sd->on_content_set_func) return; + sd->on_content_set_func(obj, item, content); +} + +EAPI Evas_Object * +elm_widget_content_part_get(const Evas_Object *obj, const char *item) +{ + API_ENTRY return NULL; + + if (!sd->on_content_get_func) return NULL; + return sd->on_content_get_func(obj, item); +} + +EAPI Evas_Object * +elm_widget_content_part_unset(Evas_Object *obj, const char *item) +{ + API_ENTRY return NULL; + + if (!sd->on_content_unset_func) return NULL; + return sd->on_content_unset_func(obj, item); +} + EAPI Elm_Theme * elm_widget_theme_get(const Evas_Object *obj) { diff --git a/src/lib/elm_widget.h b/src/lib/elm_widget.h index b8885be..895a424 100644 --- a/src/lib/elm_widget.h +++ b/src/lib/elm_widget.h @@ -230,6 +230,9 @@ EAPI void elm_widget_on_show_region_hook_set(Evas_Object *obj, void EAPI void elm_widget_focus_region_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)); EAPI void elm_widget_text_set_hook_set(Evas_Object *obj, void (*func)(Evas_Object *obj, const char *item, const char *text)); EAPI void elm_widget_text_get_hook_set(Evas_Object *obj, const char *(*func)(const Evas_Object *obj, const char *item)); +EAPI void elm_widget_content_set_hook_set(Evas_Object *obj, void (*func)(Evas_Object *obj, const char *item, Evas_Object *content)); +EAPI void elm_widget_content_get_hook_set(Evas_Object *obj, Evas_Object *(*func)(const Evas_Object *obj, const char *item)); +EAPI void elm_widget_content_unset_hook_set(Evas_Object *obj, Evas_Object *(*func)(Evas_Object *obj, const char *item)); EAPI void elm_widget_on_focus_region_hook_set(Evas_Object *obj, void (*func) (const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)); EAPI void elm_widget_data_set(Evas_Object *obj, void *data); EAPI void *elm_widget_data_get(const Evas_Object *obj); @@ -313,7 +316,9 @@ EAPI void elm_widget_focus_mouse_down_handle(Evas_Object *obj); EAPI void elm_widget_focus_disabled_handle(Evas_Object *obj); EAPI void elm_widget_text_part_set(Evas_Object *obj, const char *item, const char *label); EAPI const char *elm_widget_text_part_get(const Evas_Object *obj, const char *item); - +EAPI void elm_widget_content_part_set(Evas_Object *obj, const char *item, Evas_Object *content); +EAPI Evas_Object *elm_widget_content_part_get(const Evas_Object *obj, const char *item); +EAPI Evas_Object *elm_widget_content_part_unset(Evas_Object *obj, const char *item); EAPI Elm_Widget_Item *_elm_widget_item_new(Evas_Object *parent, size_t alloc_size); EAPI void _elm_widget_item_del(Elm_Widget_Item *item); EAPI void _elm_widget_item_pre_notify_del(Elm_Widget_Item *item); -- 2.7.4