elm_gengrid: fix correct parent-child relation of item content

Summary:
see 1b2401849a that said
`evas_object_smart_member_del` doesn't make sense here.
I guess `_sub_object_del` should have been used when item_all_contents_unset is
implemented.

Item content should have widget(gengrid) as the parent. but that relationship
is removed by c075b7caaa.
See also, `_item_content_realize` of genlist.

Test Plan: make check

Reviewers: Hermet, SanghyeonLee, bu5hm4n

Reviewed By: Hermet

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8238
This commit is contained in:
Yeongjong Lee 2019-03-08 13:18:05 +09:00 committed by Hermet Park
parent 88b4646ea7
commit 97416e9996
3 changed files with 104 additions and 1 deletions

View File

@ -1108,6 +1108,7 @@ _item_content_realize(Elm_Gen_Item *it,
_elm_widget_full_eval(content);
}
elm_widget_sub_object_add(WIDGET(it), content);
if (elm_wdg_item_disabled_get(EO_OBJ(it)))
elm_widget_disabled_set(content, EINA_TRUE);
@ -1231,7 +1232,7 @@ _elm_gengrid_item_all_contents_unset(Eo *eo_item EINA_UNUSED, Elm_Gen_Item *it,
EINA_LIST_FREE (it->contents, content)
{
evas_object_smart_member_del(content);
_elm_widget_sub_object_redirect_to_top(WIDGET(it), content);
// edje can be reused by item caching,
// content should be un-swallowed from edje
edje_object_part_unswallow(VIEW(it), content);

View File

@ -153,11 +153,62 @@ EFL_START_TEST(elm_gengrid_focus)
}
EFL_END_TEST
static void
_gengrid_item_content_test_realize(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
ecore_main_loop_quit();
}
static Evas_Object *
_item_content_get(void *data EINA_UNUSED, Evas_Object *obj, const char *part EINA_UNUSED)
{
Evas_Object *ic = elm_button_add(obj);
return ic;
}
EFL_START_TEST(elm_gengrid_item_content)
{
Evas_Object *win, *gengrid;
Elm_Genlist_Item_Class *gtc;
Evas_Object *content, *parent;
Elm_Object_Item *it;
gtc = elm_gengrid_item_class_new();
gtc->item_style = "default";
gtc->func.content_get = _item_content_get;
gtc->func.state_get = NULL;
gtc->func.del = NULL;
win = win_add(NULL, "gengrid", ELM_WIN_BASIC);
gengrid = elm_gengrid_add(win);
evas_object_smart_callback_add(gengrid, "realized", _gengrid_item_content_test_realize, NULL);
it = elm_gengrid_item_append(gengrid, gtc, NULL, NULL, NULL);
evas_object_resize(gengrid, 100, 100);
evas_object_resize(win, 150, 150);
evas_object_show(gengrid);
evas_object_show(win);
ecore_main_loop_begin();
content = elm_object_item_part_content_get(it, "elm.swallow.end");
parent = elm_object_parent_widget_get(content);
ck_assert_ptr_eq(parent, gengrid);
elm_gengrid_item_all_contents_unset(it, NULL);
parent = elm_object_parent_widget_get(content);
ck_assert_ptr_eq(parent, win);
}
EFL_END_TEST
void elm_test_gengrid(TCase *tc)
{
tcase_add_test(tc, elm_gengrid_legacy_type_check);
tcase_add_test(tc, elm_atspi_role_get);
tcase_add_test(tc, elm_gengrid_focus);
tcase_add_test(tc, elm_gengrid_item_content);
#if 0
tcase_add_test(tc, elm_atspi_children_parent);
#endif

View File

@ -119,6 +119,56 @@ EFL_START_TEST(elm_genlist_test_item_iteration)
}
EFL_END_TEST
static void
_genlist_item_content_test_realize(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
ecore_main_loop_quit();
}
static Evas_Object *
_item_content_get(void *data EINA_UNUSED, Evas_Object *obj, const char *part EINA_UNUSED)
{
Evas_Object *ic = elm_button_add(obj);
return ic;
}
EFL_START_TEST(elm_genlist_test_item_content)
{
Elm_Genlist_Item_Class *gtc;
Evas_Object *content, *parent;
Elm_Object_Item *it;
gtc = elm_genlist_item_class_new();
gtc->item_style = "default";
gtc->func.content_get = _item_content_get;
gtc->func.state_get = NULL;
gtc->func.del = NULL;
win = win_add(NULL, "genlist", ELM_WIN_BASIC);
genlist = elm_genlist_add(win);
evas_object_smart_callback_add(genlist, "realized", _genlist_item_content_test_realize, NULL);
it = elm_genlist_item_append(genlist, gtc, NULL, NULL,
ELM_GENLIST_ITEM_NONE, NULL, NULL);
evas_object_resize(genlist, 100, 100);
evas_object_resize(win, 150, 150);
evas_object_show(genlist);
evas_object_show(win);
ecore_main_loop_begin();
content = elm_object_item_part_content_get(it, "elm.swallow.end");
parent = elm_object_parent_widget_get(content);
ck_assert_ptr_eq(parent, genlist);
elm_genlist_item_all_contents_unset(it, NULL);
parent = elm_object_parent_widget_get(content);
ck_assert_ptr_eq(parent, win);
}
EFL_END_TEST
EFL_START_TEST(elm_genlist_test_legacy_type_check)
{
const char *type;
@ -520,6 +570,7 @@ void elm_test_genlist(TCase *tc)
tcase_add_test(tc, elm_genlist_test_legacy_type_check);
tcase_add_test(tc, elm_genlist_test_item_destroy);
tcase_add_test(tc, elm_genlist_test_item_iteration);
tcase_add_test(tc, elm_genlist_test_item_content);
tcase_add_test(tc, elm_genlist_test_atspi_role_get);
tcase_add_test(tc, elm_genlist_test_atspi_children_get1);
tcase_add_test(tc, elm_genlist_test_atspi_children_get2);