elm_ctxpopup: Implemented elm_widget_item_del_pre for elm_ctxpopup_item
authorarosis <jh0506.yun@samsung.com>
Thu, 10 Aug 2017 05:02:06 +0000 (14:02 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Thu, 10 Aug 2017 05:42:08 +0000 (14:42 +0900)
Summary:
ctxpopup item have elm_list item internally.
But when elm_ctxpopup item was deleted, elm_list item was not deleted.
elm_list item in elm_ctxpopup item should be deleted in del_pre
when elm_ctxpopup item is deleted by elm_wdg_item_del()

Test Plan:
1. launch elementary_test - ctxpopup
2. click Ctxpopup with label only
3. "Never Show" item should not shown in ctxpopup

Reviewers: jpeg, cedric, woohyun

Subscribers: cedric, jpeg

Differential Revision: https://phab.enlightenment.org/D5044

src/bin/elementary/test_ctxpopup.c
src/lib/elementary/elc_ctxpopup.c
src/lib/elementary/elm_ctxpopup_item.eo

index 0c11412..6be16a5 100644 (file)
@@ -159,6 +159,8 @@ _list_item_cb3(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_U
    elm_object_item_disabled_set(it, EINA_TRUE);
    _ctxpopup_item_new(ctxpopup, "Embryo", NULL);
    _ctxpopup_item_new(ctxpopup, "Edje", NULL);
+   it = _ctxpopup_item_new(ctxpopup, "Never Show", NULL);
+   elm_object_item_del(it);
 
    evas_pointer_canvas_xy_get(evas_object_evas_get(obj), &x, &y);
    evas_object_move(ctxpopup, x, y);
index 1a20710..9b42539 100644 (file)
@@ -907,6 +907,23 @@ _elm_ctxpopup_item_elm_widget_item_disable(Eo *eo_ctxpopup_it,
      (ctxpopup_it->list_item, elm_wdg_item_disabled_get(eo_ctxpopup_it));
 }
 
+EOLIAN static Eina_Bool
+_elm_ctxpopup_item_elm_widget_item_del_pre(Eo *eo_ctxpopup_it EINA_UNUSED,
+                                           Elm_Ctxpopup_Item_Data *ctxpopup_it)
+{
+   ELM_CTXPOPUP_DATA_GET(WIDGET(ctxpopup_it), sd);
+   if (!sd) return EINA_FALSE;
+
+   if (ctxpopup_it->list_item)
+     {
+        efl_unref(ctxpopup_it->list_item);
+        elm_wdg_item_del(ctxpopup_it->list_item);
+        ctxpopup_it->list_item = NULL;
+     }
+
+   return EINA_TRUE;
+}
+
 EOLIAN static void
 _elm_ctxpopup_item_elm_widget_item_signal_emit(Eo *eo_ctxpopup_it EINA_UNUSED,
                                                Elm_Ctxpopup_Item_Data *ctxpopup_it,
index a6f14e2..47dd0ff 100644 (file)
@@ -17,6 +17,7 @@ class Elm.Ctxpopup.Item(Elm.Widget.Item, Efl.Ui.Item)
         Efl.Object.destructor;
         Elm.Widget.Item.disable;
         Elm.Widget.Item.signal_emit;
+        Elm.Widget.Item.del_pre;
         Elm.Widget.Item.part_text { get; set; }
         Elm.Widget.Item.part_content { get; set; }
         Elm.Widget.Item.focus { get; set; }