elm_ctxpopup: enable ctxpopup item insert before/after for mobile_lib 13/138413/1
authorJEONGHYUN YUN <jh0506.yun@samsung.com>
Wed, 12 Jul 2017 06:38:44 +0000 (15:38 +0900)
committerJEONGHYUN YUN <jh0506.yun@samsung.com>
Wed, 12 Jul 2017 06:39:56 +0000 (15:39 +0900)
Change-Id: I4f96499e0636e1784b634116e7915df8e33e2a45
Signed-off-by: JEONGHYUN YUN <jh0506.yun@samsung.com>
src/mobile_lib/elc_ctxpopup.c

index f9f024b52b97ea51365b8222fffed65061bbdf20..296fe950e66a36104b324ed01b562cbc09f56368 100644 (file)
@@ -2236,15 +2236,45 @@ _item_new(Evas_Object *obj,
 EOLIAN static Elm_Object_Item*
 _elm_ctxpopup_item_insert_before(Eo *obj, Elm_Ctxpopup_Data *sd, Elm_Object_Item *eo_before, const char *label, Evas_Object *icon, Evas_Smart_Cb func, const void *data)
 {
-   // This will be implemented later on.
-   return NULL;
+   Elm_Ctxpopup_Item_Data *item;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(eo_before, NULL);
+   ELM_CTXPOPUP_ITEM_DATA_GET(eo_before, before_it);
+   ELM_CTXPOPUP_ITEM_CHECK_OR_RETURN(before_it,  NULL);
+
+   if (!before_it->btn) return NULL;
+
+   item = _item_new(obj, sd, label, icon, func, data);
+   if (!item) return NULL;
+
+   elm_box_pack_before(sd->box, item->btn, before_it->btn);
+   sd->items = eina_list_prepend_relative(sd->items, item, before_it);
+
+   _items_sizing_eval(obj, sd);
+
+   return EO_OBJ(item);
 }
 
 EOLIAN static Elm_Object_Item*
 _elm_ctxpopup_item_insert_after(Eo *obj, Elm_Ctxpopup_Data *sd, Elm_Object_Item *eo_after, const char *label, Evas_Object *icon, Evas_Smart_Cb func, const void *data)
 {
-   // This will be implemented later on.
-   return NULL;
+   Elm_Ctxpopup_Item_Data *item;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(eo_after, NULL);
+   ELM_CTXPOPUP_ITEM_DATA_GET(eo_after, after_it);
+   ELM_CTXPOPUP_ITEM_CHECK_OR_RETURN(after_it,  NULL);
+
+   if (!after_it->btn) return NULL;
+
+   item = _item_new(obj, sd, label, icon, func, data);
+   if (!item) return NULL;
+
+   elm_box_pack_after(sd->box, item->btn, after_it->btn);
+   sd->items = eina_list_append_relative(sd->items, item, after_it);
+
+   _items_sizing_eval(obj, sd);
+
+   return EO_OBJ(item);
 }
 
 EOLIAN static Elm_Object_Item*