Deduplicate cr3 image loader
[geeqie.git] / src / thumb-standard.h
1 /*
2  * Copyright (C) 2006 John Ellis
3  * Copyright (C) 2008 - 2016 The Geeqie Team
4  *
5  * Author: John Ellis
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 #ifndef THUMB_STANDARD_H
23 #define THUMB_STANDARD_H
24
25 #include <sys/types.h>
26
27 #include <gdk-pixbuf/gdk-pixbuf.h>
28 #include <glib.h>
29
30 #include <config.h>
31
32 #include "main-defines.h"
33
34 struct FileData;
35 struct ImageLoader;
36
37 #if GLIB_CHECK_VERSION (2, 34, 0)
38 #define THUMB_FOLDER_GLOBAL "thumbnails"
39 #else
40 #define THUMB_FOLDER_GLOBAL ".thumbnails"
41 #endif
42 #define THUMB_FOLDER_LOCAL  ".thumblocal"
43 #define THUMB_FOLDER_NORMAL "normal"
44 #define THUMB_FOLDER_LARGE  "large"
45 #define THUMB_FOLDER_FAIL   "fail" G_DIR_SEPARATOR_S GQ_APPNAME_LC "-" VERSION
46 #define THUMB_NAME_EXTENSION ".png"
47
48
49 struct ThumbLoaderStd
50 {
51         gboolean standard_loader;
52
53         ImageLoader *il;
54         FileData *fd;
55
56         time_t source_mtime;
57         off_t source_size;
58         mode_t source_mode;
59
60         gchar *thumb_path;
61         gchar *thumb_uri;
62         const gchar *local_uri;
63
64         gboolean thumb_path_local;
65
66         gint requested_width;
67         gint requested_height;
68
69         gboolean cache_enable;
70         gboolean cache_local;
71         gboolean cache_hit;
72         gboolean cache_retry;
73
74         gdouble progress;
75
76         using Func = void (*)(ThumbLoaderStd *, gpointer);
77         Func func_done;
78         Func func_error;
79         Func func_progress;
80
81         gpointer data;
82 };
83
84
85 ThumbLoaderStd *thumb_loader_std_new(gint width, gint height);
86 void thumb_loader_std_set_callbacks(ThumbLoaderStd *tl,
87                                     ThumbLoaderStd::Func func_done,
88                                     ThumbLoaderStd::Func func_error,
89                                     ThumbLoaderStd::Func func_progress,
90                                     gpointer data);
91 void thumb_loader_std_set_cache(ThumbLoaderStd *tl, gboolean enable_cache, gboolean local, gboolean retry_failed);
92 gboolean thumb_loader_std_start(ThumbLoaderStd *tl, FileData *fd);
93 void thumb_loader_std_free(ThumbLoaderStd *tl);
94
95 GdkPixbuf *thumb_loader_std_get_pixbuf(ThumbLoaderStd *tl);
96
97 void thumb_loader_std_calibrate_pixbuf(FileData *fd, GdkPixbuf *pixbuf);
98
99 /**
100  * @headerfile thumb_loader_std_thumb_file_validate
101  * validates a non local thumbnail file,
102  * calling func_valid with the information when app is idle
103  * for thumbnail's without a file: uri, validates against allowed_age in days
104  */
105 ThumbLoaderStd *thumb_loader_std_thumb_file_validate(const gchar *thumb_path, gint allowed_days,
106                                                      void (*func_valid)(const gchar *path, gboolean valid, gpointer data),
107                                                      gpointer data);
108 void thumb_loader_std_thumb_file_validate_cancel(ThumbLoaderStd *tl);
109
110
111 void thumb_std_maint_removed(const gchar *source);
112 void thumb_std_maint_moved(const gchar *source, const gchar *dest);
113
114
115 #endif
116 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */