summaryrefslogtreecommitdiff
path: root/src/bin/e_fileman_smart.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/e_fileman_smart.c')
-rw-r--r--src/bin/e_fileman_smart.c171
1 files changed, 91 insertions, 80 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 {