From: Shilpa Singh Date: Tue, 29 Nov 2011 09:17:12 +0000 (+0530) Subject: [Review comments fixed] X-Git-Tag: REL_F_I9500_20111202_1~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9036c1b44a0faf1338f30d883f102b4b3c787d7d;p=framework%2Fuifw%2Felementary.git [Review comments fixed] [elc_naviframe]: title_content_set function refactored. 1. Considers NULL content case. 2. unnecessary parameter removed. 3. optimization Change-Id: I06be24d9d9844eee9d7dbd739e30f42ba1f8e017 --- diff --git a/src/lib/elc_naviframe.c b/src/lib/elc_naviframe.c index 32c8cbd..57ac054 100644 --- a/src/lib/elc_naviframe.c +++ b/src/lib/elc_naviframe.c @@ -118,7 +118,6 @@ static void _title_icon_del(void *data, Evas_Object *obj, void *event_info); static void _title_content_set(Elm_Naviframe_Item *it, - Elm_Naviframe_Content_Item_Pair *pair, const char *part, Evas_Object *content); static void _title_prev_btn_set(Elm_Naviframe_Item *it, @@ -314,7 +313,6 @@ _item_content_set_hook(Elm_Object_Item *it, { ELM_OBJ_ITEM_CHECK_OR_RETURN(it); - Elm_Naviframe_Content_Item_Pair *pair = NULL; Elm_Naviframe_Item *navi_it = (Elm_Naviframe_Item *) it; //specified parts @@ -340,7 +338,7 @@ _item_content_set_hook(Elm_Object_Item *it, } //common part - _title_content_set(navi_it, pair, part, content); + _title_content_set(navi_it, part, content); } static Evas_Object * @@ -608,55 +606,55 @@ _item_content_del(void *data, static void _title_content_set(Elm_Naviframe_Item *it, - Elm_Naviframe_Content_Item_Pair *pair, const char *part, Evas_Object *content) { char buf[1024]; + Elm_Naviframe_Content_Item_Pair *pair = NULL; EINA_INLIST_FOREACH(it->content_list, pair) if (!strcmp(part, pair->part)) break; - if (!pair) + if ((pair) && (pair->content)) { - pair = ELM_NEW(Elm_Naviframe_Content_Item_Pair); - if (!pair) + if (!content) { - ERR("Failed to allocate new content part of the item! : naviframe=%p", WIDGET(it)); + evas_object_del(pair->content); + pair->content = NULL; return; } - pair->it = it; - eina_stringshare_replace(&pair->part, part); - it->content_list = eina_inlist_append(it->content_list, - EINA_INLIST_GET(pair)); - } - - if (pair->content != content) - { + if (pair->content == content) return; evas_object_event_callback_del(pair->content, EVAS_CALLBACK_DEL, _title_content_del); evas_object_del(pair->content); - elm_widget_sub_object_add(WIDGET(it), content); - evas_object_event_callback_add(content, - EVAS_CALLBACK_DEL, - _title_content_del, - pair); - } - if (content) - { - edje_object_part_swallow(VIEW(it), part, content); - snprintf(buf, sizeof(buf), "elm,state,%s,show", part); + snprintf(buf, sizeof(buf), "elm,state,%s,hide", part); edje_object_signal_emit(VIEW(it), buf, "elm"); - pair->content = content; - _item_sizing_eval(it); } else { - snprintf(buf, sizeof(buf), "elm,state,%s,hide", part); - edje_object_signal_emit(VIEW(it), buf, "elm"); - pair->content = NULL; + pair = ELM_NEW(Elm_Naviframe_Content_Item_Pair); + if (!pair) + { + ERR("Failed to allocate new content part of the item! : naviframe=%p", WIDGET(it)); + return; + } + pair->it = it; + eina_stringshare_replace(&pair->part, part); + it->content_list = eina_inlist_append(it->content_list, + EINA_INLIST_GET(pair)); } + + elm_widget_sub_object_add(WIDGET(it), content); + evas_object_event_callback_add(content, + EVAS_CALLBACK_DEL, + _title_content_del, + pair); + edje_object_part_swallow(VIEW(it), part, content); + snprintf(buf, sizeof(buf), "elm,state,%s,show", part); + edje_object_signal_emit(VIEW(it), buf, "elm"); + pair->content = content; + _item_sizing_eval(it); } static void