Mercurial > geeqie
comparison src/filedata.c @ 923:893cd191db23
removed file_data_add_change_info
reduced code redundancy - patch by Laurent, slightly modified
author | nadvornik |
---|---|
date | Wed, 23 Jul 2008 20:53:05 +0000 |
parents | 408879d2a660 |
children | 6a42ab7051f2 |
comparison
equal
deleted
inserted
replaced
922:826d5862f671 | 923:893cd191db23 |
---|---|
641 | 641 |
642 if (len1 < len2) return -1; | 642 if (len1 < len2) return -1; |
643 if (len1 > len2) return 1; | 643 if (len1 > len2) return 1; |
644 | 644 |
645 return strncmp(fd1->name, fd2->name, len1); /* FIXME: utf8 */ | 645 return strncmp(fd1->name, fd2->name, len1); /* FIXME: utf8 */ |
646 } | |
647 | |
648 gboolean file_data_add_change_info(FileData *fd, FileDataChangeType type, const gchar *src, const gchar *dest) | |
649 { | |
650 FileDataChangeInfo *fdci; | |
651 | |
652 if (fd->change) return FALSE; | |
653 | |
654 fdci = g_new0(FileDataChangeInfo, 1); | |
655 fdci->type = type; | |
656 | |
657 if (src) | |
658 fdci->source = g_strdup(src); | |
659 else | |
660 fdci->source = g_strdup(fd->path); | |
661 | |
662 if (dest) | |
663 fdci->dest = g_strdup(dest); | |
664 | |
665 fd->change = fdci; | |
666 | |
667 return TRUE; | |
668 } | 646 } |
669 | 647 |
670 void file_data_change_info_free(FileDataChangeInfo *fdci, FileData *fd) | 648 void file_data_change_info_free(FileDataChangeInfo *fdci, FileData *fd) |
671 { | 649 { |
672 if (!fdci && fd) | 650 if (!fdci && fd) |
1348 file_data_sc_free_ci(fd); | 1326 file_data_sc_free_ci(fd); |
1349 work = work->prev; | 1327 work = work->prev; |
1350 } | 1328 } |
1351 } | 1329 } |
1352 | 1330 |
1353 | 1331 static gboolean file_data_sc_add_ci_list_call_func(GList *fd_list, const gchar *dest, gboolean (*func)(FileData *, const gchar *)) |
1354 gboolean file_data_sc_add_ci_copy_list(GList *fd_list, const gchar *dest) | |
1355 { | 1332 { |
1356 GList *work; | 1333 GList *work; |
1357 | 1334 |
1358 work = fd_list; | 1335 work = fd_list; |
1359 while (work) | 1336 while (work) |
1360 { | 1337 { |
1361 FileData *fd = work->data; | 1338 FileData *fd = work->data; |
1362 | 1339 |
1363 if (!file_data_sc_add_ci_copy(fd, dest)) | 1340 if (!func(fd, dest)) |
1364 { | 1341 { |
1365 file_data_sc_revert_ci_list(work->prev); | 1342 file_data_sc_revert_ci_list(work->prev); |
1366 return FALSE; | 1343 return FALSE; |
1367 } | 1344 } |
1368 work = work->next; | 1345 work = work->next; |
1369 } | 1346 } |
1370 | 1347 |
1371 return TRUE; | 1348 return TRUE; |
1372 } | 1349 } |
1373 | 1350 |
1351 gboolean file_data_sc_add_ci_copy_list(GList *fd_list, const gchar *dest) | |
1352 { | |
1353 return file_data_sc_add_ci_list_call_func(fd_list, dest, file_data_sc_add_ci_copy); | |
1354 } | |
1355 | |
1374 gboolean file_data_sc_add_ci_move_list(GList *fd_list, const gchar *dest) | 1356 gboolean file_data_sc_add_ci_move_list(GList *fd_list, const gchar *dest) |
1375 { | 1357 { |
1376 GList *work; | 1358 return file_data_sc_add_ci_list_call_func(fd_list, dest, file_data_sc_add_ci_move); |
1377 | |
1378 work = fd_list; | |
1379 while (work) | |
1380 { | |
1381 FileData *fd = work->data; | |
1382 | |
1383 if (!file_data_sc_add_ci_move(fd, dest)) | |
1384 { | |
1385 file_data_sc_revert_ci_list(work->prev); | |
1386 return FALSE; | |
1387 } | |
1388 work = work->next; | |
1389 } | |
1390 | |
1391 return TRUE; | |
1392 } | 1359 } |
1393 | 1360 |
1394 gboolean file_data_sc_add_ci_rename_list(GList *fd_list, const gchar *dest) | 1361 gboolean file_data_sc_add_ci_rename_list(GList *fd_list, const gchar *dest) |
1395 { | 1362 { |
1396 GList *work; | 1363 return file_data_sc_add_ci_list_call_func(fd_list, dest, file_data_sc_add_ci_rename); |
1397 | |
1398 work = fd_list; | |
1399 while (work) | |
1400 { | |
1401 FileData *fd = work->data; | |
1402 | |
1403 if (!file_data_sc_add_ci_rename(fd, dest)) | |
1404 { | |
1405 file_data_sc_revert_ci_list(work->prev); | |
1406 return FALSE; | |
1407 } | |
1408 work = work->next; | |
1409 } | |
1410 | |
1411 return TRUE; | |
1412 } | 1364 } |
1413 | 1365 |
1414 gboolean file_data_sc_add_ci_unspecified_list(GList *fd_list, const gchar *dest) | 1366 gboolean file_data_sc_add_ci_unspecified_list(GList *fd_list, const gchar *dest) |
1415 { | 1367 { |
1416 GList *work; | 1368 return file_data_sc_add_ci_list_call_func(fd_list, dest, file_data_sc_add_ci_unspecified); |
1417 | |
1418 work = fd_list; | |
1419 while (work) | |
1420 { | |
1421 FileData *fd = work->data; | |
1422 | |
1423 if (!file_data_sc_add_ci_unspecified(fd, dest)) | |
1424 { | |
1425 file_data_sc_revert_ci_list(work->prev); | |
1426 return FALSE; | |
1427 } | |
1428 work = work->next; | |
1429 } | |
1430 | |
1431 return TRUE; | |
1432 } | 1369 } |
1433 | 1370 |
1434 void file_data_sc_free_ci_list(GList *fd_list) | 1371 void file_data_sc_free_ci_list(GList *fd_list) |
1435 { | 1372 { |
1436 GList *work; | 1373 GList *work; |