From 58fa2271b05707da5c4b665026b9dac8ba51d722 Mon Sep 17 00:00:00 2001 From: hermet Date: Wed, 30 Nov 2011 05:10:23 +0000 Subject: [PATCH] elementary/toolbar - Elm_Toolbar_Item -> Elm_Object_Item tweet: API Changes. This change may cause build break. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@65708 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/bin/config.c | 16 +- src/bin/test_cursor.c | 16 +- src/bin/test_panel.c | 12 +- src/bin/test_toolbar.c | 168 ++--- src/bin/test_tooltip.c | 12 +- src/examples/toolbar_example_01.c | 6 +- src/examples/toolbar_example_02.c | 18 +- src/examples/toolbar_example_03.c | 16 +- src/examples/web_example.c | 2 +- src/lib/Elementary.h.in | 233 +++---- src/lib/elm_toolbar.c | 1213 +++++++++++++++++++------------------ 11 files changed, 843 insertions(+), 869 deletions(-) diff --git a/src/bin/config.c b/src/bin/config.c index d07f940..eff412b 100644 --- a/src/bin/config.c +++ b/src/bin/config.c @@ -2965,7 +2965,7 @@ _status_config_full(Evas_Object *win, Evas_Object *bx0) { Evas_Object *tb, *pager; - Elm_Toolbar_Item *sizing, *it; + Elm_Object_Item *tb_sizing, *tb_it; tb = elm_toolbar_add(win); elm_toolbar_menu_parent_set(tb, win); @@ -2973,20 +2973,20 @@ _status_config_full(Evas_Object *win, evas_object_size_hint_weight_set(tb, 1.0, 0.0); evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL); - sizing = elm_toolbar_item_append(tb, "zoom-fit-best", "Sizing", + tb_sizing = elm_toolbar_item_append(tb, "zoom-fit-best", "Sizing", _cf_sizing, win); - elm_toolbar_item_priority_set(sizing, 100); + elm_toolbar_item_priority_set(tb_sizing, 100); - it = elm_toolbar_item_append(tb, "preferences-desktop-theme", "Theme", + tb_it = elm_toolbar_item_append(tb, "preferences-desktop-theme", "Theme", _cf_themes, win); - elm_toolbar_item_priority_set(it, 90); + elm_toolbar_item_priority_set(tb_it, 90); elm_toolbar_item_append(tb, "preferences-desktop-font", "Fonts", _cf_fonts, win); - it = elm_toolbar_item_append(tb, "system-users", "Profiles", + tb_it = elm_toolbar_item_append(tb, "system-users", "Profiles", _cf_profiles, win); - elm_toolbar_item_priority_set(it, 90); + elm_toolbar_item_priority_set(tb_it, 90); elm_toolbar_item_append(tb, "system-run", "Scrolling", _cf_scrolling, win); elm_toolbar_item_append(tb, "video-display", "Rendering", @@ -3011,7 +3011,7 @@ _status_config_full(Evas_Object *win, // FIXME uncomment after flip style fix, please //elm_object_style_set(pager, "flip"); - elm_toolbar_item_selected_set(sizing, EINA_TRUE); + elm_toolbar_item_selected_set(tb_sizing, EINA_TRUE); elm_box_pack_end(bx0, pager); evas_object_show(pager); } diff --git a/src/bin/test_cursor.c b/src/bin/test_cursor.c index 0e0dc7f..e35628f 100644 --- a/src/bin/test_cursor.c +++ b/src/bin/test_cursor.c @@ -165,7 +165,7 @@ test_cursor2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_inf { Evas_Object *win, *bg, *bx, *o, *grid, *gl; Elm_Genlist_Item *it1, *it2, *it3; - Elm_Toolbar_Item *tit; + Elm_Object_Item *tb_it; Elm_List_Item *lit; char buf[PATH_MAX]; static Testitem ti[144]; @@ -201,13 +201,13 @@ test_cursor2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_inf elm_toolbar_homogeneous_set(o, 0); evas_object_size_hint_weight_set(o, 0.0, 0.0); evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0); - tit = elm_toolbar_item_append(o, NULL, "Bogosity", NULL, NULL); - elm_toolbar_item_cursor_set(tit, ELM_CURSOR_BOGOSITY); - tit = elm_toolbar_item_append(o, NULL, "Unset", NULL, NULL); - elm_toolbar_item_cursor_set(tit, ELM_CURSOR_BOGOSITY); - elm_toolbar_item_cursor_unset(tit); - tit = elm_toolbar_item_append(o, NULL, "Xterm", NULL, NULL); - elm_toolbar_item_cursor_set(tit, ELM_CURSOR_XTERM); + tb_it = elm_toolbar_item_append(o, NULL, "Bogosity", NULL, NULL); + elm_toolbar_item_cursor_set(tb_it, ELM_CURSOR_BOGOSITY); + tb_it = elm_toolbar_item_append(o, NULL, "Unset", NULL, NULL); + elm_toolbar_item_cursor_set(tb_it, ELM_CURSOR_BOGOSITY); + elm_toolbar_item_cursor_unset(tb_it); + tb_it = elm_toolbar_item_append(o, NULL, "Xterm", NULL, NULL); + elm_toolbar_item_cursor_set(tb_it, ELM_CURSOR_XTERM); elm_box_pack_end(bx, o); evas_object_show(o); diff --git a/src/bin/test_panel.c b/src/bin/test_panel.c index ffe2a58..9e94886 100644 --- a/src/bin/test_panel.c +++ b/src/bin/test_panel.c @@ -18,7 +18,7 @@ static Eina_Bool _dir_has_subs(const char *path); static void _tstatus(void *data, Evas_Object *obj, void *event_info __UNUSED__) { - Elm_Toolbar_Item *sel; + Elm_Object_Item *tb_it; const char *status; if (elm_panel_hidden_get((Evas_Object*)data)) @@ -26,14 +26,14 @@ _tstatus(void *data, Evas_Object *obj, void *event_info __UNUSED__) else status = "shown"; printf("The top panel is currently %s\n", status); - sel = elm_toolbar_selected_item_get(obj); - elm_toolbar_item_selected_set(sel, EINA_FALSE); + tb_it = elm_toolbar_selected_item_get(obj); + elm_toolbar_item_selected_set(tb_it, EINA_FALSE); } static void _bstatus(void *data, Evas_Object *obj, void *event_info __UNUSED__) { - Elm_Toolbar_Item *sel; + Elm_Object_Item *tb_it; const char *status; if (elm_panel_hidden_get((Evas_Object*)data)) @@ -41,8 +41,8 @@ _bstatus(void *data, Evas_Object *obj, void *event_info __UNUSED__) else status = "shown"; printf("The bottom panel is currently %s\n", status); - sel = elm_toolbar_selected_item_get(obj); - elm_toolbar_item_selected_set(sel, EINA_FALSE); + tb_it = elm_toolbar_selected_item_get(obj); + elm_toolbar_item_selected_set(tb_it, EINA_FALSE); } static char * diff --git a/src/bin/test_toolbar.c b/src/bin/test_toolbar.c index 55c369a..e63e6f1 100644 --- a/src/bin/test_toolbar.c +++ b/src/bin/test_toolbar.c @@ -66,7 +66,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_Object_Item *tb_it; Elm_Object_Item *menu_it; char buf[PATH_MAX]; @@ -95,27 +95,27 @@ test_toolbar(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_inf ph3 = elm_photo_add(win); ph4 = elm_photo_add(win); - item = elm_toolbar_item_append(tb, "document-print", "Hello", tb_1, ph1); - elm_toolbar_item_disabled_set(item, EINA_TRUE); - elm_toolbar_item_priority_set(item, 100); + tb_it = elm_toolbar_item_append(tb, "document-print", "Hello", tb_1, ph1); + elm_toolbar_item_disabled_set(tb_it, EINA_TRUE); + elm_toolbar_item_priority_set(tb_it, 100); - item = elm_toolbar_item_append(tb, "folder-new", "World", tb_2, ph1); - elm_toolbar_item_priority_set(item, -100); + tb_it = elm_toolbar_item_append(tb, "folder-new", "World", tb_2, ph1); + elm_toolbar_item_priority_set(tb_it, -100); - item = elm_toolbar_item_append(tb, "object-rotate-right", "H", tb_3, ph4); - elm_toolbar_item_priority_set(item, 150); + tb_it = elm_toolbar_item_append(tb, "object-rotate-right", "H", tb_3, ph4); + elm_toolbar_item_priority_set(tb_it, 150); - item = elm_toolbar_item_append(tb, "mail-send", "Comes", tb_4, ph4); - elm_toolbar_item_priority_set(item, 0); + tb_it = elm_toolbar_item_append(tb, "mail-send", "Comes", tb_4, ph4); + elm_toolbar_item_priority_set(tb_it, 0); - item = elm_toolbar_item_append(tb, "clock", "Elementary", tb_5, ph4); - elm_toolbar_item_priority_set(item, -200); + tb_it = elm_toolbar_item_append(tb, "clock", "Elementary", tb_5, ph4); + elm_toolbar_item_priority_set(tb_it, -200); - item = elm_toolbar_item_append(tb, "refresh", "Menu", NULL, NULL); - elm_toolbar_item_menu_set(item, 1); - elm_toolbar_item_priority_set(item, -999999); + tb_it = elm_toolbar_item_append(tb, "refresh", "Menu", NULL, NULL); + elm_toolbar_item_menu_set(tb_it, 1); + elm_toolbar_item_priority_set(tb_it, -999999); elm_toolbar_menu_parent_set(tb, win); - menu = elm_toolbar_item_menu_get(item); + menu = elm_toolbar_item_menu_get(tb_it); elm_menu_item_add(menu, NULL, "edit-cut", "Shrink", tb_3, ph4); menu_it = elm_menu_item_add(menu, NULL, "edit-copy", "Mode", tb_4, ph4); @@ -176,7 +176,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_Object_Item *item; Elm_Object_Item *menu_it; char buf[PATH_MAX]; @@ -286,7 +286,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_Object_Item *tb_it; Elm_Object_Item *menu_it; char buf[PATH_MAX]; @@ -315,27 +315,27 @@ test_toolbar3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in ph3 = elm_photo_add(win); ph4 = elm_photo_add(win); - item = elm_toolbar_item_append(tb, "document-print", "Hello", tb_1, ph1); - elm_toolbar_item_disabled_set(item, EINA_TRUE); - elm_toolbar_item_priority_set(item, 0); + tb_it = elm_toolbar_item_append(tb, "document-print", "Hello", tb_1, ph1); + elm_toolbar_item_disabled_set(tb_it, EINA_TRUE); + elm_toolbar_item_priority_set(tb_it, 0); - item = elm_toolbar_item_append(tb, "folder-new", "World", tb_2, ph1); - elm_toolbar_item_priority_set(item, -200); + tb_it = elm_toolbar_item_append(tb, "folder-new", "World", tb_2, ph1); + elm_toolbar_item_priority_set(tb_it, -200); - item = elm_toolbar_item_append(tb, "object-rotate-right", "H", tb_3, ph4); - elm_toolbar_item_priority_set(item, 1); + tb_it = elm_toolbar_item_append(tb, "object-rotate-right", "H", tb_3, ph4); + elm_toolbar_item_priority_set(tb_it, 1); - item = elm_toolbar_item_append(tb, "mail-send", "Comes", tb_4, ph4); - elm_toolbar_item_priority_set(item, -10); + tb_it = elm_toolbar_item_append(tb, "mail-send", "Comes", tb_4, ph4); + elm_toolbar_item_priority_set(tb_it, -10); - item = elm_toolbar_item_append(tb, "clock", "Elementary", tb_5, ph4); - elm_toolbar_item_priority_set(item, 50); + tb_it = elm_toolbar_item_append(tb, "clock", "Elementary", tb_5, ph4); + elm_toolbar_item_priority_set(tb_it, 50); - item = elm_toolbar_item_append(tb, "refresh", "Menu", NULL, NULL); - elm_toolbar_item_menu_set(item, 1); - elm_toolbar_item_priority_set(item, 999999); + tb_it = elm_toolbar_item_append(tb, "refresh", "Menu", NULL, NULL); + elm_toolbar_item_menu_set(tb_it, 1); + elm_toolbar_item_priority_set(tb_it, 999999); elm_toolbar_menu_parent_set(tb, win); - menu = elm_toolbar_item_menu_get(item); + menu = elm_toolbar_item_menu_get(tb_it); elm_menu_item_add(menu, NULL, "edit-cut", "Shrink", tb_3, ph4); menu_it = elm_menu_item_add(menu, NULL, "edit-copy", "Mode", tb_4, ph4); @@ -396,7 +396,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_Object_Item *tb_it; Elm_Object_Item *menu_it; char buf[PATH_MAX]; @@ -425,27 +425,27 @@ test_toolbar4(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in ph3 = elm_photo_add(win); ph4 = elm_photo_add(win); - item = elm_toolbar_item_append(tb, "document-print", "Hello", tb_1, ph1); - elm_toolbar_item_disabled_set(item, EINA_TRUE); - elm_toolbar_item_priority_set(item, 100); + tb_it = elm_toolbar_item_append(tb, "document-print", "Hello", tb_1, ph1); + elm_toolbar_item_disabled_set(tb_it, EINA_TRUE); + elm_toolbar_item_priority_set(tb_it, 100); - item = elm_toolbar_item_append(tb, "folder-new", "World", tb_2, ph1); - elm_toolbar_item_priority_set(item, -100); + tb_it = elm_toolbar_item_append(tb, "folder-new", "World", tb_2, ph1); + elm_toolbar_item_priority_set(tb_it, -100); - item = elm_toolbar_item_append(tb, "object-rotate-right", "H", tb_3, ph4); - elm_toolbar_item_priority_set(item, 150); + tb_it = elm_toolbar_item_append(tb, "object-rotate-right", "H", tb_3, ph4); + elm_toolbar_item_priority_set(tb_it, 150); - item = elm_toolbar_item_append(tb, "mail-send", "Comes", tb_4, ph4); - elm_toolbar_item_priority_set(item, 0); + tb_it = elm_toolbar_item_append(tb, "mail-send", "Comes", tb_4, ph4); + elm_toolbar_item_priority_set(tb_it, 0); - item = elm_toolbar_item_append(tb, "clock", "Elementary", tb_5, ph4); - elm_toolbar_item_priority_set(item, -200); + tb_it = elm_toolbar_item_append(tb, "clock", "Elementary", tb_5, ph4); + elm_toolbar_item_priority_set(tb_it, -200); - item = elm_toolbar_item_append(tb, "refresh", "Menu", NULL, NULL); - elm_toolbar_item_menu_set(item, 1); - elm_toolbar_item_priority_set(item, -999999); + tb_it = elm_toolbar_item_append(tb, "refresh", "Menu", NULL, NULL); + elm_toolbar_item_menu_set(tb_it, 1); + elm_toolbar_item_priority_set(tb_it, -999999); elm_toolbar_menu_parent_set(tb, win); - menu = elm_toolbar_item_menu_get(item); + menu = elm_toolbar_item_menu_get(tb_it); elm_menu_item_add(menu, NULL, "edit-cut", "Shrink", tb_3, ph4); menu_it = elm_menu_item_add(menu, NULL, "edit-copy", "Mode", tb_4, ph4); @@ -506,7 +506,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_Object_Item *tb_it; Elm_Object_Item *menu_it; char buf[PATH_MAX]; @@ -536,31 +536,31 @@ test_toolbar5(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in ph3 = elm_photo_add(win); ph4 = elm_photo_add(win); - item = elm_toolbar_item_append(tb, "document-print", "Hello", tb_1, ph1); - elm_toolbar_item_disabled_set(item, EINA_TRUE); - elm_toolbar_item_priority_set(item, 100); + tb_it = elm_toolbar_item_append(tb, "document-print", "Hello", tb_1, ph1); + elm_toolbar_item_disabled_set(tb_it, EINA_TRUE); + elm_toolbar_item_priority_set(tb_it, 100); snprintf(buf, sizeof(buf), "%s/images/icon_04.pngj", elm_app_data_dir_get()); - item = elm_toolbar_item_append(tb, buf, "World", tb_2, ph1); - elm_toolbar_item_priority_set(item, -100); + tb_it = elm_toolbar_item_append(tb, buf, "World", tb_2, ph1); + elm_toolbar_item_priority_set(tb_it, -100); - item = elm_toolbar_item_append(tb, "object-rotate-right", "H", tb_3a, ph4); - elm_toolbar_item_state_add(item, "object-rotate-left", "H2", tb_3b, ph4); - elm_toolbar_item_priority_set(item, 150); + tb_it = elm_toolbar_item_append(tb, "object-rotate-right", "H", tb_3a, ph4); + elm_toolbar_item_state_add(tb_it, "object-rotate-left", "H2", tb_3b, ph4); + elm_toolbar_item_priority_set(tb_it, 150); - item = elm_toolbar_item_append(tb, "mail-send", "Comes", tb_4a, ph4); - elm_toolbar_item_state_add(item, "emptytrash", "Comes2", tb_4a, ph4); - elm_toolbar_item_state_add(item, "trashcan_full", "Comes3", tb_4a, ph4); - elm_toolbar_item_priority_set(item, 0); + tb_it = elm_toolbar_item_append(tb, "mail-send", "Comes", tb_4a, ph4); + elm_toolbar_item_state_add(tb_it, "emptytrash", "Comes2", tb_4a, ph4); + elm_toolbar_item_state_add(tb_it, "trashcan_full", "Comes3", tb_4a, ph4); + elm_toolbar_item_priority_set(tb_it, 0); - item = elm_toolbar_item_append(tb, "clock", "Elementary", tb_5, ph4); - elm_toolbar_item_priority_set(item, -200); + tb_it = elm_toolbar_item_append(tb, "clock", "Elementary", tb_5, ph4); + elm_toolbar_item_priority_set(tb_it, -200); - item = elm_toolbar_item_append(tb, "refresh", "Menu", NULL, NULL); - elm_toolbar_item_menu_set(item, 1); - elm_toolbar_item_priority_set(item, -999999); + tb_it = elm_toolbar_item_append(tb, "refresh", "Menu", NULL, NULL); + elm_toolbar_item_menu_set(tb_it, 1); + elm_toolbar_item_priority_set(tb_it, -999999); elm_toolbar_menu_parent_set(tb, win); - menu = elm_toolbar_item_menu_get(item); + menu = elm_toolbar_item_menu_get(tb_it); elm_menu_item_add(menu, NULL, "edit-cut", "Shrink", tb_3, ph4); menu_it = elm_menu_item_add(menu, NULL, "edit-copy", "Mode", tb_4, ph4); @@ -620,7 +620,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_Object_Item *tb_it; Elm_Object_Item *menu_it; char buf[PATH_MAX]; @@ -651,27 +651,27 @@ test_toolbar6(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in ph3 = elm_photo_add(win); ph4 = elm_photo_add(win); - item = elm_toolbar_item_append(tb, "document-print", "Hello", tb_1, ph1); - elm_toolbar_item_disabled_set(item, EINA_TRUE); - elm_toolbar_item_priority_set(item, 100); + tb_it = elm_toolbar_item_append(tb, "document-print", "Hello", tb_1, ph1); + elm_toolbar_item_disabled_set(tb_it, EINA_TRUE); + elm_toolbar_item_priority_set(tb_it, 100); - item = elm_toolbar_item_append(tb, "folder-new", "World", tb_2, ph1); - elm_toolbar_item_priority_set(item, -100); + tb_it = elm_toolbar_item_append(tb, "folder-new", "World", tb_2, ph1); + elm_toolbar_item_priority_set(tb_it, -100); - item = elm_toolbar_item_append(tb, "object-rotate-right", "H", tb_3, ph4); - elm_toolbar_item_priority_set(item, 150); + tb_it = elm_toolbar_item_append(tb, "object-rotate-right", "H", tb_3, ph4); + elm_toolbar_item_priority_set(tb_it, 150); - item = elm_toolbar_item_append(tb, "mail-send", "Comes", tb_4, ph4); - elm_toolbar_item_priority_set(item, 0); + tb_it = elm_toolbar_item_append(tb, "mail-send", "Comes", tb_4, ph4); + elm_toolbar_item_priority_set(tb_it, 0); - item = elm_toolbar_item_append(tb, "clock", "Elementary", tb_5, ph4); - elm_toolbar_item_priority_set(item, -200); + tb_it = elm_toolbar_item_append(tb, "clock", "Elementary", tb_5, ph4); + elm_toolbar_item_priority_set(tb_it, -200); - item = elm_toolbar_item_append(tb, "refresh", "Menu", NULL, NULL); - elm_toolbar_item_menu_set(item, 1); - elm_toolbar_item_priority_set(item, -999999); + tb_it = elm_toolbar_item_append(tb, "refresh", "Menu", NULL, NULL); + elm_toolbar_item_menu_set(tb_it, 1); + elm_toolbar_item_priority_set(tb_it, -999999); elm_toolbar_menu_parent_set(tb, win); - menu = elm_toolbar_item_menu_get(item); + menu = elm_toolbar_item_menu_get(tb_it); elm_menu_item_add(menu, NULL, "edit-cut", "Shrink", tb_3, ph4); menu_it = elm_menu_item_add(menu, NULL, "edit-copy", "Mode", tb_4, ph4); diff --git a/src/bin/test_tooltip.c b/src/bin/test_tooltip.c index 005b89f..65d2194 100644 --- a/src/bin/test_tooltip.c +++ b/src/bin/test_tooltip.c @@ -371,7 +371,7 @@ test_tooltip(void *data __UNUSED__, void *event_info __UNUSED__) { Evas_Object *win, *bg, *bx, *tb, *bt, *se, *lst; - Elm_Toolbar_Item *ti; + Elm_Object_Item *tb_it; Elm_List_Item *li; win = elm_win_add(NULL, "tooltip", ELM_WIN_BASIC); @@ -397,13 +397,13 @@ test_tooltip(void *data __UNUSED__, elm_box_pack_end(bx, tb); evas_object_show(tb); - ti = elm_toolbar_item_append(tb, NULL, "Open", NULL, NULL); - elm_toolbar_item_tooltip_text_set(ti, "Opens a file"); + tb_it = elm_toolbar_item_append(tb, NULL, "Open", NULL, NULL); + elm_toolbar_item_tooltip_text_set(tb_it, "Opens a file"); - ti = elm_toolbar_item_append(tb, NULL, "Icon", NULL, NULL); + tb_it = elm_toolbar_item_append(tb, NULL, "Icon", NULL, NULL); elm_toolbar_item_tooltip_content_cb_set - (ti, _tt_item_icon, (void *)456L, _tt_item_icon_del); - elm_toolbar_item_tooltip_style_set(ti, "transparent"); + (tb_it, _tt_item_icon, (void *)456L, _tt_item_icon_del); + elm_toolbar_item_tooltip_style_set(tb_it, "transparent"); bt = elm_button_add(win); elm_object_text_set(bt, "Simple text tooltip"); diff --git a/src/examples/toolbar_example_01.c b/src/examples/toolbar_example_01.c index 4d44447..c4d911b 100644 --- a/src/examples/toolbar_example_01.c +++ b/src/examples/toolbar_example_01.c @@ -50,7 +50,7 @@ EAPI_MAIN int elm_main(int argc __UNUSED__, char **argv __UNUSED__) { Evas_Object *win, *bg, *bx, *tb, *bt; - Elm_Toolbar_Item *item; + Elm_Object_Item *tb_it; win = elm_win_add(NULL, "toolbar", ELM_WIN_BASIC); elm_win_title_set(win, "Toolbar Example"); @@ -82,9 +82,9 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__) elm_toolbar_item_append(tb, "document-print", "Print", _item_1_pressed, bt); elm_toolbar_item_append(tb, "folder-new", "New Folder", _item_2_pressed, bt); - item = elm_toolbar_item_append(tb, "mail-send", "Create and send email", + tb_it = elm_toolbar_item_append(tb, "mail-send", "Create and send email", _item_3_pressed, bt); - elm_toolbar_item_disabled_set(item, EINA_TRUE); + elm_toolbar_item_disabled_set(tb_it, EINA_TRUE); elm_toolbar_homogeneous_set(tb, EINA_FALSE); diff --git a/src/examples/toolbar_example_02.c b/src/examples/toolbar_example_02.c index fafdb42..e8dd4b9 100644 --- a/src/examples/toolbar_example_02.c +++ b/src/examples/toolbar_example_02.c @@ -27,16 +27,16 @@ _on_done(void *data __UNUSED__, static void _item_pressed(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - Elm_Toolbar_Item *item = event_info; - elm_toolbar_item_state_set(item, elm_toolbar_item_state_next(item)); - elm_toolbar_item_selected_set(item, EINA_FALSE); + Elm_Object_Item *tb_it = event_info; + elm_toolbar_item_state_set(tb_it, elm_toolbar_item_state_next(tb_it)); + elm_toolbar_item_selected_set(tb_it, EINA_FALSE); } EAPI_MAIN int elm_main(int argc __UNUSED__, char **argv __UNUSED__) { Evas_Object *win, *bg, *bx, *tb, *bt; - Elm_Toolbar_Item *item; + Elm_Object_Item *tb_it; win = elm_win_add(NULL, "toolbar", ELM_WIN_BASIC); elm_win_title_set(win, "Toolbar Example"); @@ -70,14 +70,14 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__) elm_toolbar_item_append(tb, "clock", "Clock", NULL, NULL); elm_toolbar_item_append(tb, "refresh", "Update", NULL, NULL); - item = elm_toolbar_item_append(tb, "mail-send", "Send Mail", - _item_pressed, NULL); - elm_toolbar_item_state_add(item, "emptytrash", "Empty Trash", + tb_it = elm_toolbar_item_append(tb, "mail-send", "Send Mail", + _item_pressed, NULL); + elm_toolbar_item_state_add(tb_it, "emptytrash", "Empty Trash", _item_pressed, NULL); - elm_toolbar_item_state_add(item, "trashcan_full", "Full Trash", + elm_toolbar_item_state_add(tb_it, "trashcan_full", "Full Trash", _item_pressed, NULL); - elm_toolbar_item_priority_set(item, 10); + elm_toolbar_item_priority_set(tb_it, 10); elm_box_pack_end(bx, tb); elm_box_pack_end(bx, bt); diff --git a/src/examples/toolbar_example_03.c b/src/examples/toolbar_example_03.c index e32ef00..471df22 100644 --- a/src/examples/toolbar_example_03.c +++ b/src/examples/toolbar_example_03.c @@ -27,16 +27,16 @@ _on_done(void *data __UNUSED__, static void _item_pressed(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - Elm_Toolbar_Item *item = event_info; - elm_toolbar_item_state_set(item, elm_toolbar_item_state_next(item)); - elm_toolbar_item_selected_set(item, EINA_FALSE); + Elm_Object_Item *tb_it = event_info; + elm_toolbar_item_state_set(tb_it, elm_toolbar_item_state_next(item)); + elm_toolbar_item_selected_set(tb_it, EINA_FALSE); } EAPI_MAIN int elm_main(int argc __UNUSED__, char **argv __UNUSED__) { Evas_Object *win, *bg, *bx, *tb, *bt, *menu; - Elm_Toolbar_Item *item; + Elm_Object_Item *tb_it; win = elm_win_add(NULL, "toolbar", ELM_WIN_BASIC); elm_win_title_set(win, "Toolbar Example"); @@ -71,14 +71,14 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__) elm_toolbar_menu_parent_set(tb, win); - item = elm_toolbar_item_append(tb, "mail-send", "Send Mail", NULL, NULL); - elm_toolbar_item_menu_set(item, EINA_TRUE); + tb_it = elm_toolbar_item_append(tb, "mail-send", "Send Mail", NULL, NULL); + elm_toolbar_item_menu_set(tb_it, EINA_TRUE); - menu = elm_toolbar_item_menu_get(item); + menu = elm_toolbar_item_menu_get(tb_it); elm_menu_item_add(menu, NULL, "emptytrash", "Empty Trash", NULL, NULL); elm_menu_item_add(menu, NULL, "trashcan_full", "Full Trash", NULL, NULL); - elm_toolbar_item_priority_set(item, 10); + elm_toolbar_item_priority_set(tb_it, 10); elm_box_pack_end(bx, tb); elm_box_pack_end(bx, bt); diff --git a/src/examples/web_example.c b/src/examples/web_example.c index a98705b..82fc54e 100644 --- a/src/examples/web_example.c +++ b/src/examples/web_example.c @@ -40,7 +40,7 @@ struct _Tab_Data { Evas_Object *web; App_Data *app; - Elm_Toolbar_Item *tab; + Elm_Object_Item *tab; }; static Evas_Object * _web_create_window_cb(void *data, Evas_Object *obj, Eina_Bool js, const Elm_Web_Window_Features *wf); diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index 087acf5..d1e5ad0 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -14542,8 +14542,6 @@ extern "C" { ELM_TOOLBAR_SHRINK_LAST /**< Indicates error if returned by elm_toolbar_shrink_mode_get() */ } Elm_Toolbar_Shrink_Mode; - typedef struct _Elm_Toolbar_Item Elm_Toolbar_Item; /**< Item of Elm_Toolbar. Sub-type of Elm_Widget_Item. Can be created with elm_toolbar_item_append(), elm_toolbar_item_prepend() and functions to add items in relative positions, like elm_toolbar_item_insert_before(), and deleted with elm_toolbar_item_del(). */ - typedef struct _Elm_Toolbar_Item_State Elm_Toolbar_Item_State; /**< State of a Elm_Toolbar_Item. Can be created with elm_toolbar_item_state_add() and removed with elm_toolbar_item_state_del(). */ /** @@ -14558,7 +14556,6 @@ extern "C" { * @ingroup Toolbar */ EAPI Evas_Object *elm_toolbar_add(Evas_Object *parent) EINA_ARG_NONNULL(1); - /** * Set the icon size, in pixels, to be used by toolbar items. * @@ -14572,7 +14569,6 @@ extern "C" { * @ingroup Toolbar */ EAPI void elm_toolbar_icon_size_set(Evas_Object *obj, int icon_size) EINA_ARG_NONNULL(1); - /** * Get the icon size, in pixels, to be used by toolbar items. * @@ -14584,7 +14580,6 @@ extern "C" { * @ingroup Toolbar */ EAPI int elm_toolbar_icon_size_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); - /** * Sets icon lookup order, for toolbar items' icons. * @@ -14599,7 +14594,6 @@ extern "C" { * @ingroup Toolbar */ EAPI void elm_toolbar_icon_order_lookup_set(Evas_Object *obj, Elm_Icon_Lookup_Order order) EINA_ARG_NONNULL(1); - /** * Gets the icon lookup order. * @@ -14611,7 +14605,6 @@ extern "C" { * @ingroup Toolbar */ EAPI Elm_Icon_Lookup_Order elm_toolbar_icon_order_lookup_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); - /** * Set whether the toolbar should always have an item selected. * @@ -14630,7 +14623,6 @@ extern "C" { * @ingroup Toolbar */ EAPI void elm_toolbar_always_select_mode_set(Evas_Object *obj, Eina_Bool always_select) EINA_ARG_NONNULL(1); - /** * Get whether the toolbar should always have an item selected. * @@ -14643,7 +14635,6 @@ extern "C" { * @ingroup Toolbar */ EAPI Eina_Bool elm_toolbar_always_select_mode_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); - /** * Set whether the toolbar items' should be selected by the user or not. * @@ -14675,7 +14666,6 @@ extern "C" { * @ingroup Toolbar */ EAPI Eina_Bool elm_toolbar_no_select_mode_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); - /** * Append item to the toolbar. * @@ -14710,8 +14700,7 @@ extern "C" { * * @ingroup Toolbar */ - EAPI Elm_Toolbar_Item *elm_toolbar_item_append(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb func, const void *data) EINA_ARG_NONNULL(1); - + EAPI Elm_Object_Item *elm_toolbar_item_append(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb func, const void *data) EINA_ARG_NONNULL(1); /** * Prepend item to the toolbar. * @@ -14746,8 +14735,7 @@ extern "C" { * * @ingroup Toolbar */ - EAPI Elm_Toolbar_Item *elm_toolbar_item_prepend(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb func, const void *data) EINA_ARG_NONNULL(1); - + EAPI Elm_Object_Item *elm_toolbar_item_prepend(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb func, const void *data) EINA_ARG_NONNULL(1); /** * Insert a new item into the toolbar object before item @p before. * @@ -14783,7 +14771,7 @@ extern "C" { * * @ingroup Toolbar */ - EAPI Elm_Toolbar_Item *elm_toolbar_item_insert_before(Evas_Object *obj, Elm_Toolbar_Item *before, const char *icon, const char *label, Evas_Smart_Cb func, const void *data) EINA_ARG_NONNULL(1); + EAPI Elm_Object_Item *elm_toolbar_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *icon, const char *label, Evas_Smart_Cb func, const void *data) EINA_ARG_NONNULL(1); /** * Insert a new item into the toolbar object after item @p after. @@ -14820,8 +14808,7 @@ extern "C" { * * @ingroup Toolbar */ - EAPI Elm_Toolbar_Item *elm_toolbar_item_insert_after(Evas_Object *obj, Elm_Toolbar_Item *after, const char *icon, const char *label, Evas_Smart_Cb func, const void *data) EINA_ARG_NONNULL(1); - + EAPI Elm_Object_Item *elm_toolbar_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *icon, const char *label, Evas_Smart_Cb func, const void *data) EINA_ARG_NONNULL(1); /** * Get the first item in the given toolbar widget's list of * items. @@ -14835,8 +14822,7 @@ extern "C" { * * @ingroup Toolbar */ - EAPI Elm_Toolbar_Item *elm_toolbar_first_item_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); - + EAPI Elm_Object_Item *elm_toolbar_first_item_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); /** * Get the last item in the given toolbar widget's list of * items. @@ -14850,12 +14836,11 @@ extern "C" { * * @ingroup Toolbar */ - EAPI Elm_Toolbar_Item *elm_toolbar_last_item_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); - + EAPI Elm_Object_Item *elm_toolbar_last_item_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); /** * Get the item after @p item in toolbar. * - * @param item The toolbar item. + * @param it The toolbar item. * @return The item after @p item, or @c NULL if none or on failure. * * @note If it is the last item, @c NULL will be returned. @@ -14864,8 +14849,7 @@ extern "C" { * * @ingroup Toolbar */ - EAPI Elm_Toolbar_Item *elm_toolbar_item_next_get(const Elm_Toolbar_Item *item) EINA_ARG_NONNULL(1); - + EAPI Elm_Object_Item *elm_toolbar_item_next_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * Get the item before @p item in toolbar. * @@ -14878,24 +14862,22 @@ extern "C" { * * @ingroup Toolbar */ - EAPI Elm_Toolbar_Item *elm_toolbar_item_prev_get(const Elm_Toolbar_Item *item) EINA_ARG_NONNULL(1); - + EAPI Elm_Object_Item *elm_toolbar_item_prev_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * Get the toolbar object from an item. * - * @param item The item. + * @param it The item. * @return The toolbar object. * * This returns the toolbar object itself that an item belongs to. * * @ingroup Toolbar */ - EAPI Evas_Object *elm_toolbar_item_toolbar_get(const Elm_Toolbar_Item *item) EINA_ARG_NONNULL(1); - + EAPI Evas_Object *elm_toolbar_item_toolbar_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * Set the priority of a toolbar item. * - * @param item The toolbar item. + * @param it The toolbar item. * @param priority The item priority. The default is zero. * * This is used only when the toolbar shrink mode is set to @@ -14909,24 +14891,22 @@ extern "C" { * * @ingroup Toolbar */ - EAPI void elm_toolbar_item_priority_set(Elm_Toolbar_Item *item, int priority) EINA_ARG_NONNULL(1); - + EAPI void elm_toolbar_item_priority_set(Elm_Object_Item *it, int priority) EINA_ARG_NONNULL(1); /** * Get the priority of a toolbar item. * - * @param item The toolbar item. + * @param it The toolbar item. * @return The @p item priority, or @c 0 on failure. * * @see elm_toolbar_item_priority_set() for details. * * @ingroup Toolbar */ - EAPI int elm_toolbar_item_priority_get(const Elm_Toolbar_Item *item) EINA_ARG_NONNULL(1); - + EAPI int elm_toolbar_item_priority_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * Get the label of item. * - * @param item The item of toolbar. + * @param it The item of toolbar. * @return The label of item. * * The return value is a pointer to the label associated to @p item when @@ -14940,12 +14920,11 @@ extern "C" { * * @ingroup Toolbar */ - EAPI const char *elm_toolbar_item_label_get(const Elm_Toolbar_Item *item) EINA_ARG_NONNULL(1); - + EAPI const char *elm_toolbar_item_label_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * Set the label of item. * - * @param item The item of toolbar. + * @param it The item of toolbar. * @param text The label of item. * * The label to be displayed by the item. @@ -14960,24 +14939,22 @@ extern "C" { * * @ingroup Toolbar */ - EAPI void elm_toolbar_item_label_set(Elm_Toolbar_Item *item, const char *label) EINA_ARG_NONNULL(1); - + EAPI void elm_toolbar_item_label_set(Elm_Object_Item *it, const char *label) EINA_ARG_NONNULL(1); /** * Return the data associated with a given toolbar widget item. * - * @param item The toolbar widget item handle. + * @param it The toolbar widget item handle. * @return The data associated with @p item. * * @see elm_toolbar_item_data_set() * * @ingroup Toolbar */ - EAPI void *elm_toolbar_item_data_get(const Elm_Toolbar_Item *item) EINA_ARG_NONNULL(1); - + EAPI void *elm_toolbar_item_data_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * Set the data associated with a given toolbar widget item. * - * @param item The toolbar widget item handle. + * @param it The toolbar widget item handle * @param data The new data pointer to set to @p item. * * This sets new item data on @p item. @@ -14987,8 +14964,7 @@ extern "C" { * * @ingroup Toolbar */ - EAPI void elm_toolbar_item_data_set(Elm_Toolbar_Item *item, const void *data) EINA_ARG_NONNULL(1); - + EAPI void elm_toolbar_item_data_set(Elm_Object_Item *it, const void *data) EINA_ARG_NONNULL(1); /** * Returns a pointer to a toolbar item by its label. * @@ -15000,12 +14976,11 @@ extern "C" { * * @ingroup Toolbar */ - EAPI Elm_Toolbar_Item *elm_toolbar_item_find_by_label(const Evas_Object *obj, const char *label) EINA_ARG_NONNULL(1); - + EAPI Elm_Object_Item *elm_toolbar_item_find_by_label(const Evas_Object *obj, const char *label) EINA_ARG_NONNULL(1); /* * Get whether the @p item is selected or not. * - * @param item The toolbar item. + * @param it The toolbar item. * @return @c EINA_TRUE means item is selected. @c EINA_FALSE indicates * it's not. If @p obj is @c NULL, @c EINA_FALSE is returned. * @@ -15014,12 +14989,11 @@ extern "C" { * * @ingroup Toolbar */ - EAPI Eina_Bool elm_toolbar_item_selected_get(const Elm_Toolbar_Item *item) EINA_ARG_NONNULL(1); - + EAPI Eina_Bool elm_toolbar_item_selected_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * Set the selected state of an item. * - * @param item The toolbar item + * @param it The toolbar item * @param selected The selected state * * This sets the selected state of the given item @p it. @@ -15036,8 +15010,7 @@ extern "C" { * * @ingroup Toolbar */ - EAPI void elm_toolbar_item_selected_set(Elm_Toolbar_Item *item, Eina_Bool selected) EINA_ARG_NONNULL(1); - + EAPI void elm_toolbar_item_selected_set(Elm_Object_Item *it, Eina_Bool selected) EINA_ARG_NONNULL(1); /** * Get the selected item. * @@ -15053,13 +15026,12 @@ extern "C" { * * @ingroup Toolbar */ - EAPI Elm_Toolbar_Item *elm_toolbar_selected_item_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); - + EAPI Elm_Object_Item *elm_toolbar_selected_item_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); /** * Set the icon associated with @p item. * * @param obj The parent of this item. - * @param item The toolbar item. + * @param it The toolbar item. * @param icon A string with icon name or the absolute path of an image file. * * Toolbar will load icon image from fdo or current theme. @@ -15071,46 +15043,42 @@ extern "C" { * * @ingroup Toolbar */ - EAPI void elm_toolbar_item_icon_set(Elm_Toolbar_Item *item, const char *icon) EINA_ARG_NONNULL(1); - + EAPI void elm_toolbar_item_icon_set(Elm_Object_Item *it, const char *icon) EINA_ARG_NONNULL(1); /** * Get the string used to set the icon of @p item. * - * @param item The toolbar item. + * @param it The toolbar item. * @return The string associated with the icon object. * * @see elm_toolbar_item_icon_set() for details. * * @ingroup Toolbar */ - EAPI const char *elm_toolbar_item_icon_get(const Elm_Toolbar_Item *item) EINA_ARG_NONNULL(1); - + EAPI const char *elm_toolbar_item_icon_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * Get the object of @p item. * - * @param item The toolbar item. + * @param it The toolbar item. * @return The object * * @ingroup Toolbar */ - EAPI Evas_Object *elm_toolbar_item_object_get(const Elm_Toolbar_Item *item) EINA_ARG_NONNULL(1); - + EAPI Evas_Object *elm_toolbar_item_object_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * Get the icon object of @p item. * - * @param item The toolbar item. + * @param it The toolbar item. * @return The icon object * * @see elm_toolbar_item_icon_set() or elm_toolbar_item_icon_memfile_set() for details. * * @ingroup Toolbar */ - EAPI Evas_Object *elm_toolbar_item_icon_object_get(Elm_Toolbar_Item *item) EINA_ARG_NONNULL(1); - + EAPI Evas_Object *elm_toolbar_item_icon_object_get(Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * Set the icon associated with @p item to an image in a binary buffer. * - * @param item The toolbar item. + * @param it The toolbar item. * @param img The binary data that will be used as an image * @param size The size of binary data @p img * @param format Optional format of @p img to pass to the image loader @@ -15123,24 +15091,23 @@ extern "C" { * * @ingroup Toolbar */ - EAPI Eina_Bool elm_toolbar_item_icon_memfile_set(Elm_Toolbar_Item *item, const void *img, size_t size, const char *format, const char *key) EINA_ARG_NONNULL(1); - + EAPI Eina_Bool elm_toolbar_item_icon_memfile_set(Elm_Object_Item *it, const void *img, size_t size, const char *format, const char *key) EINA_ARG_NONNULL(1); /** * Delete them item from the toolbar. * - * @param item The item of toolbar to be deleted. + * @param it The item of toolbar to be deleted. * * @see elm_toolbar_item_append() * @see elm_toolbar_item_del_cb_set() * * @ingroup Toolbar */ - EAPI void elm_toolbar_item_del(Elm_Toolbar_Item *item) EINA_ARG_NONNULL(1); + EAPI void elm_toolbar_item_del(Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * Set the function called when a toolbar item is freed. * - * @param item The item to set the callback on. + * @param it The item to set the callback on. * @param func The function called. * * If there is a @p func, then it will be called prior item's memory release. @@ -15153,24 +15120,24 @@ extern "C" { * * @ingroup Toolbar */ - EAPI void elm_toolbar_item_del_cb_set(Elm_Toolbar_Item *item, Evas_Smart_Cb func) EINA_ARG_NONNULL(1); + EAPI void elm_toolbar_item_del_cb_set(Elm_Object_Item *it, Evas_Smart_Cb func) EINA_ARG_NONNULL(1); /** * Get a value whether toolbar item is disabled or not. * - * @param item The item. + * @param it The item. * @return The disabled state. * * @see elm_toolbar_item_disabled_set() for more details. * * @ingroup Toolbar */ - EAPI Eina_Bool elm_toolbar_item_disabled_get(const Elm_Toolbar_Item *item) EINA_ARG_NONNULL(1); + EAPI Eina_Bool elm_toolbar_item_disabled_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * Sets the disabled/enabled state of a toolbar item. * - * @param item The item. + * @param it The item. * @param disabled The disabled state. * * A disabled item cannot be selected or unselected. It will also @@ -15180,12 +15147,12 @@ extern "C" { * * @ingroup Toolbar */ - EAPI void elm_toolbar_item_disabled_set(Elm_Toolbar_Item *item, Eina_Bool disabled) EINA_ARG_NONNULL(1); + EAPI void elm_toolbar_item_disabled_set(Elm_Object_Item *it, Eina_Bool disabled) EINA_ARG_NONNULL(1); /** * Set or unset item as a separator. * - * @param item The toolbar item. + * @param it The toolbar item. * @param setting @c EINA_TRUE to set item @p item as separator or * @c EINA_FALSE to unset, i.e., item will be used as a regular item. * @@ -15198,12 +15165,12 @@ extern "C" { * * @ingroup Toolbar */ - EAPI void elm_toolbar_item_separator_set(Elm_Toolbar_Item *item, Eina_Bool separator) EINA_ARG_NONNULL(1); + EAPI void elm_toolbar_item_separator_set(Elm_Object_Item *it, Eina_Bool separator) EINA_ARG_NONNULL(1); /** * Get a value whether item is a separator or not. * - * @param item The toolbar item. + * @param it The toolbar item. * @return @c EINA_TRUE means item @p it is a separator. @c EINA_FALSE * indicates it's not. If @p it is @c NULL, @c EINA_FALSE is returned. * @@ -15211,7 +15178,7 @@ extern "C" { * * @ingroup Toolbar */ - EAPI Eina_Bool elm_toolbar_item_separator_get(const Elm_Toolbar_Item *item) EINA_ARG_NONNULL(1); + EAPI Eina_Bool elm_toolbar_item_separator_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * Set the shrink state of toolbar @p obj. @@ -15284,7 +15251,6 @@ extern "C" { * @ingroup Toolbar */ EAPI void elm_toolbar_menu_parent_set(Evas_Object *obj, Evas_Object *parent) EINA_ARG_NONNULL(1); - /** * Get the parent object of the toolbar items' menus. * @@ -15296,7 +15262,6 @@ extern "C" { * @ingroup Toolbar */ EAPI Evas_Object *elm_toolbar_menu_parent_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); - /** * Set the alignment of the items. * @@ -15315,7 +15280,6 @@ extern "C" { * @ingroup Toolbar */ EAPI void elm_toolbar_align_set(Evas_Object *obj, double align) EINA_ARG_NONNULL(1); - /** * Get the alignment of the items. * @@ -15328,11 +15292,10 @@ extern "C" { * @ingroup Toolbar */ EAPI double elm_toolbar_align_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); - /** * Set whether the toolbar item opens a menu. * - * @param item The toolbar item. + * @param it The toolbar item. * @param menu If @c EINA_TRUE, @p item will opens a menu when selected. * * A toolbar item can be set to be a menu, using this function. @@ -15361,12 +15324,11 @@ extern "C" { * * @ingroup Toolbar */ - EAPI void elm_toolbar_item_menu_set(Elm_Toolbar_Item *item, Eina_Bool menu) EINA_ARG_NONNULL(1); - + EAPI void elm_toolbar_item_menu_set(Elm_Object_Item *it, Eina_Bool menu) EINA_ARG_NONNULL(1); /** * Get toolbar item's menu. * - * @param item The toolbar item. + * @param it The toolbar item. * @return Item's menu object or @c NULL on failure. * * If @p item wasn't set as menu item with elm_toolbar_item_menu_set(), @@ -15376,12 +15338,11 @@ extern "C" { * * @ingroup Toolbar */ - EAPI Evas_Object *elm_toolbar_item_menu_get(const Elm_Toolbar_Item *item) EINA_ARG_NONNULL(1); - + EAPI Evas_Object *elm_toolbar_item_menu_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * Add a new state to @p item. * - * @param item The item. + * @param it The toolbar item. * @param icon A string with icon name or the absolute path of an image file. * @param label The label of the new state. * @param func The function to call when the item is clicked when this @@ -15402,23 +15363,21 @@ extern "C" { * * @ingroup Toolbar */ - EAPI Elm_Toolbar_Item_State *elm_toolbar_item_state_add(Elm_Toolbar_Item *item, const char *icon, const char *label, Evas_Smart_Cb func, const void *data) EINA_ARG_NONNULL(1); - + EAPI Elm_Toolbar_Item_State *elm_toolbar_item_state_add(Elm_Object_Item *it, const char *icon, const char *label, Evas_Smart_Cb func, const void *data) EINA_ARG_NONNULL(1); /** * Delete a previoulsy added state to @p item. * - * @param item The toolbar item. + * @param it The toolbar item. * @param state The state to be deleted. * @return @c EINA_TRUE on success or @c EINA_FALSE on failure. * * @see elm_toolbar_item_state_add() */ - EAPI Eina_Bool elm_toolbar_item_state_del(Elm_Toolbar_Item *item, Elm_Toolbar_Item_State *state) EINA_ARG_NONNULL(1); - + EAPI Eina_Bool elm_toolbar_item_state_del(Elm_Object_Item *it, Elm_Toolbar_Item_State *state) EINA_ARG_NONNULL(1); /** * Set @p state as the current state of @p it. * - * @param it The item. + * @param it The toolbar item. * @param state The state to use. * @return @c EINA_TRUE on success or @c EINA_FALSE on failure. * @@ -15430,12 +15389,11 @@ extern "C" { * * @ingroup Toolbar */ - EAPI Eina_Bool elm_toolbar_item_state_set(Elm_Toolbar_Item *it, Elm_Toolbar_Item_State *state) EINA_ARG_NONNULL(1); - + EAPI Eina_Bool elm_toolbar_item_state_set(Elm_Object_Item *it, Elm_Toolbar_Item_State *state) EINA_ARG_NONNULL(1); /** * Unset the state of @p it. * - * @param it The item. + * @param it The toolbar item. * * The default icon and label from this item will be displayed. * @@ -15443,12 +15401,11 @@ extern "C" { * * @ingroup Toolbar */ - EAPI void elm_toolbar_item_state_unset(Elm_Toolbar_Item *it) EINA_ARG_NONNULL(1); - + EAPI void elm_toolbar_item_state_unset(Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * Get the current state of @p it. * - * @param item The item. + * @param it The toolbar item. * @return The selected state or @c NULL if none is selected or on failure. * * @see elm_toolbar_item_state_set() for details. @@ -15457,8 +15414,7 @@ extern "C" { * * @ingroup Toolbar */ - EAPI Elm_Toolbar_Item_State *elm_toolbar_item_state_get(const Elm_Toolbar_Item *it) EINA_ARG_NONNULL(1); - + EAPI Elm_Toolbar_Item_State *elm_toolbar_item_state_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * Get the state after selected state in toolbar's @p item. * @@ -15472,8 +15428,7 @@ extern "C" { * * @ingroup Toolbar */ - EAPI Elm_Toolbar_Item_State *elm_toolbar_item_state_next(Elm_Toolbar_Item *it) EINA_ARG_NONNULL(1); - + EAPI Elm_Toolbar_Item_State *elm_toolbar_item_state_next(Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * Get the state before selected state in toolbar's @p item. * @@ -15487,12 +15442,11 @@ extern "C" { * * @ingroup Toolbar */ - EAPI Elm_Toolbar_Item_State *elm_toolbar_item_state_prev(Elm_Toolbar_Item *it) EINA_ARG_NONNULL(1); - + EAPI Elm_Toolbar_Item_State *elm_toolbar_item_state_prev(Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * Set the text to be shown in a given toolbar item's tooltips. * - * @param item Target item. + * @param it toolbar item. * @param text The text to set in the content. * * Setup the text as tooltip to object. The item can have only one tooltip, @@ -15503,8 +15457,7 @@ extern "C" { * * @ingroup Toolbar */ - EAPI void elm_toolbar_item_tooltip_text_set(Elm_Toolbar_Item *item, const char *text) EINA_ARG_NONNULL(1); - + EAPI void elm_toolbar_item_tooltip_text_set(Elm_Object_Item *it, const char *text) EINA_ARG_NONNULL(1); /** * Set the content to be shown in the tooltip item. * @@ -15514,7 +15467,7 @@ extern "C" { * return a valid Evas_Object. This object is then managed fully by * tooltip system and is deleted when the tooltip is gone. * - * @param item the toolbar item being attached a tooltip. + * @param it the toolbar item being attached a tooltip. * @param func the function used to create the tooltip contents. * @param data what to provide to @a func as callback data/context. * @param del_cb called when data is not needed anymore, either when @@ -15527,12 +15480,11 @@ extern "C" { * * @ingroup Toolbar */ - EAPI void elm_toolbar_item_tooltip_content_cb_set(Elm_Toolbar_Item *item, Elm_Tooltip_Item_Content_Cb func, const void *data, Evas_Smart_Cb del_cb) EINA_ARG_NONNULL(1); - + EAPI void elm_toolbar_item_tooltip_content_cb_set(Elm_Object_Item *it, Elm_Tooltip_Item_Content_Cb func, const void *data, Evas_Smart_Cb del_cb) EINA_ARG_NONNULL(1); /** * Unset tooltip from item. * - * @param item toolbar item to remove previously set tooltip. + * @param it toolbar item to remove previously set tooltip. * * Remove tooltip from item. The callback provided as del_cb to * elm_toolbar_item_tooltip_content_cb_set() will be called to notify @@ -15543,8 +15495,7 @@ extern "C" { * * @ingroup Toolbar */ - EAPI void elm_toolbar_item_tooltip_unset(Elm_Toolbar_Item *item) EINA_ARG_NONNULL(1); - + EAPI void elm_toolbar_item_tooltip_unset(Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * Sets a different style for this item tooltip. * @@ -15552,19 +15503,18 @@ extern "C" { * elm_toolbar_item_tooltip_content_cb_set() or * elm_toolbar_item_tooltip_text_set() * - * @param item toolbar item with tooltip already set. + * @param it toolbar item with tooltip already set. * @param style the theme style to use (default, transparent, ...) * * @see elm_object_tooltip_style_set() for more details. * * @ingroup Toolbar */ - EAPI void elm_toolbar_item_tooltip_style_set(Elm_Toolbar_Item *item, const char *style) EINA_ARG_NONNULL(1); - + EAPI void elm_toolbar_item_tooltip_style_set(Elm_Object_Item *it, const char *style) EINA_ARG_NONNULL(1); /** * Get the style for this item tooltip. * - * @param item toolbar item with tooltip already set. + * @param it toolbar item with tooltip already set. * @return style the theme style in use, defaults to "default". If the * object does not have a tooltip set, then NULL is returned. * @@ -15573,13 +15523,12 @@ extern "C" { * * @ingroup Toolbar */ - EAPI const char *elm_toolbar_item_tooltip_style_get(const Elm_Toolbar_Item *item) EINA_ARG_NONNULL(1); - + EAPI const char *elm_toolbar_item_tooltip_style_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * Set the type of mouse pointer/cursor decoration to be shown, * when the mouse pointer is over the given toolbar widget item * - * @param item toolbar item to customize cursor on + * @param it toolbar item to customize cursor on * @param cursor the cursor type's name * * This function works analogously as elm_object_cursor_set(), but @@ -15597,13 +15546,13 @@ extern "C" { * * @ingroup Toolbar */ - EAPI void elm_toolbar_item_cursor_set(Elm_Toolbar_Item *item, const char *cursor) EINA_ARG_NONNULL(1); + EAPI void elm_toolbar_item_cursor_set(Elm_Object_Item *it, const char *cursor) EINA_ARG_NONNULL(1); /* * Get the type of mouse pointer/cursor decoration set to be shown, * when the mouse pointer is over the given toolbar widget item * - * @param item toolbar item with custom cursor set + * @param it toolbar item with custom cursor set * @return the cursor type's name or @c NULL, if no custom cursors * were set to @p item (and on errors) * @@ -15613,14 +15562,14 @@ extern "C" { * * @ingroup Toolbar */ - EAPI const char *elm_toolbar_item_cursor_get(const Elm_Toolbar_Item *item) EINA_ARG_NONNULL(1); + EAPI const char *elm_toolbar_item_cursor_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * Unset any custom mouse pointer/cursor decoration set to be * shown, when the mouse pointer is over the given toolbar widget * item, thus making it show the @b default cursor again. * - * @param item a toolbar item + * @param it a toolbar item * * Use this call to undo any custom settings on this item's cursor * decoration, bringing it back to defaults (no custom style set). @@ -15630,13 +15579,13 @@ extern "C" { * * @ingroup Toolbar */ - EAPI void elm_toolbar_item_cursor_unset(Elm_Toolbar_Item *item) EINA_ARG_NONNULL(1); + EAPI void elm_toolbar_item_cursor_unset(Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * Set a different @b style for a given custom cursor set for a * toolbar item. * - * @param item toolbar item with custom cursor set + * @param it toolbar item with custom cursor set * @param style the theme style to use (e.g. @c "default", * @c "transparent", etc) * @@ -15655,13 +15604,13 @@ extern "C" { * * @ingroup Toolbar */ - EAPI void elm_toolbar_item_cursor_style_set(Elm_Toolbar_Item *item, const char *style) EINA_ARG_NONNULL(1); + EAPI void elm_toolbar_item_cursor_style_set(Elm_Object_Item *it, const char *style) EINA_ARG_NONNULL(1); /** * Get the current @b style set for a given toolbar item's custom * cursor * - * @param item toolbar item with custom cursor set. + * @param it toolbar item with custom cursor set. * @return style the cursor style in use. If the object does not * have a cursor set, then @c NULL is returned. * @@ -15669,14 +15618,14 @@ extern "C" { * * @ingroup Toolbar */ - EAPI const char *elm_toolbar_item_cursor_style_get(const Elm_Toolbar_Item *item) EINA_ARG_NONNULL(1); + EAPI const char *elm_toolbar_item_cursor_style_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * Set if the (custom)cursor for a given toolbar item should be * searched in its theme, also, or should only rely on the * rendering engine. * - * @param item item with custom (custom) cursor already set on + * @param it item with custom (custom) cursor already set on * @param engine_only Use @c EINA_TRUE to have cursors looked for * only on those provided by the rendering engine, @c EINA_FALSE to * have them searched on the widget's theme, as well. @@ -15689,14 +15638,14 @@ extern "C" { * * @ingroup Toolbar */ - EAPI void elm_toolbar_item_cursor_engine_only_set(Elm_Toolbar_Item *item, Eina_Bool engine_only) EINA_ARG_NONNULL(1); + EAPI void elm_toolbar_item_cursor_engine_only_set(Elm_Object_Item *it, Eina_Bool engine_only) EINA_ARG_NONNULL(1); /** * Get if the (custom) cursor for a given toolbar item is being * searched in its theme, also, or is only relying on the rendering * engine. * - * @param item a toolbar item + * @param it a toolbar item * @return @c EINA_TRUE, if cursors are being looked for only on * those provided by the rendering engine, @c EINA_FALSE if they * are being searched on the widget's theme, as well. @@ -15705,7 +15654,7 @@ extern "C" { * * @ingroup Toolbar */ - EAPI Eina_Bool elm_toolbar_item_cursor_engine_only_get(const Elm_Toolbar_Item *item) EINA_ARG_NONNULL(1); + EAPI Eina_Bool elm_toolbar_item_cursor_engine_only_get(const Elm_Object_Item *it) EINA_ARG_NONNULL(1); /** * Change a toolbar's orientation diff --git a/src/lib/elm_toolbar.c b/src/lib/elm_toolbar.c index 79f4314..6c8cfcd 100644 --- a/src/lib/elm_toolbar.c +++ b/src/lib/elm_toolbar.c @@ -5,6 +5,7 @@ #include "els_icon.h" typedef struct _Widget_Data Widget_Data; +typedef struct _Elm_Toolbar_Item Elm_Toolbar_Item; struct _Widget_Data { @@ -161,7 +162,8 @@ _item_select(Elm_Toolbar_Item *it) } else { - it2 = elm_toolbar_selected_item_get(WIDGET(it)); + it2 = (Elm_Toolbar_Item *) + elm_toolbar_selected_item_get(WIDGET(it)); _item_unselect(it2); it->selected = EINA_TRUE; @@ -191,7 +193,7 @@ _menu_hide(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *ev { Elm_Toolbar_Item *selected; Elm_Toolbar_Item *it = data; - selected = elm_toolbar_selected_item_get(WIDGET(it)); + selected = (Elm_Toolbar_Item *) elm_toolbar_selected_item_get(WIDGET(it)); _item_unselect(selected); } @@ -523,7 +525,8 @@ _resize_job(void *data) _item_menu_destroy(wd->more_item); _item_menu_create(wd, wd->more_item); - menu = elm_toolbar_item_menu_get(wd->more_item); + menu = + elm_toolbar_item_menu_get((Elm_Object_Item *) wd->more_item); EINA_INLIST_FOREACH(wd->items, it) { @@ -830,6 +833,174 @@ _item_new(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb f return it; } +static void +_elm_toolbar_item_label_update(Elm_Toolbar_Item *item) +{ + Evas_Coord mw = -1, mh = -1; + Widget_Data *wd = elm_widget_data_get(WIDGET(item)); + edje_object_part_text_set(VIEW(item), "elm.text", item->label); + + elm_coords_finger_size_adjust(1, &mw, 1, &mh); + edje_object_size_min_restricted_calc(VIEW(item), &mw, &mh, mw, mh); + elm_coords_finger_size_adjust(1, &mw, 1, &mh); + if (wd->vertical) + { + evas_object_size_hint_weight_set(VIEW(item), EVAS_HINT_EXPAND, -1.0); + evas_object_size_hint_align_set(VIEW(item), EVAS_HINT_FILL, 0.5); + } + else + { + evas_object_size_hint_weight_set(VIEW(item), -1.0, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(VIEW(item), 0.5, EVAS_HINT_FILL); + } + evas_object_size_hint_min_set(VIEW(item), mw, mh); +} + +static void +_elm_toolbar_item_label_set_cb (void *data, Evas_Object *obj, const char *emission, const char *source) +{ + Elm_Toolbar_Item *item = data; + _elm_toolbar_item_label_update(item); + edje_object_signal_callback_del(obj, emission, source, + _elm_toolbar_item_label_set_cb); + edje_object_signal_emit (VIEW(item), "elm,state,label,reset", "elm"); +} + +static void +_item_label_set(Elm_Toolbar_Item *item, const char *label, const char *signal) +{ + const char *s; + + if ((label) && (item->label) && (!strcmp(label, item->label))) return; + + eina_stringshare_replace(&item->label, label); + s = edje_object_data_get(VIEW(item), "transition_animation_on"); + if ((s) && (atoi(s))) + { + edje_object_part_text_set(VIEW(item), "elm.text_new", item->label); + edje_object_signal_emit (VIEW(item), signal, "elm"); + edje_object_signal_callback_add(VIEW(item), + "elm,state,label_set,done", "elm", + _elm_toolbar_item_label_set_cb, item); + } + else + _elm_toolbar_item_label_update(item); + _resize(WIDGET(item), NULL, NULL, NULL); +} + +static void +_elm_toolbar_item_icon_update(Elm_Toolbar_Item *item) +{ + Elm_Toolbar_Item_State *it_state; + Eina_List *l; + Evas_Coord mw = -1, mh = -1; + Widget_Data *wd = elm_widget_data_get(WIDGET(item)); + Evas_Object *old_icon = edje_object_part_swallow_get(VIEW(item), + "elm.swallow.icon"); + elm_widget_sub_object_del(VIEW(item), old_icon); + evas_object_hide(old_icon); + edje_object_part_swallow(VIEW(item), "elm.swallow.icon", item->icon); + elm_coords_finger_size_adjust(1, &mw, 1, &mh); + edje_object_size_min_restricted_calc(VIEW(item), &mw, &mh, mw, mh); + elm_coords_finger_size_adjust(1, &mw, 1, &mh); + if (wd->vertical) + { + evas_object_size_hint_weight_set(VIEW(item), EVAS_HINT_EXPAND, -1.0); + evas_object_size_hint_align_set(VIEW(item), EVAS_HINT_FILL, 0.5); + } + else + { + evas_object_size_hint_weight_set(VIEW(item), -1.0, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(VIEW(item), 0.5, EVAS_HINT_FILL); + } + evas_object_size_hint_min_set(VIEW(item), mw, mh); + + EINA_LIST_FOREACH(item->states, l, it_state) + if (it_state->icon == old_icon) + return; + evas_object_del(old_icon); +} + +static void +_elm_toolbar_item_icon_set_cb (void *data, Evas_Object *obj, const char *emission, const char *source) +{ + Elm_Toolbar_Item *item = data; + edje_object_part_unswallow(VIEW(item), item->icon); + _elm_toolbar_item_icon_update(item); + edje_object_signal_callback_del(obj, emission, source, + _elm_toolbar_item_icon_set_cb); + edje_object_signal_emit (VIEW(item), "elm,state,icon,reset", "elm"); +} + +static void +_elm_toolbar_item_icon_obj_set(Evas_Object *obj, Elm_Toolbar_Item *item, Evas_Object *icon_obj, const char *icon_str, double icon_size, const char *signal) +{ + Evas_Object *old_icon; + int ms = 0; + const char *s; + + if (icon_str) + eina_stringshare_replace(&item->icon_str, icon_str); + else + { + eina_stringshare_del(item->icon_str); + item->icon_str = NULL; + } + item->icon = icon_obj; + if (icon_obj) + { + ms = (icon_size * _elm_config->scale); + evas_object_size_hint_min_set(item->icon, ms, ms); + evas_object_size_hint_max_set(item->icon, ms, ms); + evas_object_show(item->icon); + elm_widget_sub_object_add(obj, item->icon); + } + s = edje_object_data_get(VIEW(item), "transition_animation_on"); + if ((s) && (atoi(s))) + { + old_icon = edje_object_part_swallow_get(VIEW(item), + "elm.swallow.icon_new"); + if (old_icon) + { + elm_widget_sub_object_del(VIEW(item), old_icon); + evas_object_hide(old_icon); + } + edje_object_part_swallow(VIEW(item), "elm.swallow.icon_new", + item->icon); + edje_object_signal_emit (VIEW(item), signal, "elm"); + edje_object_signal_callback_add(VIEW(item), + "elm,state,icon_set,done", "elm", + _elm_toolbar_item_icon_set_cb, item); + } + else + _elm_toolbar_item_icon_update(item); + _resize(obj, NULL, NULL, NULL); +} + +static void +_elm_toolbar_item_state_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) +{ + Elm_Toolbar_Item *it = event_info; + Elm_Toolbar_Item_State *it_state; + + it_state = eina_list_data_get(it->current_state); + if (it_state->func) + it_state->func((void *)it_state->data, obj, event_info); +} + +static Elm_Toolbar_Item_State * +_item_state_new(const char *label, const char *icon_str, Evas_Object *icon, Evas_Smart_Cb func, const void *data) +{ + Elm_Toolbar_Item_State *it_state; + it_state = ELM_NEW(Elm_Toolbar_Item_State); + it_state->label = eina_stringshare_add(label); + it_state->icon_str = eina_stringshare_add(icon_str); + it_state->icon = icon; + it_state->func = func; + it_state->data = data; + return it_state; +} + EAPI Evas_Object * elm_toolbar_add(Evas_Object *parent) { @@ -907,7 +1078,7 @@ elm_toolbar_icon_size_get(const Evas_Object *obj) return wd->icon_size; } -EAPI Elm_Toolbar_Item * +EAPI Elm_Object_Item * elm_toolbar_item_append(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb func, const void *data) { ELM_CHECK_WIDTYPE(obj, widtype) NULL; @@ -925,547 +1096,220 @@ elm_toolbar_item_append(Evas_Object *obj, const char *icon, const char *label, E _theme_hook_item(obj, it, scale, wd->icon_size); _sizing_eval(obj); - return it; + return (Elm_Object_Item *) it; } -static void -_elm_toolbar_item_state_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) +EAPI Elm_Object_Item * +elm_toolbar_item_prepend(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb func, const void *data) { - Elm_Toolbar_Item *it = event_info; - Elm_Toolbar_Item_State *it_state; + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return NULL; - it_state = eina_list_data_get(it->current_state); - if (it_state->func) - it_state->func((void *)it_state->data, obj, event_info); + Elm_Toolbar_Item *it = _item_new(obj, icon, label, func, data); + if (!it) return NULL; + double scale = (elm_widget_scale_get(obj) * _elm_config->scale); + + wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it)); + evas_object_box_prepend(wd->bx, VIEW(it)); + evas_object_show(VIEW(it)); + _theme_hook_item(obj, it, scale, wd->icon_size); + _sizing_eval(obj); + + return (Elm_Object_Item *) it; } -EAPI Elm_Toolbar_Item_State * -elm_toolbar_item_state_next(Elm_Toolbar_Item *item) +EAPI Elm_Object_Item * +elm_toolbar_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *icon, const char *label, Evas_Smart_Cb func, const void *data) { + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + ELM_OBJ_ITEM_CHECK_OR_RETURN(before, NULL); Widget_Data *wd; - Evas_Object *obj; - Eina_List *next_state; - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL); + Elm_Toolbar_Item *it, *_before; - obj = WIDGET(item); wd = elm_widget_data_get(obj); if (!wd) return NULL; - if (!item->states) return NULL; + _before = (Elm_Toolbar_Item *) before; + it = _item_new(obj, icon, label, func, data); + if (!it) return NULL; + double scale = (elm_widget_scale_get(obj) * _elm_config->scale); - next_state = eina_list_next(item->current_state); - if (!next_state) - next_state = eina_list_next(item->states); - return eina_list_data_get(next_state); + wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it), + EINA_INLIST_GET(_before)); + evas_object_box_insert_before(wd->bx, VIEW(it), VIEW(_before)); + evas_object_show(VIEW(it)); + _theme_hook_item(obj, it, scale, wd->icon_size); + _sizing_eval(obj); + + return (Elm_Object_Item *) it; } -EAPI Elm_Toolbar_Item_State * -elm_toolbar_item_state_prev(Elm_Toolbar_Item *item) +EAPI Elm_Object_Item * +elm_toolbar_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *icon, const char *label, Evas_Smart_Cb func, const void *data) { + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + ELM_OBJ_ITEM_CHECK_OR_RETURN(after, NULL); Widget_Data *wd; - Evas_Object *obj; - Eina_List *prev_state; - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL); + Elm_Toolbar_Item *it, *_after; - obj = WIDGET(item); wd = elm_widget_data_get(obj); if (!wd) return NULL; - if (!item->states) return NULL; + _after = (Elm_Toolbar_Item *) after; + it = _item_new(obj, icon, label, func, data); + if (!it) return NULL; + double scale = (elm_widget_scale_get(obj) * _elm_config->scale); - prev_state = eina_list_prev(item->current_state); - if ((!prev_state) || (prev_state == item->states)) - prev_state = eina_list_last(item->states); - return eina_list_data_get(prev_state); + wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it), + EINA_INLIST_GET(_after)); + evas_object_box_insert_after(wd->bx, VIEW(it), VIEW(_after)); + evas_object_show(VIEW(it)); + _theme_hook_item(obj, it, scale, wd->icon_size); + _sizing_eval(obj); + + return (Elm_Object_Item *) it; } -EAPI void -elm_toolbar_item_state_unset(Elm_Toolbar_Item *it) +EAPI Elm_Object_Item * +elm_toolbar_first_item_get(const Evas_Object *obj) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it); - elm_toolbar_item_state_set(it, NULL); + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd || !wd->items) return NULL; + return (Elm_Object_Item *) ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items); } -EAPI Eina_Bool -elm_toolbar_item_state_set(Elm_Toolbar_Item *it, Elm_Toolbar_Item_State *state) +EAPI Elm_Object_Item * +elm_toolbar_last_item_get(const Evas_Object *obj) { - Widget_Data *wd; - Eina_List *next_state; - Elm_Toolbar_Item_State *it_state; - Evas_Object *obj; - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE); + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd || !wd->items) return NULL; + return (Elm_Object_Item *) ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items->last); +} - obj = WIDGET(it); - wd = elm_widget_data_get(obj); - if (!wd) return EINA_FALSE; - if (!it->states) return EINA_FALSE; +EAPI Elm_Object_Item * +elm_toolbar_item_next_get(const Elm_Object_Item *it) +{ + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); + return (Elm_Object_Item *) ELM_TOOLBAR_ITEM_FROM_INLIST( + EINA_INLIST_GET(((Elm_Toolbar_Item *) it))->next); +} - if (state) - { - next_state = eina_list_data_find_list(it->states, state); - if (!next_state) return EINA_FALSE; - } - else - next_state = it->states; +EAPI Elm_Object_Item * +elm_toolbar_item_prev_get(const Elm_Object_Item *it) +{ + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); + return (Elm_Object_Item *) ELM_TOOLBAR_ITEM_FROM_INLIST( + EINA_INLIST_GET(((Elm_Toolbar_Item *) it))->prev); +} - if (next_state == it->current_state) return EINA_TRUE; - - it_state = eina_list_data_get(next_state); - if (eina_list_data_find(it->current_state, state)) - { - _item_label_set(it, it_state->label, "elm,state,label_set,forward"); - _elm_toolbar_item_icon_obj_set(obj, it, it_state->icon, it_state->icon_str, - wd->icon_size, "elm,state,icon_set,forward"); - } - else - { - _item_label_set(it, it_state->label, "elm,state,label_set,backward"); - _elm_toolbar_item_icon_obj_set(obj, it, it_state->icon, it_state->icon_str, - wd->icon_size, "elm,state,icon_set,backward"); - } - if (it->disabled) - elm_widget_signal_emit(it->icon, "elm,state,disabled", "elm"); - else - elm_widget_signal_emit(it->icon, "elm,state,enabled", "elm"); - - it->current_state = next_state; - return EINA_TRUE; -} - -EAPI Elm_Toolbar_Item_State * -elm_toolbar_item_state_get(const Elm_Toolbar_Item *it) -{ - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL); - if ((!it->states) || (!it->current_state)) return NULL; - if (it->current_state == it->states) return NULL; - - return eina_list_data_get(it->current_state); -} - -static Elm_Toolbar_Item_State * -_item_state_new(const char *label, const char *icon_str, Evas_Object *icon, Evas_Smart_Cb func, const void *data) -{ - Elm_Toolbar_Item_State *it_state; - it_state = ELM_NEW(Elm_Toolbar_Item_State); - it_state->label = eina_stringshare_add(label); - it_state->icon_str = eina_stringshare_add(icon_str); - it_state->icon = icon; - it_state->func = func; - it_state->data = data; - return it_state; -} - -EAPI Elm_Toolbar_Item_State * -elm_toolbar_item_state_add(Elm_Toolbar_Item *item, const char *icon, const char *label, Evas_Smart_Cb func, const void *data) -{ - Elm_Toolbar_Item_State *it_state; - Evas_Object *icon_obj; - Evas_Object *obj; - Widget_Data *wd; - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL); - obj = WIDGET(item); - wd = elm_widget_data_get(WIDGET(item)); - if (!wd) return NULL; - - if (!item->states) - { - it_state = _item_state_new(item->label, item->icon_str, item->icon, - item->func, item->base.data); - item->states = eina_list_append(item->states, it_state); - item->current_state = item->states; - } - - icon_obj = elm_icon_add(obj); - elm_icon_order_lookup_set(icon_obj, wd->lookup_order); - if (!icon_obj) goto error_state_add; - - if (!_item_icon_set(icon_obj, "toolbar/", icon)) - { - evas_object_del(icon_obj); - icon_obj = NULL; - icon = NULL; - } - - it_state = _item_state_new(label, icon, icon_obj, func, data); - item->states = eina_list_append(item->states, it_state); - item->func = _elm_toolbar_item_state_cb; - item->base.data = NULL; - - return it_state; - -error_state_add: - if (item->states && !eina_list_next(item->states)) - { - eina_stringshare_del(item->label); - eina_stringshare_del(item->icon_str); - free(eina_list_data_get(item->states)); - eina_list_free(item->states); - item->states = NULL; - } - return NULL; -} - -EAPI Eina_Bool -elm_toolbar_item_state_del(Elm_Toolbar_Item *item, Elm_Toolbar_Item_State *state) -{ - Eina_List *del_state; - Elm_Toolbar_Item_State *it_state; - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE); - - if (!state) return EINA_FALSE; - if (!item->states) return EINA_FALSE; - - del_state = eina_list_data_find_list(item->states, state); - if (del_state == item->states) return EINA_FALSE; - if (del_state == item->current_state) - elm_toolbar_item_state_unset(item); - - eina_stringshare_del(state->label); - eina_stringshare_del(state->icon_str); - if (state->icon) evas_object_del(state->icon); - free(state); - item->states = eina_list_remove_list(item->states, del_state); - if (item->states && !eina_list_next(item->states)) - { - it_state = eina_list_data_get(item->states); - item->base.data = it_state->data; - item->func = it_state->func; - eina_stringshare_del(it_state->label); - eina_stringshare_del(it_state->icon_str); - free(eina_list_data_get(item->states)); - eina_list_free(item->states); - item->states = NULL; - } - return EINA_TRUE; -} - -EAPI Elm_Toolbar_Item * -elm_toolbar_item_prepend(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb func, const void *data) -{ - ELM_CHECK_WIDTYPE(obj, widtype) NULL; - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return NULL; - - Elm_Toolbar_Item *it = _item_new(obj, icon, label, func, data); - if (!it) return NULL; - double scale = (elm_widget_scale_get(obj) * _elm_config->scale); - - wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it)); - evas_object_box_prepend(wd->bx, VIEW(it)); - evas_object_show(VIEW(it)); - _theme_hook_item(obj, it, scale, wd->icon_size); - _sizing_eval(obj); - - return it; -} - -EAPI Elm_Toolbar_Item * -elm_toolbar_item_insert_before(Evas_Object *obj, Elm_Toolbar_Item *before, const char *icon, const char *label, Evas_Smart_Cb func, const void *data) -{ - ELM_CHECK_WIDTYPE(obj, widtype) NULL; - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(before, NULL); - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return NULL; - - Elm_Toolbar_Item *it = _item_new(obj, icon, label, func, data); - if (!it) return NULL; - double scale = (elm_widget_scale_get(obj) * _elm_config->scale); - - wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it), - EINA_INLIST_GET(before)); - evas_object_box_insert_before(wd->bx, VIEW(it), VIEW(before)); - evas_object_show(VIEW(it)); - _theme_hook_item(obj, it, scale, wd->icon_size); - _sizing_eval(obj); - - return it; -} - -EAPI Elm_Toolbar_Item * -elm_toolbar_item_insert_after(Evas_Object *obj, Elm_Toolbar_Item *after, const char *icon, const char *label, Evas_Smart_Cb func, const void *data) -{ - ELM_CHECK_WIDTYPE(obj, widtype) NULL; - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(after, NULL); - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return NULL; - - Elm_Toolbar_Item *it = _item_new(obj, icon, label, func, data); - if (!it) return NULL; - double scale = (elm_widget_scale_get(obj) * _elm_config->scale); - - wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it), - EINA_INLIST_GET(after)); - evas_object_box_insert_after(wd->bx, VIEW(it), VIEW(after)); - evas_object_show(VIEW(it)); - _theme_hook_item(obj, it, scale, wd->icon_size); - _sizing_eval(obj); - - return it; -} - -EAPI Elm_Toolbar_Item * -elm_toolbar_first_item_get(const Evas_Object *obj) -{ - ELM_CHECK_WIDTYPE(obj, widtype) NULL; - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd || !wd->items) return NULL; - Elm_Toolbar_Item *it = ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items); - return it; -} - -EAPI Elm_Toolbar_Item * -elm_toolbar_last_item_get(const Evas_Object *obj) -{ - ELM_CHECK_WIDTYPE(obj, widtype) NULL; - Widget_Data *wd = elm_widget_data_get(obj); - if (!wd || !wd->items) return NULL; - Elm_Toolbar_Item *it = ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items->last); - return it; -} - -EAPI Elm_Toolbar_Item * -elm_toolbar_item_next_get(const Elm_Toolbar_Item *item) -{ - Elm_Toolbar_Item *next; - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL); - next = ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next); - return next; -} - -EAPI Elm_Toolbar_Item * -elm_toolbar_item_prev_get(const Elm_Toolbar_Item *item) -{ - Elm_Toolbar_Item *prev; - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL); - prev = ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev); - return prev; -} - -EAPI Evas_Object * -elm_toolbar_item_toolbar_get(const Elm_Toolbar_Item *item) -{ - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL); - return WIDGET(item); -} +EAPI Evas_Object * +elm_toolbar_item_toolbar_get(const Elm_Object_Item *it) +{ + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); + return elm_object_item_object_get(it); +} EAPI void -elm_toolbar_item_priority_set(Elm_Toolbar_Item *item, int priority) +elm_toolbar_item_priority_set(Elm_Object_Item *it, int priority) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); + Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it; if (item->prio.priority == priority) return; item->prio.priority = priority; _resize(WIDGET(item), NULL, NULL, NULL); } EAPI int -elm_toolbar_item_priority_get(const Elm_Toolbar_Item *item) +elm_toolbar_item_priority_get(const Elm_Object_Item *it) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, 0); - return item->prio.priority; + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, 0); + return ((Elm_Toolbar_Item *) it)->prio.priority; } EAPI const char * -elm_toolbar_item_icon_get(const Elm_Toolbar_Item *item) -{ - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL); - return item->icon_str; -} - -EAPI const char * -elm_toolbar_item_label_get(const Elm_Toolbar_Item *item) -{ - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL); - return item->label; -} - -static void -_elm_toolbar_item_label_update(Elm_Toolbar_Item *item) -{ - Evas_Coord mw = -1, mh = -1; - Widget_Data *wd = elm_widget_data_get(WIDGET(item)); - edje_object_part_text_set(VIEW(item), "elm.text", item->label); - - elm_coords_finger_size_adjust(1, &mw, 1, &mh); - edje_object_size_min_restricted_calc(VIEW(item), &mw, &mh, mw, mh); - elm_coords_finger_size_adjust(1, &mw, 1, &mh); - if (wd->vertical) - { - evas_object_size_hint_weight_set(VIEW(item), EVAS_HINT_EXPAND, -1.0); - evas_object_size_hint_align_set(VIEW(item), EVAS_HINT_FILL, 0.5); - } - else - { - evas_object_size_hint_weight_set(VIEW(item), -1.0, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(VIEW(item), 0.5, EVAS_HINT_FILL); - } - evas_object_size_hint_min_set(VIEW(item), mw, mh); -} - -static void -_elm_toolbar_item_label_set_cb (void *data, Evas_Object *obj, const char *emission, const char *source) +elm_toolbar_item_label_get(const Elm_Object_Item *it) { - Elm_Toolbar_Item *item = data; - _elm_toolbar_item_label_update(item); - edje_object_signal_callback_del(obj, emission, source, - _elm_toolbar_item_label_set_cb); - edje_object_signal_emit (VIEW(item), "elm,state,label,reset", "elm"); -} - -static void -_item_label_set(Elm_Toolbar_Item *item, const char *label, const char *signal) -{ - const char *s; - - if ((label) && (item->label) && (!strcmp(label, item->label))) return; - - eina_stringshare_replace(&item->label, label); - s = edje_object_data_get(VIEW(item), "transition_animation_on"); - if ((s) && (atoi(s))) - { - edje_object_part_text_set(VIEW(item), "elm.text_new", item->label); - edje_object_signal_emit (VIEW(item), signal, "elm"); - edje_object_signal_callback_add(VIEW(item), - "elm,state,label_set,done", "elm", - _elm_toolbar_item_label_set_cb, item); - } - else - _elm_toolbar_item_label_update(item); - _resize(WIDGET(item), NULL, NULL, NULL); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); + return ((Elm_Toolbar_Item *) it)->label; } EAPI void -elm_toolbar_item_label_set(Elm_Toolbar_Item *item, const char *label) +elm_toolbar_item_label_set(Elm_Object_Item *it, const char *label) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item); - _item_label_set(item, label, "elm,state,label_set"); -} - -static void -_elm_toolbar_item_icon_update(Elm_Toolbar_Item *item) -{ - Elm_Toolbar_Item_State *it_state; - Eina_List *l; - Evas_Coord mw = -1, mh = -1; - Widget_Data *wd = elm_widget_data_get(WIDGET(item)); - Evas_Object *old_icon = edje_object_part_swallow_get(VIEW(item), - "elm.swallow.icon"); - elm_widget_sub_object_del(VIEW(item), old_icon); - evas_object_hide(old_icon); - edje_object_part_swallow(VIEW(item), "elm.swallow.icon", item->icon); - elm_coords_finger_size_adjust(1, &mw, 1, &mh); - edje_object_size_min_restricted_calc(VIEW(item), &mw, &mh, mw, mh); - elm_coords_finger_size_adjust(1, &mw, 1, &mh); - if (wd->vertical) - { - evas_object_size_hint_weight_set(VIEW(item), EVAS_HINT_EXPAND, -1.0); - evas_object_size_hint_align_set(VIEW(item), EVAS_HINT_FILL, 0.5); - } - else - { - evas_object_size_hint_weight_set(VIEW(item), -1.0, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(VIEW(item), 0.5, EVAS_HINT_FILL); - } - evas_object_size_hint_min_set(VIEW(item), mw, mh); - - EINA_LIST_FOREACH(item->states, l, it_state) - if (it_state->icon == old_icon) - return; - evas_object_del(old_icon); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); + _item_label_set(((Elm_Toolbar_Item *) it), label, "elm,state,label_set"); } -EAPI Eina_Bool -elm_toolbar_item_selected_get(const Elm_Toolbar_Item *item) +EAPI void * +elm_toolbar_item_data_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, NULL); + return elm_object_item_data_get(it); } EAPI void -elm_toolbar_item_selected_set(Elm_Toolbar_Item *item, Eina_Bool selected) +elm_toolbar_item_data_set(Elm_Object_Item *it, const void *data) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item); - Widget_Data *wd = elm_widget_data_get(WIDGET(item)); - if (!wd) return; - - if (item->selected == selected) return; - - if (selected) - _item_select(item); - else - _item_unselect(item); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); + elm_object_item_data_set(it, (void *) data); } -EAPI Elm_Toolbar_Item * -elm_toolbar_selected_item_get(const Evas_Object *obj) +EAPI Elm_Object_Item * +elm_toolbar_item_find_by_label(const Evas_Object *obj, const char *label) { ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Elm_Toolbar_Item *it; Widget_Data *wd = elm_widget_data_get(obj); - if (!wd) return NULL; - return wd->selected_item; -} - -static void -_elm_toolbar_item_icon_set_cb (void *data, Evas_Object *obj, const char *emission, const char *source) -{ - Elm_Toolbar_Item *item = data; - edje_object_part_unswallow(VIEW(item), item->icon); - _elm_toolbar_item_icon_update(item); - edje_object_signal_callback_del(obj, emission, source, - _elm_toolbar_item_icon_set_cb); - edje_object_signal_emit (VIEW(item), "elm,state,icon,reset", "elm"); -} - -static void -_elm_toolbar_item_icon_obj_set(Evas_Object *obj, Elm_Toolbar_Item *item, Evas_Object *icon_obj, const char *icon_str, double icon_size, const char *signal) -{ - Evas_Object *old_icon; - int ms = 0; - const char *s; - - if (icon_str) - eina_stringshare_replace(&item->icon_str, icon_str); - else - { - eina_stringshare_del(item->icon_str); - item->icon_str = NULL; - } - item->icon = icon_obj; - if (icon_obj) - { - ms = (icon_size * _elm_config->scale); - evas_object_size_hint_min_set(item->icon, ms, ms); - evas_object_size_hint_max_set(item->icon, ms, ms); - evas_object_show(item->icon); - elm_widget_sub_object_add(obj, item->icon); - } - s = edje_object_data_get(VIEW(item), "transition_animation_on"); - if ((s) && (atoi(s))) - { - old_icon = edje_object_part_swallow_get(VIEW(item), - "elm.swallow.icon_new"); - if (old_icon) - { - elm_widget_sub_object_del(VIEW(item), old_icon); - evas_object_hide(old_icon); - } - edje_object_part_swallow(VIEW(item), "elm.swallow.icon_new", - item->icon); - edje_object_signal_emit (VIEW(item), signal, "elm"); - edje_object_signal_callback_add(VIEW(item), - "elm,state,icon_set,done", "elm", - _elm_toolbar_item_icon_set_cb, item); + if (!wd) return NULL; + + EINA_INLIST_FOREACH(wd->items, it) + { + if (!strcmp(it->label, label)) + return (Elm_Object_Item *) it; } - else - _elm_toolbar_item_icon_update(item); - _resize(obj, NULL, NULL, NULL); + return NULL; +} + +EAPI void +elm_toolbar_item_selected_set(Elm_Object_Item *it, Eina_Bool selected) +{ + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); + Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it; + Widget_Data *wd = elm_widget_data_get(WIDGET(item)); + if (!wd) return; + + if (item->selected == selected) return; + if (selected) _item_select(item); + else _item_unselect(item); +} + +EAPI Eina_Bool +elm_toolbar_item_selected_get(const Elm_Object_Item *it) +{ + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE); + return ((Elm_Toolbar_Item *) it)->selected; +} + +EAPI Elm_Object_Item * +elm_toolbar_selected_item_get(const Evas_Object *obj) +{ + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return NULL; + return (Elm_Object_Item *) wd->selected_item; } EAPI void -elm_toolbar_item_icon_set(Elm_Toolbar_Item *item, const char *icon) +elm_toolbar_item_icon_set(Elm_Object_Item *it, const char *icon) { + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); + Evas_Object *icon_obj; Widget_Data *wd; Evas_Object *obj; + Elm_Toolbar_Item * item = (Elm_Toolbar_Item *) it; - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item); obj = WIDGET(item); wd = elm_widget_data_get(obj); if (!wd) return; @@ -1484,15 +1328,47 @@ elm_toolbar_item_icon_set(Elm_Toolbar_Item *item, const char *icon) } } +EAPI const char * +elm_toolbar_item_icon_get(const Elm_Object_Item *it) +{ + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); + return ((Elm_Toolbar_Item *) it)->icon_str; +} + +EAPI Evas_Object * +elm_toolbar_item_object_get(const Elm_Object_Item *it) +{ + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); + + Widget_Data *wd; + Evas_Object *obj; + Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it; + + obj = WIDGET(item); + wd = elm_widget_data_get(obj); + if (!wd) return NULL; + + return VIEW(item); +} + +EAPI Evas_Object * +elm_toolbar_item_icon_object_get(Elm_Object_Item *it) +{ + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); + return ((Elm_Toolbar_Item *) it)->icon; +} + EAPI Eina_Bool -elm_toolbar_item_icon_memfile_set(Elm_Toolbar_Item *item, const void *img, size_t size, const char *format, const char *key) +elm_toolbar_item_icon_memfile_set(Elm_Object_Item *it, const void *img, size_t size, const char *format, const char *key) { + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE); + Evas_Object *icon_obj; Widget_Data *wd; Evas_Object *obj; Eina_Bool ret; + Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it; - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE); obj = WIDGET(item); wd = elm_widget_data_get(obj); if (!wd) return EINA_FALSE; @@ -1515,42 +1391,16 @@ elm_toolbar_item_icon_memfile_set(Elm_Toolbar_Item *item, const void *img, size_ return EINA_TRUE; } -EAPI Evas_Object * -elm_toolbar_item_object_get(const Elm_Toolbar_Item *item) -{ - Widget_Data *wd; - Evas_Object *obj; - - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL); - obj = WIDGET(item); - wd = elm_widget_data_get(obj); - if (!wd) return NULL; - - return VIEW(item); -} - -EAPI Evas_Object * -elm_toolbar_item_icon_object_get(Elm_Toolbar_Item *item) -{ - Widget_Data *wd; - Evas_Object *obj; - - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL); - obj = WIDGET(item); - wd = elm_widget_data_get(obj); - if (!wd) return NULL; - - return item->icon; -} - EAPI void -elm_toolbar_item_del(Elm_Toolbar_Item *item) +elm_toolbar_item_del(Elm_Object_Item *it) { + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); + Widget_Data *wd; Evas_Object *obj2; - Elm_Toolbar_Item *next; + Elm_Toolbar_Item *item, *next; + item = (Elm_Toolbar_Item *) it; - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item); wd = elm_widget_data_get(WIDGET(item)); if (!wd) return; obj2 = WIDGET(item); @@ -1563,31 +1413,33 @@ elm_toolbar_item_del(Elm_Toolbar_Item *item) } EAPI void -elm_toolbar_item_del_cb_set(Elm_Toolbar_Item *item, Evas_Smart_Cb func) +elm_toolbar_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_toolbar_item_del_cb_set(it, func); } EAPI Eina_Bool -elm_toolbar_item_disabled_get(const Elm_Toolbar_Item *item) +elm_toolbar_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_Widget_Item *) it)->disabled; } EAPI void -elm_toolbar_item_disabled_set(Elm_Toolbar_Item *item, Eina_Bool disabled) +elm_toolbar_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_Toolbar_Item *item = (Elm_Toolbar_Item *) it; _item_disable(item, disabled); _resize(WIDGET(item), NULL, NULL, NULL); } EAPI void -elm_toolbar_item_separator_set(Elm_Toolbar_Item *item, Eina_Bool separator) +elm_toolbar_item_separator_set(Elm_Object_Item *it, Eina_Bool separator) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); + Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it; Evas_Object *obj = WIDGET(item); Widget_Data *wd = elm_widget_data_get(obj); double scale; @@ -1598,10 +1450,10 @@ elm_toolbar_item_separator_set(Elm_Toolbar_Item *item, Eina_Bool separator) } EAPI Eina_Bool -elm_toolbar_item_separator_get(const Elm_Toolbar_Item *item) +elm_toolbar_item_separator_get(const 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_Toolbar_Item *) it)->separator; } EAPI void @@ -1722,9 +1574,10 @@ elm_toolbar_align_get(const Evas_Object *obj) } EAPI void -elm_toolbar_item_menu_set(Elm_Toolbar_Item *item, Eina_Bool menu) +elm_toolbar_item_menu_set(Elm_Object_Item *it, Eina_Bool menu) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); + Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it; Widget_Data *wd = elm_widget_data_get(WIDGET(item)); if (!wd) return; @@ -1733,127 +1586,301 @@ elm_toolbar_item_menu_set(Elm_Toolbar_Item *item, Eina_Bool menu) else _item_menu_destroy(item); } -EAPI void -elm_toolbar_item_tooltip_text_set(Elm_Toolbar_Item *item, const char *text) +EAPI Evas_Object * +elm_toolbar_item_menu_get(const Elm_Object_Item *it) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item); - elm_widget_item_tooltip_text_set(item, text); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); + Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it; + if (!item->menu) return NULL; + Widget_Data *wd = elm_widget_data_get(WIDGET(item)); + if (!wd) return NULL; + return item->o_menu; } -EAPI void -elm_toolbar_item_tooltip_content_cb_set(Elm_Toolbar_Item *item, Elm_Tooltip_Item_Content_Cb func, const void *data, Evas_Smart_Cb del_cb) +EAPI Elm_Toolbar_Item_State * +elm_toolbar_item_state_add(Elm_Object_Item *it, const char *icon, const char *label, Evas_Smart_Cb func, const void *data) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item); - elm_widget_item_tooltip_content_cb_set(item, func, data, del_cb); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); + + Elm_Toolbar_Item_State *it_state; + Evas_Object *icon_obj; + Evas_Object *obj; + Widget_Data *wd; + Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it; + obj = WIDGET(item); + wd = elm_widget_data_get(WIDGET(item)); + if (!wd) return NULL; + + if (!item->states) + { + it_state = _item_state_new(item->label, item->icon_str, item->icon, + item->func, item->base.data); + item->states = eina_list_append(item->states, it_state); + item->current_state = item->states; + } + + icon_obj = elm_icon_add(obj); + elm_icon_order_lookup_set(icon_obj, wd->lookup_order); + if (!icon_obj) goto error_state_add; + + if (!_item_icon_set(icon_obj, "toolbar/", icon)) + { + evas_object_del(icon_obj); + icon_obj = NULL; + icon = NULL; + } + + it_state = _item_state_new(label, icon, icon_obj, func, data); + item->states = eina_list_append(item->states, it_state); + item->func = _elm_toolbar_item_state_cb; + item->base.data = NULL; + + return it_state; + +error_state_add: + if (item->states && !eina_list_next(item->states)) + { + eina_stringshare_del(item->label); + eina_stringshare_del(item->icon_str); + free(eina_list_data_get(item->states)); + eina_list_free(item->states); + item->states = NULL; + } + return NULL; } -EAPI void -elm_toolbar_item_tooltip_unset(Elm_Toolbar_Item *item) +EAPI Eina_Bool +elm_toolbar_item_state_del(Elm_Object_Item *it, Elm_Toolbar_Item_State *state) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item); - elm_widget_item_tooltip_unset(item); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE); + + Eina_List *del_state; + Elm_Toolbar_Item_State *it_state; + Elm_Toolbar_Item *item; + + if (!state) return EINA_FALSE; + + item = (Elm_Toolbar_Item *) it; + if (!item->states) return EINA_FALSE; + + del_state = eina_list_data_find_list(item->states, state); + if (del_state == item->states) return EINA_FALSE; + if (del_state == item->current_state) + elm_toolbar_item_state_unset(it); + + eina_stringshare_del(state->label); + eina_stringshare_del(state->icon_str); + if (state->icon) evas_object_del(state->icon); + free(state); + item->states = eina_list_remove_list(item->states, del_state); + if (item->states && !eina_list_next(item->states)) + { + it_state = eina_list_data_get(item->states); + item->base.data = it_state->data; + item->func = it_state->func; + eina_stringshare_del(it_state->label); + eina_stringshare_del(it_state->icon_str); + free(eina_list_data_get(item->states)); + eina_list_free(item->states); + item->states = NULL; + } + return EINA_TRUE; +} + +EAPI Eina_Bool +elm_toolbar_item_state_set(Elm_Object_Item *it, Elm_Toolbar_Item_State *state) +{ + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE); + + Widget_Data *wd; + Eina_List *next_state; + Elm_Toolbar_Item_State *it_state; + Evas_Object *obj; + Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it; + + obj = WIDGET(item); + wd = elm_widget_data_get(obj); + if (!wd) return EINA_FALSE; + if (!item->states) return EINA_FALSE; + + if (state) + { + next_state = eina_list_data_find_list(item->states, state); + if (!next_state) return EINA_FALSE; + } + else + next_state = item->states; + + if (next_state == item->current_state) return EINA_TRUE; + + it_state = eina_list_data_get(next_state); + if (eina_list_data_find(item->current_state, state)) + { + _item_label_set(item, it_state->label, "elm,state,label_set,forward"); + _elm_toolbar_item_icon_obj_set(obj, item, it_state->icon, it_state->icon_str, + wd->icon_size, "elm,state,icon_set,forward"); + } + else + { + _item_label_set(item, it_state->label, "elm,state,label_set,backward"); + _elm_toolbar_item_icon_obj_set(obj, + item, + it_state->icon, + it_state->icon_str, + wd->icon_size, + "elm,state,icon_set,backward"); + } + if (item->disabled) + elm_widget_signal_emit(item->icon, "elm,state,disabled", "elm"); + else + elm_widget_signal_emit(item->icon, "elm,state,enabled", "elm"); + + item->current_state = next_state; + return EINA_TRUE; } EAPI void -elm_toolbar_item_tooltip_style_set(Elm_Toolbar_Item *item, const char *style) +elm_toolbar_item_state_unset(Elm_Object_Item *it) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item); - elm_widget_item_tooltip_style_set(item, style); + elm_toolbar_item_state_set(it, NULL); } -EAPI const char * -elm_toolbar_item_tooltip_style_get(const Elm_Toolbar_Item *item) +EAPI Elm_Toolbar_Item_State * +elm_toolbar_item_state_get(const Elm_Object_Item *it) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL); - return elm_widget_item_tooltip_style_get(item); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); + Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it; + + if ((!item->states) || (!item->current_state)) return NULL; + if (item->current_state == item->states) return NULL; + + return eina_list_data_get(item->current_state); +} + +EAPI Elm_Toolbar_Item_State * +elm_toolbar_item_state_next(Elm_Object_Item *it) +{ + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); + + Widget_Data *wd; + Evas_Object *obj; + Eina_List *next_state; + Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it; + + obj = WIDGET(item); + wd = elm_widget_data_get(obj); + if (!wd) return NULL; + if (!item->states) return NULL; + + next_state = eina_list_next(item->current_state); + if (!next_state) + next_state = eina_list_next(item->states); + return eina_list_data_get(next_state); +} + +EAPI Elm_Toolbar_Item_State * +elm_toolbar_item_state_prev(Elm_Object_Item *it) +{ + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); + + Widget_Data *wd; + Evas_Object *obj; + Eina_List *prev_state; + Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it; + + obj = WIDGET(item); + wd = elm_widget_data_get(obj); + if (!wd) return NULL; + if (!item->states) return NULL; + + prev_state = eina_list_prev(item->current_state); + if ((!prev_state) || (prev_state == item->states)) + prev_state = eina_list_last(item->states); + return eina_list_data_get(prev_state); } EAPI void -elm_toolbar_item_cursor_set(Elm_Toolbar_Item *item, const char *cursor) +elm_toolbar_item_tooltip_text_set(Elm_Object_Item *it, const char *text) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item); - elm_widget_item_cursor_set(item, cursor); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); + elm_widget_item_tooltip_text_set(it, text); } -EAPI const char * -elm_toolbar_item_cursor_get(const Elm_Toolbar_Item *item) +EAPI void +elm_toolbar_item_tooltip_content_cb_set(Elm_Object_Item *it, Elm_Tooltip_Item_Content_Cb func, const void *data, Evas_Smart_Cb del_cb) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL); - return elm_widget_item_cursor_get(item); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); + elm_widget_item_tooltip_content_cb_set(it, func, data, del_cb); } EAPI void -elm_toolbar_item_cursor_unset(Elm_Toolbar_Item *item) +elm_toolbar_item_tooltip_unset(Elm_Object_Item *it) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item); - elm_widget_item_cursor_unset(item); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); + elm_widget_item_tooltip_unset(it); } EAPI void -elm_toolbar_item_cursor_style_set(Elm_Toolbar_Item *item, const char *style) +elm_toolbar_item_tooltip_style_set(Elm_Object_Item *it, const char *style) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item); - elm_widget_item_cursor_style_set(item, style); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); + elm_widget_item_tooltip_style_set(it, style); } EAPI const char * -elm_toolbar_item_cursor_style_get(const Elm_Toolbar_Item *item) +elm_toolbar_item_tooltip_style_get(const Elm_Object_Item *it) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL); - return elm_widget_item_cursor_style_get(item); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); + return elm_widget_item_tooltip_style_get(it); } EAPI void -elm_toolbar_item_cursor_engine_only_set(Elm_Toolbar_Item *item, Eina_Bool engine_only) +elm_toolbar_item_cursor_set(Elm_Object_Item *it, const char *cursor) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item); - elm_widget_item_cursor_engine_only_set(item, engine_only); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); + elm_widget_item_cursor_set(it, cursor); } -EAPI Eina_Bool -elm_toolbar_item_cursor_engine_only_get(const Elm_Toolbar_Item *item) +EAPI const char * +elm_toolbar_item_cursor_get(const Elm_Object_Item *it) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE); - return elm_widget_item_cursor_engine_only_get(item); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); + return elm_widget_item_cursor_get(it); } -EAPI Evas_Object * -elm_toolbar_item_menu_get(const Elm_Toolbar_Item *item) +EAPI void +elm_toolbar_item_cursor_unset(Elm_Object_Item *it) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL); - Widget_Data *wd = elm_widget_data_get(WIDGET(item)); - if ((!wd) || (!item->menu)) return NULL; - return item->o_menu; + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); + elm_widget_item_cursor_unset(it); } -EAPI Elm_Toolbar_Item * -elm_toolbar_item_find_by_label(const Evas_Object *obj, const char *label) +EAPI void +elm_toolbar_item_cursor_style_set(Elm_Object_Item *it, const char *style) { - Elm_Toolbar_Item *it; - ELM_CHECK_WIDTYPE(obj, widtype) NULL; - Widget_Data *wd = elm_widget_data_get(obj); - - if (!wd) return NULL; - EINA_INLIST_FOREACH(wd->items, it) - { - if (!strcmp(it->label, label)) return it; - } + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); + elm_widget_item_cursor_style_set(it, style); +} - return NULL; +EAPI const char * +elm_toolbar_item_cursor_style_get(const Elm_Object_Item *it) +{ + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL); + return elm_widget_item_cursor_style_get(it); } EAPI void -elm_toolbar_item_data_set(Elm_Toolbar_Item *item, const void *data) +elm_toolbar_item_cursor_engine_only_set(Elm_Object_Item *it, Eina_Bool engine_only) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item); - elm_widget_item_data_set(item, data); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it); + elm_widget_item_cursor_engine_only_set(it, engine_only); } -EAPI void * -elm_toolbar_item_data_get(const Elm_Toolbar_Item *item) +EAPI Eina_Bool +elm_toolbar_item_cursor_engine_only_get(const Elm_Object_Item *it) { - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL); - return elm_widget_item_data_get(item); + ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE); + return elm_widget_item_cursor_engine_only_get(it); } EAPI void @@ -1948,5 +1975,3 @@ elm_toolbar_horizontal_get(const Evas_Object *obj) if (!wd) return EINA_FALSE; return !wd->vertical; } - - -- 2.7.4