Removed slideshow support

This commit is contained in:
Bert Münnich 2012-02-11 02:34:18 +01:00
parent d2ec67e331
commit c3c95ab218
7 changed files with 8 additions and 115 deletions

View File

@ -1,4 +1,4 @@
VERSION = git-20111217 VERSION = git-20120211
CC = gcc CC = gcc
CFLAGS = -ansi -Wall -pedantic -O2 CFLAGS = -ansi -Wall -pedantic -O2

View File

@ -36,7 +36,6 @@ void load_image(int);
void redraw(void); void redraw(void);
void reset_cursor(void); void reset_cursor(void);
void animate(void); void animate(void);
void slideshow(void);
void set_timeout(timeout_f, int, bool); void set_timeout(timeout_f, int, bool);
void reset_timeout(timeout_f); void reset_timeout(timeout_f);
@ -65,10 +64,6 @@ bool it_switch_mode(arg_t a) {
tns_init(&tns, filecnt, &win); tns_init(&tns, filecnt, &win);
img_close(&img, false); img_close(&img, false);
reset_timeout(reset_cursor); reset_timeout(reset_cursor);
if (img.slideshow) {
img.slideshow = false;
reset_timeout(slideshow);
}
tns.sel = fileidx; tns.sel = fileidx;
tns.dirty = true; tns.dirty = true;
mode = MODE_THUMB; mode = MODE_THUMB;
@ -335,59 +330,6 @@ bool i_rotate(arg_t a) {
return false; return false;
} }
bool i_toggle_slideshow(arg_t a) {
if (mode == MODE_IMAGE) {
if (img.slideshow) {
img.slideshow = false;
reset_timeout(slideshow);
return true;
} else if (fileidx + 1 < filecnt) {
img.slideshow = true;
set_timeout(slideshow, img.ss_delay, true);
return true;
}
}
return false;
}
bool i_adjust_slideshow(arg_t a) {
long d = (long) a;
int i;
if (mode != MODE_IMAGE || !img.slideshow)
return false;
if (d < 0) {
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(ss_delays); i++) {
if (img.ss_delay < ss_delays[i] * 1000) {
img.ss_delay = ss_delays[i] * 1000;
return true;
}
}
}
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);

View File

@ -43,9 +43,6 @@ static const float zoom_levels[] = {
100.0, 150.0, 200.0, 400.0, 800.0 100.0, 150.0, 200.0, 400.0, 800.0
}; };
/* default slideshow delay (in sec, overwritten via -S option): */
enum { SLIDESHOW_DELAY = 5 };
/* default settings for multi-frame gif images: */ /* default settings for multi-frame gif images: */
enum { enum {
GIF_DELAY = 100, /* delay time (in ms) */ GIF_DELAY = 100, /* delay time (in ms) */
@ -119,11 +116,6 @@ static const keymap_t keys[] = {
{ false, XK_less, i_rotate, (arg_t) DIR_LEFT }, { false, XK_less, i_rotate, (arg_t) DIR_LEFT },
{ false, XK_greater, i_rotate, (arg_t) DIR_RIGHT }, { false, XK_greater, i_rotate, (arg_t) DIR_RIGHT },
{ false, XK_s, i_toggle_slideshow, (arg_t) None },
{ true, XK_plus, 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 },

View File

@ -68,8 +68,6 @@ void img_init(img_t *img, win_t *win) {
img->dirty = false; img->dirty = false;
img->aa = options->aa; img->aa = options->aa;
img->alpha = true; img->alpha = true;
img->slideshow = false;
img->ss_delay = SLIDESHOW_DELAY * 1000;
img->multi.cap = img->multi.cnt = 0; img->multi.cap = img->multi.cnt = 0;
img->multi.animate = false; img->multi.animate = false;
} }
@ -725,7 +723,7 @@ bool img_frame_animate(img_t *img, bool restart) {
return false; return false;
if (img->multi.sel + 1 >= img->multi.cnt) { if (img->multi.sel + 1 >= img->multi.cnt) {
if (restart || (GIF_LOOP && !img->slideshow)) { if (restart || GIF_LOOP) {
img_frame_goto(img, 0); img_frame_goto(img, 0);
} else { } else {
img->multi.animate = false; img->multi.animate = false;

41
main.c
View File

@ -52,7 +52,6 @@ typedef struct {
void redraw(void); void redraw(void);
void reset_cursor(void); void reset_cursor(void);
void animate(void); void animate(void);
void slideshow(void);
appmode_t mode; appmode_t mode;
img_t img; img_t img;
@ -71,7 +70,6 @@ timeout_t timeouts[] = {
{ { 0, 0 }, false, redraw }, { { 0, 0 }, false, redraw },
{ { 0, 0 }, false, reset_cursor }, { { 0, 0 }, false, reset_cursor },
{ { 0, 0 }, false, animate }, { { 0, 0 }, false, animate },
{ { 0, 0 }, false, slideshow },
}; };
void cleanup(void) { void cleanup(void) {
@ -220,10 +218,9 @@ void load_image(int new) {
void update_title(void) { void update_title(void) {
int n; int n;
char sshow_info[16];
char frame_info[16]; char frame_info[16];
float size, time; float size;
const char *size_unit, *time_unit; const char *size_unit;
if (mode == MODE_THUMB) { if (mode == MODE_THUMB) {
n = snprintf(win_title, TITLE_LEN, "sxiv: [%d/%d] %s", n = snprintf(win_title, TITLE_LEN, "sxiv: [%d/%d] %s",
@ -233,14 +230,6 @@ void update_title(void) {
size = filesize; size = filesize;
size_readable(&size, &size_unit); size_readable(&size, &size_unit);
if (img.slideshow) {
time = img.ss_delay / 1000.0;
time_readable(&time, &time_unit);
snprintf(sshow_info, sizeof(sshow_info), "*%d%s* ",
(int) time, time_unit);
} else {
sshow_info[0] = '\0';
}
if (img.multi.cnt > 0) if (img.multi.cnt > 0)
snprintf(frame_info, sizeof(frame_info), "{%d/%d} ", snprintf(frame_info, sizeof(frame_info), "{%d/%d} ",
img.multi.sel + 1, img.multi.cnt); img.multi.sel + 1, img.multi.cnt);
@ -248,10 +237,10 @@ void update_title(void) {
frame_info[0] = '\0'; frame_info[0] = '\0';
n = snprintf(win_title, TITLE_LEN, n = snprintf(win_title, TITLE_LEN,
"sxiv: [%d/%d] <%dx%d:%d%%> (%.2f%s) %s%s%s", "sxiv: [%d/%d] <%dx%d:%d%%> (%.2f%s) %s%s",
fileidx + 1, filecnt, img.w, img.h, fileidx + 1, filecnt, img.w, img.h,
(int) (img.zoom * 100.0), size, size_unit, (int) (img.zoom * 100.0), size, size_unit,
sshow_info, frame_info, files[fileidx].name); frame_info, files[fileidx].name);
} }
if (n >= TITLE_LEN) { if (n >= TITLE_LEN) {
@ -263,17 +252,10 @@ void update_title(void) {
} }
void redraw(void) { void redraw(void) {
if (mode == MODE_IMAGE) { if (mode == MODE_IMAGE)
img_render(&img); img_render(&img);
if (img.slideshow && !img.multi.animate) { else
if (fileidx + 1 < filecnt)
set_timeout(slideshow, img.ss_delay, true);
else
img.slideshow = false;
}
} else {
tns_render(&tns); tns_render(&tns);
}
update_title(); update_title();
reset_timeout(redraw); reset_timeout(redraw);
reset_cursor(); reset_cursor();
@ -307,17 +289,6 @@ void animate(void) {
} }
} }
void slideshow(void) {
if (mode == MODE_IMAGE && !img.multi.animate) {
if (fileidx + 1 < filecnt) {
load_image(fileidx + 1);
redraw();
} else {
img.slideshow = false;
}
}
}
bool keymask(const keymap_t *k, unsigned int state) { bool keymask(const keymap_t *k, unsigned int state) {
return (k->ctrl ? ControlMask : 0) == (state & ControlMask); return (k->ctrl ? ControlMask : 0) == (state & ControlMask);
} }

9
util.c
View File

@ -134,15 +134,6 @@ void size_readable(float *size, const char **unit) {
*unit = units[MIN(i, ARRLEN(units) - 1)]; *unit = units[MIN(i, ARRLEN(units) - 1)];
} }
void time_readable(float *time, const char **unit) {
const char *units[] = { "s", "m", "h" };
int i;
for (i = 0; i < ARRLEN(units) && *time >= 60.0; i++)
*time /= 60.0;
*unit = units[MIN(i, ARRLEN(units) - 1)];
}
char* absolute_path(const char *filename) { char* absolute_path(const char *filename) {
size_t len; size_t len;
const char *basename; const char *basename;

1
util.h
View File

@ -71,7 +71,6 @@ void die(const char*, ...);
ssize_t get_line(char**, size_t*, FILE*); ssize_t get_line(char**, size_t*, FILE*);
void size_readable(float*, const char**); void size_readable(float*, const char**);
void time_readable(float*, const char**);
char* absolute_path(const char*); char* absolute_path(const char*);