summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcodewarrior <codewarrior>2005-11-06 13:09:54 +0000
committercodewarrior <codewarrior@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>2005-11-06 13:09:54 +0000
commit773afb13362bbc9fd07a76c4f8e66e06a51ce49e (patch)
tree67711a21c77d8ff64dc436dda57ce72ce280de53
parent582177522c619b04931f9efdddaf698ebf2a495c (diff)
- optimize e_icon_layout (still need to do unpack)
- optimize loading of large folders (10,000+ files load well now) Please test and report bugs. I have found a couple myself but havent traced them down yet. SVN revision: 18339
-rw-r--r--src/bin/e_fileman_smart.c171
-rw-r--r--src/bin/e_icon_layout.c61
2 files changed, 141 insertions, 91 deletions
diff --git a/src/bin/e_fileman_smart.c b/src/bin/e_fileman_smart.c
index 9a4fa12..8ce1f63 100644
--- a/src/bin/e_fileman_smart.c
+++ b/src/bin/e_fileman_smart.c
@@ -122,6 +122,10 @@ struct _E_Fm_Smart_Data
122 Evas_Object *entry_object; 122 Evas_Object *entry_object;
123 123
124 char *dir; 124 char *dir;
125 DIR *dir2;
126
127 double timer_int;
128 Ecore_Timer *timer;
125 129
126 Evas_List *event_handlers; 130 Evas_List *event_handlers;
127 131
@@ -208,7 +212,7 @@ static void _e_fm_file_rename (E_Fm_Icon *icon, const cha
208static void _e_fm_file_delete (E_Fm_Icon *icon); 212static void _e_fm_file_delete (E_Fm_Icon *icon);
209 213
210static void _e_fm_dir_set (E_Fm_Smart_Data *sd, const char *dir); 214static void _e_fm_dir_set (E_Fm_Smart_Data *sd, const char *dir);
211static Evas_List *_e_fm_dir_files_get (E_Fm_Smart_Data *sd, int type); 215static int _e_fm_dir_files_get (void *data);
212static char *_e_fm_dir_pop (const char *path); 216static char *_e_fm_dir_pop (const char *path);
213static void _e_fm_file_free (E_Fm_Icon *icon); 217static void _e_fm_file_free (E_Fm_Icon *icon);
214static void _e_fm_dir_monitor_cb (void *data, Ecore_File_Monitor *ecore_file_monitor, Ecore_File_Event event, const char *path); 218static void _e_fm_dir_monitor_cb (void *data, Ecore_File_Monitor *ecore_file_monitor, Ecore_File_Event event, const char *path);
@@ -496,6 +500,9 @@ _e_fm_smart_add(Evas_Object *object)
496 sd->icon_info.x_space = 12; 500 sd->icon_info.x_space = 12;
497 sd->icon_info.y_space = 10; 501 sd->icon_info.y_space = 10;
498 502
503 sd->timer_int = 0.001;
504 sd->timer = NULL;
505
499 sd->evas = evas_object_evas_get(object); 506 sd->evas = evas_object_evas_get(object);
500 sd->frozen = 0; 507 sd->frozen = 0;
501 sd->is_selector = 0; 508 sd->is_selector = 0;
@@ -606,6 +613,14 @@ _e_fm_smart_del(Evas_Object *object)
606 613
607 e_config_domain_save("efm", sd->conf.main_edd, sd->conf.main); 614 e_config_domain_save("efm", sd->conf.main_edd, sd->conf.main);
608 615
616 if(sd->timer)
617 {
618 if(sd->dir2)
619 closedir(sd->dir2);
620 ecore_timer_del(sd->timer);
621 sd->timer = NULL;
622 }
623
609 if (sd->monitor) ecore_file_monitor_del(sd->monitor); 624 if (sd->monitor) ecore_file_monitor_del(sd->monitor);
610 sd->monitor = NULL; 625 sd->monitor = NULL;
611 626
@@ -621,7 +636,7 @@ _e_fm_smart_del(Evas_Object *object)
621 _e_fm_file_free(sd->files->data); 636 _e_fm_file_free(sd->files->data);
622 sd->files = evas_list_remove_list(sd->files, sd->files); 637 sd->files = evas_list_remove_list(sd->files, sd->files);
623 } 638 }
624 639
625 evas_object_del(sd->selection.band.obj); 640 evas_object_del(sd->selection.band.obj);
626 evas_object_del(sd->clip); 641 evas_object_del(sd->clip);
627 evas_object_del(sd->bg); 642 evas_object_del(sd->bg);
@@ -1317,10 +1332,13 @@ _e_fm_dir_set(E_Fm_Smart_Data *sd, const char *dir)
1317 Evas_List *l; 1332 Evas_List *l;
1318 E_Event_Fm_Reconfigure *ev; 1333 E_Event_Fm_Reconfigure *ev;
1319 E_Event_Fm_Directory_Change *ev2; 1334 E_Event_Fm_Directory_Change *ev2;
1335 DIR *dir2;
1320 1336
1321 if (!dir) return; 1337 if (!dir) return;
1322 if ((sd->dir) && (!strcmp(sd->dir, dir))) return; 1338 if ((sd->dir) && (!strcmp(sd->dir, dir))) return;
1323 1339
1340 if (!(dir2 = opendir(dir))) return;
1341
1324 if (sd->dir) free (sd->dir); 1342 if (sd->dir) free (sd->dir);
1325 sd->dir = strdup(dir); 1343 sd->dir = strdup(dir);
1326 1344
@@ -1336,9 +1354,9 @@ _e_fm_dir_set(E_Fm_Smart_Data *sd, const char *dir)
1336 _e_fm_file_free(sd->files->data); 1354 _e_fm_file_free(sd->files->data);
1337 sd->files = evas_list_remove_list(sd->files, sd->files); 1355 sd->files = evas_list_remove_list(sd->files, sd->files);
1338 } 1356 }
1357 e_icon_layout_reset(sd->layout);
1339 1358
1340 /* Get new files */ 1359 /* Get new files */
1341 sd->files = _e_fm_dir_files_get(sd, E_FM_FILE_TYPE_NORMAL);
1342 if (sd->monitor) ecore_file_monitor_del(sd->monitor); 1360 if (sd->monitor) ecore_file_monitor_del(sd->monitor);
1343 sd->monitor = ecore_file_monitor_add(sd->dir, _e_fm_dir_monitor_cb, sd); 1361 sd->monitor = ecore_file_monitor_add(sd->dir, _e_fm_dir_monitor_cb, sd);
1344 1362
@@ -1346,8 +1364,8 @@ _e_fm_dir_set(E_Fm_Smart_Data *sd, const char *dir)
1346 if (strcmp(sd->dir, "/")) 1364 if (strcmp(sd->dir, "/"))
1347 { 1365 {
1348 E_Fm_Icon *icon; 1366 E_Fm_Icon *icon;
1349 char path[PATH_MAX]; 1367 char path[PATH_MAX];
1350 1368
1351 icon = E_NEW(E_Fm_Icon, 1); 1369 icon = E_NEW(E_Fm_Icon, 1);
1352 if (icon) 1370 if (icon)
1353 { 1371 {
@@ -1357,79 +1375,45 @@ _e_fm_dir_set(E_Fm_Smart_Data *sd, const char *dir)
1357 icon->file->type = E_FM_FILE_TYPE_DIRECTORY; 1375 icon->file->type = E_FM_FILE_TYPE_DIRECTORY;
1358 icon->icon_object = e_fm_icon_add(sd->evas); 1376 icon->icon_object = e_fm_icon_add(sd->evas);
1359 icon->sd = sd; 1377 icon->sd = sd;
1360 e_fm_icon_file_set(icon->icon_object, icon->file); 1378 e_fm_icon_file_set(icon->icon_object, icon->file);
1361 //evas_object_resize(icon->icon_object,
1362 //sd->icon_info.w,
1363 //sd->icon_info.h);
1364 sd->files = evas_list_prepend(sd->files, icon); 1379 sd->files = evas_list_prepend(sd->files, icon);
1380 e_icon_layout_pack(sd->layout, icon->icon_object);
1381 evas_object_event_callback_add(icon->icon_object, EVAS_CALLBACK_MOUSE_DOWN, _e_fm_icon_mouse_down_cb, icon);
1382 evas_object_event_callback_add(icon->icon_object, EVAS_CALLBACK_MOUSE_UP, _e_fm_icon_mouse_up_cb, icon);
1383 evas_object_event_callback_add(icon->icon_object, EVAS_CALLBACK_MOUSE_IN, _e_fm_icon_mouse_in_cb, icon);
1384 evas_object_event_callback_add(icon->icon_object, EVAS_CALLBACK_MOUSE_OUT, _e_fm_icon_mouse_out_cb, icon);
1365 } 1385 }
1366 } 1386 }
1367
1368 /* Add icons to layout */
1369 e_icon_layout_freeze(sd->layout);
1370 for (l = sd->files; l; l = l->next)
1371 {
1372 E_Fm_Icon *icon;
1373
1374 icon = l->data;
1375
1376 //evas_object_resize(icon->icon_object,
1377 // sd->icon_info.w,
1378 // sd->icon_info.h);
1379 evas_object_show(icon->icon_object);
1380 e_icon_layout_pack(sd->layout, icon->icon_object);
1381 evas_object_event_callback_add(icon->icon_object, EVAS_CALLBACK_MOUSE_DOWN, _e_fm_icon_mouse_down_cb, icon);
1382 evas_object_event_callback_add(icon->icon_object, EVAS_CALLBACK_MOUSE_UP, _e_fm_icon_mouse_up_cb, icon);
1383 evas_object_event_callback_add(icon->icon_object, EVAS_CALLBACK_MOUSE_IN, _e_fm_icon_mouse_in_cb, icon);
1384 evas_object_event_callback_add(icon->icon_object, EVAS_CALLBACK_MOUSE_OUT, _e_fm_icon_mouse_out_cb, icon);
1385 }
1386 e_icon_layout_thaw(sd->layout);
1387
1388 /* Draw layout */
1389 _e_fm_redraw(sd);
1390
1391 /* raise dir change event */
1392 ev2 = E_NEW(E_Event_Fm_Directory_Change, 1);
1393 if (ev2)
1394 {
1395 ev2->object = sd->object;
1396 ev2->w = sd->child.w;
1397 ev2->h = sd->child.h;
1398 ecore_event_add(E_EVENT_FM_DIRECTORY_CHANGE, ev2, NULL, NULL);
1399 }
1400
1401 if (sd->frozen)
1402 return;
1403
1404 /* raise reconfigure event */
1405 e_icon_layout_virtual_size_get(sd->layout, &sd->child.w, &sd->child.h);
1406 evas_object_smart_callback_call(sd->object, "changed", NULL);
1407 1387
1408 ev = E_NEW(E_Event_Fm_Reconfigure, 1); 1388 sd->dir2 = dir2;
1409 if (ev) 1389 if(sd->timer)
1410 { 1390 ecore_timer_del(sd->timer);
1411 e_icon_layout_virtual_size_get(sd->layout, &sd->child.w, &sd->child.h); 1391 sd->timer = ecore_timer_add(sd->timer_int, _e_fm_dir_files_get, sd);
1412 ev->object = sd->object;
1413 ev->w = sd->child.w;
1414 ev->h = sd->child.h;
1415 //ecore_event_add(E_EVENT_FM_RECONFIGURE, ev, NULL, NULL);
1416 }
1417} 1392}
1418 1393
1419static Evas_List * 1394static int
1420_e_fm_dir_files_get(E_Fm_Smart_Data *sd, int type) 1395_e_fm_dir_files_get(void *data)
1421{ 1396{
1422 DIR *dir; 1397 E_Fm_Smart_Data *sd;
1423 char path[PATH_MAX]; 1398 Evas_List *l;
1424 struct dirent *dir_entry; 1399 E_Fm_Icon *icon;
1425 Evas_List *files = NULL; 1400 struct dirent *dir_entry;
1426 1401 char path[PATH_MAX];
1427 if (!(dir = opendir(sd->dir))) return NULL; 1402 int i;
1403 int type;
1404
1405 /* FIXME: This needs to be passed in to decide what file types to show */
1406 type = E_FM_FILE_TYPE_NORMAL;
1407 i = 0;
1408 sd = data;
1409
1410 e_icon_layout_freeze(sd->layout);
1428 1411
1429 while ((dir_entry = readdir(dir)) != NULL) 1412 while (i < 2)
1430 { 1413 {
1431 E_Fm_Icon *icon; 1414 dir_entry = readdir(sd->dir2);
1432 1415 if(!dir_entry)
1416 break;
1433 if ((!strcmp(dir_entry->d_name, ".") || (!strcmp (dir_entry->d_name, "..")))) continue; 1417 if ((!strcmp(dir_entry->d_name, ".") || (!strcmp (dir_entry->d_name, "..")))) continue;
1434 if ((dir_entry->d_name[0] == '.') && (!(type & E_FM_FILE_TYPE_HIDDEN))) continue; 1418 if ((dir_entry->d_name[0] == '.') && (!(type & E_FM_FILE_TYPE_HIDDEN))) continue;
1435 1419
@@ -1446,17 +1430,45 @@ _e_fm_dir_files_get(E_Fm_Smart_Data *sd, int type)
1446 icon->icon_object = e_fm_icon_add(sd->evas); 1430 icon->icon_object = e_fm_icon_add(sd->evas);
1447 icon->sd = sd; 1431 icon->sd = sd;
1448 e_fm_icon_file_set(icon->icon_object, icon->file); 1432 e_fm_icon_file_set(icon->icon_object, icon->file);
1449 //evas_object_resize(icon->icon_object, 1433 sd->files = evas_list_append(sd->files, icon);
1450 //sd->icon_info.w, 1434 evas_object_event_callback_add(icon->icon_object, EVAS_CALLBACK_MOUSE_DOWN, _e_fm_icon_mouse_down_cb, icon);
1451 //sd->icon_info.h); 1435 evas_object_event_callback_add(icon->icon_object, EVAS_CALLBACK_MOUSE_UP, _e_fm_icon_mouse_up_cb, icon);
1452 files = evas_list_append(files, icon); 1436 evas_object_event_callback_add(icon->icon_object, EVAS_CALLBACK_MOUSE_IN, _e_fm_icon_mouse_in_cb, icon);
1437 evas_object_event_callback_add(icon->icon_object, EVAS_CALLBACK_MOUSE_OUT, _e_fm_icon_mouse_out_cb, icon);
1438 evas_object_show(icon->icon_object);
1439 e_icon_layout_pack(sd->layout, icon->icon_object);
1453 } 1440 }
1441 i++;
1454 } 1442 }
1455 closedir(dir);
1456 1443
1457 files = evas_list_sort(files, evas_list_count(files), _e_fm_files_sort_name_cb); 1444 e_icon_layout_thaw(sd->layout);
1458 1445
1459 return files; 1446 e_icon_layout_virtual_size_get(sd->layout, &sd->child.w, &sd->child.h);
1447 evas_object_smart_callback_call(sd->object, "changed", NULL);
1448
1449 if(!dir_entry) {
1450 closedir(sd->dir2);
1451 sd->files = evas_list_sort(sd->files,
1452 evas_list_count(sd->files),
1453 _e_fm_files_sort_name_cb);
1454
1455 e_icon_layout_freeze(sd->layout);
1456 e_icon_layout_reset(sd->layout);
1457
1458 for(l = sd->files; l; l = l->next)
1459 {
1460 icon = l->data;
1461 e_icon_layout_pack(sd->layout, icon->icon_object);
1462 }
1463 e_icon_layout_thaw(sd->layout);
1464 sd->timer = NULL;
1465 return 0;
1466 }
1467 else
1468 {
1469 sd->timer = ecore_timer_add(sd->timer_int, _e_fm_dir_files_get, sd);
1470 return 0;
1471 }
1460} 1472}
1461 1473
1462static char * 1474static char *
@@ -2354,7 +2366,6 @@ _e_fm_icon_select_down(E_Fm_Smart_Data *sd)
2354 if(!E_CONTAINS(sd->x, sd->y, sd->w, sd->h, x, y, w, h)) 2366 if(!E_CONTAINS(sd->x, sd->y, sd->w, sd->h, x, y, w, h))
2355 { 2367 {
2356 E_Event_Fm_Reconfigure *ev; 2368 E_Event_Fm_Reconfigure *ev;
2357 printf("!E_CONTAINS %s\n", icon->file->name);
2358 ev = E_NEW(E_Event_Fm_Reconfigure, 1); 2369 ev = E_NEW(E_Event_Fm_Reconfigure, 1);
2359 if (ev) 2370 if (ev)
2360 { 2371 {
diff --git a/src/bin/e_icon_layout.c b/src/bin/e_icon_layout.c
index 6db4474..82bb98d 100644
--- a/src/bin/e_icon_layout.c
+++ b/src/bin/e_icon_layout.c
@@ -13,6 +13,7 @@ struct _E_Smart_Data
13 Evas_Coord vw, vh; 13 Evas_Coord vw, vh;
14 Evas_Coord xs, ys; 14 Evas_Coord xs, ys;
15 Evas_Coord xc, yc; 15 Evas_Coord xc, yc;
16 Evas_Coord mw, mh;
16 Evas_Object *clip; 17 Evas_Object *clip;
17 Evas_Object *obj; 18 Evas_Object *obj;
18 int frozen; 19 int frozen;
@@ -143,8 +144,40 @@ e_icon_layout_pack(Evas_Object *obj, Evas_Object *child)
143 _e_icon_layout_smart_adopt(sd, child); 144 _e_icon_layout_smart_adopt(sd, child);
144 sd->items = evas_list_append(sd->items, child); 145 sd->items = evas_list_append(sd->items, child);
145 li = evas_object_data_get(child, "e_icon_layout_data"); 146 li = evas_object_data_get(child, "e_icon_layout_data");
146 li->x = sd->xc; 147
147 li->y = sd->yc; 148 if (sd->fixed == 0)
149 {
150 if(li->h > sd->mh) sd->mh = li->h;
151 if(sd->xc > sd->x + sd->vw || sd->xc + li->w > sd->x + sd->vw)
152 {
153 sd->xc = sd->x + sd->xs;
154 sd->yc += sd->mh + sd->ys;
155 sd->mh = 0;
156 }
157
158 li->x = sd->xc;
159 li->y = sd->yc;
160
161 sd->xc += li->w + sd->xs;
162 sd->vh = sd->yc - sd->y;
163 }
164 else
165 {
166 if(li->w > sd->mw) sd->mw = li->w;
167
168 if(sd->yc > sd->y + sd->vh || sd->yc + li->h > sd->y + sd->vh)
169 {
170 sd->yc = sd->y + sd->ys;
171 sd->xc += sd->mw + sd->xs;
172 sd->mw = 0;
173 }
174
175 li->x = sd->xc;
176 li->y = sd->yc;
177
178 sd->yc += li->h + sd->ys;
179 sd->vw = sd->xc - sd->x;
180 }
148 _e_icon_layout_smart_move_resize_item(li); 181 _e_icon_layout_smart_move_resize_item(li);
149} 182}
150 183
@@ -171,8 +204,8 @@ e_icon_layout_unpack(Evas_Object *obj)
171 204
172 li = evas_object_data_get(obj, "e_icon_layout_data"); 205 li = evas_object_data_get(obj, "e_icon_layout_data");
173 if (!li) return; 206 if (!li) return;
174 sd = li->sd; 207 sd = li->sd;
175 sd->items = evas_list_remove(sd->items, obj); 208 sd->items = evas_list_remove(sd->items, obj);
176 _e_icon_layout_smart_disown(obj); 209 _e_icon_layout_smart_disown(obj);
177} 210}
178 211
@@ -221,6 +254,8 @@ e_icon_layout_reset(Evas_Object *obj)
221 254
222 sd->xc = sd->x + sd->xs; 255 sd->xc = sd->x + sd->xs;
223 sd->yc = sd->y + sd->ys; 256 sd->yc = sd->y + sd->ys;
257 sd->mw = 0;
258 sd->mh = 0;
224 259
225 while (sd->items) 260 while (sd->items)
226 { 261 {
@@ -258,16 +293,16 @@ static E_Icon_Layout_Item *
258_e_icon_layout_smart_adopt(E_Smart_Data *sd, Evas_Object *obj) 293_e_icon_layout_smart_adopt(E_Smart_Data *sd, Evas_Object *obj)
259{ 294{
260 E_Icon_Layout_Item *li; 295 E_Icon_Layout_Item *li;
296 Evas_Coord w, h;
261 297
262 li = calloc(1, sizeof(E_Icon_Layout_Item)); 298 li = calloc(1, sizeof(E_Icon_Layout_Item));
263 if (!li) return NULL; 299 if (!li) return NULL;
264 li->sd = sd; 300 li->sd = sd;
265 li->obj = obj; 301 li->obj = obj;
302 evas_object_geometry_get(obj, NULL, NULL, &li->w, &li->h);
266 /* defaults */ 303 /* defaults */
267 li->x = 0; 304 li->x = 0;
268 li->y = 0; 305 li->y = 0;
269 li->w = 0;
270 li->h = 0;
271 evas_object_clip_set(obj, sd->clip); 306 evas_object_clip_set(obj, sd->clip);
272 evas_object_smart_member_add(obj, li->sd->obj); 307 evas_object_smart_member_add(obj, li->sd->obj);
273 evas_object_show(obj); 308 evas_object_show(obj);
@@ -312,7 +347,7 @@ _e_icon_layout_smart_reconfigure(E_Smart_Data *sd)
312 Evas_Coord x, y, w, h, maxw, maxh; 347 Evas_Coord x, y, w, h, maxw, maxh;
313 Evas_List *l; 348 Evas_List *l;
314 349
315 //if (!sd->changed) return; 350 if (!sd->changed) return;
316 351
317 x = sd->x + sd->xs; 352 x = sd->x + sd->xs;
318 y = sd->y + sd->ys; 353 y = sd->y + sd->ys;
@@ -390,11 +425,13 @@ _e_icon_layout_smart_reconfigure(E_Smart_Data *sd)
390static void 425static void
391_e_icon_layout_smart_move_resize_item(E_Icon_Layout_Item *li) 426_e_icon_layout_smart_move_resize_item(E_Icon_Layout_Item *li)
392{ 427{
393 if(li->w == 0 || li->h == 0) 428 if(li->w == 0 || li->h == 0)
394 evas_object_geometry_get(li->obj, NULL, NULL, &li->w, &li->h); 429 {
430 evas_object_geometry_get(li->obj, NULL, NULL, &li->w, &li->h);
431 evas_object_resize(li->obj, li->w, li->h);
432 }
395 433
396 evas_object_move(li->obj, li->x, li->y); 434 evas_object_move(li->obj, li->x, li->y);
397 //evas_object_resize(li->obj, li->w, li->h);
398} 435}
399 436
400static void 437static void
@@ -455,6 +492,8 @@ _e_icon_layout_smart_add(Evas_Object *obj)
455 sd->ys = 0; 492 sd->ys = 0;
456 sd->xc = 0; 493 sd->xc = 0;
457 sd->yc = 0; 494 sd->yc = 0;
495 sd->mw = 0;
496 sd->mh = 0;
458 sd->fixed = 0; 497 sd->fixed = 0;
459 sd->clip = evas_object_rectangle_add(evas_object_evas_get(obj)); 498 sd->clip = evas_object_rectangle_add(evas_object_evas_get(obj));
460 evas_object_move(sd->clip, 0, 0); 499 evas_object_move(sd->clip, 0, 0);