From 8b1cfd3c79a1c9964137685d074d8dd5b4300a75 Mon Sep 17 00:00:00 2001 From: tasn Date: Mon, 4 Jul 2011 10:14:11 +0000 Subject: [PATCH] elm bubble: add the elm_object_text_set/get hooks. deprecate: elm_bubble_indicator_label_set/get. git-svn-id: https://svn.enlightenment.org/svn/e/trunk/elementary@60995 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/Elementary.h.in | 12 +++++--- src/lib/elm_bubble.c | 76 +++++++++++++++++++++++++++++++++---------------- 2 files changed, 60 insertions(+), 28 deletions(-) diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index bffe4af..50f70b1 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -3716,8 +3716,9 @@ extern "C" { * * This function sets the title of the bubble. Where this appears depends on * the selected corner. + * @deprecated use elm_object_text_set() instead. */ - EAPI void elm_bubble_label_set(Evas_Object *obj, const char *label) EINA_ARG_NONNULL(1); + EINA_DEPRECATED EAPI void elm_bubble_label_set(Evas_Object *obj, const char *label) EINA_ARG_NONNULL(1); /** * Get the label of the bubble * @@ -3725,8 +3726,9 @@ extern "C" { * @return The string of set in the label * * This function gets the title of the bubble. + * @deprecated use elm_object_text_set() instead. */ - EAPI const char *elm_bubble_label_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); + EINA_DEPRECATED EAPI const char *elm_bubble_label_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); /** * Set the info of the bubble * @@ -3735,8 +3737,9 @@ extern "C" { * * This function sets the info of the bubble. Where this appears depends on * the selected corner. + * @deprecated use elm_object_text_set() instead. */ - EAPI void elm_bubble_info_set(Evas_Object *obj, const char *info) EINA_ARG_NONNULL(1); + EINA_DEPRECATED EAPI void elm_bubble_info_set(Evas_Object *obj, const char *info) EINA_ARG_NONNULL(1); /** * Get the info of the bubble * @@ -3745,8 +3748,9 @@ extern "C" { * @return The "info" string of the bubble * * This function gets the info text. + * @deprecated use elm_object_text_set() instead. */ - EAPI const char *elm_bubble_info_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); + EINA_DEPRECATED EAPI const char *elm_bubble_info_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); /** * Set the content to be shown in the bubble * diff --git a/src/lib/elm_bubble.c b/src/lib/elm_bubble.c index cbc2b45..fcbd8da 100644 --- a/src/lib/elm_bubble.c +++ b/src/lib/elm_bubble.c @@ -136,6 +136,52 @@ _mouse_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *eve evas_object_smart_callback_call(data, SIG_CLICKED, NULL); } +static void +_elm_bubble_label_set(Evas_Object *obj, const char *item, const char *label) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + + if (!item) + { + eina_stringshare_replace(&wd->label, label); + edje_object_part_text_set(wd->bbl, "elm.text", label); + if (label) edje_object_signal_emit(wd->bbl, "elm,state,text,visible", + "elm"); + else edje_object_signal_emit(wd->bbl, "elm,state,text,hidden", "elm"); + _sizing_eval(obj); + } + else if (!strcmp(item, "info")) + { + eina_stringshare_replace(&wd->info, label); + edje_object_part_text_set(wd->bbl, "elm.info", label); + if (label) edje_object_signal_emit(wd->bbl, "elm,state,info,visible", + "elm"); + else edje_object_signal_emit(wd->bbl, "elm,state,info,hidden", "elm"); + _sizing_eval(obj); + } +} + +static const char* +_elm_bubble_label_get(const Evas_Object *obj, const char *item) +{ + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return NULL; + + if (!item) + { + return wd->label; + } + else if (!strcmp(item, "info")) + { + return wd->info; + } + + return NULL; +} + EAPI Evas_Object * elm_bubble_add(Evas_Object *parent) { @@ -153,6 +199,8 @@ elm_bubble_add(Evas_Object *parent) elm_widget_theme_hook_set(obj, _theme_hook); elm_widget_focus_next_hook_set(obj, _elm_bubble_focus_next_hook); elm_widget_can_focus_set(obj, EINA_FALSE); + elm_widget_text_set_hook_set(obj, _elm_bubble_label_set); + elm_widget_text_get_hook_set(obj, _elm_bubble_label_get); wd->corner = eina_stringshare_add("base"); @@ -174,45 +222,25 @@ elm_bubble_add(Evas_Object *parent) EAPI void elm_bubble_label_set(Evas_Object *obj, const char *label) { - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - eina_stringshare_replace(&wd->label, label); - edje_object_part_text_set(wd->bbl, "elm.text", label); - if (label) edje_object_signal_emit(wd->bbl, "elm,state,text,visible", "elm"); - else edje_object_signal_emit(wd->bbl, "elm,state,text,hidden", "elm"); - _sizing_eval(obj); + _elm_bubble_label_set(obj, NULL, label); } EAPI const char* elm_bubble_label_get(const Evas_Object *obj) { - ELM_CHECK_WIDTYPE(obj, widtype) NULL; - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return NULL; - return wd->label; + return _elm_bubble_label_get(obj, NULL); } EAPI void elm_bubble_info_set(Evas_Object *obj, const char *info) { - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - eina_stringshare_replace(&wd->info, info); - edje_object_part_text_set(wd->bbl, "elm.info", info); - if (info) edje_object_signal_emit(wd->bbl, "elm,state,info,visible", "elm"); - else edje_object_signal_emit(wd->bbl, "elm,state,info,hidden", "elm"); - _sizing_eval(obj); + _elm_bubble_label_set(obj, "info", info); } EAPI const char * elm_bubble_info_get(const Evas_Object *obj) { - ELM_CHECK_WIDTYPE(obj, widtype) NULL; - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return NULL; - return wd->info; + return _elm_bubble_label_get(obj, "info"); } EAPI void -- 2.7.4