From: discomfitor Date: Fri, 29 Jul 2011 14:00:31 +0000 (+0000) Subject: +elm_menu_item_index_get X-Git-Tag: REL_F_I9500_20120323_1~17^2~2100 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2e9cbf8e1bc2447cf560ff833041a4f5a078b535;p=framework%2Fuifw%2Felementary.git +elm_menu_item_index_get git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@61892 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index 1b1758a..535ce8f 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -9823,6 +9823,7 @@ extern "C" { EAPI void *elm_menu_item_data_get(const Elm_Menu_Item *it) EINA_ARG_NONNULL(1); EAPI void elm_menu_item_data_set(Elm_Menu_Item *item, const void *data) EINA_ARG_NONNULL(1); EAPI const Eina_List *elm_menu_item_subitems_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1); + EAPI unsigned int elm_menu_item_index_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1) EINA_PURE; EAPI Elm_Menu_Item *elm_menu_selected_item_get(const Evas_Object * obj) EINA_ARG_NONNULL(1); EAPI Elm_Menu_Item *elm_menu_last_item_get(const Evas_Object * obj) EINA_ARG_NONNULL(1); EAPI Elm_Menu_Item *elm_menu_first_item_get(const Evas_Object * obj) EINA_ARG_NONNULL(1); diff --git a/src/lib/elm_menu.c b/src/lib/elm_menu.c index 1e01665..6d5380c 100644 --- a/src/lib/elm_menu.c +++ b/src/lib/elm_menu.c @@ -24,6 +24,7 @@ struct _Elm_Menu_Item const char *icon_str; const char *label; Evas_Smart_Cb func; + unsigned int idx; struct { Evas_Object *hv, *bx, *location; @@ -689,11 +690,13 @@ elm_menu_item_add(Evas_Object *obj, Elm_Menu_Item *parent, const char *icon, con if (!parent->submenu.bx) _item_submenu_obj_create(parent); elm_box_pack_end(parent->submenu.bx, subitem->base.view); parent->submenu.items = eina_list_append(parent->submenu.items, subitem); + subitem->idx = eina_list_count(parent->submenu.items) - 1; } else { elm_box_pack_end(wd->bx, subitem->base.view); wd->items = eina_list_append(wd->items, subitem); + subitem->idx = eina_list_count(wd->items) - 1; } _sizing_eval(obj); @@ -740,11 +743,13 @@ elm_menu_item_add_object(Evas_Object *obj, Elm_Menu_Item *parent, Evas_Object *s if (!parent->submenu.bx) _item_submenu_obj_create(parent); elm_box_pack_end(parent->submenu.bx, subitem->base.view); parent->submenu.items = eina_list_append(parent->submenu.items, subitem); + subitem->idx = eina_list_count(parent->submenu.items) - 1; } else { elm_box_pack_end(wd->bx, subitem->base.view); wd->items = eina_list_append(wd->items, subitem); + subitem->idx = eina_list_count(wd->items) - 1; } _sizing_eval(obj); @@ -752,6 +757,23 @@ elm_menu_item_add_object(Evas_Object *obj, Elm_Menu_Item *parent, Evas_Object *s } /** + * Get the position of a menu item + * + * This function returns the index position of a menu item in a menu. + * For a sub-menu, this number is relative to the first item in the sub-menu. + * @param item The menu item + * @return The item's index + * @note Index values begin with 0 + * @ingroup Menu + */ +EAPI unsigned int +elm_menu_item_index_get(const Elm_Menu_Item *item) +{ + ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, 0); + return item->idx; +} + +/** * Set the label of a menu item * * @param item The menu item object.