From: Iván Briano Date: Wed, 27 Oct 2010 17:41:25 +0000 (+0000) Subject: content_get for layout and some macros to make it easier to set X-Git-Tag: v1.0.0~3924 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ba3290389bcd9da8112cb5e1a6601cc7e4b3bc97;p=platform%2Fupstream%2Felementary.git content_get for layout and some macros to make it easier to set things in common layouts SVN revision: 53929 --- diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index 3761d7e..fdba0b1 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -872,6 +872,7 @@ extern "C" { EAPI Eina_Bool elm_layout_file_set(Evas_Object *obj, const char *file, const char *group); EAPI Eina_Bool elm_layout_theme_set(Evas_Object *obj, const char *clas, const char *group, const char *style); EAPI void elm_layout_content_set(Evas_Object *obj, const char *swallow, Evas_Object *content); + EAPI const Evas_Object *elm_layout_content_get(const Evas_Object *obj, const char *swallow); EAPI Evas_Object *elm_layout_content_unset(Evas_Object *obj, const char *swallow); EAPI void elm_layout_text_set(Evas_Object *obj, const char *part, const char *text); EAPI const char *elm_layout_text_get(const Evas_Object *obj, const char *part); @@ -896,6 +897,66 @@ extern "C" { EAPI Eina_Bool elm_layout_part_cursor_engine_only_set(Evas_Object *obj, const char *part_name, Eina_Bool engine_only); EAPI Eina_Bool elm_layout_part_cursor_engine_only_get(const Evas_Object *obj, const char *part_name); +/** + * @def elm_layout_icon_set + * Convienience macro to set the icon object in a layout that follows the + * Elementary naming convention for its parts. + * + * @ingroup Layout + */ +#define elm_layout_icon_set(_ly, _obj) \ + elm_layout_content_set((_ly), "elm.swallow.icon", (_obj)) + +/** + * @def elm_layout_icon_get + * Convienience macro to get the icon object from a layout that follows the + * Elementary naming convention for its parts. + * + * @ingroup Layout + */ +#define elm_layout_icon_get(_ly, _obj) \ + elm_layout_content_get((_ly), "elm.swallow.icon", (_obj)) + +/** + * @def elm_layout_end_set + * Convienience macro to set the end object in a layout that follows the + * Elementary naming convention for its parts. + * + * @ingroup Layout + */ +#define elm_layout_end_set(_ly, _obj) \ + elm_layout_content_set((_ly), "elm.swallow.end", (_obj)) + +/** + * @def elm_layout_end_get + * Convienience macro to get the end object in a layout that follows the + * Elementary naming convention for its parts. + * + * @ingroup Layout + */ +#define elm_layout_end_get(_ly, _obj) \ + elm_layout_content_get((_ly), "elm.swallow.end", (_obj)) + +/** + * @def elm_layout_label_set + * Convienience macro to set the label in a layout that follows the + * Elementary naming convention for its parts. + * + * @ingroup Layout + */ +#define elm_layout_label_set(_ly, _txt) \ + elm_layout_text_set((_ly), "elm.text", (_txt)) + +/** + * @def elm_layout_label_get + * Convienience macro to get the label in a layout that follows the + * Elementary naming convention for its parts. + * + * @ingroup Layout + */ +#define elm_layout_label_get(_ly, _txt) \ + elm_layout_text_get((_ly), "elm.text", (_txt)) + /* smart callbacks called: */ diff --git a/src/lib/elm_layout.c b/src/lib/elm_layout.c index a5cfa13..1cdce20 100644 --- a/src/lib/elm_layout.c +++ b/src/lib/elm_layout.c @@ -417,6 +417,32 @@ elm_layout_content_set(Evas_Object *obj, const char *swallow, Evas_Object *conte } /** + * Get the swallowed object in the given part + * + * @param obj The layout object + * @param swallow The SWALLOW part to get its content + * + * @return The swallowed object or NULL if none or an error occurred + * + * @ingroup Layout + */ +EAPI const Evas_Object * +elm_layout_content_get(const Evas_Object *obj, const char *swallow) +{ + Widget_Data *wd = elm_widget_data_get(obj); + const Eina_List *l; + Subinfo *si; + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + + EINA_LIST_FOREACH(wd->subs, l, si) + { + if ((si->type == SWALLOW) && !strcmp(swallow, si->part)) + return si->obj; + } + return NULL; +} + +/** * Unset the layout content * * Unparent and return the content object which was set for this widget