From b7448963b9fc4a61d247596a96342949ac794151 Mon Sep 17 00:00:00 2001 From: ShilpaOnkar Singh Date: Thu, 1 Dec 2011 11:41:47 +0000 Subject: [PATCH] elementary/naviframe - title_content_set refactored. 1. Modified to support NULL content. 2. Unnecessary parameter removed. 3. Number of lines Optimization. Signed-Off-By: ShilpaOnkar Singh Signed-Off-By: ChunEon Park SVN revision: 65777 --- src/lib/elc_naviframe.c | 68 ++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/src/lib/elc_naviframe.c b/src/lib/elc_naviframe.c index 6e9e822..b06f86c 100644 --- a/src/lib/elc_naviframe.c +++ b/src/lib/elc_naviframe.c @@ -117,7 +117,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, @@ -321,7 +320,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 @@ -347,7 +345,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 * @@ -555,31 +553,24 @@ _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); @@ -587,30 +578,37 @@ _title_content_set(Elm_Naviframe_Item *it, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints); 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); - evas_object_event_callback_add(content, - EVAS_CALLBACK_CHANGED_SIZE_HINTS, - _changed_size_hints, - WIDGET(it)); - } - 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; - _sizing_eval(WIDGET(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); + evas_object_event_callback_add(content, + EVAS_CALLBACK_CHANGED_SIZE_HINTS, + _changed_size_hints, + WIDGET(it)); + 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; + _sizing_eval(WIDGET(it)); } static void -- 2.7.4