elementary: Updated test_inwin.c to do API testing
Signed-off-by: Aharon Hillel <a.hillel@partner.samsung.com> SVN revision: 68334
This commit is contained in:
parent
1727622837
commit
8c3588c41b
|
@ -1,16 +1,73 @@
|
|||
#include <Elementary.h>
|
||||
#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 *inwin;
|
||||
};
|
||||
typedef struct _api_data api_data;
|
||||
|
||||
enum _api_state
|
||||
{
|
||||
CONTENT_UNSET,
|
||||
API_STATE_LAST
|
||||
};
|
||||
typedef enum _api_state api_state;
|
||||
|
||||
static void
|
||||
set_api_state(api_data *api)
|
||||
{
|
||||
Evas_Object *t;
|
||||
switch(api->state)
|
||||
{
|
||||
case CONTENT_UNSET:
|
||||
t = elm_win_inwin_content_unset(api->inwin);
|
||||
evas_object_del(t);
|
||||
t = elm_label_add(elm_object_parent_widget_get(api->inwin));
|
||||
elm_object_text_set(t, "Content was unset.<br>DONE!");
|
||||
elm_win_inwin_content_set(api->inwin, t);
|
||||
evas_object_show(t);
|
||||
|
||||
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_inwin(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
||||
{
|
||||
Evas_Object *win, *bg, *inwin, *lb;
|
||||
Evas_Object *win, *bg, *inwin, *lb, *bxx, *bt;
|
||||
api_data *api = calloc(1, sizeof(api_data));
|
||||
|
||||
win = elm_win_add(NULL, "inwin", ELM_WIN_BASIC);
|
||||
elm_win_title_set(win, "Inwin");
|
||||
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);
|
||||
|
@ -18,8 +75,20 @@ test_inwin(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
|
|||
evas_object_show(bg);
|
||||
|
||||
inwin = elm_win_inwin_add(win);
|
||||
api->inwin = inwin;
|
||||
evas_object_show(inwin);
|
||||
|
||||
bxx = elm_box_add(inwin);
|
||||
evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_show(bxx);
|
||||
|
||||
bt = elm_button_add(inwin);
|
||||
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);
|
||||
|
||||
lb = elm_label_add(win);
|
||||
elm_object_text_set(lb,
|
||||
"This is an \"inwin\" - a window in a<br/>"
|
||||
|
@ -27,7 +96,8 @@ test_inwin(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
|
|||
"you want centered, taking over the window<br/>"
|
||||
"until dismissed somehow. Unlike hovers they<br/>"
|
||||
"don't hover over their target.");
|
||||
elm_win_inwin_content_set(inwin, lb);
|
||||
elm_box_pack_end(bxx, lb);
|
||||
elm_win_inwin_content_set(inwin, bxx);
|
||||
evas_object_show(lb);
|
||||
|
||||
evas_object_resize(win, 320, 240);
|
||||
|
|
Loading…
Reference in New Issue