panel test is now less retarded and opens much faster

SVN revision: 67863
This commit is contained in:
Mike Blumenkrantz 2012-02-12 22:35:56 +00:00
parent b3af72d606
commit a36ff02e72
1 changed files with 24 additions and 15 deletions

View File

@ -4,6 +4,8 @@
#endif #endif
#ifndef ELM_LIB_QUICKLAUNCH #ifndef ELM_LIB_QUICKLAUNCH
#define LIST_ITEM_MAX 20
static Elm_Genlist_Item_Class itc; static Elm_Genlist_Item_Class itc;
static void _bstatus(void *data, Evas_Object *obj, void *event_info); static void _bstatus(void *data, Evas_Object *obj, void *event_info);
@ -15,6 +17,8 @@ static void _item_del(void *data, Evas_Object *obj);
static void _fill_list(Evas_Object *obj); static void _fill_list(Evas_Object *obj);
static Eina_Bool _dir_has_subs(const char *path); static Eina_Bool _dir_has_subs(const char *path);
static Eina_List *dirs = NULL;
static void static void
_tstatus(void *data, Evas_Object *obj, void *event_info __UNUSED__) _tstatus(void *data, Evas_Object *obj, void *event_info __UNUSED__)
{ {
@ -87,24 +91,26 @@ _fill_list(Evas_Object *obj)
{ {
DIR *d; DIR *d;
struct dirent *de; struct dirent *de;
Eina_List *dirs = NULL, *l; Eina_List *l;
char *real; char *real;
unsigned int x = 0;
if (!(d = opendir(getenv("HOME")))) return; if (!dirs)
while ((de = readdir(d)))
{ {
char buff[PATH_MAX]; if (!(d = opendir(getenv("HOME")))) return;
while ((de = readdir(d)) && (x < LIST_ITEM_MAX))
{
char buff[PATH_MAX];
if (de->d_name[0] == '.') continue; if (de->d_name[0] == '.') continue;
snprintf(buff, sizeof(buff), "%s/%s", getenv("HOME"), de->d_name); snprintf(buff, sizeof(buff), "%s/%s", getenv("HOME"), de->d_name);
if (!ecore_file_is_dir(buff)) continue; if (!ecore_file_is_dir(buff)) continue;
real = ecore_file_realpath(buff); x++;
dirs = eina_list_append(dirs, real); real = ecore_file_realpath(buff);
dirs = eina_list_sorted_insert(dirs, EINA_COMPARE_CB(strcoll), real);
}
closedir(d);
} }
closedir(d);
dirs = eina_list_sort(dirs, eina_list_count(dirs), EINA_COMPARE_CB(strcoll));
EINA_LIST_FOREACH(dirs, l, real) EINA_LIST_FOREACH(dirs, l, real)
{ {
Eina_Bool result = EINA_FALSE; Eina_Bool result = EINA_FALSE;
@ -117,9 +123,7 @@ _fill_list(Evas_Object *obj)
elm_genlist_item_append(obj, &itc, eina_stringshare_add(real), elm_genlist_item_append(obj, &itc, eina_stringshare_add(real),
NULL, ELM_GENLIST_ITEM_SUBITEMS, NULL, ELM_GENLIST_ITEM_SUBITEMS,
NULL, NULL); NULL, NULL);
free(real);
} }
eina_list_free(dirs);
} }
static Eina_Bool static Eina_Bool
@ -234,6 +238,11 @@ test_panel(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
evas_object_show(panel); evas_object_show(panel);
_fill_list(list); _fill_list(list);
{
char *dir;
EINA_LIST_FREE(dirs, dir)
free(dir);
}
elm_box_pack_end(vbx, bx); elm_box_pack_end(vbx, bx);