summaryrefslogtreecommitdiff
path: root/src/lib/elementary/elc_ctxpopup.c
diff options
context:
space:
mode:
authorAmitesh Singh <amitesh.sh@samsung.com>2016-11-30 16:18:46 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-11-30 17:59:56 +0900
commita58e2e1a790732428fa09d479fec63d433931f06 (patch)
tree81d1d75af4995c0d00f18c2d9d7e59c22d742a8e /src/lib/elementary/elc_ctxpopup.c
parent496f2ed4277dbc03740494a7185a67060f7b2198 (diff)
Menu,Item Interface: Common interface for menu, toolbar and ctxpopup
Summary: efl_ui_menu interface provides common functions of menu, toolbar and ctxpopup. efl_ui_item interface provides common functions of menu_item, toolbar_item and ctxpopup_item. Also implemented some missing functions like selected_item set/get in ctxpopup. efl_ui_item interface should be used for other widget items as well. Test Plan: elementary_test Reviewers: jpeg, felipealmeida, raster, SanghyeonLee, cedric, yashu21985 Subscribers: bu5hm4n Differential Revision: https://phab.enlightenment.org/D3897
Diffstat (limited to 'src/lib/elementary/elc_ctxpopup.c')
-rw-r--r--src/lib/elementary/elc_ctxpopup.c109
1 files changed, 102 insertions, 7 deletions
diff --git a/src/lib/elementary/elc_ctxpopup.c b/src/lib/elementary/elc_ctxpopup.c
index f1c72e1..aeba54f 100644
--- a/src/lib/elementary/elc_ctxpopup.c
+++ b/src/lib/elementary/elc_ctxpopup.c
@@ -1237,10 +1237,61 @@ elm_ctxpopup_horizontal_get(const Evas_Object *obj)
1237 return sd->orient == EFL_ORIENT_HORIZONTAL ? EINA_TRUE : EINA_FALSE; 1237 return sd->orient == EFL_ORIENT_HORIZONTAL ? EINA_TRUE : EINA_FALSE;
1238} 1238}
1239 1239
1240EAPI const Eina_List *
1241elm_ctxpopup_items_get(const Evas_Object *obj)
1242{
1243 Eina_List *lst = NULL;
1244 Eina_Iterator *it;
1245 void *item_data;
1246
1247 it = efl_ui_menu_items_get(obj);
1248 EINA_ITERATOR_FOREACH(it, item_data)
1249 {
1250 lst = eina_list_append(lst, item_data);
1251 }
1252 eina_iterator_free(it);
1253 return lst;
1254}
1255
1256EAPI Elm_Widget_Item *
1257elm_ctxpopup_first_item_get(const Evas_Object *obj)
1258{
1259 return efl_ui_menu_first_item_get(obj);
1260}
1261
1262EAPI Elm_Widget_Item *
1263elm_ctxpopup_last_item_get(const Evas_Object *obj)
1264{
1265 return efl_ui_menu_last_item_get(obj);
1266}
1267
1268EAPI Elm_Widget_Item *
1269elm_ctxpopup_item_prev_get(const Evas_Object *obj)
1270{
1271 return efl_ui_item_prev_get(obj);
1272}
1273
1274EAPI Elm_Widget_Item *
1275elm_ctxpopup_item_next_get(const Evas_Object *obj)
1276{
1277 return efl_ui_item_next_get(obj);
1278}
1279
1240static void 1280static void
1241_item_wrap_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 1281_item_wrap_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1242{ 1282{
1243 Elm_Ctxpopup_Item_Data *item = data; 1283 Elm_Ctxpopup_Item_Data *item = data;
1284 Eina_List *l;
1285 Elm_Object_Item *eo_item;
1286
1287 ELM_CTXPOPUP_DATA_GET_OR_RETURN(item->wcb.cobj, sd);
1288 EINA_LIST_FOREACH(sd->items, l, eo_item)
1289 {
1290 ELM_CTXPOPUP_ITEM_DATA_GET(eo_item, item);
1291 item->selected = EINA_FALSE;
1292 }
1293 item->selected = EINA_TRUE;
1294
1244 if (!item->wcb.org_func_cb) return; 1295 if (!item->wcb.org_func_cb) return;
1245 item->wcb.org_func_cb((void *)item->wcb.org_data, item->wcb.cobj, EO_OBJ(item)); 1296 item->wcb.org_func_cb((void *)item->wcb.org_data, item->wcb.cobj, EO_OBJ(item));
1246} 1297}
@@ -1325,14 +1376,14 @@ _elm_ctxpopup_class_constructor(Efl_Class *klass)
1325 evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass); 1376 evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
1326} 1377}
1327 1378
1328EOLIAN static const Eina_List* 1379EOLIAN static Eina_Iterator*
1329_elm_ctxpopup_items_get(Eo *obj EINA_UNUSED, Elm_Ctxpopup_Data *sd) 1380_elm_ctxpopup_efl_ui_menu_items_get(Eo *obj EINA_UNUSED, Elm_Ctxpopup_Data *sd)
1330{ 1381{
1331 return sd->items; 1382 return eina_list_iterator_new(sd->items);
1332} 1383}
1333 1384
1334EOLIAN static Elm_Object_Item* 1385EOLIAN static Elm_Object_Item*
1335_elm_ctxpopup_first_item_get(Eo *obj EINA_UNUSED, Elm_Ctxpopup_Data *sd) 1386_elm_ctxpopup_efl_ui_menu_first_item_get(Eo *obj EINA_UNUSED, Elm_Ctxpopup_Data *sd)
1336{ 1387{
1337 if (!sd->items) return NULL; 1388 if (!sd->items) return NULL;
1338 1389
@@ -1340,7 +1391,7 @@ _elm_ctxpopup_first_item_get(Eo *obj EINA_UNUSED, Elm_Ctxpopup_Data *sd)
1340} 1391}
1341 1392
1342EOLIAN static Elm_Object_Item* 1393EOLIAN static Elm_Object_Item*
1343_elm_ctxpopup_last_item_get(Eo *obj EINA_UNUSED, Elm_Ctxpopup_Data *sd) 1394_elm_ctxpopup_efl_ui_menu_last_item_get(Eo *obj EINA_UNUSED, Elm_Ctxpopup_Data *sd)
1344{ 1395{
1345 if (!sd->items) return NULL; 1396 if (!sd->items) return NULL;
1346 1397
@@ -1348,6 +1399,21 @@ _elm_ctxpopup_last_item_get(Eo *obj EINA_UNUSED, Elm_Ctxpopup_Data *sd)
1348} 1399}
1349 1400
1350EOLIAN static Elm_Object_Item* 1401EOLIAN static Elm_Object_Item*
1402_elm_ctxpopup_efl_ui_menu_selected_item_get(Eo *obj EINA_UNUSED, Elm_Ctxpopup_Data *sd)
1403{
1404 Eina_List *l;
1405 Elm_Object_Item *eo_item;
1406
1407 EINA_LIST_FOREACH(sd->items, l, eo_item)
1408 {
1409 ELM_CTXPOPUP_ITEM_DATA_GET(eo_item, item);
1410 if (item->selected) return eo_item;
1411 }
1412
1413 return NULL;
1414}
1415
1416EOLIAN static Elm_Object_Item*
1351_elm_ctxpopup_item_prepend(Eo *obj, Elm_Ctxpopup_Data *sd, const char *label, Evas_Object *icon, Evas_Smart_Cb func, const void *data) 1417_elm_ctxpopup_item_prepend(Eo *obj, Elm_Ctxpopup_Data *sd, const char *label, Evas_Object *icon, Evas_Smart_Cb func, const void *data)
1352{ 1418{
1353 Eo *eo_item; 1419 Eo *eo_item;
@@ -1368,7 +1434,7 @@ _elm_ctxpopup_item_prepend(Eo *obj, Elm_Ctxpopup_Data *sd, const char *label, Ev
1368} 1434}
1369 1435
1370EOLIAN static Elm_Object_Item * 1436EOLIAN static Elm_Object_Item *
1371_elm_ctxpopup_item_prev_get(Eo *eo_item EINA_UNUSED, Elm_Ctxpopup_Item_Data *item) 1437_elm_ctxpopup_item_efl_ui_item_prev_get(Eo *eo_item EINA_UNUSED, Elm_Ctxpopup_Item_Data *item)
1372{ 1438{
1373 Eina_List *l; 1439 Eina_List *l;
1374 1440
@@ -1383,7 +1449,7 @@ _elm_ctxpopup_item_prev_get(Eo *eo_item EINA_UNUSED, Elm_Ctxpopup_Item_Data *ite
1383} 1449}
1384 1450
1385EOLIAN static Elm_Object_Item * 1451EOLIAN static Elm_Object_Item *
1386_elm_ctxpopup_item_next_get(Eo *eo_item EINA_UNUSED, Elm_Ctxpopup_Item_Data *item) 1452_elm_ctxpopup_item_efl_ui_item_next_get(Eo *eo_item EINA_UNUSED, Elm_Ctxpopup_Item_Data *item)
1387{ 1453{
1388 Eina_List *l; 1454 Eina_List *l;
1389 1455
@@ -1398,6 +1464,35 @@ _elm_ctxpopup_item_next_get(Eo *eo_item EINA_UNUSED, Elm_Ctxpopup_Item_Data *ite
1398} 1464}
1399 1465
1400EOLIAN static void 1466EOLIAN static void
1467_elm_ctxpopup_item_efl_ui_item_selected_set(Eo *eo_item EINA_UNUSED,
1468 Elm_Ctxpopup_Item_Data *item,
1469 Eina_Bool selected)
1470{
1471 Eina_List *l;
1472 Elm_Object_Item *temp_item;
1473
1474 if (selected == item->selected) return;
1475
1476 if (selected)
1477 {
1478 ELM_CTXPOPUP_DATA_GET_OR_RETURN(item->wcb.cobj, sd);
1479 EINA_LIST_FOREACH(sd->items, l, temp_item)
1480 {
1481 ELM_CTXPOPUP_ITEM_DATA_GET(temp_item, item);
1482 item->selected = EINA_FALSE;
1483 }
1484 }
1485 elm_list_item_selected_set(item->list_item, selected);
1486 item->selected = selected;
1487}
1488
1489EOLIAN static Eina_Bool
1490_elm_ctxpopup_item_efl_ui_item_selected_get(Eo *eo_item EINA_UNUSED, Elm_Ctxpopup_Item_Data *item)
1491{
1492 return item->selected;
1493}
1494
1495EOLIAN static void
1401_elm_ctxpopup_item_init(Eo *eo_item, 1496_elm_ctxpopup_item_init(Eo *eo_item,
1402 Elm_Ctxpopup_Item_Data *item, 1497 Elm_Ctxpopup_Item_Data *item,
1403 Evas_Smart_Cb func, 1498 Evas_Smart_Cb func,