From: Daniel Juyung Seo Date: Thu, 29 Mar 2012 11:09:40 +0000 (+0000) Subject: elm elm_object: Fixed part content set hooks. X-Git-Tag: v1.0.0~160 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a037a137b428d735e1843833e28fc783b4d998d1;p=platform%2Fupstream%2Felementary.git elm elm_object: Fixed part content set hooks. 1. delete old content object 2. check whether new content object is same as old content object 3. added some doxygen description. SVN revision: 69743 --- diff --git a/src/lib/elc_ctxpopup.c b/src/lib/elc_ctxpopup.c index 61b57c3..31f57a8 100644 --- a/src/lib/elc_ctxpopup.c +++ b/src/lib/elc_ctxpopup.c @@ -774,13 +774,11 @@ _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content) { ELM_CHECK_WIDTYPE(obj, widtype); Evas_Coord min_w = -1, min_h = -1; - Widget_Data *wd; - if ((part) && (strcmp(part, "default"))) return; - wd = elm_widget_data_get(obj); if ((!wd) || (!content)) return; + if (content == wd->content) return; //TODO: wd->list if (wd->content) evas_object_del(wd->content); diff --git a/src/lib/elc_hoversel.c b/src/lib/elc_hoversel.c index 63012df..fb07d78 100644 --- a/src/lib/elc_hoversel.c +++ b/src/lib/elc_hoversel.c @@ -280,6 +280,7 @@ _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content) ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); if (!wd) return; + elm_object_part_content_set(wd->btn, part, content); } diff --git a/src/lib/elc_player.c b/src/lib/elc_player.c index a6ef91c..aef28ce 100644 --- a/src/lib/elc_player.c +++ b/src/lib/elc_player.c @@ -464,12 +464,14 @@ _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content) if (part && strcmp(part, "video")) return; ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); - + if (!wd) return; double pos, length; Eina_Bool seekable; if (!_elm_video_check(content)) return; + if (wd->video == content) return; + if (wd->video) evas_object_del(wd->video); _cleanup_callback(wd); wd->video = content; @@ -542,6 +544,7 @@ elm_player_add(Evas_Object *parent) elm_widget_can_focus_set(obj, EINA_TRUE); elm_widget_event_hook_set(obj, _event_hook); elm_widget_content_set_hook_set(obj, _content_set_hook); + /* TODO: add content_unset and content_get hook */ wd->layout = edje_object_add(e); _elm_theme_object_set(obj, wd->layout, "player", "base", "default"); diff --git a/src/lib/elc_popup.c b/src/lib/elc_popup.c index d1e21cc..43d51d2 100644 --- a/src/lib/elc_popup.c +++ b/src/lib/elc_popup.c @@ -699,11 +699,8 @@ _title_icon_set(Evas_Object *obj, Evas_Object *icon) if (!wd) return; if (wd->title_icon == icon) return; title_visibility_old = (wd->title_text) || (wd->title_icon); - if (wd->title_icon) - { - evas_object_del(wd->title_icon); - wd->title_icon = NULL; - } + if (wd->title_icon) evas_object_del(wd->title_icon); + wd->title_icon = icon; title_visibility_current = (wd->title_text) || (wd->title_icon); elm_object_part_content_set(wd->base, "elm.swallow.title.icon", diff --git a/src/lib/elm_bg.c b/src/lib/elm_bg.c index 79400c2..df29d5b 100644 --- a/src/lib/elm_bg.c +++ b/src/lib/elm_bg.c @@ -122,19 +122,16 @@ _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content) { ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd; - if (part && strcmp(part, "overlay")) return; - wd = elm_widget_data_get(obj); if (!wd) return; - if (wd->overlay) - { - evas_object_del(wd->overlay); - wd->overlay = NULL; - } + + if (content == wd->overlay) return; + if (wd->overlay) evas_object_del(wd->overlay); + + wd->overlay = content; if (content) { - wd->overlay = content; edje_object_part_swallow(wd->base, "elm.swallow.content", content); elm_widget_sub_object_add(obj, content); } diff --git a/src/lib/elm_entry.c b/src/lib/elm_entry.c index ebbef48..8df66ba 100644 --- a/src/lib/elm_entry.c +++ b/src/lib/elm_entry.c @@ -855,6 +855,7 @@ _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content) { Widget_Data *wd = elm_widget_data_get(obj); Evas_Object *edje; + Evas_Object *prev_content; if ((!wd) || (!content)) return; if (wd->scroll) @@ -862,23 +863,20 @@ _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content) else edje = wd->ent; - /* Delete the currently swallowed object */ - Evas_Object *cswallow; - if (!part || !strcmp(part, "icon")) { - cswallow = edje_object_part_swallow_get(edje, "elm.swallow.icon"); + prev_content = edje_object_part_swallow_get(edje, "elm.swallow.icon"); edje_object_signal_emit(edje, "elm,action,show,icon", "elm"); } else if (!strcmp(part, "end")) { - cswallow = edje_object_part_swallow_get(edje, "elm.swallow.end"); + prev_content = edje_object_part_swallow_get(edje, "elm.swallow.end"); edje_object_signal_emit(edje, "elm,action,show,end", "elm"); } else - cswallow = edje_object_part_swallow_get(edje, part); + prev_content = edje_object_part_swallow_get(edje, part); - if (cswallow) evas_object_del(cswallow); + if (prev_content) evas_object_del(prev_content); evas_event_freeze(evas_object_evas_get(obj)); elm_widget_sub_object_add(obj, content); diff --git a/src/lib/elm_object.h b/src/lib/elm_object.h index 033c243..68a863d 100644 --- a/src/lib/elm_object.h +++ b/src/lib/elm_object.h @@ -35,6 +35,10 @@ EAPI const char *elm_object_part_text_get(const Evas_Object *ob * @param part The content part name to set (NULL for the default content) * @param content The new content of the object * + * This sets a new object to a widget as a content object. If any object was + * already set as a content object in the same part, previous object will be + * deleted automatically. + * * @note Elementary objects may have many contents * * @ingroup General