From 2403c512bff1d30574c2953839f79154d8ca4eba Mon Sep 17 00:00:00 2001 From: ChunEon Park Date: Fri, 25 Nov 2011 10:57:39 +0000 Subject: [PATCH] elementary/menu - Elm_Menu_Item -> Elm_Object_Item SVN revision: 65596 --- src/bin/test_map.c | 13 ++- src/bin/test_menu.c | 113 ++++++++++--------- src/bin/test_toolbar.c | 39 +++---- src/examples/menu_example_01.c | 26 ++--- src/lib/Elementary.h.in | 97 ++++++++-------- src/lib/elm_menu.c | 246 +++++++++++++++++++++++------------------ src/lib/elm_priv.h | 2 +- src/lib/elm_toolbar.c | 12 +- 8 files changed, 295 insertions(+), 253 deletions(-) diff --git a/src/bin/test_map.c b/src/bin/test_map.c index 8b1a033..8c78e73 100644 --- a/src/bin/test_map.c +++ b/src/bin/test_map.c @@ -603,17 +603,18 @@ _map_move_resize_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, } static void -_populate(void *data, Elm_Menu_Item *item) +_populate(void *data, Elm_Object_Item *menu_it) { int idx; - if ((!data) || (!item) || (!source_names)) return; + if ((!data) || (!menu_it) || (!source_names)) return; for (idx = 0; source_names[idx]; idx++) { if (idx >= SOURCE_MAX) break; ms[idx].map = data; ms[idx].source_name = strdup(source_names[idx]); - elm_menu_item_add(menu, item, "", source_names[idx], map_source, &ms[idx]); + elm_menu_item_add(menu, menu_it, "", source_names[idx], map_source, + &ms[idx]); } } @@ -621,7 +622,7 @@ static void _map_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info) { Evas_Event_Mouse_Down *down = event_info; - Elm_Menu_Item *item; + Elm_Object_Item *menu_it; if (!down) return; if (down->button == 2) @@ -633,8 +634,8 @@ _map_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event else if (down->button == 3) { menu = elm_menu_add(obj); - item = elm_menu_item_add(menu, NULL, NULL, "Source", NULL, NULL); - _populate(data, item); + menu_it = elm_menu_item_add(menu, NULL, NULL, "Source", NULL, NULL); + _populate(data, menu_it); elm_menu_item_add(menu, NULL, NULL, "Show Urmatt", map_show_urmatt, data); elm_menu_item_add(menu, NULL, NULL, "Bring Seoul", map_bring_seoul, data); elm_menu_item_add(menu, NULL, NULL, "Paused Set", map_paused_set, data); diff --git a/src/bin/test_menu.c b/src/bin/test_menu.c index 540b425..47c17de 100644 --- a/src/bin/test_menu.c +++ b/src/bin/test_menu.c @@ -15,80 +15,88 @@ _show(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_i } static void -_populate_4(Elm_Menu_Item *item) +_populate_4(Elm_Object_Item *menu_it) { - Elm_Menu_Item *item2; - - elm_menu_item_add(menu, item, "go-bottom", "menu 2", NULL, NULL); - elm_menu_item_add(menu, item, "go-first", "menu 3", NULL, NULL); - elm_menu_item_separator_add(menu, item); - item2 = elm_menu_item_add(menu, item, "go-last", "Disabled item", NULL, NULL); - elm_menu_item_disabled_set(item2, 1); - item2 = elm_menu_item_add(menu, item, "go-next", "Disabled item", NULL, NULL); - elm_menu_item_disabled_set(item2, 1); - item2 = elm_menu_item_add(menu, item, "go-up", "Disabled item", NULL, NULL); - elm_menu_item_disabled_set(item2, 1); + Elm_Object_Item *menu_it2; + + elm_menu_item_add(menu, menu_it, "go-bottom", "menu 2", NULL, NULL); + elm_menu_item_add(menu, menu_it, "go-first", "menu 3", NULL, NULL); + elm_menu_item_separator_add(menu, menu_it); + menu_it2 = elm_menu_item_add(menu, menu_it, "go-last", "Disabled item", NULL, + NULL); + elm_menu_item_disabled_set(menu_it2, EINA_TRUE); + menu_it2 = elm_menu_item_add(menu, menu_it, "go-next", "Disabled item", NULL, + NULL); + elm_menu_item_disabled_set(menu_it2, EINA_TRUE); + menu_it2 = elm_menu_item_add(menu, menu_it, "go-up", "Disabled item", NULL, + NULL); + elm_menu_item_disabled_set(menu_it2, EINA_TRUE); } static void -_populate_3(Elm_Menu_Item *item) +_populate_3(Elm_Object_Item *menu_it) { - Elm_Menu_Item *item2; - - elm_menu_item_add(menu, item, "media-eject", "menu 2", NULL, NULL); - elm_menu_item_add(menu, item, "media-playback-start", "menu 3", NULL, NULL); - elm_menu_item_separator_add(menu,item); - item2 = elm_menu_item_add(menu, item, "media-playback-stop", "Disabled item", NULL, NULL); - elm_menu_item_disabled_set(item2, 1); + Elm_Object_Item *menu_it2; + + elm_menu_item_add(menu, menu_it, "media-eject", "menu 2", NULL, NULL); + elm_menu_item_add(menu, menu_it, "media-playback-start", "menu 3", NULL, + NULL); + elm_menu_item_separator_add(menu, menu_it); + menu_it2 = elm_menu_item_add(menu, menu_it, "media-playback-stop", + "Disabled item", NULL, NULL); + elm_menu_item_disabled_set(menu_it2, EINA_TRUE); } static void -_populate_2(Elm_Menu_Item *item) +_populate_2(Elm_Object_Item *menu_it) { - Elm_Menu_Item *item2, *item3; - - elm_menu_item_add(menu, item, "system-reboot", "menu 2", NULL, NULL); - item2 = elm_menu_item_add(menu, item, "system-shutdown", "menu 3", NULL, NULL); - - _populate_3(item2); - - elm_menu_item_separator_add(menu,item); - elm_menu_item_separator_add(menu,item); - elm_menu_item_separator_add(menu,item); - elm_menu_item_separator_add(menu,item); - elm_menu_item_separator_add(menu,item); - elm_menu_item_separator_add(menu,item); - elm_menu_item_separator_add(menu,item); - - item2 = elm_menu_item_add(menu, item, "system-lock-screen", "menu 2", NULL, NULL); - elm_menu_item_separator_add(menu,item); - - item3 = elm_menu_item_add(menu, item, "system-run", "Disabled item", NULL, NULL); - elm_menu_item_disabled_set(item3, 1); - - _populate_4(item2); + Elm_Object_Item *menu_it2, *menu_it3; + + elm_menu_item_add(menu, menu_it, "system-reboot", "menu 2", NULL, NULL); + menu_it2 = elm_menu_item_add(menu, menu_it, "system-shutdown", "menu 3", + NULL, NULL); + _populate_3(menu_it2); + + elm_menu_item_separator_add(menu, menu_it); + elm_menu_item_separator_add(menu, menu_it); + elm_menu_item_separator_add(menu, menu_it); + elm_menu_item_separator_add(menu, menu_it); + elm_menu_item_separator_add(menu, menu_it); + elm_menu_item_separator_add(menu, menu_it); + elm_menu_item_separator_add(menu, menu_it); + + menu_it2 = elm_menu_item_add(menu, menu_it, "system-lock-screen", "menu 2", + NULL, NULL); + elm_menu_item_separator_add(menu, menu_it); + + menu_it3 = elm_menu_item_add(menu, menu_it, "system-run", "Disabled item", + NULL, NULL); + elm_menu_item_disabled_set(menu_it3, EINA_TRUE); + + _populate_4(menu_it2); } static void -_populate_1(Evas_Object *win, Elm_Menu_Item *item) +_populate_1(Evas_Object *win, Elm_Object_Item *menu_it) { - Elm_Menu_Item *item2; + Elm_Object_Item *menu_it2; Evas_Object *radio; radio = elm_radio_add(win); elm_radio_state_value_set(radio, 0); elm_radio_value_set(radio, 0); elm_object_text_set(radio, "radio in menu"); - item2 = elm_menu_item_add(menu, item, "object-rotate-left", "menu 1", NULL, NULL); - elm_menu_item_add_object(menu, item, radio, NULL, NULL); + menu_it2 = elm_menu_item_add(menu, menu_it, "object-rotate-left", "menu 1", + NULL, NULL); + elm_menu_item_add_object(menu, menu_it, radio, NULL, NULL); - _populate_2(item2); + _populate_2(menu_it2); } void test_menu(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - Elm_Menu_Item *item; + Elm_Object_Item *menu_it; win = elm_win_add(NULL, "menu", ELM_WIN_BASIC); elm_win_title_set(win, "Menu"); @@ -107,10 +115,11 @@ test_menu(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info _ menu = elm_menu_add(win); elm_menu_item_add(menu, NULL, NULL, "first item", NULL, NULL); - item = elm_menu_item_add(menu, NULL, "mail-reply-all", "second item", NULL, NULL); - _populate_1(win, item); + menu_it = elm_menu_item_add(menu, NULL, "mail-reply-all", "second item", + NULL, NULL); + _populate_1(win, menu_it); - elm_menu_item_add(menu, item, "window-new", "sub menu", NULL, NULL); + elm_menu_item_add(menu, menu_it, "window-new", "sub menu", NULL, NULL); evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_DOWN, _show, menu); diff --git a/src/bin/test_toolbar.c b/src/bin/test_toolbar.c index 5d41b1b..55c369a 100644 --- a/src/bin/test_toolbar.c +++ b/src/bin/test_toolbar.c @@ -67,7 +67,7 @@ test_toolbar(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_inf Evas_Object *win, *bg, *bx, *tb, *ph, *menu; Evas_Object *ph1, *ph2, *ph3, *ph4; Elm_Toolbar_Item *item; - Elm_Menu_Item *menu_item; + Elm_Object_Item *menu_it; char buf[PATH_MAX]; win = elm_win_add(NULL, "toolbar", ELM_WIN_BASIC); @@ -118,8 +118,8 @@ test_toolbar(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_inf menu = elm_toolbar_item_menu_get(item); elm_menu_item_add(menu, NULL, "edit-cut", "Shrink", tb_3, ph4); - menu_item = elm_menu_item_add(menu, NULL, "edit-copy", "Mode", tb_4, ph4); - elm_menu_item_add(menu, menu_item, "edit-paste", "is set to", tb_4, ph4); + menu_it = elm_menu_item_add(menu, NULL, "edit-copy", "Mode", tb_4, ph4); + elm_menu_item_add(menu, menu_it, "edit-paste", "is set to", tb_4, ph4); elm_menu_item_add(menu, NULL, "edit-delete", "Menu", tb_5, ph4); elm_box_pack_end(bx, tb); @@ -177,7 +177,7 @@ test_toolbar2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in Evas_Object *win, *bg, *bx, *tb, *ph, *menu; Evas_Object *ph1, *ph2, *ph3, *ph4; Elm_Toolbar_Item *item; - Elm_Menu_Item *menu_item; + Elm_Object_Item *menu_it; char buf[PATH_MAX]; win = elm_win_add(NULL, "toolbar2", ELM_WIN_BASIC); @@ -228,8 +228,8 @@ test_toolbar2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in menu = elm_toolbar_item_menu_get(item); elm_menu_item_add(menu, NULL, "edit-cut", "Shrink", tb_3, ph4); - menu_item = elm_menu_item_add(menu, NULL, "edit-copy", "Mode", tb_4, ph4); - elm_menu_item_add(menu, menu_item, "edit-paste", "is set to", tb_4, ph4); + menu_it = elm_menu_item_add(menu, NULL, "edit-copy", "Mode", tb_4, ph4); + elm_menu_item_add(menu, menu_it, "edit-paste", "is set to", tb_4, ph4); elm_menu_item_add(menu, NULL, "edit-delete", "Scroll", tb_5, ph4); elm_box_pack_end(bx, tb); @@ -287,7 +287,7 @@ test_toolbar3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in Evas_Object *win, *bg, *bx, *tb, *ph, *menu; Evas_Object *ph1, *ph2, *ph3, *ph4; Elm_Toolbar_Item *item; - Elm_Menu_Item *menu_item; + Elm_Object_Item *menu_it; char buf[PATH_MAX]; win = elm_win_add(NULL, "toolbar3", ELM_WIN_BASIC); @@ -338,15 +338,14 @@ test_toolbar3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in menu = elm_toolbar_item_menu_get(item); elm_menu_item_add(menu, NULL, "edit-cut", "Shrink", tb_3, ph4); - menu_item = elm_menu_item_add(menu, NULL, "edit-copy", "Mode", tb_4, ph4); - elm_menu_item_add(menu, menu_item, "edit-paste", "is set to", tb_4, ph4); + menu_it = elm_menu_item_add(menu, NULL, "edit-copy", "Mode", tb_4, ph4); + elm_menu_item_add(menu, menu_it, "edit-paste", "is set to", tb_4, ph4); elm_menu_item_add(menu, NULL, "edit-delete", "None", tb_5, ph4); elm_box_pack_end(bx, tb); evas_object_show(tb); tb = elm_table_add(win); - //elm_table_homogeneous_set(tb, 1); evas_object_size_hint_weight_set(tb, 0.0, EVAS_HINT_EXPAND); evas_object_size_hint_fill_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL); @@ -398,7 +397,7 @@ test_toolbar4(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in Evas_Object *win, *bg, *bx, *tb, *ph, *menu; Evas_Object *ph1, *ph2, *ph3, *ph4; Elm_Toolbar_Item *item; - Elm_Menu_Item *menu_item; + Elm_Object_Item *menu_it; char buf[PATH_MAX]; win = elm_win_add(NULL, "toolbar4", ELM_WIN_BASIC); @@ -449,8 +448,8 @@ test_toolbar4(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in menu = elm_toolbar_item_menu_get(item); elm_menu_item_add(menu, NULL, "edit-cut", "Shrink", tb_3, ph4); - menu_item = elm_menu_item_add(menu, NULL, "edit-copy", "Mode", tb_4, ph4); - elm_menu_item_add(menu, menu_item, "edit-paste", "is set to", tb_4, ph4); + menu_it = elm_menu_item_add(menu, NULL, "edit-copy", "Mode", tb_4, ph4); + elm_menu_item_add(menu, menu_it, "edit-paste", "is set to", tb_4, ph4); elm_menu_item_add(menu, NULL, "edit-delete", "Menu", tb_5, ph4); elm_box_pack_end(bx, tb); @@ -508,7 +507,7 @@ test_toolbar5(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in Evas_Object *win, *bg, *bx, *tb, *ph, *menu; Evas_Object *ph1, *ph2, *ph3, *ph4; Elm_Toolbar_Item *item; - Elm_Menu_Item *menu_item; + Elm_Object_Item *menu_it; char buf[PATH_MAX]; win = elm_win_add(NULL, "toolbar5", ELM_WIN_BASIC); @@ -564,15 +563,14 @@ test_toolbar5(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in menu = elm_toolbar_item_menu_get(item); elm_menu_item_add(menu, NULL, "edit-cut", "Shrink", tb_3, ph4); - menu_item = elm_menu_item_add(menu, NULL, "edit-copy", "Mode", tb_4, ph4); - elm_menu_item_add(menu, menu_item, "edit-paste", "is set to", tb_4, ph4); + menu_it = elm_menu_item_add(menu, NULL, "edit-copy", "Mode", tb_4, ph4); + elm_menu_item_add(menu, menu_it, "edit-paste", "is set to", tb_4, ph4); elm_menu_item_add(menu, NULL, "edit-delete", "Menu", tb_5, ph4); elm_box_pack_end(bx, tb); evas_object_show(tb); tb = elm_table_add(win); - //elm_table_homogeneous_set(tb, 1); evas_object_size_hint_weight_set(tb, 0.0, EVAS_HINT_EXPAND); evas_object_size_hint_fill_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL); @@ -623,7 +621,7 @@ test_toolbar6(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in Evas_Object *win, *bg, *bx, *tb, *ph, *menu; Evas_Object *ph1, *ph2, *ph3, *ph4; Elm_Toolbar_Item *item; - Elm_Menu_Item *menu_item; + Elm_Object_Item *menu_it; char buf[PATH_MAX]; win = elm_win_add(NULL, "toolbar", ELM_WIN_BASIC); @@ -676,15 +674,14 @@ test_toolbar6(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in menu = elm_toolbar_item_menu_get(item); elm_menu_item_add(menu, NULL, "edit-cut", "Shrink", tb_3, ph4); - menu_item = elm_menu_item_add(menu, NULL, "edit-copy", "Mode", tb_4, ph4); - elm_menu_item_add(menu, menu_item, "edit-paste", "is set to", tb_4, ph4); + menu_it = elm_menu_item_add(menu, NULL, "edit-copy", "Mode", tb_4, ph4); + elm_menu_item_add(menu, menu_it, "edit-paste", "is set to", tb_4, ph4); elm_menu_item_add(menu, NULL, "edit-delete", "Menu", tb_5, ph4); elm_box_pack_end(bx, tb); evas_object_show(tb); tb = elm_table_add(win); - //elm_table_homogeneous_set(tb, 1); evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_fill_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL); diff --git a/src/examples/menu_example_01.c b/src/examples/menu_example_01.c index 2b920a4..5761797 100644 --- a/src/examples/menu_example_01.c +++ b/src/examples/menu_example_01.c @@ -10,9 +10,9 @@ static void _del_it(void *data, Evas_Object *obj, void *event_info) { Eina_List *l; - Elm_Menu_Item *it = elm_menu_first_item_get(data); - it = elm_menu_item_next_get(it); - l = elm_menu_item_subitems_get(it); + Elm_Object_Item *menu_it = elm_menu_first_item_get(data); + menu_it = elm_menu_item_next_get(menu_it); + l = elm_menu_item_subitems_get(menu_it); elm_menu_item_del(eina_list_data_get(l)); } @@ -28,7 +28,7 @@ EAPI_MAIN int elm_main(int argc, char **argv) { Evas_Object *win, *bg, *menu, *button, *rect; - Elm_Menu_Item *item; + Elm_Object_Item *meu_it; win = elm_win_add(NULL, "menu", ELM_WIN_BASIC); elm_win_title_set(win, "Menu"); @@ -46,20 +46,20 @@ elm_main(int argc, char **argv) menu = elm_menu_add(win); elm_menu_item_add(menu, NULL, NULL, "first item", NULL, NULL); - item = elm_menu_item_add(menu, NULL, "mail-reply-all", "second item", NULL, NULL); + menu_it = elm_menu_item_add(menu, NULL, "mail-reply-all", "second item", NULL, NULL); - elm_menu_item_add(menu, item, "object-rotate-left", "menu 1", NULL, NULL); + elm_menu_item_add(menu, menu_it, "object-rotate-left", "menu 1", NULL, NULL); button = elm_button_add(win); elm_object_text_set(button, "button - delete items"); - elm_menu_item_add_object(menu, item, button, NULL, NULL); + elm_menu_item_add_object(menu, menu_it, button, NULL, NULL); evas_object_smart_callback_add(button, "clicked", _del_it, menu); - elm_menu_item_separator_add(menu, item); - elm_menu_item_add(menu, item, NULL, "third item", NULL, NULL); - elm_menu_item_add(menu, item, NULL, "fourth item", NULL, NULL); - elm_menu_item_add(menu, item, "window-new", "sub menu", NULL, NULL); + elm_menu_item_separator_add(menu, menu_it); + elm_menu_item_add(menu, menu_it, NULL, "third item", NULL, NULL); + elm_menu_item_add(menu, menu_it, NULL, "fourth item", NULL, NULL); + elm_menu_item_add(menu, menu_it, "window-new", "sub menu", NULL, NULL); - item = elm_menu_item_add(menu, NULL, NULL, "third item", NULL, NULL); - elm_menu_item_disabled_set(item, EINA_TRUE); + menu_it = elm_menu_item_add(menu, NULL, NULL, "third item", NULL, NULL); + elm_menu_item_disabled_set(menu_it, EINA_TRUE); evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_DOWN, _show, menu); evas_object_show(menu); diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index 9f2f467..d46106a 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -15978,7 +15978,7 @@ extern "C" { * @see @ref tutorial_menu * @{ */ - typedef struct _Elm_Menu_Item Elm_Menu_Item; /**< Item of Elm_Menu. Sub-type of Elm_Widget_Item */ + /** * @brief Add a new menu to the parent * @@ -16038,7 +16038,7 @@ extern "C" { * * @warning Don't manipulate this object! */ - EAPI Evas_Object *elm_menu_item_object_get(const Elm_Menu_Item *it) EINA_ARG_NONNULL(1); + EAPI Evas_Object *elm_menu_item_object_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * @brief Add an item at the end of the given menu widget * @@ -16050,7 +16050,7 @@ extern "C" { * @param data Data sent by the callback. * @return Returns the new item. */ - EAPI Elm_Menu_Item *elm_menu_item_add(Evas_Object *obj, Elm_Menu_Item *parent, const char *icon, const char *label, Evas_Smart_Cb func, const void *data) EINA_ARG_NONNULL(1); + EAPI Elm_Object_Item *elm_menu_item_add(Evas_Object *obj, Elm_Object_Item *parent, const char *icon, const char *label, Evas_Smart_Cb func, const void *data) EINA_ARG_NONNULL(1); /** * @brief Add an object swallowed in an item at the end of the given menu * widget @@ -16064,57 +16064,57 @@ extern "C" { * * Add an evas object as an item to the menu. */ - EAPI Elm_Menu_Item *elm_menu_item_add_object(Evas_Object *obj, Elm_Menu_Item *parent, Evas_Object *subobj, Evas_Smart_Cb func, const void *data) EINA_ARG_NONNULL(1); + EAPI Elm_Object_Item *elm_menu_item_add_object(Evas_Object *obj, Elm_Object_Item *parent, Evas_Object *subobj, Evas_Smart_Cb func, const void *data) EINA_ARG_NONNULL(1); /** * @brief Set the label of a menu item * - * @param item The menu item object. + * @param it The menu item object. * @param label The label to set for @p item * * @warning Don't use this funcion on items created with * elm_menu_item_add_object() or elm_menu_item_separator_add(). */ - EAPI void elm_menu_item_label_set(Elm_Menu_Item *item, const char *label) EINA_ARG_NONNULL(1); + EAPI void elm_menu_item_label_set(Elm_Object_Item *it, const char *label) EINA_ARG_NONNULL(1); /** * @brief Get the label of a menu item * - * @param item The menu item object. + * @param it The menu item object. * @return The label of @p item */ - EAPI const char *elm_menu_item_label_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1); + EAPI const char *elm_menu_item_label_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * @brief Set the icon of a menu item to the standard icon with name @p icon * - * @param item The menu item object. + * @param it The menu item object. * @param icon The icon object to set for the content of @p item * * Once this icon is set, any previously set icon will be deleted. */ - EAPI void elm_menu_item_object_icon_name_set(Elm_Menu_Item *item, const char *icon) EINA_ARG_NONNULL(1, 2); + EAPI void elm_menu_item_object_icon_name_set(Elm_Object_Item *it, const char *icon) EINA_ARG_NONNULL(1, 2); /** * @brief Get the string representation from the icon of a menu item * - * @param item The menu item object. + * @param it The menu item object. * @return The string representation of @p item's icon or NULL * * @see elm_menu_item_object_icon_name_set() */ - EAPI const char *elm_menu_item_object_icon_name_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1); + EAPI const char *elm_menu_item_object_icon_name_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * @brief Set the content object of a menu item * - * @param item The menu item object + * @param it The menu item object * @param The content object or NULL * @return EINA_TRUE on success, else EINA_FALSE * * Use this function to change the object swallowed by a menu item, deleting * any previously swallowed object. */ - EAPI Eina_Bool elm_menu_item_object_content_set(Elm_Menu_Item *item, Evas_Object *obj) EINA_ARG_NONNULL(1); + EAPI Eina_Bool elm_menu_item_object_content_set(Elm_Object_Item *it, Evas_Object *obj) EINA_ARG_NONNULL(1); /** * @brief Get the content object of a menu item * - * @param item The menu item object + * @param it The menu item object * @return The content object or NULL * @note If @p item was added with elm_menu_item_add_object, this * function will return the object passed, else it will return the @@ -16122,39 +16122,39 @@ extern "C" { * * @see elm_menu_item_object_content_set() */ - EAPI Evas_Object *elm_menu_item_object_content_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1); + EAPI Evas_Object *elm_menu_item_object_content_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * @brief Set the selected state of @p item. * - * @param item The menu item object. + * @param it The menu item object. * @param selected The selected/unselected state of the item */ - EAPI void elm_menu_item_selected_set(Elm_Menu_Item *item, Eina_Bool selected) EINA_ARG_NONNULL(1); + EAPI void elm_menu_item_selected_set(Elm_Object_Item *it, Eina_Bool selected) EINA_ARG_NONNULL(1); /** * @brief Get the selected state of @p item. * - * @param item The menu item object. + * @param it The menu item object. * @return The selected/unselected state of the item * * @see elm_menu_item_selected_set() */ - EAPI Eina_Bool elm_menu_item_selected_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1); + EAPI Eina_Bool elm_menu_item_selected_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * @brief Set the disabled state of @p item. * - * @param item The menu item object. + * @param it The menu item object. * @param disabled The enabled/disabled state of the item */ - EAPI void elm_menu_item_disabled_set(Elm_Menu_Item *item, Eina_Bool disabled) EINA_ARG_NONNULL(1); + EAPI void elm_menu_item_disabled_set(Elm_Object_Item *it, Eina_Bool disabled) EINA_ARG_NONNULL(1); /** * @brief Get the disabled state of @p item. * - * @param item The menu item object. + * @param it The menu item object. * @return The enabled/disabled state of the item * * @see elm_menu_item_disabled_set() */ - EAPI Eina_Bool elm_menu_item_disabled_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1); + EAPI Eina_Bool elm_menu_item_disabled_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * @brief Add a separator item to menu @p obj under @p parent. * @@ -16164,63 +16164,64 @@ extern "C" { * * This is item is a @ref Separator. */ - EAPI Elm_Menu_Item *elm_menu_item_separator_add(Evas_Object *obj, Elm_Menu_Item *parent) EINA_ARG_NONNULL(1); + EAPI Elm_Object_Item *elm_menu_item_separator_add(Evas_Object *obj, Elm_Object_Item *parent) EINA_ARG_NONNULL(1); /** * @brief Returns whether @p item is a separator. * - * @param item The item to check + * @param it The item to check * @return If true, @p item is a separator * * @see elm_menu_item_separator_add() */ - EAPI Eina_Bool elm_menu_item_is_separator(Elm_Menu_Item *item) EINA_ARG_NONNULL(1); + EAPI Eina_Bool elm_menu_item_is_separator(Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * @brief Deletes an item from the menu. * - * @param item The item to delete. + * @param it The item to delete. * * @see elm_menu_item_add() */ - EAPI void elm_menu_item_del(Elm_Menu_Item *item) EINA_ARG_NONNULL(1); + EAPI void elm_menu_item_del(Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * @brief Set the function called when a menu item is deleted. * - * @param item The item to set the callback on + * @param it The item to set the callback on * @param func The function called * * @see elm_menu_item_add() * @see elm_menu_item_del() */ - EAPI void elm_menu_item_del_cb_set(Elm_Menu_Item *it, Evas_Smart_Cb func) EINA_ARG_NONNULL(1); + EAPI void elm_menu_item_del_cb_set(Elm_Object_Item *it, Evas_Smart_Cb func) EINA_ARG_NONNULL(1); /** * @brief Returns the data associated with menu item @p item. * - * @param item The item + * @param it The item * @return The data associated with @p item or NULL if none was set. * * This is the data set with elm_menu_add() or elm_menu_item_data_set(). */ - EAPI void *elm_menu_item_data_get(const Elm_Menu_Item *it) EINA_ARG_NONNULL(1); + EAPI void *elm_menu_item_data_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * @brief Sets the data to be associated with menu item @p item. * - * @param item The item + * @param it The item * @param data The data to be associated with @p item */ - EAPI void elm_menu_item_data_set(Elm_Menu_Item *item, const void *data) EINA_ARG_NONNULL(1); + EAPI void elm_menu_item_data_set(Elm_Object_Item *it, const void *data) EINA_ARG_NONNULL(1); + /** * @brief Returns a list of @p item's subitems. * - * @param item The item + * @param it The item * @return An Eina_List* of @p item's subitems * * @see elm_menu_add() */ - EAPI const Eina_List *elm_menu_item_subitems_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1); + EAPI const Eina_List *elm_menu_item_subitems_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * @brief Get the position of a menu item * - * @param item The menu item + * @param it The menu item * @return The item's index * * This function returns the index position of a menu item in a menu. @@ -16228,16 +16229,16 @@ extern "C" { * * @note Index values begin with 0 */ - EAPI unsigned int elm_menu_item_index_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1) EINA_PURE; + EAPI unsigned int elm_menu_item_index_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1) EINA_PURE; /** * @brief @brief Return a menu item's owner menu * - * @param item The menu item + * @param it The menu item * @return The menu object owning @p item, or NULL on failure * * Use this function to get the menu object owning an item. */ - EAPI Evas_Object *elm_menu_item_menu_get(const Elm_Menu_Item *item) EINA_ARG_NONNULL(1) EINA_PURE; + EAPI Evas_Object *elm_menu_item_menu_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1) EINA_PURE; /** * @brief Get the selected item in the menu * @@ -16247,35 +16248,35 @@ extern "C" { * @see elm_menu_item_selected_get() * @see elm_menu_item_selected_set() */ - EAPI Elm_Menu_Item *elm_menu_selected_item_get(const Evas_Object * obj) EINA_ARG_NONNULL(1); + EAPI Elm_Object_Item *elm_menu_selected_item_get(const Evas_Object * obj) EINA_ARG_NONNULL(1); /** * @brief Get the last item in the menu * * @param obj The menu object * @return The last item, or NULL if none */ - EAPI Elm_Menu_Item *elm_menu_last_item_get(const Evas_Object * obj) EINA_ARG_NONNULL(1); + EAPI Elm_Object_Item *elm_menu_last_item_get(const Evas_Object * obj) EINA_ARG_NONNULL(1); /** * @brief Get the first item in the menu * * @param obj The menu object * @return The first item, or NULL if none */ - EAPI Elm_Menu_Item *elm_menu_first_item_get(const Evas_Object * obj) EINA_ARG_NONNULL(1); + EAPI Elm_Object_Item *elm_menu_first_item_get(const Evas_Object * obj) EINA_ARG_NONNULL(1); /** * @brief Get the next item in the menu. * - * @param item The menu item object. + * @param it The menu item object. * @return The item after it, or NULL if none */ - EAPI Elm_Menu_Item *elm_menu_item_next_get(const Elm_Menu_Item *it) EINA_ARG_NONNULL(1); + EAPI Elm_Object_Item *elm_menu_item_next_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * @brief Get the previous item in the menu. * - * @param item The menu item object. + * @param it The menu item object. * @return The item before it, or NULL if none */ - EAPI Elm_Menu_Item *elm_menu_item_prev_get(const Elm_Menu_Item *it) EINA_ARG_NONNULL(1); + EAPI Elm_Object_Item *elm_menu_item_prev_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * @} */ diff --git a/src/lib/elm_menu.c b/src/lib/elm_menu.c index 33ee737..a1e25c9 100644 --- a/src/lib/elm_menu.c +++ b/src/lib/elm_menu.c @@ -2,6 +2,7 @@ #include "elm_priv.h" typedef struct _Widget_Data Widget_Data; +typedef struct _Elm_Menu_Item Elm_Menu_Item; struct _Elm_Menu_Item { @@ -116,15 +117,19 @@ _theme_hook(Evas_Object *obj) _elm_theme_object_set (obj, VIEW(item), "menu", "item_with_submenu", elm_widget_style_get(obj)); - elm_menu_item_label_set(item, item->label); - elm_menu_item_object_icon_name_set(item, item->icon_str); + elm_menu_item_label_set((Elm_Object_Item *) item, + item->label); + elm_menu_item_object_icon_name_set((Elm_Object_Item *) item, + item->icon_str); } else { _elm_theme_object_set(obj, VIEW(item), "menu", "item", elm_widget_style_get(obj)); - elm_menu_item_label_set(item, item->label); - elm_menu_item_object_icon_name_set(item, item->icon_str); + elm_menu_item_label_set((Elm_Object_Item *) item, + item->label); + elm_menu_item_object_icon_name_set((Elm_Object_Item *) item, + item->icon_str); } if (item->disabled) edje_object_signal_emit @@ -328,7 +333,8 @@ _menu_item_activate(void *data, Evas_Object *obj __UNUSED__, const char *emissio { EINA_LIST_FOREACH(item->parent->submenu.items, l, item2) { - if (item2 != item) elm_menu_item_selected_set(item2, 0); + if (item2 != item) + elm_menu_item_selected_set((Elm_Object_Item *) item2, 0); } } else @@ -336,7 +342,8 @@ _menu_item_activate(void *data, Evas_Object *obj __UNUSED__, const char *emissio Widget_Data *wd = elm_widget_data_get(WIDGET(item)); EINA_LIST_FOREACH(wd->items, l, item2) { - if (item2 != item) elm_menu_item_selected_set(item2, 0); + if (item2 != item) + elm_menu_item_selected_set((Elm_Object_Item *) item2, 0); } } } @@ -419,9 +426,11 @@ _item_submenu_obj_create(Elm_Menu_Item *item) edje_object_mirrored_set(VIEW(item), elm_widget_mirrored_get(WIDGET(item))); _elm_theme_object_set(WIDGET(item), VIEW(item), "menu", "item_with_submenu", elm_widget_style_get(WIDGET(item))); - elm_menu_item_label_set(item, item->label); - if (item->icon_str) elm_menu_item_object_icon_name_set(item, item->icon_str); - + elm_menu_item_label_set((Elm_Object_Item *) item, + item->label); + if (item->icon_str) + elm_menu_item_object_icon_name_set((Elm_Object_Item *) item, + item->icon_str); edje_object_signal_callback_add(VIEW(item), "elm,action,open", "", _submenu_open, item); evas_object_event_callback_add(VIEW(item), EVAS_CALLBACK_MOVE, _item_move_resize, item); @@ -545,30 +554,36 @@ elm_menu_close(Evas_Object *obj) } EAPI Evas_Object * -elm_menu_item_object_get(const Elm_Menu_Item *item) +elm_menu_item_object_get(const Elm_Object_Item *it) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL); - return VIEW(item); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); + return VIEW(((Elm_Menu_Item *) it)); } static void _item_clone(Evas_Object *obj, Elm_Menu_Item *parent, Elm_Menu_Item *item) { - Elm_Menu_Item *new_item, *subitem; + Elm_Object_Item *new_item; + Elm_Menu_Item *subitem; Eina_List *iter; if (item->separator) - new_item = elm_menu_item_separator_add(obj, parent); + new_item = elm_menu_item_separator_add(obj, (Elm_Object_Item *) parent); else - new_item = elm_menu_item_add(obj, parent, item->icon_str, item->label, item->func, item->base.data); + new_item = elm_menu_item_add(obj, + (Elm_Object_Item *) parent, + item->icon_str, + item->label, + item->func, + item->base.data); elm_menu_item_disabled_set(new_item, item->disabled); EINA_LIST_FOREACH(item->submenu.items, iter, subitem) - _item_clone(obj, new_item, subitem); + _item_clone(obj, (Elm_Menu_Item *) new_item, subitem); } void -elm_menu_clone(Evas_Object *from_menu, Evas_Object *to_menu, Elm_Menu_Item *parent) +elm_menu_clone(Evas_Object *from_menu, Evas_Object *to_menu, Elm_Object_Item *parent) { ELM_CHECK_WIDTYPE(from_menu, widtype); ELM_CHECK_WIDTYPE(to_menu, widtype); @@ -578,7 +593,7 @@ elm_menu_clone(Evas_Object *from_menu, Evas_Object *to_menu, Elm_Menu_Item *pare if (!from_wd) return; EINA_LIST_FOREACH(from_wd->items, iter, item) - _item_clone(to_menu, parent, item); + _item_clone(to_menu, (Elm_Menu_Item *) parent, item); } static void @@ -601,8 +616,8 @@ _elm_menu_item_add_helper(Evas_Object *obj, Elm_Menu_Item *parent, Elm_Menu_Item _sizing_eval(obj); } -EAPI Elm_Menu_Item * -elm_menu_item_add(Evas_Object *obj, Elm_Menu_Item *parent, const char *icon, const char *label, Evas_Smart_Cb func, const void *data) +EAPI Elm_Object_Item * +elm_menu_item_add(Evas_Object *obj, Elm_Object_Item *parent, const char *icon, const char *label, Evas_Smart_Cb func, const void *data) { Elm_Menu_Item *subitem; ELM_CHECK_WIDTYPE(obj, widtype) NULL; @@ -620,23 +635,24 @@ elm_menu_item_add(Evas_Object *obj, Elm_Menu_Item *parent, const char *icon, con } subitem->base.data = data; subitem->func = func; - subitem->parent = parent; + subitem->parent = (Elm_Menu_Item *) parent; subitem->content = icon_obj; _item_obj_create(subitem); - elm_menu_item_label_set(subitem, label); + elm_menu_item_label_set((Elm_Object_Item *) subitem, label); elm_widget_sub_object_add(WIDGET(subitem), subitem->content); edje_object_part_swallow(VIEW(subitem), "elm.swallow.content", subitem->content); - if (icon) elm_menu_item_object_icon_name_set(subitem, icon); + if (icon) + elm_menu_item_object_icon_name_set((Elm_Object_Item *) subitem, icon); - _elm_menu_item_add_helper(obj, parent, subitem, wd); + _elm_menu_item_add_helper(obj, (Elm_Menu_Item *) parent, subitem, wd); - return subitem; + return (Elm_Object_Item *) subitem; } -EAPI Elm_Menu_Item * -elm_menu_item_add_object(Evas_Object *obj, Elm_Menu_Item *parent, Evas_Object *subobj, Evas_Smart_Cb func, const void *data) +EAPI Elm_Object_Item * +elm_menu_item_add_object(Evas_Object *obj, Elm_Object_Item *parent, Evas_Object *subobj, Evas_Smart_Cb func, const void *data) { Elm_Menu_Item *subitem; ELM_CHECK_WIDTYPE(obj, widtype) NULL; @@ -648,7 +664,7 @@ elm_menu_item_add_object(Evas_Object *obj, Elm_Menu_Item *parent, Evas_Object *s subitem->base.data = data; subitem->func = func; - subitem->parent = parent; + subitem->parent = (Elm_Menu_Item *) parent; subitem->object_item = EINA_TRUE; subitem->content = subobj; @@ -658,22 +674,24 @@ elm_menu_item_add_object(Evas_Object *obj, Elm_Menu_Item *parent, Evas_Object *s edje_object_part_swallow(VIEW(subitem), "elm.swallow.content", subobj); _sizing_eval(WIDGET(subitem)); - _elm_menu_item_add_helper(obj, parent, subitem, wd); + _elm_menu_item_add_helper(obj, (Elm_Menu_Item *) parent, subitem, wd); - return subitem; + return (Elm_Object_Item *) subitem; } EAPI unsigned int -elm_menu_item_index_get(const Elm_Menu_Item *item) +elm_menu_item_index_get(const Elm_Object_Item *it) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, 0); - return item->idx; + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, 0); + return ((Elm_Menu_Item *) it)->idx; } EAPI void -elm_menu_item_label_set(Elm_Menu_Item *item, const char *label) +elm_menu_item_label_set(Elm_Object_Item *it, const char *label) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); + Elm_Menu_Item *item = (Elm_Menu_Item *) it; + eina_stringshare_replace(&item->label, label); if (label) @@ -687,18 +705,20 @@ elm_menu_item_label_set(Elm_Menu_Item *item, const char *label) } EAPI const char * -elm_menu_item_label_get(const Elm_Menu_Item *item) +elm_menu_item_label_get(const Elm_Object_Item *it) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL); - return item->label; + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); + return ((Elm_Menu_Item *) it)->label; } EAPI void -elm_menu_item_object_icon_name_set(Elm_Menu_Item *item, const char *icon) +elm_menu_item_object_icon_name_set(Elm_Object_Item *it, const char *icon) { - char icon_tmp[512]; - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); EINA_SAFETY_ON_NULL_RETURN(icon); + char icon_tmp[512]; + Elm_Menu_Item *item = (Elm_Menu_Item *) it; + if (!*icon) return; if ((item->icon_str) && (!strcmp(item->icon_str, icon))) return; if ((snprintf(icon_tmp, sizeof(icon_tmp), "menu/%s", icon) > 0) && @@ -715,9 +735,11 @@ elm_menu_item_object_icon_name_set(Elm_Menu_Item *item, const char *icon) } EAPI void -elm_menu_item_disabled_set(Elm_Menu_Item *item, Eina_Bool disabled) +elm_menu_item_disabled_set(Elm_Object_Item *it, Eina_Bool disabled) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); + Elm_Menu_Item *item = (Elm_Menu_Item *) it; + if (disabled == item->disabled) return; item->disabled = !!disabled; if (disabled) @@ -731,23 +753,24 @@ elm_menu_item_disabled_set(Elm_Menu_Item *item, Eina_Bool disabled) } EAPI Eina_Bool -elm_menu_item_disabled_get(const Elm_Menu_Item *item) +elm_menu_item_disabled_get(const Elm_Object_Item *it) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE); - return item->disabled; + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE); + return ((Elm_Menu_Item *) it)->disabled; } -EAPI Elm_Menu_Item * -elm_menu_item_separator_add(Evas_Object *obj, Elm_Menu_Item *parent) +EAPI Elm_Object_Item * +elm_menu_item_separator_add(Evas_Object *obj, Elm_Object_Item *parent) { - Elm_Menu_Item *subitem; ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Elm_Menu_Item *subitem; Widget_Data *wd = elm_widget_data_get(obj); + Elm_Menu_Item *p_item = (Elm_Menu_Item *) parent; if (!wd) return NULL; /* don't add a separator as the first item */ if (!wd->items) return NULL; /* don't allow adding more than one separator in a row */ - if (parent) subitem = eina_list_last(parent->submenu.items)->data; + if (p_item) subitem = eina_list_last(p_item->submenu.items)->data; else subitem = eina_list_last(wd->items)->data; if (subitem->separator) return NULL; @@ -756,25 +779,28 @@ elm_menu_item_separator_add(Evas_Object *obj, Elm_Menu_Item *parent) WIDGET(subitem) = obj; subitem->separator = 1; _item_separator_obj_create(subitem); - if (!parent) + if (!p_item) { elm_box_pack_end(wd->bx, VIEW(subitem)); wd->items = eina_list_append(wd->items, subitem); } else { - if (!parent->submenu.bx) _item_submenu_obj_create(parent); - elm_box_pack_end(parent->submenu.bx, VIEW(subitem)); - parent->submenu.items = eina_list_append(parent->submenu.items, subitem); + if (!p_item->submenu.bx) _item_submenu_obj_create(p_item); + elm_box_pack_end(p_item->submenu.bx, VIEW(subitem)); + p_item->submenu.items = eina_list_append(p_item->submenu.items, + subitem); } _sizing_eval(obj); - return subitem; + return (Elm_Object_Item *) subitem; } EAPI Eina_Bool -elm_menu_item_object_content_set(Elm_Menu_Item *item, Evas_Object *obj) +elm_menu_item_object_content_set(Elm_Object_Item *it, Evas_Object *obj) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE); + Elm_Menu_Item *item = (Elm_Menu_Item *) it; + if (item->content) { elm_widget_sub_object_del(WIDGET(item), item->content); @@ -790,31 +816,32 @@ elm_menu_item_object_content_set(Elm_Menu_Item *item, Evas_Object *obj) } EAPI Evas_Object * -elm_menu_item_object_content_get(const Elm_Menu_Item *item) +elm_menu_item_object_content_get(const Elm_Object_Item *it) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL); - return item->content; + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); + return ((Elm_Menu_Item *) it)->content; } EAPI const char * -elm_menu_item_object_icon_name_get(const Elm_Menu_Item *item) +elm_menu_item_object_icon_name_get(const Elm_Object_Item *it) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL); - return item->icon_str; + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); + return ((Elm_Menu_Item *) it)->icon_str; } EAPI Eina_Bool -elm_menu_item_is_separator(Elm_Menu_Item *item) +elm_menu_item_is_separator(Elm_Object_Item *it) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE); - return item->separator; + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE); + return ((Elm_Menu_Item *) it)->separator; } EAPI void -elm_menu_item_del(Elm_Menu_Item *item) +elm_menu_item_del(Elm_Object_Item *it) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item); - Elm_Menu_Item *_item; + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); + Elm_Menu_Item *item = (Elm_Menu_Item *) it; + Elm_Object_Item *_item; elm_widget_item_pre_notify_del(item); @@ -836,31 +863,29 @@ elm_menu_item_del(Elm_Menu_Item *item) } EAPI void -elm_menu_item_del_cb_set(Elm_Menu_Item *item, Evas_Smart_Cb func) +elm_menu_item_del_cb_set(Elm_Object_Item *it, Evas_Smart_Cb func) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item); - elm_widget_item_del_cb_set(item, func); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); + elm_widget_item_del_cb_set(it, func); } EAPI void * -elm_menu_item_data_get(const Elm_Menu_Item *item) +elm_menu_item_data_get(const Elm_Object_Item *it) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL); - return elm_widget_item_data_get(item); + return elm_object_item_data_get(it); } EAPI void -elm_menu_item_data_set(Elm_Menu_Item *item, const void *data) +elm_menu_item_data_set(Elm_Object_Item *it, const void *data) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item); - elm_widget_item_data_set(item, data); + elm_object_item_data_set(it, (void *) data); } EAPI const Eina_List * -elm_menu_item_subitems_get(const Elm_Menu_Item *item) +elm_menu_item_subitems_get(const Elm_Object_Item *it) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL); - return item->submenu.items; + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); + return ((Elm_Menu_Item *) it)->submenu.items; } EAPI const Eina_List * @@ -872,9 +897,11 @@ elm_menu_items_get(const Evas_Object * obj) } EAPI void -elm_menu_item_selected_set(Elm_Menu_Item *item, Eina_Bool selected) +elm_menu_item_selected_set(Elm_Object_Item *it, Eina_Bool selected) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); + Elm_Menu_Item *item = (Elm_Menu_Item *) it; + if (selected == item->selected) return; item->selected = selected; if (selected) @@ -891,28 +918,31 @@ elm_menu_item_selected_set(Elm_Menu_Item *item, Eina_Bool selected) } EAPI Eina_Bool -elm_menu_item_selected_get(const Elm_Menu_Item *item) +elm_menu_item_selected_get(const Elm_Object_Item *it) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE); - return item->selected; + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE); + return ((Elm_Menu_Item *) it)->selected; } -EAPI Elm_Menu_Item * -elm_menu_item_prev_get(const Elm_Menu_Item *it) +EAPI Elm_Object_Item * +elm_menu_item_prev_get(const Elm_Object_Item *it) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL); - if (it->parent) + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); + Elm_Menu_Item *item = (Elm_Menu_Item *) it; + + if (item->parent) { - Eina_List *l = eina_list_data_find_list(it->parent->submenu.items, it); + Eina_List *l = eina_list_data_find_list(item->parent->submenu.items, + item); l = eina_list_prev(l); if (!l) return NULL; return l->data; } else { - Widget_Data *wd = elm_widget_data_get(WIDGET(it)); + Widget_Data *wd = elm_widget_data_get(WIDGET(item)); if (!wd || !wd->items) return NULL; - Eina_List *l = eina_list_data_find_list(wd->items, it); + Eina_List *l = eina_list_data_find_list(wd->items, item); l = eina_list_prev(l); if (!l) return NULL; return l->data; @@ -920,22 +950,25 @@ elm_menu_item_prev_get(const Elm_Menu_Item *it) return NULL; } -EAPI Elm_Menu_Item * -elm_menu_item_next_get(const Elm_Menu_Item *it) +EAPI Elm_Object_Item * +elm_menu_item_next_get(const Elm_Object_Item *it) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL); - if (it->parent) + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); + Elm_Menu_Item *item = (Elm_Menu_Item *) it; + + if (item->parent) { - Eina_List *l = eina_list_data_find_list(it->parent->submenu.items, it); + Eina_List *l = eina_list_data_find_list(item->parent->submenu.items, + item); l = eina_list_next(l); if (!l) return NULL; return l->data; } else { - Widget_Data *wd = elm_widget_data_get(WIDGET(it)); + Widget_Data *wd = elm_widget_data_get(WIDGET(item)); if (!wd || !wd->items) return NULL; - Eina_List *l = eina_list_data_find_list(wd->items, it); + Eina_List *l = eina_list_data_find_list(wd->items, item); l = eina_list_next(l); if (!l) return NULL; return l->data; @@ -944,13 +977,12 @@ elm_menu_item_next_get(const Elm_Menu_Item *it) } EAPI Evas_Object * -elm_menu_item_menu_get(const Elm_Menu_Item *item) +elm_menu_item_menu_get(const Elm_Object_Item *it) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL); - return WIDGET(item); + return elm_object_item_object_get(it); } -EAPI Elm_Menu_Item * +EAPI Elm_Object_Item * elm_menu_first_item_get(const Evas_Object * obj) { ELM_CHECK_WIDTYPE(obj, widtype) NULL; @@ -960,7 +992,7 @@ elm_menu_first_item_get(const Evas_Object * obj) return NULL; } -EAPI Elm_Menu_Item * +EAPI Elm_Object_Item * elm_menu_last_item_get(const Evas_Object * obj) { ELM_CHECK_WIDTYPE(obj, widtype) NULL; @@ -971,7 +1003,7 @@ elm_menu_last_item_get(const Evas_Object * obj) return NULL; } -EAPI Elm_Menu_Item * +EAPI Elm_Object_Item * elm_menu_selected_item_get(const Evas_Object * obj) { ELM_CHECK_WIDTYPE(obj, widtype) NULL; @@ -981,7 +1013,7 @@ elm_menu_selected_item_get(const Evas_Object * obj) Elm_Menu_Item *item; EINA_LIST_FOREACH(wd->items, l, item) { - if (item->selected) return item; + if (item->selected) return ((Elm_Object_Item *) item); } return NULL; } diff --git a/src/lib/elm_priv.h b/src/lib/elm_priv.h index 4372267..65d2ec2 100644 --- a/src/lib/elm_priv.h +++ b/src/lib/elm_priv.h @@ -246,7 +246,7 @@ void elm_object_sub_tooltip_content_cb_set(Evas_Object *eventare void elm_cursor_theme(Elm_Cursor *cur); void elm_object_sub_cursor_set(Evas_Object *eventarea, Evas_Object *owner, const char *cursor); -void elm_menu_clone(Evas_Object *from_menu, Evas_Object *to_menu, Elm_Menu_Item *parent); +void elm_menu_clone(Evas_Object *from_menu, Evas_Object *to_menu, Elm_Object_Item *parent); Eina_Bool _elm_dangerous_call_check(const char *call); diff --git a/src/lib/elm_toolbar.c b/src/lib/elm_toolbar.c index 1985531..2975f2b 100644 --- a/src/lib/elm_toolbar.c +++ b/src/lib/elm_toolbar.c @@ -533,11 +533,13 @@ _resize_job(void *data) elm_menu_item_separator_add(menu, NULL); else { - Elm_Menu_Item *item; - item = elm_menu_item_add(menu, NULL, it->icon_str, it->label, - _elm_toolbar_item_menu_cb, it); - elm_menu_item_disabled_set(item, it->disabled); - if (it->o_menu) elm_menu_clone(it->o_menu, menu, item); + Elm_Object_Item *menu_it; + menu_it = elm_menu_item_add(menu, NULL, + it->icon_str, it->label, + _elm_toolbar_item_menu_cb, it); + elm_menu_item_disabled_set(menu_it, it->disabled); + if (it->o_menu) + elm_menu_clone(it->o_menu, menu, menu_it); } evas_object_hide(VIEW(it)); } -- 2.7.4