summaryrefslogtreecommitdiff
path: root/src/thumbnail.h
blob: d8bab866f5ddd7f35569377f7098c6db2f7b8da7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef GGAZE_THUMBNAIL_H
#define GGAZE_THUMBNAIL_H

/*:*
 * ggaze — thumbnail cache
 *
 * freedesktop Thumbnail Managing Standard: ~/.cache/thumbnails/normal (128)
 * and large (256), plus a custom x-large bucket for >256 (decision #37/T).
 * Stores PNG with Thumb::URI/MTime/Size; verifies mtime before trust. Decodes
 * asynchronously in a GTask worker; the GdkTexture is returned on the main
 * thread. See docs/tech-stack.md "Thumbnail cache".
 *
 * Copyright (c) 2026 ggaze contributors
 * SPDX-License-Identifier: GPL-3.0-or-later
 *:*/

#include <gdk/gdk.h>
#include <gio/gio.h>
#include <glib.h>

G_BEGIN_DECLS

typedef struct Thumbnail Thumbnail;

Thumbnail *thumbnail_new(void);
void       thumbnail_delete(Thumbnail *p_t);

/* Asynchronously get a thumbnail for p_file at ~i_size px (the nearest TMS
 * bucket >= i_size is cached). Returns the GdkTexture via p_cb on the main
 * thread (transfer full in thumbnail_get_finish). */
void thumbnail_get_async(Thumbnail *p_t, GFile *p_file, int i_size,
                         GCancellable *p_cancel, GAsyncReadyCallback p_cb,
                         gpointer p_data);
GdkTexture *thumbnail_get_finish(Thumbnail *p_t, GAsyncResult *p_res,
                                 GError **p_err);

G_END_DECLS

#endif /* GGAZE_THUMBNAIL_H */