summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJEONGHYUN YUN <jh0506.yun@samsung.com>2017-08-10 14:12:08 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-08-10 14:42:08 +0900
commitbf0b3e0b75f5c6ebc5cb96211b3b21235422e358 (patch)
tree1a53d2dfc466f9088d890cb5697f130ade24ffd7
parent080c92658890bc3023aa2568c3f4679987a5154f (diff)
elm_ctxpopup: Add APIs to insert before/after item to a ctxpopup object.
Summary: There were only 2 APIs (item_append, item_prepend) for ctxpopup item add. Added more item add APIs (item_insert_before and item_insert_after) for convenience. Test Plan: 1. launch elementary_test - ctxpopup 2. click Ctxpopup with callback function sample 3. check whether there are 3 items on ctxpopup Reviewers: woohyun, Jaehyun, jpeg, cedric Reviewed By: jpeg Subscribers: cedric, jpeg Differential Revision: https://phab.enlightenment.org/D5004
-rw-r--r--src/bin/elementary/test_ctxpopup.c7
-rw-r--r--src/lib/elementary/elc_ctxpopup.c52
-rw-r--r--src/lib/elementary/elm_ctxpopup.eo35
3 files changed, 90 insertions, 4 deletions
diff --git a/src/bin/elementary/test_ctxpopup.c b/src/bin/elementary/test_ctxpopup.c
index 6be16a50f1..9fc3de3d39 100644
--- a/src/bin/elementary/test_ctxpopup.c
+++ b/src/bin/elementary/test_ctxpopup.c
@@ -327,15 +327,16 @@ _list_item_cb7(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_U
327{ 327{
328 Evas_Object *ctxpopup; 328 Evas_Object *ctxpopup;
329 Evas_Coord x,y; 329 Evas_Coord x,y;
330 Elm_Object_Item *item;
330 331
331 if (list_mouse_down > 0) return; 332 if (list_mouse_down > 0) return;
332 ctxpopup = elm_ctxpopup_add(obj); 333 ctxpopup = elm_ctxpopup_add(obj);
333 evas_object_smart_callback_add(ctxpopup, "dismissed", _dismissed, NULL); 334 evas_object_smart_callback_add(ctxpopup, "dismissed", _dismissed, NULL);
334 evas_object_smart_callback_add(ctxpopup, "geometry,update", _geometry_update, NULL); 335 evas_object_smart_callback_add(ctxpopup, "geometry,update", _geometry_update, NULL);
335 336
336 elm_ctxpopup_item_append(ctxpopup, "Disable this item", NULL, _ctxpopup_item_disable_cb, ctxpopup); 337 item = elm_ctxpopup_item_prepend(ctxpopup, "Disable this item", NULL, _ctxpopup_item_disable_cb, ctxpopup);
337 elm_ctxpopup_item_append(ctxpopup, "Delete this ctxpopup", NULL, _ctxpopup_item_delete_cb, ctxpopup); 338 elm_ctxpopup_item_insert_before(ctxpopup, item, "Delete this ctxpopup", NULL, _ctxpopup_item_delete_cb, ctxpopup);
338 elm_ctxpopup_item_append(ctxpopup, "Another item", NULL, _ctxpopup_item_cb, NULL); 339 elm_ctxpopup_item_insert_after(ctxpopup, item, "Another item", NULL, _ctxpopup_item_cb, NULL);
339 340
340 evas_pointer_canvas_xy_get(evas_object_evas_get(obj), &x, &y); 341 evas_pointer_canvas_xy_get(evas_object_evas_get(obj), &x, &y);
341 evas_object_size_hint_max_set(ctxpopup, 240, 240); 342 evas_object_size_hint_max_set(ctxpopup, 240, 240);
diff --git a/src/lib/elementary/elc_ctxpopup.c b/src/lib/elementary/elc_ctxpopup.c
index 9b42539d6b..ecf418fdb2 100644
--- a/src/lib/elementary/elc_ctxpopup.c
+++ b/src/lib/elementary/elc_ctxpopup.c
@@ -1326,6 +1326,58 @@ _elm_ctxpopup_item_efl_object_constructor(Eo *obj, Elm_Ctxpopup_Item_Data *it)
1326} 1326}
1327 1327
1328EOLIAN static Elm_Object_Item* 1328EOLIAN static Elm_Object_Item*
1329_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)
1330{
1331 Eo *eo_item;
1332
1333 EINA_SAFETY_ON_NULL_RETURN_VAL(eo_before, NULL);
1334 ELM_CTXPOPUP_ITEM_DATA_GET(eo_before, before_it);
1335 ELM_CTXPOPUP_ITEM_CHECK_OR_RETURN(before_it, NULL);
1336
1337 if (!before_it->list_item) return NULL;
1338
1339 eo_item = efl_add(ELM_CTXPOPUP_ITEM_CLASS, obj, elm_obj_ctxpopup_item_init(efl_added, func, data));
1340 if (!eo_item) return NULL;
1341
1342 ELM_CTXPOPUP_ITEM_DATA_GET(eo_item, item);
1343
1344 item->list_item =
1345 elm_list_item_insert_before(sd->list, before_it->list_item, label, icon, NULL, _item_wrap_cb, item);
1346 efl_ref(item->list_item);
1347 sd->items = eina_list_prepend_relative(sd->items, eo_item, eo_before);
1348
1349 if (sd->visible) elm_layout_sizing_eval(obj);
1350
1351 return eo_item;
1352}
1353
1354EOLIAN static Elm_Object_Item*
1355_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)
1356{
1357 Eo *eo_item;
1358
1359 EINA_SAFETY_ON_NULL_RETURN_VAL(eo_after, NULL);
1360 ELM_CTXPOPUP_ITEM_DATA_GET(eo_after, after_it);
1361 ELM_CTXPOPUP_ITEM_CHECK_OR_RETURN(after_it, NULL);
1362
1363 if (!after_it->list_item) return NULL;
1364
1365 eo_item = efl_add(ELM_CTXPOPUP_ITEM_CLASS, obj, elm_obj_ctxpopup_item_init(efl_added, func, data));
1366 if (!eo_item) return NULL;
1367
1368 ELM_CTXPOPUP_ITEM_DATA_GET(eo_item, item);
1369
1370 item->list_item =
1371 elm_list_item_insert_after(sd->list, after_it->list_item, label, icon, NULL, _item_wrap_cb, item);
1372 efl_ref(item->list_item);
1373 sd->items = eina_list_append_relative(sd->items, eo_item, eo_after);
1374
1375 if (sd->visible) elm_layout_sizing_eval(obj);
1376
1377 return eo_item;
1378}
1379
1380EOLIAN static Elm_Object_Item*
1329_elm_ctxpopup_item_append(Eo *obj, Elm_Ctxpopup_Data *sd, const char *label, Evas_Object *icon, Evas_Smart_Cb func, const void *data) 1381_elm_ctxpopup_item_append(Eo *obj, Elm_Ctxpopup_Data *sd, const char *label, Evas_Object *icon, Evas_Smart_Cb func, const void *data)
1330{ 1382{
1331 Eo *eo_item; 1383 Eo *eo_item;
diff --git a/src/lib/elementary/elm_ctxpopup.eo b/src/lib/elementary/elm_ctxpopup.eo
index 39448e2f27..69615eecd6 100644
--- a/src/lib/elementary/elm_ctxpopup.eo
+++ b/src/lib/elementary/elm_ctxpopup.eo
@@ -113,10 +113,43 @@ class Elm.Ctxpopup (Efl.Ui.Layout, Elm.Interface.Atspi_Widget_Action,
113 clear { 113 clear {
114 [[Clear all items in the given ctxpopup object.]] 114 [[Clear all items in the given ctxpopup object.]]
115 } 115 }
116 item_insert_before {
117 [[Insert a new item to a ctxpopup object before item $before.
118
119 See also elm_object_content_set.
120
121 @since 1.21
122 ]]
123 return: Elm.Widget.Item; [[A handle to the item added or $null, on errors.]]
124
125 params {
126 @in before: Elm.Widget.Item; [[The ctxpopup item to insert before.]]
127 @in label: string; [[The Label of the new item]]
128 @in icon: Efl.Canvas.Object @optional; [[Icon to be set on new item]]
129 @in func: Evas_Smart_Cb @optional; [[Convenience function called when item selected]]
130 @in data: const(void_ptr) @optional; [[Data passed to $func]]
131 }
132 }
133 item_insert_after {
134 [[Insert a new item to a ctxpopup object after item $after.
135
136 See also elm_object_content_set.
137
138 @since 1.21
139 ]]
140 return: Elm.Widget.Item; [[A handle to the item added or $null, on errors.]]
141
142 params {
143 @in after: Elm.Widget.Item; [[The ctxpopup item to insert after.]]
144 @in label: string; [[The Label of the new item]]
145 @in icon: Efl.Canvas.Object @optional; [[Icon to be set on new item]]
146 @in func: Evas_Smart_Cb @optional; [[Convenience function called when item selected]]
147 @in data: const(void_ptr) @optional; [[Data passed to $func]]
148 }
149 }
116 item_append { 150 item_append {
117 [[Add a new item to a ctxpopup object. 151 [[Add a new item to a ctxpopup object.
118 152
119
120 Warning:Ctxpopup can't hold both an item list and a content at the same 153 Warning:Ctxpopup can't hold both an item list and a content at the same
121 time. When an item is added, any previous content will be removed. 154 time. When an item is added, any previous content will be removed.
122 155