Mercurial > geeqie
comparison src/view_file_list.c @ 771:24726eddb252
vflist_populate_view: better handle selected files that are renamed or deleted
author | nadvornik |
---|---|
date | Fri, 30 May 2008 21:41:46 +0000 |
parents | 842c15317bdf |
children | f53c2bb5b1b1 |
comparison
equal
deleted
inserted
replaced
770:842c15317bdf | 771:24726eddb252 |
---|---|
704 { | 704 { |
705 return TRUE; | 705 return TRUE; |
706 } | 706 } |
707 */ | 707 */ |
708 | 708 |
709 | |
710 static void vflist_setup_iter(ViewFile *vf, GtkTreeStore *store, GtkTreeIter *iter, FileData *fd) | 709 static void vflist_setup_iter(ViewFile *vf, GtkTreeStore *store, GtkTreeIter *iter, FileData *fd) |
711 { | 710 { |
712 int i; | 711 int i; |
713 gchar *size; | 712 gchar *size; |
714 gchar *sidecars = NULL; | 713 gchar *sidecars = NULL; |
731 g_free(size); | 730 g_free(size); |
732 if (sidecars) | 731 if (sidecars) |
733 g_free(sidecars); | 732 g_free(sidecars); |
734 } | 733 } |
735 | 734 |
736 static void vflist_setup_iter_recursive(ViewFile *vf, GtkTreeStore *store, GtkTreeIter *parent_iter, GList *list, GList *selection) | 735 static void vflist_setup_iter_recursive(ViewFile *vf, GtkTreeStore *store, GtkTreeIter *parent_iter, GList *list, GList *selected) |
737 { | 736 { |
738 GList *work; | 737 GList *work; |
739 GtkTreeIter iter; | 738 GtkTreeIter iter; |
740 gint valid; | 739 gint valid; |
741 | 740 |
792 { | 791 { |
793 gtk_tree_store_append(store, &new, parent_iter); | 792 gtk_tree_store_append(store, &new, parent_iter); |
794 } | 793 } |
795 | 794 |
796 vflist_setup_iter(vf, store, &new, fd); | 795 vflist_setup_iter(vf, store, &new, fd); |
797 vflist_setup_iter_recursive(vf, store, &new, fd->sidecar_files, selection); | 796 vflist_setup_iter_recursive(vf, store, &new, fd->sidecar_files, selected); |
797 | |
798 if (g_list_find(selected, fd)) | |
799 { | |
800 /* renamed files - the same fd appears at different position - select it again*/ | |
801 GtkTreeSelection *selection; | |
802 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview)); | |
803 gtk_tree_selection_select_iter(selection, &new); | |
804 } | |
798 | 805 |
799 done = TRUE; | 806 done = TRUE; |
800 } | 807 } |
801 else if (match > 0) | 808 else if (match > 0) |
802 { | 809 { |
805 else | 812 else |
806 { | 813 { |
807 if (fd->version != old_version) | 814 if (fd->version != old_version) |
808 { | 815 { |
809 vflist_setup_iter(vf, store, &iter, fd); | 816 vflist_setup_iter(vf, store, &iter, fd); |
810 vflist_setup_iter_recursive(vf, store, &iter, fd->sidecar_files, selection); | 817 vflist_setup_iter_recursive(vf, store, &iter, fd->sidecar_files, selected); |
811 } | 818 } |
812 | 819 |
813 if (valid) valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter); | 820 if (valid) valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter); |
814 | 821 |
815 done = TRUE; | 822 done = TRUE; |
1350 gtk_tree_view_set_cursor(GTK_TREE_VIEW(vf->listview), tpath, NULL, FALSE); | 1357 gtk_tree_view_set_cursor(GTK_TREE_VIEW(vf->listview), tpath, NULL, FALSE); |
1351 gtk_tree_path_free(tpath); | 1358 gtk_tree_path_free(tpath); |
1352 } | 1359 } |
1353 } | 1360 } |
1354 | 1361 |
1362 static void vflist_select_closest(ViewFile *vf, FileData *sel_fd) | |
1363 { | |
1364 GList *work; | |
1365 | |
1366 if (sel_fd->parent) sel_fd = sel_fd->parent; | |
1367 work = vf->list; | |
1368 | |
1369 while (work) | |
1370 { | |
1371 gint match; | |
1372 FileData *fd = work->data; | |
1373 work = work->next; | |
1374 | |
1375 | |
1376 match = filelist_sort_compare_filedata_full(fd, sel_fd, vf->sort_method, vf->sort_ascend); | |
1377 | |
1378 if (match >= 0) | |
1379 { | |
1380 vflist_select_by_fd(vf, fd); | |
1381 break; | |
1382 } | |
1383 } | |
1384 | |
1385 } | |
1386 | |
1355 void vflist_mark_to_selection(ViewFile *vf, gint mark, MarkToSelectionMode mode) | 1387 void vflist_mark_to_selection(ViewFile *vf, gint mark, MarkToSelectionMode mode) |
1356 { | 1388 { |
1357 GtkTreeModel *store; | 1389 GtkTreeModel *store; |
1358 GtkTreeIter iter; | 1390 GtkTreeIter iter; |
1359 GtkTreeSelection *selection; | 1391 GtkTreeSelection *selection; |
1468 { | 1500 { |
1469 GtkTreeStore *store; | 1501 GtkTreeStore *store; |
1470 gint thumbs; | 1502 gint thumbs; |
1471 GtkTreeRowReference *visible_row = NULL; | 1503 GtkTreeRowReference *visible_row = NULL; |
1472 GtkTreePath *tpath; | 1504 GtkTreePath *tpath; |
1505 GList *selected; | |
1473 | 1506 |
1474 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview))); | 1507 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview))); |
1475 thumbs = VFLIST_INFO(vf, thumbs_enabled); | 1508 thumbs = VFLIST_INFO(vf, thumbs_enabled); |
1476 | 1509 |
1477 vflist_thumb_stop(vf); | 1510 vflist_thumb_stop(vf); |
1490 gtk_tree_path_free(tpath); | 1523 gtk_tree_path_free(tpath); |
1491 } | 1524 } |
1492 | 1525 |
1493 vflist_listview_set_height(vf->listview, thumbs); | 1526 vflist_listview_set_height(vf->listview, thumbs); |
1494 | 1527 |
1495 vflist_setup_iter_recursive(vf, store, NULL, vf->list, NULL); | 1528 selected = vflist_selection_get_list(vf); |
1529 | |
1530 vflist_setup_iter_recursive(vf, store, NULL, vf->list, selected); | |
1531 | |
1532 if (selected && vflist_selection_count(vf, NULL) == 0) | |
1533 { | |
1534 /* all selected files disappeared */ | |
1535 vflist_select_closest(vf, selected->data); | |
1536 } | |
1537 | |
1538 filelist_free(selected); | |
1496 | 1539 |
1497 if (visible_row) | 1540 if (visible_row) |
1498 { | 1541 { |
1499 if (gtk_tree_row_reference_valid(visible_row)) | 1542 if (gtk_tree_row_reference_valid(visible_row)) |
1500 { | 1543 { |