From 29d8ff40d6a26d0503a69fbce08172aa842f607a Mon Sep 17 00:00:00 2001 From: Jaehwan Kim Date: Wed, 25 May 2011 17:18:35 +0900 Subject: [PATCH] [controlbar] elm_controlbar_item_view_set bug fix, add elm_controlbar_item_view_unset API Change-Id: I512ed48b7911bae59deed63150946d6e5cd232c0 --- src/lib/Elementary.h.in | 1 + src/lib/elm_controlbar.c | 37 +++++++++++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index 0b40a77..4dff73e 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -2949,6 +2949,7 @@ extern "C" { EAPI Elm_Controlbar_Item *elm_controlbar_item_next(Elm_Controlbar_Item *it); EAPI void elm_controlbar_item_view_set(Elm_Controlbar_Item *it, Evas_Object * view); EAPI Evas_Object *elm_controlbar_item_view_get(Elm_Controlbar_Item *it); + EAPI Evas_Object *elm_controlbar_item_view_unset(Elm_Controlbar_Item *it); EAPI void elm_controlbar_mode_set(Evas_Object *obj, int mode); EAPI void elm_controlbar_alpha_set(Evas_Object *obj, int alpha); EAPI void elm_controlbar_item_auto_align_set(Evas_Object *obj, Eina_Bool auto_align); diff --git a/src/lib/elm_controlbar.c b/src/lib/elm_controlbar.c index 34a7928..28c32e8 100644 --- a/src/lib/elm_controlbar.c +++ b/src/lib/elm_controlbar.c @@ -1374,11 +1374,10 @@ EAPI Evas_Object * elm_controlbar_add(Evas_Object * parent) _controlbar_object_show, obj); evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_HIDE, _controlbar_object_hide, obj); -#if 0 + bg = elm_layout_content_get(wd->edje, "bg_image"); evas_object_event_callback_add(bg, EVAS_CALLBACK_MOVE, _controlbar_object_move, obj); evas_object_event_callback_add(bg, EVAS_CALLBACK_RESIZE, _controlbar_object_resize, obj); -#endif wd->selected_box = elm_layout_add(wd->bg); elm_layout_theme_set(wd->selected_box, "controlbar", "item_bg_move", "default"); @@ -2396,9 +2395,9 @@ EAPI void elm_controlbar_item_view_set(Elm_Controlbar_Item *it, Evas_Object * view) { if (!it) return; + if (it->view == view) return; - if (it->view) evas_object_del(it->view); - + evas_object_del(it->view); it->view = view; } @@ -2419,6 +2418,36 @@ elm_controlbar_item_view_get(Elm_Controlbar_Item *it) } /** + * Unset the view of the item + * + * @param it The item of controlbar + * @return The view for the item + * + * @ingroup Controlbar + */ +EAPI Evas_Object * +elm_controlbar_item_view_unset(Elm_Controlbar_Item *it) +{ + if (!it) return NULL; + if (it->obj == NULL) return NULL; + Widget_Data * wd = elm_widget_data_get(it->obj); + if (!wd) return NULL; + Evas_Object *content; + + if (it->view == elm_layout_content_get(wd->view, "elm.swallow.view")) + { + content = elm_layout_content_unset(wd->view, "elm.swallow.view"); + if (content) evas_object_hide(content); + } + else + content = it->view; + + it->view = NULL; + + return content; +} + +/** * Set the mode of the controlbar * * @param obj The object of the controlbar -- 2.7.4