Krolyxon
Commit cd34aa2

Branches

Refs →

nsxivmain.c

822 lines · 17.3 KB · C

1/* Copyright 2011-2013 Bert Muennich
2 *
3 * This file is part of sxiv.
4 *
5 * sxiv is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published
7 * by the Free Software Foundation; either version 2 of the License,
8 * or (at your option) any later version.
9 *
10 * sxiv is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with sxiv. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#define _POSIX_C_SOURCE 200112L
20#define _MAPPINGS_CONFIG
21
22#include <stdlib.h>
23#include <stdio.h>
24#include <string.h>
25#include <fcntl.h>
26#include <unistd.h>
27#include <errno.h>
28#include <signal.h>
29#include <sys/select.h>
30#include <sys/stat.h>
31#include <sys/time.h>
32#include <sys/wait.h>
33#include <X11/keysym.h>
34
35#include "types.h"
36#include "commands.h"
37#include "image.h"
38#include "options.h"
39#include "thumbs.h"
40#include "util.h"
41#include "window.h"
42#include "config.h"
43
44enum {
45 FILENAME_CNT = 1024,
46 TITLE_LEN = 256
47};
48
49#define EXEC_REL_DIR ".sxiv/exec"
50
51enum {
52 EXEC_INFO,
53 EXEC_KEY
54};
55
56typedef struct {
57 const char *name;
58 char *cmd;
59} exec_t;
60
61typedef struct {
62 struct timeval when;
63 bool active;
64 timeout_f handler;
65} timeout_t;
66
67/* timeout handler functions: */
68void redraw(void);
69void reset_cursor(void);
70void animate(void);
71void slideshow(void);
72void clear_resize(void);
73
74appmode_t mode;
75img_t img;
76tns_t tns;
77win_t win;
78
79fileinfo_t *files;
80int filecnt, fileidx;
81int alternate;
82
83int prefix;
84
85bool resized = false;
86
87exec_t exec[] = {
88 { "image-info", NULL },
89 { "key-handler", NULL }
90};
91
92struct {
93 char *cmd;
94 int fd;
95 unsigned int i, lastsep;
96 bool open;
97} info;
98
99timeout_t timeouts[] = {
100 { { 0, 0 }, false, redraw },
101 { { 0, 0 }, false, reset_cursor },
102 { { 0, 0 }, false, animate },
103 { { 0, 0 }, false, slideshow },
104 { { 0, 0 }, false, clear_resize },
105};
106
107void cleanup(void)
108{
109 static bool in = false;
110
111 if (!in) {
112 in = true;
113 img_close(&img, false);
114 tns_free(&tns);
115 win_close(&win);
116 }
117}
118
119void check_add_file(char *filename)
120{
121 const char *bn;
122
123 if (filename == NULL || *filename == '\0')
124 return;
125
126 if (access(filename, R_OK) < 0) {
127 warn("could not open file: %s", filename);
128 return;
129 }
130
131 if (fileidx == filecnt) {
132 filecnt *= 2;
133 files = (fileinfo_t*) s_realloc(files, filecnt * sizeof(fileinfo_t));
134 }
135 if (*filename != '/') {
136 files[fileidx].path = absolute_path(filename);
137 if (files[fileidx].path == NULL) {
138 warn("could not get absolute path of file: %s\n", filename);
139 return;
140 }
141 }
142 files[fileidx].loaded = false;
143 files[fileidx].name = s_strdup(filename);
144 if (*filename == '/')
145 files[fileidx].path = files[fileidx].name;
146 if ((bn = strrchr(files[fileidx].name , '/')) != NULL && bn[1] != '\0')
147 files[fileidx].base = ++bn;
148 else
149 files[fileidx].base = files[fileidx].name;
150 fileidx++;
151}
152
153void remove_file(int n, bool manual)
154{
155 if (n < 0 || n >= filecnt)
156 return;
157
158 if (filecnt == 1) {
159 if (!manual)
160 fprintf(stderr, "sxiv: no more files to display, aborting\n");
161 cleanup();
162 exit(manual ? EXIT_SUCCESS : EXIT_FAILURE);
163 }
164
165 if (files[n].path != files[n].name)
166 free((void*) files[n].path);
167 free((void*) files[n].name);
168
169 if (n + 1 < filecnt)
170 memmove(files + n, files + n + 1, (filecnt - n - 1) * sizeof(fileinfo_t));
171 if (n + 1 < tns.cnt) {
172 memmove(tns.thumbs + n, tns.thumbs + n + 1, (tns.cnt - n - 1) *
173 sizeof(thumb_t));
174 memset(tns.thumbs + tns.cnt - 1, 0, sizeof(thumb_t));
175 }
176
177 filecnt--;
178 if (n < tns.cnt)
179 tns.cnt--;
180 if (n < alternate)
181 alternate--;
182}
183
184void set_timeout(timeout_f handler, int time, bool overwrite)
185{
186 int i;
187
188 for (i = 0; i < ARRLEN(timeouts); i++) {
189 if (timeouts[i].handler == handler) {
190 if (!timeouts[i].active || overwrite) {
191 gettimeofday(&timeouts[i].when, 0);
192 TV_ADD_MSEC(&timeouts[i].when, time);
193 timeouts[i].active = true;
194 }
195 return;
196 }
197 }
198}
199
200void reset_timeout(timeout_f handler)
201{
202 int i;
203
204 for (i = 0; i < ARRLEN(timeouts); i++) {
205 if (timeouts[i].handler == handler) {
206 timeouts[i].active = false;
207 return;
208 }
209 }
210}
211
212bool check_timeouts(struct timeval *t)
213{
214 int i = 0, tdiff, tmin = -1;
215 struct timeval now;
216
217 while (i < ARRLEN(timeouts)) {
218 if (timeouts[i].active) {
219 gettimeofday(&now, 0);
220 tdiff = TV_DIFF(&timeouts[i].when, &now);
221 if (tdiff <= 0) {
222 timeouts[i].active = false;
223 if (timeouts[i].handler != NULL)
224 timeouts[i].handler();
225 i = tmin = -1;
226 } else if (tmin < 0 || tdiff < tmin) {
227 tmin = tdiff;
228 }
229 }
230 i++;
231 }
232 if (tmin > 0 && t != NULL)
233 TV_SET_MSEC(t, tmin);
234 return tmin > 0;
235}
236
237void open_info(void)
238{
239 static pid_t pid;
240 int pfd[2];
241
242 if (info.cmd == NULL || info.open || win.bar.h == 0)
243 return;
244 if (info.fd != -1) {
245 close(info.fd);
246 kill(pid, SIGTERM);
247 info.fd = -1;
248 }
249 win.bar.l[0] = '\0';
250
251 if (pipe(pfd) < 0)
252 return;
253 pid = fork();
254 if (pid > 0) {
255 close(pfd[1]);
256 fcntl(pfd[0], F_SETFL, O_NONBLOCK);
257 info.fd = pfd[0];
258 info.i = info.lastsep = 0;
259 info.open = true;
260 } else if (pid == 0) {
261 close(pfd[0]);
262 dup2(pfd[1], 1);
263 execl(info.cmd, info.cmd, files[fileidx].name, NULL);
264 warn("could not exec: %s", info.cmd);
265 exit(EXIT_FAILURE);
266 }
267}
268
269void read_info(void)
270{
271 ssize_t i, n;
272 char buf[BAR_L_LEN];
273
274 while (true) {
275 n = read(info.fd, buf, sizeof(buf));
276 if (n < 0 && errno == EAGAIN)
277 return;
278 else if (n == 0)
279 goto end;
280 for (i = 0; i < n; i++) {
281 if (buf[i] == '\n') {
282 if (info.lastsep == 0) {
283 win.bar.l[info.i++] = ' ';
284 info.lastsep = 1;
285 }
286 } else {
287 win.bar.l[info.i++] = buf[i];
288 info.lastsep = 0;
289 }
290 if (info.i + 1 == sizeof(win.bar.l))
291 goto end;
292 }
293 }
294end:
295 info.i -= info.lastsep;
296 win.bar.l[info.i] = '\0';
297 win_update_bar(&win);
298 close(info.fd);
299 info.fd = -1;
300 while (waitpid(-1, NULL, WNOHANG) > 0);
301}
302
303void load_image(int new)
304{
305 if (new < 0 || new >= filecnt)
306 return;
307
308 win_set_cursor(&win, CURSOR_WATCH);
309 reset_timeout(slideshow);
310
311 if (new != fileidx)
312 alternate = fileidx;
313
314 img_close(&img, false);
315 while (!img_load(&img, &files[new])) {
316 remove_file(new, false);
317 if (new >= filecnt)
318 new = filecnt - 1;
319 else if (new > 0 && new < fileidx)
320 new--;
321 }
322 files[new].loaded = true;
323 fileidx = new;
324
325 info.open = false;
326 open_info();
327
328 if (img.multi.cnt > 0 && img.multi.animate)
329 set_timeout(animate, img.multi.frames[img.multi.sel].delay, true);
330 else
331 reset_timeout(animate);
332}
333
334void update_info(void)
335{
336 int sel;
337 unsigned int i, fn, fw, n;
338 unsigned int llen = sizeof(win.bar.l), rlen = sizeof(win.bar.r);
339 char *lt = win.bar.l, *rt = win.bar.r, title[TITLE_LEN];
340 const char * mark;
341 bool ow_info;
342
343 for (fw = 0, i = filecnt; i > 0; fw++, i /= 10);
344 sel = mode == MODE_IMAGE ? fileidx : tns.sel;
345
346 /* update window title */
347 if (mode == MODE_THUMB) {
348 win_set_title(&win, "sxiv");
349 } else {
350 snprintf(title, sizeof(title), "sxiv - %s", files[sel].name);
351 win_set_title(&win, title);
352 }
353
354 /* update bar contents */
355 if (win.bar.h == 0)
356 return;
357 mark = files[sel].marked ? "* " : "";
358 if (mode == MODE_THUMB) {
359 if (tns.cnt == filecnt) {
360 n = snprintf(rt, rlen, "%s%0*d/%d", mark, fw, sel + 1, filecnt);
361 ow_info = true;
362 } else {
363 snprintf(lt, llen, "Loading... %0*d/%d", fw, tns.cnt, filecnt);
364 rt[0] = '\0';
365 ow_info = false;
366 }
367 } else {
368 n = snprintf(rt, rlen, "%s", mark);
369 if (img.ss.on)
370 n += snprintf(rt + n, rlen - n, "%ds | ", img.ss.delay);
371 if (img.gamma != 0)
372 n += snprintf(rt + n, rlen - n, "G%+d | ", img.gamma);
373 n += snprintf(rt + n, rlen - n, "%3d%% | ", (int) (img.zoom * 100.0));
374 if (img.multi.cnt > 0) {
375 for (fn = 0, i = img.multi.cnt; i > 0; fn++, i /= 10);
376 n += snprintf(rt + n, rlen - n, "%0*d/%d | ",
377 fn, img.multi.sel + 1, img.multi.cnt);
378 }
379 n += snprintf(rt + n, rlen - n, "%0*d/%d", fw, sel + 1, filecnt);
380 ow_info = info.cmd == NULL;
381 }
382 if (ow_info) {
383 fn = strlen(files[sel].name);
384 if (fn < llen &&
385 win_textwidth(files[sel].name, fn, true) +
386 win_textwidth(rt, n, true) < win.w)
387 {
388 strncpy(lt, files[sel].name, llen);
389 } else {
390 strncpy(lt, files[sel].base, llen);
391 }
392 }
393}
394
395void redraw(void)
396{
397 int t;
398
399 if (mode == MODE_IMAGE) {
400 img_render(&img);
401 if (img.ss.on) {
402 t = img.ss.delay * 1000;
403 if (img.multi.cnt > 0 && img.multi.animate)
404 t = MAX(t, img.multi.length);
405 set_timeout(slideshow, t, false);
406 }
407 } else {
408 tns_render(&tns);
409 }
410 update_info();
411 win_draw(&win);
412 reset_timeout(redraw);
413 reset_cursor();
414}
415
416void reset_cursor(void)
417{
418 int i;
419 cursor_t cursor = CURSOR_NONE;
420
421 if (mode == MODE_IMAGE) {
422 for (i = 0; i < ARRLEN(timeouts); i++) {
423 if (timeouts[i].handler == reset_cursor) {
424 if (timeouts[i].active)
425 cursor = CURSOR_ARROW;
426 break;
427 }
428 }
429 } else {
430 if (tns.cnt != filecnt)
431 cursor = CURSOR_WATCH;
432 else
433 cursor = CURSOR_ARROW;
434 }
435 win_set_cursor(&win, cursor);
436}
437
438void animate(void)
439{
440 if (img_frame_animate(&img, false)) {
441 redraw();
442 set_timeout(animate, img.multi.frames[img.multi.sel].delay, true);
443 }
444}
445
446void slideshow(void)
447{
448 load_image(fileidx + 1 < filecnt ? fileidx + 1 : 0);
449 redraw();
450}
451
452void clear_resize(void)
453{
454 resized = false;
455}
456
457void key_handler(const char *key, unsigned int mask)
458{
459 pid_t pid;
460 int retval, status, n = mode == MODE_IMAGE ? fileidx : tns.sel;
461 char *cmd = exec[EXEC_KEY].cmd, kstr[32];
462
463 if (cmd == NULL || key == NULL)
464 return;
465
466 snprintf(kstr, sizeof(kstr), "%s%s%s%s",
467 mask & ControlMask ? "C-" : "",
468 mask & Mod1Mask ? "M-" : "",
469 mask & ShiftMask ? "S-" : "", key);
470
471 if ((pid = fork()) == 0) {
472 execl(cmd, cmd, kstr, files[n].path, NULL);
473 warn("could not exec key handler");
474 exit(EXIT_FAILURE);
475 } else if (pid < 0) {
476 warn("could not fork key handler");
477 return;
478 }
479 win_set_cursor(&win, CURSOR_WATCH);
480
481 waitpid(pid, &status, 0);
482 retval = WEXITSTATUS(status);
483 if (WIFEXITED(status) == 0 || retval != 0)
484 warn("key handler exited with non-zero return value: %d", retval);
485 if (mode == MODE_IMAGE) {
486 img_close(&img, true);
487 load_image(fileidx);
488 }
489 if (!tns_load(&tns, n, &files[n], true, mode == MODE_IMAGE) &&
490 mode == MODE_THUMB)
491 {
492 remove_file(tns.sel, false);
493 tns.dirty = true;
494 if (tns.sel >= tns.cnt)
495 tns.sel = tns.cnt - 1;
496 }
497 redraw();
498}
499
500#define MODMASK(mask) ((mask) & (ShiftMask|ControlMask|Mod1Mask))
501
502void on_keypress(XKeyEvent *kev)
503{
504 int i;
505 unsigned int sh;
506 KeySym ksym, shksym;
507 char key;
508
509 if (kev == NULL)
510 return;
511
512 if (kev->state & ShiftMask) {
513 kev->state &= ~ShiftMask;
514 XLookupString(kev, &key, 1, &shksym, NULL);
515 kev->state |= ShiftMask;
516 }
517 XLookupString(kev, &key, 1, &ksym, NULL);
518 sh = (kev->state & ShiftMask) && ksym != shksym ? ShiftMask : 0;
519
520 if (IsModifierKey(ksym))
521 return;
522
523 if ((ksym == XK_Escape && MODMASK(kev->state) == 0) ||
524 (key >= '0' && key <= '9'))
525 {
526 /* number prefix for commands */
527 prefix = ksym == XK_Escape ? 0 : prefix * 10 + (int) (key - '0');
528 return;
529 }
530
531 for (i = 0; i < ARRLEN(keys); i++) {
532 if (keys[i].ksym == ksym &&
533 MODMASK(keys[i].mask | sh) == MODMASK(kev->state))
534 {
535 if (keys[i].cmd != NULL && keys[i].cmd(keys[i].arg))
536 redraw();
537 prefix = 0;
538 return;
539 }
540 }
541 key_handler(XKeysymToString(ksym), kev->state & ~sh);
542}
543
544void on_buttonpress(XButtonEvent *bev)
545{
546 int i, sel;
547
548 if (bev == NULL)
549 return;
550
551 if (mode == MODE_IMAGE) {
552 win_set_cursor(&win, CURSOR_ARROW);
553 set_timeout(reset_cursor, TO_CURSOR_HIDE, true);
554
555 for (i = 0; i < ARRLEN(buttons); i++) {
556 if (buttons[i].button == bev->button &&
557 MODMASK(buttons[i].mask) == MODMASK(bev->state))
558 {
559 if (buttons[i].cmd != NULL && buttons[i].cmd(buttons[i].arg))
560 redraw();
561 return;
562 }
563 }
564 } else {
565 /* thumbnail mode (hard-coded) */
566 switch (bev->button) {
567 case Button1:
568 if ((sel = tns_translate(&tns, bev->x, bev->y)) >= 0) {
569 if (sel == tns.sel) {
570 mode = MODE_IMAGE;
571 set_timeout(reset_cursor, TO_CURSOR_HIDE, true);
572 load_image(tns.sel);
573 } else {
574 tns_highlight(&tns, tns.sel, false);
575 tns_highlight(&tns, sel, true);
576 tns.sel = sel;
577 }
578 redraw();
579 break;
580 }
581 break;
582 case Button3:
583 if ((sel = tns_translate(&tns, bev->x, bev->y)) >= 0) {
584 files[sel].marked = !files[sel].marked;
585 tns_mark(&tns, sel, files[sel].marked);
586 redraw();
587 }
588 break;
589 case Button4:
590 case Button5:
591 if (tns_scroll(&tns, bev->button == Button4 ? DIR_UP : DIR_DOWN,
592 (bev->state & ControlMask) != 0))
593 redraw();
594 break;
595 }
596 }
597}
598
599void run(void)
600{
601 int xfd;
602 fd_set fds;
603 struct timeval timeout;
604 bool discard, to_set;
605 XEvent ev, nextev;
606
607 redraw();
608
609 while (true) {
610 while (mode == MODE_THUMB && tns.cnt < filecnt &&
611 XPending(win.env.dpy) == 0)
612 {
613 /* load thumbnails */
614 set_timeout(redraw, TO_REDRAW_THUMBS, false);
615 if (tns_load(&tns, tns.cnt, &files[tns.cnt], false, false)) {
616 tns.cnt++;
617 } else {
618 remove_file(tns.cnt, false);
619 if (tns.sel > 0 && tns.sel >= tns.cnt)
620 tns.sel--;
621 }
622 if (tns.cnt == filecnt)
623 redraw();
624 else
625 check_timeouts(NULL);
626 }
627
628 while (XPending(win.env.dpy) == 0
629 && ((to_set = check_timeouts(&timeout)) || info.fd != -1))
630 {
631 /* check for timeouts & input */
632 xfd = ConnectionNumber(win.env.dpy);
633 FD_ZERO(&fds);
634 FD_SET(xfd, &fds);
635 if (info.fd != -1) {
636 FD_SET(info.fd, &fds);
637 xfd = MAX(xfd, info.fd);
638 }
639 select(xfd + 1, &fds, 0, 0, to_set ? &timeout : NULL);
640 if (info.fd != -1 && FD_ISSET(info.fd, &fds))
641 read_info();
642 }
643
644 do {
645 XNextEvent(win.env.dpy, &ev);
646 discard = false;
647 if (XEventsQueued(win.env.dpy, QueuedAlready) > 0) {
648 XPeekEvent(win.env.dpy, &nextev);
649 switch (ev.type) {
650 case ConfigureNotify:
651 discard = ev.type == nextev.type;
652 break;
653 case KeyPress:
654 discard = (nextev.type == KeyPress || nextev.type == KeyRelease)
655 && ev.xkey.keycode == nextev.xkey.keycode;
656 break;
657 }
658 }
659 } while (discard);
660
661 switch (ev.type) {
662 /* handle events */
663 case ButtonPress:
664 on_buttonpress(&ev.xbutton);
665 break;
666 case ClientMessage:
667 if ((Atom) ev.xclient.data.l[0] == wm_delete_win)
668 return;
669 break;
670 case ConfigureNotify:
671 if (win_configure(&win, &ev.xconfigure)) {
672 if (mode == MODE_IMAGE) {
673 img.dirty = true;
674 img.checkpan = true;
675 } else {
676 tns.dirty = true;
677 }
678 if (!resized || win.fullscreen) {
679 redraw();
680 set_timeout(clear_resize, TO_REDRAW_RESIZE, false);
681 resized = true;
682 } else {
683 set_timeout(redraw, TO_REDRAW_RESIZE, false);
684 }
685 }
686 break;
687 case Expose:
688 win_expose(&win, &ev.xexpose);
689 break;
690 case KeyPress:
691 on_keypress(&ev.xkey);
692 break;
693 case MotionNotify:
694 if (mode == MODE_IMAGE) {
695 win_set_cursor(&win, CURSOR_ARROW);
696 set_timeout(reset_cursor, TO_CURSOR_HIDE, true);
697 }
698 break;
699 }
700 }
701}
702
703int fncmp(const void *a, const void *b)
704{
705 return strcoll(((fileinfo_t*) a)->name, ((fileinfo_t*) b)->name);
706}
707
708int main(int argc, char **argv)
709{
710 int i, start;
711 size_t n;
712 ssize_t len;
713 char *filename;
714 const char *homedir;
715 struct stat fstats;
716 r_dir_t dir;
717
718 parse_options(argc, argv);
719
720 if (options->clean_cache) {
721 tns_init(&tns, 0, NULL);
722 tns_clean_cache(&tns);
723 exit(EXIT_SUCCESS);
724 }
725
726 if (options->filecnt == 0 && !options->from_stdin) {
727 print_usage();
728 exit(EXIT_FAILURE);
729 }
730
731 if (options->recursive || options->from_stdin)
732 filecnt = FILENAME_CNT;
733 else
734 filecnt = options->filecnt;
735
736 files = (fileinfo_t*) s_malloc(filecnt * sizeof(fileinfo_t));
737 fileidx = 0;
738
739 if (options->from_stdin) {
740 filename = NULL;
741 while ((len = get_line(&filename, &n, stdin)) > 0) {
742 if (filename[len-1] == '\n')
743 filename[len-1] = '\0';
744 check_add_file(filename);
745 }
746 if (filename != NULL)
747 free(filename);
748 }
749
750 for (i = 0; i < options->filecnt; i++) {
751 filename = options->filenames[i];
752
753 if (stat(filename, &fstats) < 0) {
754 warn("could not stat file: %s", filename);
755 continue;
756 }
757 if (!S_ISDIR(fstats.st_mode)) {
758 check_add_file(filename);
759 } else {
760 if (!options->recursive) {
761 warn("ignoring directory: %s", filename);
762 continue;
763 }
764 if (r_opendir(&dir, filename) < 0) {
765 warn("could not open directory: %s", filename);
766 continue;
767 }
768 start = fileidx;
769 while ((filename = r_readdir(&dir)) != NULL) {
770 check_add_file(filename);
771 free((void*) filename);
772 }
773 r_closedir(&dir);
774 if (fileidx - start > 1)
775 qsort(files + start, fileidx - start, sizeof(fileinfo_t), fncmp);
776 }
777 }
778
779 if (fileidx == 0) {
780 fprintf(stderr, "sxiv: no valid image file given, aborting\n");
781 exit(EXIT_FAILURE);
782 }
783
784 filecnt = fileidx;
785 fileidx = options->startnum < filecnt ? options->startnum : 0;
786
787 win_init(&win);
788 img_init(&img, &win);
789
790 if ((homedir = getenv("HOME")) == NULL) {
791 warn("could not locate home directory");
792 } else for (i = 0; i < ARRLEN(exec); i++) {
793 len = strlen(homedir) + strlen(EXEC_REL_DIR) + strlen(exec[i].name) + 3;
794 exec[i].cmd = (char*) s_malloc(len);
795 snprintf(exec[i].cmd, len, "%s/%s/%s", homedir, EXEC_REL_DIR, exec[i].name);
796 if (access(exec[i].cmd, X_OK) != 0) {
797 free(exec[i].cmd);
798 exec[i].cmd = NULL;
799 }
800 }
801 info.fd = -1;
802 info.cmd = exec[EXEC_INFO].cmd;
803
804 if (options->thumb_mode) {
805 mode = MODE_THUMB;
806 tns_init(&tns, filecnt, &win);
807 while (!tns_load(&tns, 0, &files[0], false, false))
808 remove_file(0, false);
809 tns.cnt = 1;
810 } else {
811 mode = MODE_IMAGE;
812 tns.thumbs = NULL;
813 load_image(fileidx);
814 }
815
816 win_open(&win);
817
818 run();
819 cleanup();
820
821 return 0;
822}