Added i_reset_slideshow: set slideshow delay to number prefix
This commit is contained in:
parent
c6bddfe838
commit
4e8dabd6ac
35
commands.c
35
commands.c
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define _POSIX_C_SOURCE 200112L
|
#define _POSIX_C_SOURCE 200112L
|
||||||
|
#define _IMAGE_CONFIG
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -27,6 +28,7 @@
|
|||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "thumbs.h"
|
#include "thumbs.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
void cleanup(void);
|
void cleanup(void);
|
||||||
void remove_file(int, bool);
|
void remove_file(int, bool);
|
||||||
@ -48,6 +50,10 @@ extern int filecnt, fileidx;
|
|||||||
|
|
||||||
extern int prefix;
|
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) {
|
bool it_quit(arg_t a) {
|
||||||
cleanup();
|
cleanup();
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
@ -118,7 +124,7 @@ bool i_navigate(arg_t a) {
|
|||||||
long n = (long) a;
|
long n = (long) a;
|
||||||
|
|
||||||
if (mode == MODE_IMAGE) {
|
if (mode == MODE_IMAGE) {
|
||||||
if (prefix)
|
if (prefix > 0)
|
||||||
n *= prefix;
|
n *= prefix;
|
||||||
n += fileidx;
|
n += fileidx;
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
@ -345,22 +351,22 @@ bool i_toggle_slideshow(arg_t a) {
|
|||||||
|
|
||||||
bool i_adjust_slideshow(arg_t a) {
|
bool i_adjust_slideshow(arg_t a) {
|
||||||
long d = (long) 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)
|
if (mode != MODE_IMAGE || !img.slideshow)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (d < 0) {
|
if (d < 0) {
|
||||||
for (i = ARRLEN(delays) - 2; i >= 0; i--) {
|
for (i = ARRLEN(ss_delays) - 2; i >= 0; i--) {
|
||||||
if (img.ss_delay > delays[i] * 1000) {
|
if (img.ss_delay > ss_delays[i] * 1000) {
|
||||||
img.ss_delay = delays[i] * 1000;
|
img.ss_delay = ss_delays[i] * 1000;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = 1; i < ARRLEN(delays); i++) {
|
for (i = 1; i < ARRLEN(ss_delays); i++) {
|
||||||
if (img.ss_delay < delays[i] * 1000) {
|
if (img.ss_delay < ss_delays[i] * 1000) {
|
||||||
img.ss_delay = delays[i] * 1000;
|
img.ss_delay = ss_delays[i] * 1000;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -368,6 +374,19 @@ bool i_adjust_slideshow(arg_t a) {
|
|||||||
return false;
|
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) {
|
bool i_toggle_antialias(arg_t a) {
|
||||||
if (mode == MODE_IMAGE) {
|
if (mode == MODE_IMAGE) {
|
||||||
img_toggle_antialias(&img);
|
img_toggle_antialias(&img);
|
||||||
|
@ -62,6 +62,7 @@ bool i_fit_to_img(arg_t);
|
|||||||
bool i_rotate(arg_t);
|
bool i_rotate(arg_t);
|
||||||
bool i_toggle_slideshow(arg_t);
|
bool i_toggle_slideshow(arg_t);
|
||||||
bool i_adjust_slideshow(arg_t);
|
bool i_adjust_slideshow(arg_t);
|
||||||
|
bool i_reset_slideshow(arg_t);
|
||||||
bool i_toggle_antialias(arg_t);
|
bool i_toggle_antialias(arg_t);
|
||||||
bool it_toggle_alpha(arg_t);
|
bool it_toggle_alpha(arg_t);
|
||||||
bool it_open_with(arg_t);
|
bool it_open_with(arg_t);
|
||||||
|
@ -121,8 +121,8 @@ static const keymap_t keys[] = {
|
|||||||
|
|
||||||
{ false, XK_s, i_toggle_slideshow, (arg_t) None },
|
{ false, XK_s, i_toggle_slideshow, (arg_t) None },
|
||||||
{ true, XK_plus, i_adjust_slideshow, (arg_t) +1 },
|
{ 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_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, i_toggle_antialias, (arg_t) None },
|
||||||
{ false, XK_A, it_toggle_alpha, (arg_t) None },
|
{ false, XK_A, it_toggle_alpha, (arg_t) None },
|
||||||
|
Loading…
Reference in New Issue
Block a user