diff options
Diffstat (limited to 'src/slideshow.c')
-rw-r--r-- | src/slideshow.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/src/slideshow.c b/src/slideshow.c index e42bd23..7ff4f39 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -322,6 +322,44 @@ void slideshow_change_image(winwidget winwid, int change, int render) try the previous file, not another jmp */ change = SLIDE_NEXT; break; + case SLIDE_JUMP_NEXT_DIR: + { + char old_dir[PATH_MAX], new_dir[PATH_MAX]; + int j; + + feh_file_dirname(old_dir, FEH_FILE(current_file->data), PATH_MAX); + + for (j = 0; j < our_filelist_len; j++) { + current_file = feh_list_jump(filelist, current_file, FORWARD, 1); + feh_file_dirname(new_dir, FEH_FILE(current_file->data), PATH_MAX); + if (strcmp(old_dir, new_dir) != 0) + break; + } + } + change = SLIDE_NEXT; + break; + case SLIDE_JUMP_PREV_DIR: + { + char old_dir[PATH_MAX], new_dir[PATH_MAX]; + int j; + + /* Start the search from the previous file in case we are on + the first file of a directory */ + current_file = feh_list_jump(filelist, current_file, BACK, 1); + feh_file_dirname(old_dir, FEH_FILE(current_file->data), PATH_MAX); + + for (j = 0; j < our_filelist_len; j++) { + current_file = feh_list_jump(filelist, current_file, BACK, 1); + feh_file_dirname(new_dir, FEH_FILE(current_file->data), PATH_MAX); + if (strcmp(old_dir, new_dir) != 0) + break; + } + + /* Next file is the first entry of prev_dir */ + current_file = feh_list_jump(filelist, current_file, FORWARD, 1); + } + change = SLIDE_NEXT; + break; default: eprintf("BUG!\n"); break; @@ -621,7 +659,12 @@ void feh_filelist_image_remove(winwidget winwid, char do_delete) feh_file_rm_and_free(filelist, doomed); exit(0); } - slideshow_change_image(winwid, SLIDE_NEXT, 0); + if (doomed->next) { + slideshow_change_image(winwid, SLIDE_NEXT, 0); + } + else { + slideshow_change_image(winwid, SLIDE_PREV, 0); + } if (do_delete) filelist = feh_file_rm_and_free(filelist, doomed); else |