| @@ -75,7 +75,7 @@ Imlib_Image tns_cache_load(const char *filepath) |
| 75 | 75 | | return im; |
| 76 | 76 | | } |
| 77 | 77 | | |
| 78 | | − | void tns_cache_write(thumb_t *t, bool force) |
| 78 | + | void tns_cache_write(thumb_t *t, const fileinfo_t *file, bool force) |
| 79 | 79 | | { |
| 80 | 80 | | char *cfile, *dirend; |
| 81 | 81 | | struct stat cstats, fstats; |
| @@ -84,12 +84,12 @@ void tns_cache_write(thumb_t *t, bool force) |
| 84 | 84 | | |
| 85 | 85 | | if (t == NULL || t->im == NULL) |
| 86 | 86 | | return; |
| 87 | | − | if (t->file == NULL || t->file->name == NULL || t->file->path == NULL) |
| 87 | + | if (file == NULL || file->name == NULL || file->path == NULL) |
| 88 | 88 | | return; |
| 89 | | − | if (stat(t->file->path, &fstats) < 0) |
| 89 | + | if (stat(file->path, &fstats) < 0) |
| 90 | 90 | | return; |
| 91 | 91 | | |
| 92 | | − | if ((cfile = tns_cache_filepath(t->file->path)) != NULL) { |
| 92 | + | if ((cfile = tns_cache_filepath(file->path)) != NULL) { |
| 93 | 93 | | if (force || stat(cfile, &cstats) < 0 || |
| 94 | 94 | | cstats.st_mtime != fstats.st_mtime) |
| 95 | 95 | | { |
| @@ -150,7 +150,7 @@ void tns_clean_cache(tns_t *tns) |
| 150 | 150 | | } |
| 151 | 151 | | |
| 152 | 152 | | |
| 153 | | − | void tns_init(tns_t *tns, int cnt, win_t *win, int *sel) |
| 153 | + | void tns_init(tns_t *tns, const fileinfo_t *files, int cnt, int *sel, win_t *win) |
| 154 | 154 | | { |
| 155 | 155 | | int len; |
| 156 | 156 | | const char *homedir, *dsuffix = ""; |
| @@ -164,6 +164,7 @@ void tns_init(tns_t *tns, int cnt, win_t *win, int *sel) |
| 164 | 164 | | } else { |
| 165 | 165 | | tns->thumbs = NULL; |
| 166 | 166 | | } |
| 167 | + | tns->files = files; |
| 167 | 168 | | tns->cap = cnt; |
| 168 | 169 | | tns->cnt = tns->loadnext = tns->first = 0; |
| 169 | 170 | | tns->sel = sel; |
| @@ -209,23 +210,24 @@ void tns_free(tns_t *tns) |
| 209 | 210 | | } |
| 210 | 211 | | } |
| 211 | 212 | | |
| 212 | | − | bool tns_load(tns_t *tns, int n, const fileinfo_t *file, bool force) |
| 213 | + | bool tns_load(tns_t *tns, int n, bool force) |
| 213 | 214 | | { |
| 214 | 215 | | int w, h; |
| 215 | 216 | | bool cache_hit = false; |
| 216 | 217 | | float z, zw, zh; |
| 217 | 218 | | thumb_t *t; |
| 218 | 219 | | Imlib_Image im = NULL; |
| 220 | + | const fileinfo_t *file; |
| 219 | 221 | | |
| 220 | 222 | | if (tns == NULL || tns->thumbs == NULL) |
| 221 | 223 | | return false; |
| 222 | | − | if (file == NULL || file->name == NULL || file->path == NULL) |
| 223 | | − | return false; |
| 224 | 224 | | if (n < 0 || n >= tns->cap) |
| 225 | 225 | | return false; |
| 226 | + | file = &tns->files[n]; |
| 227 | + | if (file->name == NULL || file->path == NULL) |
| 228 | + | return false; |
| 226 | 229 | | |
| 227 | 230 | | t = &tns->thumbs[n]; |
| 228 | | − | t->file = file; |
| 229 | 231 | | |
| 230 | 232 | | if (t->im != NULL) { |
| 231 | 233 | | imlib_context_set_image(t->im); |
| @@ -322,7 +324,7 @@ bool tns_load(tns_t *tns, int n, const fileinfo_t *file, bool force) |
| 322 | 324 | | imlib_free_image_and_decache(); |
| 323 | 325 | | |
| 324 | 326 | | if (!cache_hit) |
| 325 | | − | tns_cache_write(t, true); |
| 327 | + | tns_cache_write(t, file, true); |
| 326 | 328 | | |
| 327 | 329 | | t->loaded = true; |
| 328 | 330 | | tns->dirty = true; |
| @@ -398,7 +400,7 @@ void tns_render(tns_t *tns) |
| 398 | 400 | | imlib_context_set_image(t->im); |
| 399 | 401 | | imlib_render_image_part_on_drawable_at_size(0, 0, t->w, t->h, |
| 400 | 402 | | t->x, t->y, t->w, t->h); |
| 401 | | − | if (t->file->marked) |
| 403 | + | if (tns->files[tns->first + i].marked) |
| 402 | 404 | | tns_mark(tns, tns->first + i, true); |
| 403 | 405 | | if ((i + 1) % tns->cols == 0) { |
| 404 | 406 | | x = tns->x; |
| @@ -460,7 +462,7 @@ void tns_highlight(tns_t *tns, int n, bool hl) |
| 460 | 462 | | win_draw_rect(win, win->buf.pm, t->x - 3, t->y - 3, t->w + 6, t->h + 6, |
| 461 | 463 | | false, 2, col); |
| 462 | 464 | | |
| 463 | | − | if (!hl && t->file->marked) |
| 465 | + | if (!hl && tns->files[n].marked) |
| 464 | 466 | | tns_mark(tns, n, true); |
| 465 | 467 | | } |
| 466 | 468 | | } |