forked from enlightenment/efl
elementary_test: Search menu performance optimization.
Summary: elementary_test search menu is created again and again at each search query. Here the optimaization is to remember the menu item and retain them instead of deletion and reuse them. Signed-off-by: Umesh Tanwar <umesh.tanwar@samsung.com> Test Plan: search item in elementary_test and measure the performace time. Reviewers: jpeg Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D4218 Signed-off-by: Jean-Philippe Andre <jp.andre@samsung.com>
This commit is contained in:
parent
ac0dd31075
commit
06f4a790e6
|
@ -302,6 +302,10 @@ struct elm_test
|
|||
const char *icon;
|
||||
const char *category;
|
||||
const char *name;
|
||||
Evas_Object *frame;
|
||||
Evas_Object *box;
|
||||
Evas_Object *btn;
|
||||
|
||||
void (*cb)(void *, Evas_Object *, void *);
|
||||
};
|
||||
|
||||
|
@ -317,7 +321,7 @@ _elm_test_sort(const void *pa, const void *pb)
|
|||
static void
|
||||
_elm_test_add(Eina_List **p_list, const char *icon, const char *category, const char *name, void (*cb)(void *, Evas_Object *, void *))
|
||||
{
|
||||
struct elm_test *t = malloc(sizeof(struct elm_test));
|
||||
struct elm_test *t = calloc(1, sizeof(struct elm_test));
|
||||
t->icon = icon;
|
||||
t->category = category;
|
||||
t->name = name;
|
||||
|
@ -344,6 +348,27 @@ _frame_clicked(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_U
|
|||
printf("frame %p is: %s\n", obj, elm_frame_collapse_get(obj) ? "collapsed" : "expanded");
|
||||
}
|
||||
|
||||
static void
|
||||
_clear_menu()
|
||||
{
|
||||
Eina_List *child, *children;
|
||||
Evas_Object *box, *obj, *obj1;
|
||||
|
||||
child = elm_box_children_get(tbx);
|
||||
EINA_LIST_FREE(child, obj)
|
||||
{
|
||||
box = elm_object_content_get(obj);
|
||||
children = elm_box_children_get(box);
|
||||
EINA_LIST_FREE(children, obj1)
|
||||
{
|
||||
evas_object_hide(obj1);
|
||||
}
|
||||
elm_box_unpack_all(box);
|
||||
evas_object_hide(obj);
|
||||
}
|
||||
elm_box_unpack_all(tbx);
|
||||
}
|
||||
|
||||
static void
|
||||
_menu_create(const char *option_str)
|
||||
{
|
||||
|
@ -353,11 +378,18 @@ _menu_create(const char *option_str)
|
|||
char buf[PATH_MAX];
|
||||
Eina_List *l;
|
||||
|
||||
elm_box_clear(tbx);
|
||||
_clear_menu();
|
||||
EINA_LIST_FOREACH(tests, l, t)
|
||||
{
|
||||
if (option_str && !strcasestr(t->name, option_str)) continue;
|
||||
if ((!pcat) || (strcmp(pcat, t->category)))
|
||||
{
|
||||
if (t->frame)
|
||||
{
|
||||
elm_box_pack_end(tbx, t->frame);
|
||||
evas_object_show(t->frame);
|
||||
}
|
||||
else
|
||||
{
|
||||
cfr = elm_frame_add(win);
|
||||
// FIXME: add new style of frame for this
|
||||
|
@ -377,6 +409,15 @@ _menu_create(const char *option_str)
|
|||
elm_object_content_set(cfr, tbx2);
|
||||
evas_object_show(tbx2);
|
||||
}
|
||||
}
|
||||
|
||||
if (t->btn)
|
||||
{
|
||||
elm_box_pack_end(t->box, t->btn);
|
||||
evas_object_show(t->btn);
|
||||
}
|
||||
else
|
||||
{
|
||||
bt = elm_button_add(win);
|
||||
// FIXME: add new style of button for this like efm in e17
|
||||
elm_object_text_set(bt, t->name);
|
||||
|
@ -391,6 +432,10 @@ _menu_create(const char *option_str)
|
|||
elm_box_pack_end(tbx2, bt);
|
||||
evas_object_show(bt);
|
||||
evas_object_smart_callback_add(bt, "clicked", t->cb, win);
|
||||
t->frame = cfr;
|
||||
t->box = tbx2;
|
||||
t->btn = bt;
|
||||
}
|
||||
pcat = t->category;
|
||||
if (t == tt) tt = cfr;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue