nsxivc3c95ab
Removed slideshow support
+8 −115
7 files changed
- M Makefile +1 −1
- M commands.c +0 −58
- M config.def.h +0 −8
- M image.c +1 −3
- M main.c +6 −35
- M util.c +0 −9
- M util.h +0 −1
| @@ -1,4 +1,4 @@ | |||
| 1 | − | VERSION = git-20111217 | |
| 1 | + | VERSION = git-20120211 | |
| 2 | 2 | ||
| 3 | 3 | CC = gcc | |
| 4 | 4 | CFLAGS = -ansi -Wall -pedantic -O2 | |
| @@ -36,7 +36,6 @@ void load_image(int); | |||
| 36 | 36 | void redraw(void); | |
| 37 | 37 | void reset_cursor(void); | |
| 38 | 38 | void animate(void); | |
| 39 | − | void slideshow(void); | |
| 40 | 39 | void set_timeout(timeout_f, int, bool); | |
| 41 | 40 | void reset_timeout(timeout_f); | |
| 42 | 41 | ||
| @@ -65,10 +64,6 @@ bool it_switch_mode(arg_t a) { | |||
| 65 | 64 | tns_init(&tns, filecnt, &win); | |
| 66 | 65 | img_close(&img, false); | |
| 67 | 66 | reset_timeout(reset_cursor); | |
| 68 | − | if (img.slideshow) { | |
| 69 | − | img.slideshow = false; | |
| 70 | − | reset_timeout(slideshow); | |
| 71 | − | } | |
| 72 | 67 | tns.sel = fileidx; | |
| 73 | 68 | tns.dirty = true; | |
| 74 | 69 | mode = MODE_THUMB; | |
| @@ -335,59 +330,6 @@ bool i_rotate(arg_t a) { | |||
| 335 | 330 | return false; | |
| 336 | 331 | } | |
| 337 | 332 | ||
| 338 | − | bool i_toggle_slideshow(arg_t a) { | |
| 339 | − | if (mode == MODE_IMAGE) { | |
| 340 | − | if (img.slideshow) { | |
| 341 | − | img.slideshow = false; | |
| 342 | − | reset_timeout(slideshow); | |
| 343 | − | return true; | |
| 344 | − | } else if (fileidx + 1 < filecnt) { | |
| 345 | − | img.slideshow = true; | |
| 346 | − | set_timeout(slideshow, img.ss_delay, true); | |
| 347 | − | return true; | |
| 348 | − | } | |
| 349 | − | } | |
| 350 | − | return false; | |
| 351 | − | } | |
| 352 | − | ||
| 353 | − | bool i_adjust_slideshow(arg_t a) { | |
| 354 | − | long d = (long) a; | |
| 355 | − | int i; | |
| 356 | − | ||
| 357 | − | if (mode != MODE_IMAGE || !img.slideshow) | |
| 358 | − | return false; | |
| 359 | − | ||
| 360 | − | if (d < 0) { | |
| 361 | − | for (i = ARRLEN(ss_delays) - 2; i >= 0; i--) { | |
| 362 | − | if (img.ss_delay > ss_delays[i] * 1000) { | |
| 363 | − | img.ss_delay = ss_delays[i] * 1000; | |
| 364 | − | return true; | |
| 365 | − | } | |
| 366 | − | } | |
| 367 | − | } else { | |
| 368 | − | for (i = 1; i < ARRLEN(ss_delays); i++) { | |
| 369 | − | if (img.ss_delay < ss_delays[i] * 1000) { | |
| 370 | − | img.ss_delay = ss_delays[i] * 1000; | |
| 371 | − | return true; | |
| 372 | − | } | |
| 373 | − | } | |
| 374 | − | } | |
| 375 | − | return false; | |
| 376 | − | } | |
| 377 | − | ||
| 378 | − | bool i_reset_slideshow(arg_t a) { | |
| 379 | − | if (mode != MODE_IMAGE || !img.slideshow) | |
| 380 | − | return false; | |
| 381 | − | ||
| 382 | − | if (prefix > 0) { | |
| 383 | − | img.ss_delay = MIN(prefix, ss_delays[ARRLEN(ss_delays) - 1]); | |
| 384 | − | img.ss_delay = MAX(img.ss_delay, ss_delays[0]) * 1000; | |
| 385 | − | } else { | |
| 386 | − | img.ss_delay = SLIDESHOW_DELAY * 1000; | |
| 387 | − | } | |
| 388 | − | return true; | |
| 389 | − | } | |
| 390 | − | ||
| 391 | 333 | bool i_toggle_antialias(arg_t a) { | |
| 392 | 334 | if (mode == MODE_IMAGE) { | |
| 393 | 335 | img_toggle_antialias(&img); | |
| @@ -43,9 +43,6 @@ static const float zoom_levels[] = { | |||
| 43 | 43 | 100.0, 150.0, 200.0, 400.0, 800.0 | |
| 44 | 44 | }; | |
| 45 | 45 | ||
| 46 | − | /* default slideshow delay (in sec, overwritten via -S option): */ | |
| 47 | − | enum { SLIDESHOW_DELAY = 5 }; | |
| 48 | − | ||
| 49 | 46 | /* default settings for multi-frame gif images: */ | |
| 50 | 47 | enum { | |
| 51 | 48 | GIF_DELAY = 100, /* delay time (in ms) */ | |
| @@ -119,11 +116,6 @@ static const keymap_t keys[] = { | |||
| 119 | 116 | { false, XK_less, i_rotate, (arg_t) DIR_LEFT }, | |
| 120 | 117 | { false, XK_greater, i_rotate, (arg_t) DIR_RIGHT }, | |
| 121 | 118 | ||
| 122 | − | { false, XK_s, i_toggle_slideshow, (arg_t) None }, | |
| 123 | − | { true, XK_plus, i_adjust_slideshow, (arg_t) +1 }, | |
| 124 | − | { true, XK_minus, i_adjust_slideshow, (arg_t) -1 }, | |
| 125 | − | { true, XK_equal, i_reset_slideshow, (arg_t) None }, | |
| 126 | − | ||
| 127 | 119 | { false, XK_a, i_toggle_antialias, (arg_t) None }, | |
| 128 | 120 | { false, XK_A, it_toggle_alpha, (arg_t) None }, | |
| 129 | 121 | ||
| @@ -68,8 +68,6 @@ void img_init(img_t *img, win_t *win) { | |||
| 68 | 68 | img->dirty = false; | |
| 69 | 69 | img->aa = options->aa; | |
| 70 | 70 | img->alpha = true; | |
| 71 | − | img->slideshow = false; | |
| 72 | − | img->ss_delay = SLIDESHOW_DELAY * 1000; | |
| 73 | 71 | img->multi.cap = img->multi.cnt = 0; | |
| 74 | 72 | img->multi.animate = false; | |
| 75 | 73 | } | |
| @@ -725,7 +723,7 @@ bool img_frame_animate(img_t *img, bool restart) { | |||
| 725 | 723 | return false; | |
| 726 | 724 | ||
| 727 | 725 | if (img->multi.sel + 1 >= img->multi.cnt) { | |
| 728 | − | if (restart || (GIF_LOOP && !img->slideshow)) { | |
| 726 | + | if (restart || GIF_LOOP) { | |
| 729 | 727 | img_frame_goto(img, 0); | |
| 730 | 728 | } else { | |
| 731 | 729 | img->multi.animate = false; | |
| @@ -52,7 +52,6 @@ typedef struct { | |||
| 52 | 52 | void redraw(void); | |
| 53 | 53 | void reset_cursor(void); | |
| 54 | 54 | void animate(void); | |
| 55 | − | void slideshow(void); | |
| 56 | 55 | ||
| 57 | 56 | appmode_t mode; | |
| 58 | 57 | img_t img; | |
| @@ -71,7 +70,6 @@ timeout_t timeouts[] = { | |||
| 71 | 70 | { { 0, 0 }, false, redraw }, | |
| 72 | 71 | { { 0, 0 }, false, reset_cursor }, | |
| 73 | 72 | { { 0, 0 }, false, animate }, | |
| 74 | − | { { 0, 0 }, false, slideshow }, | |
| 75 | 73 | }; | |
| 76 | 74 | ||
| 77 | 75 | void cleanup(void) { | |
| @@ -220,10 +218,9 @@ void load_image(int new) { | |||
| 220 | 218 | ||
| 221 | 219 | void update_title(void) { | |
| 222 | 220 | int n; | |
| 223 | − | char sshow_info[16]; | |
| 224 | 221 | char frame_info[16]; | |
| 225 | − | float size, time; | |
| 226 | − | const char *size_unit, *time_unit; | |
| 222 | + | float size; | |
| 223 | + | const char *size_unit; | |
| 227 | 224 | ||
| 228 | 225 | if (mode == MODE_THUMB) { | |
| 229 | 226 | n = snprintf(win_title, TITLE_LEN, "sxiv: [%d/%d] %s", | |
| @@ -233,14 +230,6 @@ void update_title(void) { | |||
| 233 | 230 | size = filesize; | |
| 234 | 231 | size_readable(&size, &size_unit); | |
| 235 | 232 | ||
| 236 | − | if (img.slideshow) { | |
| 237 | − | time = img.ss_delay / 1000.0; | |
| 238 | − | time_readable(&time, &time_unit); | |
| 239 | − | snprintf(sshow_info, sizeof(sshow_info), "*%d%s* ", | |
| 240 | − | (int) time, time_unit); | |
| 241 | − | } else { | |
| 242 | − | sshow_info[0] = '\0'; | |
| 243 | − | } | |
| 244 | 233 | if (img.multi.cnt > 0) | |
| 245 | 234 | snprintf(frame_info, sizeof(frame_info), "{%d/%d} ", | |
| 246 | 235 | img.multi.sel + 1, img.multi.cnt); | |
| @@ -248,10 +237,10 @@ void update_title(void) { | |||
| 248 | 237 | frame_info[0] = '\0'; | |
| 249 | 238 | ||
| 250 | 239 | n = snprintf(win_title, TITLE_LEN, | |
| 251 | − | "sxiv: [%d/%d] <%dx%d:%d%%> (%.2f%s) %s%s%s", | |
| 240 | + | "sxiv: [%d/%d] <%dx%d:%d%%> (%.2f%s) %s%s", | |
| 252 | 241 | fileidx + 1, filecnt, img.w, img.h, | |
| 253 | 242 | (int) (img.zoom * 100.0), size, size_unit, | |
| 254 | − | sshow_info, frame_info, files[fileidx].name); | |
| 243 | + | frame_info, files[fileidx].name); | |
| 255 | 244 | } | |
| 256 | 245 | ||
| 257 | 246 | if (n >= TITLE_LEN) { | |
| @@ -263,17 +252,10 @@ void update_title(void) { | |||
| 263 | 252 | } | |
| 264 | 253 | ||
| 265 | 254 | void redraw(void) { | |
| 266 | − | if (mode == MODE_IMAGE) { | |
| 255 | + | if (mode == MODE_IMAGE) | |
| 267 | 256 | img_render(&img); | |
| 268 | − | if (img.slideshow && !img.multi.animate) { | |
| 269 | − | if (fileidx + 1 < filecnt) | |
| 270 | − | set_timeout(slideshow, img.ss_delay, true); | |
| 271 | − | else | |
| 272 | − | img.slideshow = false; | |
| 273 | − | } | |
| 274 | − | } else { | |
| 257 | + | else | |
| 275 | 258 | tns_render(&tns); | |
| 276 | − | } | |
| 277 | 259 | update_title(); | |
| 278 | 260 | reset_timeout(redraw); | |
| 279 | 261 | reset_cursor(); | |
| @@ -307,17 +289,6 @@ void animate(void) { | |||
| 307 | 289 | } | |
| 308 | 290 | } | |
| 309 | 291 | ||
| 310 | − | void slideshow(void) { | |
| 311 | − | if (mode == MODE_IMAGE && !img.multi.animate) { | |
| 312 | − | if (fileidx + 1 < filecnt) { | |
| 313 | − | load_image(fileidx + 1); | |
| 314 | − | redraw(); | |
| 315 | − | } else { | |
| 316 | − | img.slideshow = false; | |
| 317 | − | } | |
| 318 | − | } | |
| 319 | − | } | |
| 320 | − | ||
| 321 | 292 | bool keymask(const keymap_t *k, unsigned int state) { | |
| 322 | 293 | return (k->ctrl ? ControlMask : 0) == (state & ControlMask); | |
| 323 | 294 | } | |
| @@ -134,15 +134,6 @@ void size_readable(float *size, const char **unit) { | |||
| 134 | 134 | *unit = units[MIN(i, ARRLEN(units) - 1)]; | |
| 135 | 135 | } | |
| 136 | 136 | ||
| 137 | − | void time_readable(float *time, const char **unit) { | |
| 138 | − | const char *units[] = { "s", "m", "h" }; | |
| 139 | − | int i; | |
| 140 | − | ||
| 141 | − | for (i = 0; i < ARRLEN(units) && *time >= 60.0; i++) | |
| 142 | − | *time /= 60.0; | |
| 143 | − | *unit = units[MIN(i, ARRLEN(units) - 1)]; | |
| 144 | − | } | |
| 145 | − | ||
| 146 | 137 | char* absolute_path(const char *filename) { | |
| 147 | 138 | size_t len; | |
| 148 | 139 | const char *basename; | |
| @@ -71,7 +71,6 @@ void die(const char*, ...); | |||
| 71 | 71 | ssize_t get_line(char**, size_t*, FILE*); | |
| 72 | 72 | ||
| 73 | 73 | void size_readable(float*, const char**); | |
| 74 | − | void time_readable(float*, const char**); | |
| 75 | 74 | ||
| 76 | 75 | char* absolute_path(const char*); | |
| 77 | 76 | ||