diff options
author | guns <self@sungpae.com> | 2016-05-28 00:19:45 -0500 |
---|---|---|
committer | guns <self@sungpae.com> | 2016-05-28 00:19:45 -0500 |
commit | 5df711cbae423ed2b51b84d12a1e92f07de50de3 (patch) | |
tree | 125a238230eeb3afe197d15fa17932ad9ee10c9f /src | |
parent | 315bac4637537654b4711867911458c3a6974c7e (diff) |
Add --sort mtime to menu and fix menu when sorting by mtime
We did not preload when SORT_MTIME, so check opt.sort > SORT_MTIME
before offering to sort by file size.
The CB_* enum block was run through s/, /,\n\t/g for legibility.
Diffstat (limited to 'src')
-rw-r--r-- | src/menu.c | 49 |
1 files changed, 40 insertions, 9 deletions
@@ -49,14 +49,38 @@ void feh_menu_cb(feh_menu * m, feh_menu_item * i, int action, unsigned short dat void feh_menu_cb_opt_fullscreen(feh_menu * m, feh_menu_item * i); enum { - CB_CLOSE = 1, CB_EXIT, CB_RELOAD, CB_REMOVE, CB_DELETE, CB_RESET, - CB_REMOVE_THUMB, CB_DELETE_THUMB, CB_BG_TILED, CB_BG_SCALED, - CB_BG_CENTERED, CB_BG_FILLED, CB_BG_TILED_NOFILE, - CB_BG_SCALED_NOFILE, CB_BG_CENTERED_NOFILE, CB_BG_FILLED_NOFILE, - CB_SORT_FILENAME, CB_SORT_IMAGENAME, CB_SORT_FILESIZE, CB_SORT_RANDOMIZE, - CB_SAVE_IMAGE, CB_SAVE_FILELIST, CB_FIT, CB_OPT_DRAW_FILENAME, - CB_OPT_DRAW_ACTIONS, CB_OPT_KEEP_HTTP, CB_OPT_FREEZE_WINDOW, - CB_OPT_FULLSCREEN, CB_EDIT_ROTATE, CB_OPT_AUTO_ZOOM, CB_OPT_KEEP_ZOOM_VP + CB_CLOSE = 1, + CB_EXIT, + CB_RELOAD, + CB_REMOVE, + CB_DELETE, + CB_RESET, + CB_REMOVE_THUMB, + CB_DELETE_THUMB, + CB_BG_TILED, + CB_BG_SCALED, + CB_BG_CENTERED, + CB_BG_FILLED, + CB_BG_TILED_NOFILE, + CB_BG_SCALED_NOFILE, + CB_BG_CENTERED_NOFILE, + CB_BG_FILLED_NOFILE, + CB_SORT_FILENAME, + CB_SORT_IMAGENAME, + CB_SORT_MTIME, + CB_SORT_FILESIZE, + CB_SORT_RANDOMIZE, + CB_SAVE_IMAGE, + CB_SAVE_FILELIST, + CB_FIT, + CB_OPT_DRAW_FILENAME, + CB_OPT_DRAW_ACTIONS, + CB_OPT_KEEP_HTTP, + CB_OPT_FREEZE_WINDOW, + CB_OPT_FULLSCREEN, + CB_EDIT_ROTATE, + CB_OPT_AUTO_ZOOM, + CB_OPT_KEEP_ZOOM_VP }; feh_menu *feh_menu_new(void) @@ -923,7 +947,8 @@ void feh_menu_init_common() feh_menu_add_entry(m, "By File Name", NULL, CB_SORT_FILENAME, 0, NULL); feh_menu_add_entry(m, "By Image Name", NULL, CB_SORT_IMAGENAME, 0, NULL); - if (opt.preload || (opt.sort > SORT_FILENAME)) + feh_menu_add_entry(m, "By Modification Date", NULL, CB_SORT_MTIME, 0, NULL); + if (opt.preload || (opt.sort > SORT_MTIME)) feh_menu_add_entry(m, "By File Size", NULL, CB_SORT_FILESIZE, 0, NULL); feh_menu_add_entry(m, "Randomize", NULL, CB_SORT_RANDOMIZE, 0, NULL); @@ -1252,6 +1277,12 @@ void feh_menu_cb(feh_menu * m, feh_menu_item * i, int action, unsigned short dat slideshow_change_image(m->fehwin, SLIDE_FIRST, 1); } break; + case CB_SORT_MTIME: + filelist = gib_list_sort(filelist, feh_cmp_mtime); + if (opt.jump_on_resort) { + slideshow_change_image(m->fehwin, SLIDE_FIRST, 1); + } + break; case CB_SORT_FILESIZE: filelist = gib_list_sort(filelist, feh_cmp_size); if (opt.jump_on_resort) { |