Added i_reset_slideshow: set slideshow delay to number prefix

This commit is contained in:
Bert Münnich 2011-10-16 18:58:32 +02:00
parent c6bddfe838
commit 4e8dabd6ac
3 changed files with 29 additions and 9 deletions

View file

@ -17,6 +17,7 @@
*/
#define _POSIX_C_SOURCE 200112L
#define _IMAGE_CONFIG
#include <stdlib.h>
#include <string.h>
@ -27,6 +28,7 @@
#include "image.h"
#include "thumbs.h"
#include "util.h"
#include "config.h"
void cleanup(void);
void remove_file(int, bool);
@ -48,6 +50,10 @@ extern int filecnt, fileidx;
extern int prefix;
const int ss_delays[] = {
1, 2, 3, 5, 10, 15, 20, 30, 60, 120, 180, 300, 600
};
bool it_quit(arg_t a) {
cleanup();
exit(EXIT_SUCCESS);
@ -118,7 +124,7 @@ bool i_navigate(arg_t a) {
long n = (long) a;
if (mode == MODE_IMAGE) {
if (prefix)
if (prefix > 0)
n *= prefix;
n += fileidx;
if (n < 0)
@ -345,22 +351,22 @@ bool i_toggle_slideshow(arg_t a) {
bool i_adjust_slideshow(arg_t a) {
long d = (long) a;
int i, delays[] = { 1, 2, 3, 5, 10, 15, 20, 30, 60, 120, 180, 300, 600 };
int i;
if (mode != MODE_IMAGE || !img.slideshow)
return false;
if (d < 0) {
for (i = ARRLEN(delays) - 2; i >= 0; i--) {
if (img.ss_delay > delays[i] * 1000) {
img.ss_delay = delays[i] * 1000;
for (i = ARRLEN(ss_delays) - 2; i >= 0; i--) {
if (img.ss_delay > ss_delays[i] * 1000) {
img.ss_delay = ss_delays[i] * 1000;
return true;
}
}
} else {
for (i = 1; i < ARRLEN(delays); i++) {
if (img.ss_delay < delays[i] * 1000) {
img.ss_delay = delays[i] * 1000;
for (i = 1; i < ARRLEN(ss_delays); i++) {
if (img.ss_delay < ss_delays[i] * 1000) {
img.ss_delay = ss_delays[i] * 1000;
return true;
}
}
@ -368,6 +374,19 @@ bool i_adjust_slideshow(arg_t a) {
return false;
}
bool i_reset_slideshow(arg_t a) {
if (mode != MODE_IMAGE || !img.slideshow)
return false;
if (prefix > 0) {
img.ss_delay = MIN(prefix, ss_delays[ARRLEN(ss_delays) - 1]);
img.ss_delay = MAX(img.ss_delay, ss_delays[0]) * 1000;
} else {
img.ss_delay = SLIDESHOW_DELAY * 1000;
}
return true;
}
bool i_toggle_antialias(arg_t a) {
if (mode == MODE_IMAGE) {
img_toggle_antialias(&img);

View file

@ -62,6 +62,7 @@ bool i_fit_to_img(arg_t);
bool i_rotate(arg_t);
bool i_toggle_slideshow(arg_t);
bool i_adjust_slideshow(arg_t);
bool i_reset_slideshow(arg_t);
bool i_toggle_antialias(arg_t);
bool it_toggle_alpha(arg_t);
bool it_open_with(arg_t);

View file

@ -121,8 +121,8 @@ static const keymap_t keys[] = {
{ false, XK_s, i_toggle_slideshow, (arg_t) None },
{ true, XK_plus, i_adjust_slideshow, (arg_t) +1 },
{ true, XK_equal, i_adjust_slideshow, (arg_t) +1 },
{ true, XK_minus, i_adjust_slideshow, (arg_t) -1 },
{ true, XK_equal, i_reset_slideshow, (arg_t) None },
{ false, XK_a, i_toggle_antialias, (arg_t) None },
{ false, XK_A, it_toggle_alpha, (arg_t) None },