From 2d4790af3008ea3870a79d5ccfe7b756e4929084 Mon Sep 17 00:00:00 2001 From: tasn Date: Mon, 4 Jul 2011 10:40:07 +0000 Subject: [PATCH] elm anchorblock: add the elm_object_text_set/get hooks. deprecate: elm_anchorblock_text_set/get. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@60999 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/Elementary.h.in | 6 ++++-- src/lib/elc_anchorblock.c | 42 +++++++++++++++++++++++++++++------------- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index b0b15f2..b535d3b 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -3555,8 +3555,9 @@ extern "C" { * * Other markup can be used to style the text in different ways, but it's * up to the style defined in the theme which tags do what. + * @deprecated use elm_object_text_set() instead. */ - EAPI void elm_anchorblock_text_set(Evas_Object *obj, const char *text) EINA_ARG_NONNULL(1); + EINA_DEPRECATED EAPI void elm_anchorblock_text_set(Evas_Object *obj, const char *text) EINA_ARG_NONNULL(1); /** * Get the markup text set for the anchorblock * @@ -3565,8 +3566,9 @@ extern "C" { * @param obj The anchorblock object * @return The markup text set or @c NULL if nothing was set or an error * occurred + * @deprecated use elm_object_text_set() instead. */ - EAPI const char *elm_anchorblock_text_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); + EINA_DEPRECATED EAPI const char *elm_anchorblock_text_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); /** * Set the parent of the hover popup * diff --git a/src/lib/elc_anchorblock.c b/src/lib/elc_anchorblock.c index 77658a8..df2ae56 100644 --- a/src/lib/elc_anchorblock.c +++ b/src/lib/elc_anchorblock.c @@ -181,6 +181,31 @@ _item_provider(void *data, Evas_Object *entry __UNUSED__, const char *item) return NULL; } +static void +_elm_anchorblock_text_set(Evas_Object *obj, const char *item, const char *text) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + if (item) return; + if (!wd) return; + elm_entry_entry_set(wd->entry, text); + if (wd->hover) evas_object_del(wd->hover); + if (wd->pop) evas_object_del(wd->pop); + wd->hover = NULL; + wd->pop = NULL; + _sizing_eval(obj); +} + +static const char* +_elm_anchorblock_text_get(const Evas_Object *obj, const char *item) +{ + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Widget_Data *wd = elm_widget_data_get(obj); + if (item) return NULL; + if (!wd) return NULL; + return elm_entry_entry_get(wd->entry); +} + EAPI Evas_Object * elm_anchorblock_add(Evas_Object *parent) { @@ -198,6 +223,8 @@ elm_anchorblock_add(Evas_Object *parent) elm_widget_del_hook_set(obj, _del_hook); elm_widget_theme_hook_set(obj, _theme_hook); elm_widget_can_focus_set(obj, EINA_TRUE); + elm_widget_text_set_hook_set(obj, _elm_anchorblock_text_set); + elm_widget_text_get_hook_set(obj, _elm_anchorblock_text_get); wd->entry = elm_entry_add(parent); elm_entry_item_provider_prepend(wd->entry, _item_provider, obj); @@ -226,24 +253,13 @@ elm_anchorblock_add(Evas_Object *parent) EAPI void elm_anchorblock_text_set(Evas_Object *obj, const char *text) { - ELM_CHECK_WIDTYPE(obj, widtype); - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return; - elm_entry_entry_set(wd->entry, text); - if (wd->hover) evas_object_del(wd->hover); - if (wd->pop) evas_object_del(wd->pop); - wd->hover = NULL; - wd->pop = NULL; - _sizing_eval(obj); + _elm_anchorblock_text_set(obj, NULL, text); } EAPI const char* elm_anchorblock_text_get(const Evas_Object *obj) { - ELM_CHECK_WIDTYPE(obj, widtype) NULL; - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return NULL; - return elm_entry_entry_get(wd->entry); + return _elm_anchorblock_text_get(obj, NULL); } EAPI void -- 2.7.4