From f16baf6b22da98b5b163553f37d4e158a0ec2bde Mon Sep 17 00:00:00 2001 From: mike_m Date: Wed, 29 Jun 2011 06:40:59 +0000 Subject: [PATCH] elementary: Add generic label getter and setter These need to be hooked into each widget, one by one. Signed-off-by: Mike McCormack git-svn-id: https://svn.enlightenment.org/svn/e/trunk/elementary@60795 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/Elementary.h.in | 35 +++++++++++++++++++++++++++++++++-- src/lib/elm_main.c | 14 ++++++++++++++ src/lib/elm_widget.c | 27 +++++++++++++++++++++++++++ src/lib/elm_widget.h | 2 ++ 4 files changed, 76 insertions(+), 2 deletions(-) diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index 2295ca6..3f126e1 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -677,6 +677,37 @@ extern "C" { EAPI int elm_policy_get(unsigned int policy); /** + * Set a label of an object + * + * @param obj The Elementary object + * @param item The label id to set (NULL for the default label) + * @param label The new text of the label + * + * @note Elementary objects may have many labels (e.g. Action Slider) + * + * @ingroup General + */ + EAPI void elm_object_label_set(Evas_Object *obj, const char *item, const char *label); + +#define elm_object_text_set(obj, label) elm_object_label_set((obj), NULL, (label)) + + /** + * Get a label of an object + * + * @param obj The Elementary object + * @param item The label id to get (NULL for the default label) + * @return text of the label or + * NULL for any error + * + * @note Elementary objects may have many labels (e.g. Action Slider) + * + * @ingroup General + */ + EAPI const char *elm_object_label_get(const Evas_Object *obj, const char *item); + +#define elm_object_text_get(obj) elm_object_label_get((obj), NULL) + + /** * @} */ @@ -2579,8 +2610,8 @@ extern "C" { /* label */ EAPI Evas_Object *elm_label_add(Evas_Object *parent) EINA_ARG_NONNULL(1); - EAPI void elm_label_label_set(Evas_Object *obj, const char *label) EINA_ARG_NONNULL(1); - EAPI const char *elm_label_label_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); + EINA_DEPRECATED EAPI void elm_label_label_set(Evas_Object *obj, const char *label) EINA_ARG_NONNULL(1); /* deprecated, use elm_object_text_set instead */ + EINA_DEPRECATED EAPI const char *elm_label_label_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); /* deprecated, use elm_object_text_get instead */ EAPI void elm_label_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap) EINA_ARG_NONNULL(1); EAPI Elm_Wrap_Type elm_label_line_wrap_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); EAPI void elm_label_wrap_width_set(Evas_Object *obj, Evas_Coord w) EINA_ARG_NONNULL(1); diff --git a/src/lib/elm_main.c b/src/lib/elm_main.c index ebdbeb5..e6b0e75 100644 --- a/src/lib/elm_main.c +++ b/src/lib/elm_main.c @@ -1196,6 +1196,20 @@ elm_object_scale_get(const Evas_Object *obj) return elm_widget_scale_get(obj); } +EAPI void +elm_object_label_set(Evas_Object *obj, const char *item, const char *label) +{ + EINA_SAFETY_ON_NULL_RETURN(obj); + elm_widget_label_set(obj, item, label); +} + +EAPI const char * +elm_object_label_get(const Evas_Object *obj, const char *item) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL); + return elm_widget_label_get(obj, item); +} + /** * Get the global scaling factor * diff --git a/src/lib/elm_widget.c b/src/lib/elm_widget.c index b1aeb2c..cca3b53 100644 --- a/src/lib/elm_widget.c +++ b/src/lib/elm_widget.c @@ -70,6 +70,11 @@ struct _Smart_Data Evas_Coord *y, Evas_Coord *w, Evas_Coord *h); + void (*on_label_set_func)(Evas_Object *obj, + const char *item, + const char *text); + const char *(*on_label_get_func)(Evas_Object *obj, + const char *item); void *data; Evas_Coord rx, ry, rw, rh; int scroll_hold; @@ -2006,6 +2011,28 @@ elm_widget_theme_set(Evas_Object *obj, } } +EAPI void +elm_widget_label_set(Evas_Object *obj, const char *item, const char *label) +{ + API_ENTRY return; + + if (!sd->on_label_set_func) + return; + + sd->on_label_set_func(obj, item, label); +} + +EAPI const char * +elm_widget_label_get(const Evas_Object *obj, const char *item) +{ + API_ENTRY return NULL; + + if (!sd->on_label_get_func) + return NULL; + + return sd->on_label_get_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 9ca4186..dcc2048 100644 --- a/src/lib/elm_widget.h +++ b/src/lib/elm_widget.h @@ -308,6 +308,8 @@ EAPI Eina_List *elm_widget_stringlist_get(const char *str); EAPI void elm_widget_stringlist_free(Eina_List *list); EAPI void elm_widget_focus_hide_handle(Evas_Object *obj); EAPI void elm_widget_focus_mouse_down_handle(Evas_Object *obj); +EAPI void elm_widget_label_set(Evas_Object *obj, const char *item, const char *label); +EAPI const char *elm_widget_label_get(const 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); -- 2.7.4