# HG changeset patch # User nadvornik # Date 1213038047 0 # Node ID f1ce599855184ecabad7cea6962fec9bd98615f5 # Parent 602cec93258729a0d0c3e3df50969b81f98f65db handle deletion of selected files diff -r 602cec932587 -r f1ce59985518 src/view_file_icon.c --- a/src/view_file_icon.c Mon Jun 09 18:28:28 2008 +0000 +++ b/src/view_file_icon.c Mon Jun 09 19:00:47 2008 +0000 @@ -965,6 +965,32 @@ filelist_free(slist); } +static void vficon_select_closest(ViewFile *vf, FileData *sel_fd) +{ + GList *work; + + if (sel_fd->parent) sel_fd = sel_fd->parent; + work = vf->list; + + while (work) + { + gint match; + IconData *id = work->data; + FileData *fd = id->fd; + work = work->next; + + + match = filelist_sort_compare_filedata_full(fd, sel_fd, vf->sort_method, vf->sort_ascend); + + if (match >= 0) + { + vficon_select(vf, id); + break; + } + } + +} + /* *------------------------------------------------------------------- @@ -2062,6 +2088,8 @@ GList *work, *work_fd; IconData *focus_id; GList *new_filelist = NULL; + GList *selected; + gint num_selected = 0; focus_id = VFICON_INFO(vf, focus_id); @@ -2073,6 +2101,8 @@ vf->list = iconlist_sort(vf->list, vf->sort_method, vf->sort_ascend); /* the list might not be sorted if there were renames */ new_filelist = filelist_sort(new_filelist, vf->sort_method, vf->sort_ascend); + selected = vficon_selection_get_list(vf); + /* check for same files from old_list */ work = vf->list; work_fd = new_filelist; @@ -2095,6 +2125,7 @@ /* not changed, go to next */ work = work->next; work_fd = work_fd->next; + if (id->selected & SELECTION_SELECTED) num_selected++; continue; } @@ -2140,6 +2171,14 @@ filelist_free(new_filelist); + if (selected && num_selected == 0) + { + /* all selected files disappeared */ + vficon_select_closest(vf, selected->data); + } + + filelist_free(selected); + vficon_populate(vf, TRUE, keep_position); /* attempt to keep focus on same icon when refreshing */