From 2d9bbfd7bede19e22cea9a0b3750350626395d18 Mon Sep 17 00:00:00 2001 From: tasn Date: Thu, 23 Feb 2012 13:58:37 +0000 Subject: [PATCH] elementary: Updated test_hoversel.c to do API testing Signed-off-by: Aharon Hillel git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@68332 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/bin/test_hoversel.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 105 insertions(+), 1 deletion(-) diff --git a/src/bin/test_hoversel.c b/src/bin/test_hoversel.c index c55ab3c..023663b 100644 --- a/src/bin/test_hoversel.c +++ b/src/bin/test_hoversel.c @@ -1,28 +1,132 @@ #include +#include "test.h" #ifdef HAVE_CONFIG_H # include "elementary_config.h" #endif #ifndef ELM_LIB_QUICKLAUNCH +struct _api_data +{ + unsigned int state; /* What state we are testing */ + void *box; /* Use this to get box content */ +}; +typedef struct _api_data api_data; + +enum _api_state +{ + HOVERSEL_HORIZ, + HOVERSEL_END, + HOVERSEL_LABAL_SET, + HOVERSEL_ICON_UNSET, + HOVERSEL_CLEAR_OPEN, + HOVERSEL_CLEAR, + API_STATE_LAST +}; +typedef enum _api_state api_state; + +static void +set_api_state(api_data *api) +{ + const Eina_List *items = elm_box_children_get(api->box); + if(!eina_list_count(items)) + return; + + /* use elm_box_children_get() to get list of children */ + switch(api->state) + { /* Put all api-changes under switch */ + case HOVERSEL_HORIZ: /* Make first hover horiz (0) */ + elm_hoversel_horizontal_set(eina_list_nth(items, 0), EINA_TRUE); + elm_hoversel_hover_begin(eina_list_nth(items, 0)); + break; + + case HOVERSEL_END: /* Make first hover horiz (1) */ + elm_hoversel_hover_begin(eina_list_nth(items, 1)); + elm_hoversel_hover_end(eina_list_nth(items, 1)); + break; + + case HOVERSEL_LABAL_SET: /* set second hover label (2) */ + elm_object_text_set(eina_list_nth(items, 1), "Label from API"); + break; + + case HOVERSEL_ICON_UNSET: /* 3 */ + elm_object_text_set(eina_list_nth(items, 5), "Label only"); + elm_object_part_content_unset(eina_list_nth(items, 5), "icon"); + break; + + case HOVERSEL_CLEAR_OPEN: /* 4 */ + elm_hoversel_hover_begin(eina_list_nth(items, 1)); + elm_hoversel_clear(eina_list_nth(items, 1)); + break; + + case HOVERSEL_CLEAR: /* 5 */ + elm_hoversel_clear(eina_list_nth(items, 0)); + break; + + case API_STATE_LAST: + break; + + default: + return; + } +} + +static void +_api_bt_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__) +{ /* Will add here a SWITCH command containing code to modify test-object */ + /* in accordance a->state value. */ + api_data *a = data; + char str[128]; + + printf("clicked event on API Button: api_state=<%d>\n", a->state); + set_api_state(a); + a->state++; + sprintf(str, "Next API function (%u)", a->state); + elm_object_text_set(obj, str); + elm_object_disabled_set(obj, a->state == API_STATE_LAST); +} + +static void +_cleanup_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + free(data); +} + void test_hoversel(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) { - Evas_Object *win, *bg, *bx, *bt, *ic; + Evas_Object *win, *bg, *bx, *bt, *ic, *bxx; char buf[PATH_MAX]; + api_data *api = calloc(1, sizeof(api_data)); win = elm_win_add(NULL, "hoversel", ELM_WIN_BASIC); elm_win_title_set(win, "Hoversel"); elm_win_autodel_set(win, EINA_TRUE); + evas_object_event_callback_add(win, EVAS_CALLBACK_FREE, _cleanup_cb, api); bg = elm_bg_add(win); elm_win_resize_object_add(win, bg); evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_show(bg); + bxx = elm_box_add(win); + elm_win_resize_object_add(win, bxx); + evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_show(bxx); + bx = elm_box_add(win); elm_win_resize_object_add(win, bx); evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + api->box = bx; evas_object_show(bx); + bt = elm_button_add(win); + elm_object_text_set(bt, "Next API function"); + evas_object_smart_callback_add(bt, "clicked", _api_bt_clicked, (void *) api); + elm_box_pack_end(bxx, bt); + elm_object_disabled_set(bt, api->state == API_STATE_LAST); + evas_object_show(bt); + + elm_box_pack_end(bxx, bx); + bt = elm_hoversel_add(win); // FIXME: need to add horizontal hoversel theme to default some day // elm_hoversel_horizontal_set(bt, 1); -- 2.7.4