WIP Reverse sorting in Open & Slideshows dialog

...via --reversesort option.  WIP; need docs updated.
(Also need Tux Paint Config. changes, but that's another repo)
This commit is contained in:
Bill Kendrick 2022-05-15 23:56:53 -07:00
parent 27ec817973
commit b2225a62f5
5 changed files with 33 additions and 3 deletions

View file

@ -150,6 +150,12 @@ http://www.tuxpaint.org/
(the top of the list).
Bill Kendrick <bill@newbreedsoftware.com>
* WIP Added an option to sort the "Open" and "Slideshow" dialogs
by newest-images-first, rather than the default oldest-first.
(For https://sourceforge.net/p/tuxpaint/feature-requests/206/)
Pere Pujal i Carabantes <perepujal@gmail.com> and
Bill Kendrick <bill@newbreedsoftware.com>
* Localization Updates:
---------------------
* Albanian translation

View file

@ -139,6 +139,7 @@ print, NEGBOOL(disable_print)
printcfg, POSBOOL(use_print_config)
printcommand, MULTI(printcommand)
printdelay, MULTI(print_delay)
reversesort, POSBOOL(reversesort)
quit, NEGBOOL(disable_quit)
save, NEGBOOL(disable_save)
savedir, MULTI(savedir)

View file

@ -48,6 +48,7 @@ struct cfginfo
const char *colors_rows;
const char *print_delay;
const char *printcommand;
const char *reversesort;
// const char *promptless_save;
const char *_promptless_save_over;
const char *_promptless_save_over_new;

View file

@ -3,7 +3,7 @@
# Bill Kendrick <bill@newbreedsoftware.com>; http://www.tuxpaint.org/
# Based on inkscape's completion file, by allali@univ-mlv.fr
#
# Last modified 2022-01-18
# Last modified 2022-05-15
#
# $Id$
@ -67,6 +67,7 @@ _tuxpaint()
--nosave --save \
--autosave --noautosave \
--savedir --datadir --exportdir \
--reversesort --noreversesort \
--printdelay= \
--altprintmod --altprintalways --altprintnever \
--printcommand --altprintcommand \

View file

@ -1269,6 +1269,7 @@ static int ok_to_use_lockfile = 1;
static int start_blank;
static int autosave_on_quit;
static int no_prompt_on_quit = 0;
static int reversesort = 0;
static int dont_do_xor;
static int dont_load_stamps;
@ -2035,6 +2036,7 @@ static void disable_avail_tools(void);
static void enable_avail_tools(void);
static void reset_avail_tools(void);
static int compare_dirent2s(struct dirent2 *f1, struct dirent2 *f2);
static int compare_dirent2s_invert(struct dirent2 *f1, struct dirent2 *f2);
static void redraw_tux_text(void);
static void draw_tux_text(int which_tux, const char *const str, int want_right_to_left);
static void draw_tux_text_ex(int which_tux, const char *const str, int want_right_to_left, Uint8 locale_text);
@ -7349,6 +7351,7 @@ void show_usage(int exitcode)
" [--savedir DIRECTORY]\n"
" [--nosave | --save]\n"
" [--autosave | --noautosave]\n"
" [--reversesort | --noreversesort]\n"
"\n"
" Data:\n"
" [--nolockfile]\n"
@ -11624,6 +11627,16 @@ static int compare_dirent2s(struct dirent2 *f1, struct dirent2 *f2)
}
/**
* FIXME
*/
/* For qsort() call in do_open()... */
static int compare_dirent2s_invert(struct dirent2 *f1, struct dirent2 *f2)
{
return compare_dirent2s(f2, f1);
}
/**
* FIXME
*/
@ -15554,7 +15567,10 @@ static int do_open(void)
/* Sort: */
qsort(fs, num_files_in_dirs, sizeof(struct dirent2), (int (*)(const void *, const void *))compare_dirent2s);
if (!reversesort)
qsort(fs, num_files_in_dirs, sizeof(struct dirent2), (int (*)(const void *, const void *))compare_dirent2s);
else
qsort(fs, num_files_in_dirs, sizeof(struct dirent2), (int (*)(const void *, const void *))compare_dirent2s_invert);
/* Read directory of images and build thumbnails: */
@ -16692,7 +16708,10 @@ static int do_slideshow(void)
/* Sort: */
qsort(fs, num_files_in_dir, sizeof(struct dirent2), (int (*)(const void *, const void *))compare_dirent2s);
if (!reversesort)
qsort(fs, num_files_in_dir, sizeof(struct dirent2), (int (*)(const void *, const void *))compare_dirent2s);
else
qsort(fs, num_files_in_dir, sizeof(struct dirent2), (int (*)(const void *, const void *))compare_dirent2s_invert);
/* Read directory of images and build thumbnails: */
@ -20597,6 +20616,7 @@ static int do_new_dialog(void)
/* Sort: */
/* (N.B. "New" dialog not affected by 'reversesort' option) */
qsort(fs, num_files_in_dirs, sizeof(struct dirent2), (int (*)(const void *, const void *))compare_dirent2s);
@ -25889,6 +25909,7 @@ static void setup_config(char *argv[])
#define SETBOOL(x) do{ if(tmpcfg.x) x = (tmpcfg.x==PARSE_YES); }while(0)
SETBOOL(all_locale_fonts);
SETBOOL(autosave_on_quit);
SETBOOL(reversesort);
SETBOOL(disable_label);
SETBOOL(disable_brushspacing);
SETBOOL(disable_magic_controls);