forked from enlightenment/efl
elementary: add test for edje external combobox
This commit is contained in:
parent
a9426e09ee
commit
9622146c3d
|
@ -1177,4 +1177,40 @@ embryo script and from C code.";
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
group { name: "external/combobox";
|
||||
parts {
|
||||
COMMON_EXTERNAL_UNDER
|
||||
part { name: "combobox"; type: EXTERNAL;
|
||||
source: "elm/combobox";
|
||||
clip_to: "clip";
|
||||
description { state: "default" 0.0;
|
||||
rel2.relative: 1.0 0.0;
|
||||
align: 0.5 0.0;
|
||||
params {
|
||||
string: "guide" "Widgets";
|
||||
}
|
||||
}
|
||||
}
|
||||
part { name: "info"; type: TEXT;
|
||||
clip_to: "clip";
|
||||
description { state: "default" 0.;
|
||||
rel1 {
|
||||
to: "combobox";
|
||||
relative: 0.0 1.0;
|
||||
}
|
||||
text {
|
||||
text: "";
|
||||
font: "Sans";
|
||||
size: 24;
|
||||
align: 0.5 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
COMMON_EXTERNAL_OVER
|
||||
}
|
||||
programs {
|
||||
COMMON_EXTERNAL_PROGRAM
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -264,6 +264,7 @@ void test_external_scroller(void *data, Evas_Object *obj, void *event_info);
|
|||
void test_external_pbar(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_external_video(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_external_icon(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_external_combobox(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_config(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_video(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_eio(void *data, Evas_Object *obj, void *event_info);
|
||||
|
@ -680,6 +681,7 @@ add_tests:
|
|||
ADD_TEST(NULL, "Edje External", "ExtSlider", test_external_slider);
|
||||
ADD_TEST(NULL, "Edje External", "ExtVideo", test_external_video);
|
||||
ADD_TEST(NULL, "Edje External", "ExtIcon", test_external_icon);
|
||||
ADD_TEST(NULL, "Edje External", "ExtCombobox", test_external_combobox);
|
||||
|
||||
//------------------------------//
|
||||
ADD_TEST(NULL, "Toolbars", "Toolbar", test_toolbar);
|
||||
|
|
|
@ -202,3 +202,78 @@ test_external_icon(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e
|
|||
evas_object_resize(win, 320, 400);
|
||||
evas_object_show(win);
|
||||
}
|
||||
|
||||
static char *
|
||||
text_get_cb(void *data,
|
||||
Evas_Object *obj EINA_UNUSED,
|
||||
const char *part EINA_UNUSED)
|
||||
{
|
||||
return strdup(data);
|
||||
}
|
||||
|
||||
static void
|
||||
action_cb(void *data,
|
||||
Evas_Object *obj EINA_UNUSED,
|
||||
void *info)
|
||||
{
|
||||
Evas_Object *const lay = data;
|
||||
Elm_Object_Item *const item = info;
|
||||
|
||||
elm_layout_text_set(lay, "info", elm_object_item_data_get(item));
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_pressed_cb(void *data EINA_UNUSED,
|
||||
Evas_Object *obj,
|
||||
void *info)
|
||||
{
|
||||
const char *txt;
|
||||
|
||||
txt = elm_object_item_text_get(info);
|
||||
elm_object_text_set(obj, txt);
|
||||
elm_combobox_hover_end(obj);
|
||||
elm_entry_cursor_end_set(obj);
|
||||
}
|
||||
|
||||
void
|
||||
test_external_combobox(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *win, *ly, *cb, *edj;
|
||||
char buf[PATH_MAX];
|
||||
Elm_Genlist_Item_Class *itc;
|
||||
const char *info[] = {
|
||||
"Label", "Button", "Combobox", "Icon", "Scroller", "Layout",
|
||||
"Naviframe", "Bubble"
|
||||
};
|
||||
const unsigned int size = EINA_C_ARRAY_LENGTH(info);
|
||||
unsigned int i;
|
||||
|
||||
win = elm_win_util_standard_add("ext_combobox", "Edje External Combobox");
|
||||
elm_win_autodel_set(win, EINA_TRUE);
|
||||
|
||||
ly = elm_layout_add(win);
|
||||
snprintf(buf, sizeof(buf), "%s/objects/test_external.edj", elm_app_data_dir_get());
|
||||
elm_layout_file_set(ly, buf, "external/combobox");
|
||||
evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
elm_win_resize_object_add(win, ly);
|
||||
evas_object_show(ly);
|
||||
|
||||
itc = elm_genlist_item_class_new();
|
||||
itc->item_style = "default";
|
||||
itc->func.text_get = text_get_cb;
|
||||
|
||||
edj = elm_layout_edje_get(ly);
|
||||
cb = edje_object_part_external_object_get(edj, "combobox");
|
||||
evas_object_smart_callback_add(cb, "item,pressed", _cb_pressed_cb, NULL);
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
elm_genlist_item_append(cb, itc, info[i], NULL,
|
||||
ELM_GENLIST_ITEM_NONE, action_cb, ly);
|
||||
}
|
||||
|
||||
elm_genlist_item_class_free(itc);
|
||||
|
||||
evas_object_resize(win, 320, 400);
|
||||
evas_object_show(win);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue