annotate src/thumb_standard.c @ 1149:c4fcf8001574

Implement preliminary support for XDG Base Directory Specification. See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html. This feature was requested for a long time (feature requests #1950978 and #2289481). For now, it is disabled since it breaks compatibility with previous versions. To be able to test it, you have to enable it by defining USE_XDG to 1 in main.h. geeqierc and other conf files are going to: $XDG_CONFIG_HOME/geeqie/ (default to $HOME/.config/geeqie/). metadata and thumbnails cache (if std is not used) are going to: $XDG_CACHE_HOME/geeqie/metadata/ (default to $HOME/.cache/geeqie/metadata/) and $XDG_CACHE_HOME/geeqie/thumbnails/ (default to $HOME/.cache/geeqie/thumbnails/) collections are going to: $XDG_DATA_HOME/geeqie/collections/ (default to $HOME/.local/share/geeqie/collections/) Please test and report any issue.
author zas_
date Sat, 15 Nov 2008 20:17:14 +0000
parents 95860439070b
children 8b89e3ff286b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1 /*
196
f6e307c7bad6 rename GQview -> Geeqie over the code
nadvornik
parents: 138
diff changeset
2 * Geeqie
79
528e3432e0c0 Thu Oct 19 07:23:37 2006 John Ellis <johne@verizon.net>
gqview
parents: 66
diff changeset
3 * (C) 2006 John Ellis
475
48c8e49b571c updated copyright in source files
nadvornik
parents: 446
diff changeset
4 * Copyright (C) 2008 The Geeqie Team
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
5 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
6 * Author: John Ellis
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
7 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
8 * This software is released under the GNU General Public License (GNU GPL).
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
9 * Please read the included file COPYING for more information.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
10 * This software comes with no warranty of any kind, use at your own risk!
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
11 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
12
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
13
281
9995c5fb202a gqview.h -> main.h
zas_
parents: 255
diff changeset
14 #include "main.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
15 #include "thumb_standard.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
16
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
17 #include "image-load.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
18 #include "md5-util.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
19 #include "pixbuf_util.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
20 #include "ui_fileops.h"
838
9bd49e725ad3 use FileData in thumb_loader
nadvornik
parents: 827
diff changeset
21 #include "filedata.h"
839
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 838
diff changeset
22 #include "exif.h"
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
23
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
24
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
25 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
26 * This thumbnail caching implementation attempts to conform
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
27 * to the Thumbnail Managing Standard proposed on freedesktop.org
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
28 * The standard is documented here:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
29 * http://triq.net/~jens/thumbnail-spec/index.html
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
30 * (why isn't it actually hosted on freedesktop.org?)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
31 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
32 * This code attempts to conform to version 0.7.0 of the standard.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
33 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
34 * Notes:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
35 * > Validation of the thumb's embedded uri is a simple strcmp between our
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
36 * version of the escaped uri and the thumb's escaped uri. But not all uri
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
37 * escape functions escape the same set of chars, comparing the unescaped
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
38 * versions may be more accurate.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
39 * > Only Thumb::URI and Thumb::MTime are stored in a thumb at this time.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
40 * Storing the Size, Width, Height should probably be implemented.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
41 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
42
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
43
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44 #define THUMB_SIZE_NORMAL 128
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
45 #define THUMB_SIZE_LARGE 256
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
46
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
47 #define THUMB_MARKER_URI "tEXt::Thumb::URI"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
48 #define THUMB_MARKER_MTIME "tEXt::Thumb::MTime"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
49 #define THUMB_MARKER_SIZE "tEXt::Thumb::Size"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
50 #define THUMB_MARKER_WIDTH "tEXt::Thumb::Image::Width"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
51 #define THUMB_MARKER_HEIGHT "tEXt::Thumb::Image::Height"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
52 #define THUMB_MARKER_APP "tEXt::Software"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
53
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
54 #define THUMB_PERMS_FOLDER 0700
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
55 #define THUMB_PERMS_THUMB 0600
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
56
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
57
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
58
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
59 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
60 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
61 * thumbnail loader
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62 *-----------------------------------------------------------------------------
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
64
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
65
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
66 static void thumb_loader_std_error_cb(ImageLoader *il, gpointer data);
1009
dd311dae857a fixed thumbnail loader for the new raw preview interface
nadvornik
parents: 972
diff changeset
67 static gint thumb_loader_std_setup(ThumbLoaderStd *tl, FileData *fd);
dd311dae857a fixed thumbnail loader for the new raw preview interface
nadvornik
parents: 972
diff changeset
68 static gint thumb_loader_std_setup_path(ThumbLoaderStd *tl, const gchar *path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
69
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
70
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
71 ThumbLoaderStd *thumb_loader_std_new(gint width, gint height)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
72 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
73 ThumbLoaderStd *tl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
75 tl = g_new0(ThumbLoaderStd, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
76
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
77 tl->standard_loader = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
79 tl->requested_width = width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
80 tl->requested_height = height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
82 tl->il = NULL;
838
9bd49e725ad3 use FileData in thumb_loader
nadvornik
parents: 827
diff changeset
83 tl->fd = NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
84
333
767b53cd9ab7 Rename thumbnails related options.
zas_
parents: 318
diff changeset
85 tl->cache_enable = options->thumbnails.enable_caching;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
86 tl->cache_local = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87 tl->cache_retry = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
88
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
89 return tl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
90 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92 void thumb_loader_std_set_callbacks(ThumbLoaderStd *tl,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93 ThumbLoaderStdFunc func_done,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
94 ThumbLoaderStdFunc func_error,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
95 ThumbLoaderStdFunc func_progress,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
96 gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
98 if (!tl) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
99
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
100 tl->func_done = func_done;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
101 tl->func_error = func_error;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
102 tl->func_progress = func_progress;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
103 tl->data = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
104 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
105
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
106 static void thumb_loader_std_reset(ThumbLoaderStd *tl)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
107 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
108 image_loader_free(tl->il);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
109 tl->il = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
110
838
9bd49e725ad3 use FileData in thumb_loader
nadvornik
parents: 827
diff changeset
111 file_data_unref(tl->fd);
9bd49e725ad3 use FileData in thumb_loader
nadvornik
parents: 827
diff changeset
112 tl->fd = NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
113
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
114 g_free(tl->thumb_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
115 tl->thumb_path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
117 g_free(tl->thumb_uri);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
118 tl->thumb_uri = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
119 tl->local_uri = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
120
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
121 tl->thumb_path_local = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
123 tl->cache_hit = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
124
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
125 tl->source_mtime = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
126 tl->source_size = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
127 tl->source_mode = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
128
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
129 tl->progress = 0.0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
130 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
131
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
132 static gchar *thumb_std_cache_path(const gchar *path, const gchar *uri, gint local,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
133 const gchar *cache_subfolder)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
134 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
135 gchar *result = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
136 gchar *md5_text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
137 guchar digest[16];
716
c534b8cecc1f thumb_std_cache_path(): use g_build_filename() and simplify.
zas_
parents: 671
diff changeset
138 gchar *name;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
140 if (!path || !uri || !cache_subfolder) return NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
141
716
c534b8cecc1f thumb_std_cache_path(): use g_build_filename() and simplify.
zas_
parents: 671
diff changeset
142 md5_get_digest((guchar *)uri, strlen(uri), digest);
c534b8cecc1f thumb_std_cache_path(): use g_build_filename() and simplify.
zas_
parents: 671
diff changeset
143 md5_text = md5_digest_to_text(digest);
c534b8cecc1f thumb_std_cache_path(): use g_build_filename() and simplify.
zas_
parents: 671
diff changeset
144
c534b8cecc1f thumb_std_cache_path(): use g_build_filename() and simplify.
zas_
parents: 671
diff changeset
145 if (!md5_text) return NULL;
c534b8cecc1f thumb_std_cache_path(): use g_build_filename() and simplify.
zas_
parents: 671
diff changeset
146
c534b8cecc1f thumb_std_cache_path(): use g_build_filename() and simplify.
zas_
parents: 671
diff changeset
147 name = g_strconcat(md5_text, THUMB_NAME_EXTENSION, NULL);
c534b8cecc1f thumb_std_cache_path(): use g_build_filename() and simplify.
zas_
parents: 671
diff changeset
148
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
149 if (local)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
150 {
716
c534b8cecc1f thumb_std_cache_path(): use g_build_filename() and simplify.
zas_
parents: 671
diff changeset
151 gchar *base = remove_level_from_path(path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
152
716
c534b8cecc1f thumb_std_cache_path(): use g_build_filename() and simplify.
zas_
parents: 671
diff changeset
153 result = g_build_filename(base, THUMB_FOLDER_LOCAL, cache_subfolder, name, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
154 g_free(base);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
155 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
156 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
157 {
716
c534b8cecc1f thumb_std_cache_path(): use g_build_filename() and simplify.
zas_
parents: 671
diff changeset
158 result = g_build_filename(homedir(), THUMB_FOLDER_GLOBAL, cache_subfolder, name, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
159 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
160
716
c534b8cecc1f thumb_std_cache_path(): use g_build_filename() and simplify.
zas_
parents: 671
diff changeset
161 g_free(name);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
162 g_free(md5_text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
163
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
164 return result;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
165 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
166
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
167 static gchar *thumb_loader_std_cache_path(ThumbLoaderStd *tl, gint local, GdkPixbuf *pixbuf, gint fail)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
168 {
436
f0289d80ecc1 Rename inappropriate folder_size to folder.
zas_
parents: 333
diff changeset
169 const gchar *folder;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
170 gint w, h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
171
838
9bd49e725ad3 use FileData in thumb_loader
nadvornik
parents: 827
diff changeset
172 if (!tl->fd || !tl->thumb_uri) return NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
173
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
174 if (pixbuf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
175 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
176 w = gdk_pixbuf_get_width(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
177 h = gdk_pixbuf_get_height(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
178 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
179 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
180 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
181 w = tl->requested_width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
182 h = tl->requested_height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
183 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
184
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185 if (fail)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 {
436
f0289d80ecc1 Rename inappropriate folder_size to folder.
zas_
parents: 333
diff changeset
187 folder = THUMB_FOLDER_FAIL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
189 else if (w > THUMB_SIZE_NORMAL || h > THUMB_SIZE_NORMAL)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
190 {
436
f0289d80ecc1 Rename inappropriate folder_size to folder.
zas_
parents: 333
diff changeset
191 folder = THUMB_FOLDER_LARGE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
192 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
193 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
194 {
436
f0289d80ecc1 Rename inappropriate folder_size to folder.
zas_
parents: 333
diff changeset
195 folder = THUMB_FOLDER_NORMAL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
196 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
197
838
9bd49e725ad3 use FileData in thumb_loader
nadvornik
parents: 827
diff changeset
198 return thumb_std_cache_path(tl->fd->path,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
199 (local) ? tl->local_uri : tl->thumb_uri,
436
f0289d80ecc1 Rename inappropriate folder_size to folder.
zas_
parents: 333
diff changeset
200 local, folder);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
201 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
202
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
203 static gint thumb_loader_std_fail_check(ThumbLoaderStd *tl)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
204 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
205 gchar *fail_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
206 gint result = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
207
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
208 fail_path = thumb_loader_std_cache_path(tl, FALSE, NULL, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
209 if (isfile(fail_path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
210 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
213 if (tl->cache_retry)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
214 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
215 pixbuf = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
216 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
217 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
218 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
219 gchar *pathl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
220
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
221 pathl = path_from_utf8(fail_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
222 pixbuf = gdk_pixbuf_new_from_file(pathl, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
223 g_free(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
224 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
225
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
226 if (pixbuf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
227 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
228 const gchar *mtime_str;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
229
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
230 mtime_str = gdk_pixbuf_get_option(pixbuf, THUMB_MARKER_MTIME);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
231 if (mtime_str && strtol(mtime_str, NULL, 10) == tl->source_mtime)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
232 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
233 result = TRUE;
838
9bd49e725ad3 use FileData in thumb_loader
nadvornik
parents: 827
diff changeset
234 DEBUG_1("thumb fail valid: %s", tl->fd->path);
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
235 DEBUG_1(" thumb: %s", fail_path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
237
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
238 g_object_unref(G_OBJECT(pixbuf));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
240
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
241 if (!result) unlink_file(fail_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
242 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
243 g_free(fail_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
245 return result;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
246 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
247
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
248 static gint thumb_loader_std_validate(ThumbLoaderStd *tl, GdkPixbuf *pixbuf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
249 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
250 const gchar *valid_uri;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
251 const gchar *uri;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
252 const gchar *mtime_str;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253 time_t mtime;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
254 gint w, h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
255
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
256 if (!pixbuf) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
258 w = gdk_pixbuf_get_width(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
259 h = gdk_pixbuf_get_height(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
260
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
261 if (w != THUMB_SIZE_NORMAL && w != THUMB_SIZE_LARGE &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
262 h != THUMB_SIZE_NORMAL && h != THUMB_SIZE_LARGE) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
263
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
264 valid_uri = (tl->thumb_path_local) ? tl->local_uri : tl->thumb_uri;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
265
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
266 uri = gdk_pixbuf_get_option(pixbuf, THUMB_MARKER_URI);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
267 mtime_str = gdk_pixbuf_get_option(pixbuf, THUMB_MARKER_MTIME);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
268
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
269 if (!mtime_str || !uri || !valid_uri) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
270 if (strcmp(uri, valid_uri) != 0) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
271
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
272 mtime = strtol(mtime_str, NULL, 10);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
273 if (tl->source_mtime != mtime) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
274
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
275 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
276 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
277
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
278 static void thumb_loader_std_save(ThumbLoaderStd *tl, GdkPixbuf *pixbuf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
279 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
280 gchar *base_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
281 gchar *tmp_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
282 gint fail;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
283
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
284 if (!tl->cache_enable || tl->cache_hit) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
285 if (tl->thumb_path) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
286
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
287 if (!pixbuf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
288 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
289 /* local failures are not stored */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
290 if (tl->cache_local) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
291
436
f0289d80ecc1 Rename inappropriate folder_size to folder.
zas_
parents: 333
diff changeset
292 pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 1, 1);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
293 fail = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
294 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
295 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
296 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
297 g_object_ref(G_OBJECT(pixbuf));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
298 fail = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
299 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
300
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
301 tl->thumb_path = thumb_loader_std_cache_path(tl, tl->cache_local, pixbuf, fail);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
302 if (!tl->thumb_path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
303 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
304 g_object_unref(G_OBJECT(pixbuf));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
305 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
306 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
307 tl->thumb_path_local = tl->cache_local;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
308
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
309 /* create thumbnail dir if needed */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
310 base_path = remove_level_from_path(tl->thumb_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
311 if (tl->cache_local)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
312 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
313 if (!isdir(base_path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
314 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
315 struct stat st;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
316 gchar *source_base;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
317
838
9bd49e725ad3 use FileData in thumb_loader
nadvornik
parents: 827
diff changeset
318 source_base = remove_level_from_path(tl->fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
319 if (stat_utf8(source_base, &st))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
320 {
1148
95860439070b Replace cache_ensure_dir_exists() by new recursive_mkdir_if_not_exists().
zas_
parents: 1055
diff changeset
321 recursive_mkdir_if_not_exists(base_path, st.st_mode);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
322 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
323 g_free(source_base);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
324 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
325 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
326 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
327 {
1148
95860439070b Replace cache_ensure_dir_exists() by new recursive_mkdir_if_not_exists().
zas_
parents: 1055
diff changeset
328 recursive_mkdir_if_not_exists(base_path, THUMB_PERMS_FOLDER);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
329 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
330 g_free(base_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
331
838
9bd49e725ad3 use FileData in thumb_loader
nadvornik
parents: 827
diff changeset
332 DEBUG_1("thumb saving: %s", tl->fd->path);
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
333 DEBUG_1(" saved: %s", tl->thumb_path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
334
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
335 /* save thumb, using a temp file then renaming into place */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
336 tmp_path = unique_filename(tl->thumb_path, ".tmp", "_", 2);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
337 if (tmp_path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
338 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
339 const gchar *mark_uri;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
340 gchar *mark_app;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
341 gchar *mark_mtime;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
342 gchar *pathl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
343 gint success;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
344
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
345 mark_uri = (tl->cache_local) ? tl->local_uri :tl->thumb_uri;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
346
288
d1f74154463e Replace occurences of Geeqie / geeqie by constants defined in main.h.
zas_
parents: 281
diff changeset
347 mark_app = g_strdup_printf("%s %s", GQ_APPNAME, VERSION);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
348 mark_mtime = g_strdup_printf("%lu", tl->source_mtime);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
349
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
350 pathl = path_from_utf8(tmp_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
351 success = gdk_pixbuf_save(pixbuf, pathl, "png", NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
352 THUMB_MARKER_URI, mark_uri,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
353 THUMB_MARKER_MTIME, mark_mtime,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
354 THUMB_MARKER_APP, mark_app,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
355 NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
356 if (success)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
357 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
358 chmod(pathl, (tl->cache_local) ? tl->source_mode : THUMB_PERMS_THUMB);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
359 success = rename_file(tmp_path, tl->thumb_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
360 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
361
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
362 g_free(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
363
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
364 g_free(mark_mtime);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
365 g_free(mark_app);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
366
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
367 g_free(tmp_path);
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
368 if (!success)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
369 {
838
9bd49e725ad3 use FileData in thumb_loader
nadvornik
parents: 827
diff changeset
370 DEBUG_1("thumb save failed: %s", tl->fd->path);
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
371 DEBUG_1(" thumb: %s", tl->thumb_path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
372 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
373
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
374 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
375
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
376 g_object_unref(G_OBJECT(pixbuf));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
377 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
378
876
2d8705f33da5 set fallback thumbnail pixbuf only if the loading really fails
nadvornik
parents: 864
diff changeset
379 static void thumb_loader_std_set_fallback(ThumbLoaderStd *tl)
2d8705f33da5 set fallback thumbnail pixbuf only if the loading really fails
nadvornik
parents: 864
diff changeset
380 {
2d8705f33da5 set fallback thumbnail pixbuf only if the loading really fails
nadvornik
parents: 864
diff changeset
381 if (tl->fd->thumb_pixbuf) g_object_unref(tl->fd->thumb_pixbuf);
2d8705f33da5 set fallback thumbnail pixbuf only if the loading really fails
nadvornik
parents: 864
diff changeset
382 tl->fd->thumb_pixbuf = pixbuf_fallback(tl->fd, tl->requested_width, tl->requested_height);
2d8705f33da5 set fallback thumbnail pixbuf only if the loading really fails
nadvornik
parents: 864
diff changeset
383 }
2d8705f33da5 set fallback thumbnail pixbuf only if the loading really fails
nadvornik
parents: 864
diff changeset
384
14
25335c62cd9b ##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents: 9
diff changeset
385 static GdkPixbuf *thumb_loader_std_finish(ThumbLoaderStd *tl, GdkPixbuf *pixbuf, gint shrunk)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
386 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
387 GdkPixbuf *pixbuf_thumb = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
388 GdkPixbuf *result;
839
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 838
diff changeset
389 GdkPixbuf *rotated = NULL;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
390 gint sw, sh;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
391
839
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 838
diff changeset
392
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 838
diff changeset
393 if (!tl->cache_hit && options->image.exif_rotate_enable)
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 838
diff changeset
394 {
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 838
diff changeset
395 if (!tl->fd->exif_orientation)
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 838
diff changeset
396 {
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 838
diff changeset
397 ExifData *exif = exif_read_fd(tl->fd);
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 838
diff changeset
398 gint orientation;
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 838
diff changeset
399
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 838
diff changeset
400 if (exif && exif_get_integer(exif, "Exif.Image.Orientation", &orientation))
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 838
diff changeset
401 tl->fd->exif_orientation = orientation;
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 838
diff changeset
402 else
842
94048d7843ba do not allocate new buffer for thumbnails with correct orientation
nadvornik
parents: 841
diff changeset
403 tl->fd->exif_orientation = EXIF_ORIENTATION_TOP_LEFT;
844
efed9a1520d6 implemented generic FileData cache
nadvornik
parents: 842
diff changeset
404 exif_free_fd(tl->fd, exif);
839
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 838
diff changeset
405 }
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 838
diff changeset
406
842
94048d7843ba do not allocate new buffer for thumbnails with correct orientation
nadvornik
parents: 841
diff changeset
407 if (tl->fd->exif_orientation != EXIF_ORIENTATION_TOP_LEFT)
94048d7843ba do not allocate new buffer for thumbnails with correct orientation
nadvornik
parents: 841
diff changeset
408 {
94048d7843ba do not allocate new buffer for thumbnails with correct orientation
nadvornik
parents: 841
diff changeset
409 rotated = pixbuf_apply_orientation(pixbuf, tl->fd->exif_orientation);
94048d7843ba do not allocate new buffer for thumbnails with correct orientation
nadvornik
parents: 841
diff changeset
410 pixbuf = rotated;
94048d7843ba do not allocate new buffer for thumbnails with correct orientation
nadvornik
parents: 841
diff changeset
411 }
839
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 838
diff changeset
412 }
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 838
diff changeset
413
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414 sw = gdk_pixbuf_get_width(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415 sh = gdk_pixbuf_get_height(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
416
40
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
417 if (tl->cache_enable)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
418 {
40
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
419 if (!tl->cache_hit)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
420 {
40
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
421 gint cache_w, cache_h;
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
422
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
423 if (tl->requested_width > THUMB_SIZE_NORMAL || tl->requested_height > THUMB_SIZE_NORMAL)
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
424 {
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
425 cache_w = cache_h = THUMB_SIZE_LARGE;
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
426 }
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
427 else
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
428 {
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
429 cache_w = cache_h = THUMB_SIZE_NORMAL;
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
430 }
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
431
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
432 if (sw > cache_w || sh > cache_h || shrunk)
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
433 {
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
434 gint thumb_w, thumb_h;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
435
864
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 845
diff changeset
436 if (pixbuf_scale_aspect(cache_w, cache_h, sw, sh,
40
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
437 &thumb_w, &thumb_h))
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
438 {
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
439 pixbuf_thumb = gdk_pixbuf_scale_simple(pixbuf, thumb_w, thumb_h,
333
767b53cd9ab7 Rename thumbnails related options.
zas_
parents: 318
diff changeset
440 (GdkInterpType)options->thumbnails.quality);
40
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
441 }
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
442 else
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
443 {
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
444 pixbuf_thumb = pixbuf;
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
445 g_object_ref(G_OBJECT(pixbuf_thumb));
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
446 }
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
447
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
448 thumb_loader_std_save(tl, pixbuf_thumb);
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
449 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
450 }
40
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
451 else if (tl->cache_hit &&
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
452 tl->cache_local && !tl->thumb_path_local)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
453 {
40
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
454 /* A local cache save was requested, but a valid thumb is in $HOME,
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
455 * so specifically save as a local thumbnail.
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
456 */
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
457 g_free(tl->thumb_path);
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
458 tl->thumb_path = NULL;
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
459
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
460 tl->cache_hit = FALSE;
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
461
838
9bd49e725ad3 use FileData in thumb_loader
nadvornik
parents: 827
diff changeset
462 DEBUG_1("thumb copied: %s", tl->fd->path);
40
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
463
dcc04a6a58bf Sat Apr 16 12:29:42 2005 John Ellis <johne@verizon.net>
gqview
parents: 14
diff changeset
464 thumb_loader_std_save(tl, pixbuf);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
465 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
466 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
467
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
468 if (sw <= tl->requested_width && sh <= tl->requested_height)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
469 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
470 result = pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
471 g_object_ref(result);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
472 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
473 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
474 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
475 gint thumb_w, thumb_h;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
476
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
477 if (pixbuf_thumb)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
478 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
479 pixbuf = pixbuf_thumb;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
480 sw = gdk_pixbuf_get_width(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
481 sh = gdk_pixbuf_get_height(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
482 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
483
864
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 845
diff changeset
484 if (pixbuf_scale_aspect(tl->requested_width, tl->requested_height, sw, sh,
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
485 &thumb_w, &thumb_h))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
486 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
487 result = gdk_pixbuf_scale_simple(pixbuf, thumb_w, thumb_h,
333
767b53cd9ab7 Rename thumbnails related options.
zas_
parents: 318
diff changeset
488 (GdkInterpType)options->thumbnails.quality);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
489 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
490 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
491 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
492 result = pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
493 g_object_ref(result);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
494 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
495 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
496
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
497 if (pixbuf_thumb) g_object_unref(pixbuf_thumb);
839
14520c3a91f8 rotate thumbnails by exif
nadvornik
parents: 838
diff changeset
498 if (rotated) g_object_unref(rotated);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
499
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
500 return result;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
501 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
502
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
503 static gint thumb_loader_std_next_source(ThumbLoaderStd *tl, gint remove_broken)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
504 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
505 image_loader_free(tl->il);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
506 tl->il = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
507
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
508 if (tl->thumb_path)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
509 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
510 if (!tl->thumb_path_local && remove_broken)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
511 {
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
512 DEBUG_1("thumb broken, unlinking: %s", tl->thumb_path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
513 unlink_file(tl->thumb_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
514 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
515
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
516 g_free(tl->thumb_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
517 tl->thumb_path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
518
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
519 if (!tl->thumb_path_local)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
520 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
521 tl->thumb_path = thumb_loader_std_cache_path(tl, TRUE, NULL, FALSE);
1009
dd311dae857a fixed thumbnail loader for the new raw preview interface
nadvornik
parents: 972
diff changeset
522 if (isfile(tl->thumb_path) && thumb_loader_std_setup_path(tl, tl->thumb_path))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
523 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
524 tl->thumb_path_local = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
525 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
526 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
527
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
528 g_free(tl->thumb_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
529 tl->thumb_path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
530 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
531
1009
dd311dae857a fixed thumbnail loader for the new raw preview interface
nadvornik
parents: 972
diff changeset
532 if (thumb_loader_std_setup(tl, tl->fd)) return TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
533 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
534
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
535 thumb_loader_std_save(tl, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
536 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
537 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
538
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
539 static void thumb_loader_std_done_cb(ImageLoader *il, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
540 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
541 ThumbLoaderStd *tl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
542 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
543
881
10d0bf784323 Prevent segfault in certain conditions when displaying debug message.
zas_
parents: 876
diff changeset
544 DEBUG_1("thumb image done: %s", tl->fd ? tl->fd->path : "???");
1011
616b14da08c2 do not access image_loader directly
nadvornik
parents: 1009
diff changeset
545 DEBUG_1(" from: %s", image_loader_get_fd(tl->il)->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
546
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
547 pixbuf = image_loader_get_pixbuf(tl->il);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
548 if (!pixbuf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
549 {
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
550 DEBUG_1("...but no pixbuf");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
551 thumb_loader_std_error_cb(il, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
552 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
553 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
554
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
555 if (tl->thumb_path && !thumb_loader_std_validate(tl, pixbuf))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
556 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
557 if (thumb_loader_std_next_source(tl, TRUE)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
558
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
559 if (tl->func_error) tl->func_error(tl, tl->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
560 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
561 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
562
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
563 tl->cache_hit = (tl->thumb_path != NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
564
838
9bd49e725ad3 use FileData in thumb_loader
nadvornik
parents: 827
diff changeset
565 if (tl->fd)
9bd49e725ad3 use FileData in thumb_loader
nadvornik
parents: 827
diff changeset
566 {
845
06929cbcd796 renamed fd->pixbuf to fd->thumb_pixbuf
nadvornik
parents: 844
diff changeset
567 if (tl->fd->thumb_pixbuf) g_object_unref(tl->fd->thumb_pixbuf);
1011
616b14da08c2 do not access image_loader directly
nadvornik
parents: 1009
diff changeset
568 tl->fd->thumb_pixbuf = thumb_loader_std_finish(tl, pixbuf, image_loader_get_shrunk(il));
838
9bd49e725ad3 use FileData in thumb_loader
nadvornik
parents: 827
diff changeset
569 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
570
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
571 if (tl->func_done) tl->func_done(tl, tl->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
572 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
573
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
574 static void thumb_loader_std_error_cb(ImageLoader *il, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
575 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
576 ThumbLoaderStd *tl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
577
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
578 /* if at least some of the image is available, go to done */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
579 if (image_loader_get_pixbuf(tl->il) != NULL)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
580 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
581 thumb_loader_std_done_cb(il, data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
582 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
583 }
495
c7a2471e5c4e Introduce macros to display debug messages.
zas_
parents: 475
diff changeset
584
838
9bd49e725ad3 use FileData in thumb_loader
nadvornik
parents: 827
diff changeset
585 DEBUG_1("thumb image error: %s", tl->fd->path);
1011
616b14da08c2 do not access image_loader directly
nadvornik
parents: 1009
diff changeset
586 DEBUG_1(" from: %s", image_loader_get_fd(tl->il)->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
587
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
588 if (thumb_loader_std_next_source(tl, TRUE)) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
589
876
2d8705f33da5 set fallback thumbnail pixbuf only if the loading really fails
nadvornik
parents: 864
diff changeset
590 thumb_loader_std_set_fallback(tl);
2d8705f33da5 set fallback thumbnail pixbuf only if the loading really fails
nadvornik
parents: 864
diff changeset
591
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
592 if (tl->func_error) tl->func_error(tl, tl->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
593 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
594
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
595 static void thumb_loader_std_progress_cb(ImageLoader *il, gdouble percent, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
596 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
597 ThumbLoaderStd *tl = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
598
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
599 tl->progress = (gdouble)percent;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
600
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
601 if (tl->func_progress) tl->func_progress(tl, tl->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
602 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
603
1009
dd311dae857a fixed thumbnail loader for the new raw preview interface
nadvornik
parents: 972
diff changeset
604 static gint thumb_loader_std_setup(ThumbLoaderStd *tl, FileData *fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
605 {
1009
dd311dae857a fixed thumbnail loader for the new raw preview interface
nadvornik
parents: 972
diff changeset
606 tl->il = image_loader_new(fd);
1036
ab24c46aa6e4 load thumbnails with lower priority
nadvornik
parents: 1012
diff changeset
607 image_loader_set_priority(tl->il, G_PRIORITY_LOW);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
608
333
767b53cd9ab7 Rename thumbnails related options.
zas_
parents: 318
diff changeset
609 if (options->thumbnails.fast)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
610 {
14
25335c62cd9b ##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents: 9
diff changeset
611 /* this will speed up jpegs by up to 3x in some cases */
25335c62cd9b ##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents: 9
diff changeset
612 if (tl->requested_width <= THUMB_SIZE_NORMAL &&
25335c62cd9b ##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents: 9
diff changeset
613 tl->requested_height <= THUMB_SIZE_NORMAL)
25335c62cd9b ##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents: 9
diff changeset
614 {
25335c62cd9b ##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents: 9
diff changeset
615 image_loader_set_requested_size(tl->il, THUMB_SIZE_NORMAL, THUMB_SIZE_NORMAL);
25335c62cd9b ##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents: 9
diff changeset
616 }
25335c62cd9b ##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents: 9
diff changeset
617 else
25335c62cd9b ##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents: 9
diff changeset
618 {
25335c62cd9b ##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents: 9
diff changeset
619 image_loader_set_requested_size(tl->il, THUMB_SIZE_LARGE, THUMB_SIZE_LARGE);
25335c62cd9b ##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents: 9
diff changeset
620 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
621 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
622
1012
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
623 g_signal_connect (G_OBJECT(tl->il), "error", (GCallback)thumb_loader_std_error_cb, tl);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
624 if (tl->func_progress)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
625 {
1012
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
626 g_signal_connect (G_OBJECT(tl->il), "percent", (GCallback)thumb_loader_std_progress_cb, tl);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
627 }
1012
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
628 g_signal_connect (G_OBJECT(tl->il), "done", (GCallback)thumb_loader_std_done_cb, tl);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
629
1012
fe82830ab8fd converted image loader to a GObject and use signals for notification
nadvornik
parents: 1011
diff changeset
630 if (image_loader_start(tl->il))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
631 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
632 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
633 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
634
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
635 image_loader_free(tl->il);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
636 tl->il = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
637 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
638 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
639
1009
dd311dae857a fixed thumbnail loader for the new raw preview interface
nadvornik
parents: 972
diff changeset
640 static gint thumb_loader_std_setup_path(ThumbLoaderStd *tl, const gchar *path)
dd311dae857a fixed thumbnail loader for the new raw preview interface
nadvornik
parents: 972
diff changeset
641 {
dd311dae857a fixed thumbnail loader for the new raw preview interface
nadvornik
parents: 972
diff changeset
642 FileData *fd = file_data_new_simple(path);
dd311dae857a fixed thumbnail loader for the new raw preview interface
nadvornik
parents: 972
diff changeset
643 gint ret = thumb_loader_std_setup(tl, fd);
dd311dae857a fixed thumbnail loader for the new raw preview interface
nadvornik
parents: 972
diff changeset
644 file_data_unref(fd);
dd311dae857a fixed thumbnail loader for the new raw preview interface
nadvornik
parents: 972
diff changeset
645 return ret;
dd311dae857a fixed thumbnail loader for the new raw preview interface
nadvornik
parents: 972
diff changeset
646 }
dd311dae857a fixed thumbnail loader for the new raw preview interface
nadvornik
parents: 972
diff changeset
647
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
648 /*
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
649 * Note: Currently local_cache only specifies where to save a _new_ thumb, if
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
650 * a valid existing thumb is found anywhere the local thumb will not be created.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
651 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
652 void thumb_loader_std_set_cache(ThumbLoaderStd *tl, gint enable_cache, gint local, gint retry_failed)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
653 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
654 if (!tl) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
655
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
656 tl->cache_enable = enable_cache;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
657 tl->cache_local = local;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
658 tl->cache_retry = retry_failed;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
659 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
660
838
9bd49e725ad3 use FileData in thumb_loader
nadvornik
parents: 827
diff changeset
661 gint thumb_loader_std_start(ThumbLoaderStd *tl, FileData *fd)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
662 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
663 static gchar *thumb_cache = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
664 struct stat st;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
665
838
9bd49e725ad3 use FileData in thumb_loader
nadvornik
parents: 827
diff changeset
666 if (!tl || !fd) return FALSE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
667
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
668 thumb_loader_std_reset(tl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
669
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
670
838
9bd49e725ad3 use FileData in thumb_loader
nadvornik
parents: 827
diff changeset
671 tl->fd = file_data_ref(fd);
972
2ea1059a6091 set fallback pixbuf in case of missing file
nadvornik
parents: 881
diff changeset
672 if (!stat_utf8(fd->path, &st))
2ea1059a6091 set fallback pixbuf in case of missing file
nadvornik
parents: 881
diff changeset
673 {
2ea1059a6091 set fallback pixbuf in case of missing file
nadvornik
parents: 881
diff changeset
674 thumb_loader_std_set_fallback(tl);
2ea1059a6091 set fallback pixbuf in case of missing file
nadvornik
parents: 881
diff changeset
675 return FALSE;
2ea1059a6091 set fallback pixbuf in case of missing file
nadvornik
parents: 881
diff changeset
676 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
677 tl->source_mtime = st.st_mtime;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
678 tl->source_size = st.st_size;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
679 tl->source_mode = st.st_mode;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
680
717
aae956e84de4 Use g_build_filename().
zas_
parents: 716
diff changeset
681 if (!thumb_cache) thumb_cache = g_build_filename(homedir(), THUMB_FOLDER_GLOBAL, NULL);
838
9bd49e725ad3 use FileData in thumb_loader
nadvornik
parents: 827
diff changeset
682 if (strncmp(tl->fd->path, thumb_cache, strlen(thumb_cache)) != 0)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
683 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
684 gchar *pathl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
685
838
9bd49e725ad3 use FileData in thumb_loader
nadvornik
parents: 827
diff changeset
686 pathl = path_from_utf8(fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
687 tl->thumb_uri = g_filename_to_uri(pathl, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
688 tl->local_uri = filename_from_path(tl->thumb_uri);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
689 g_free(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
690 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
691
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
692 if (tl->cache_enable)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
693 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
694 gint found;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
695
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
696 tl->thumb_path = thumb_loader_std_cache_path(tl, FALSE, NULL, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
697 tl->thumb_path_local = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
698
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
699 found = isfile(tl->thumb_path);
1009
dd311dae857a fixed thumbnail loader for the new raw preview interface
nadvornik
parents: 972
diff changeset
700 if (found && thumb_loader_std_setup_path(tl, tl->thumb_path)) return TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
701
876
2d8705f33da5 set fallback thumbnail pixbuf only if the loading really fails
nadvornik
parents: 864
diff changeset
702 if (thumb_loader_std_fail_check(tl) ||
2d8705f33da5 set fallback thumbnail pixbuf only if the loading really fails
nadvornik
parents: 864
diff changeset
703 !thumb_loader_std_next_source(tl, found))
2d8705f33da5 set fallback thumbnail pixbuf only if the loading really fails
nadvornik
parents: 864
diff changeset
704 {
2d8705f33da5 set fallback thumbnail pixbuf only if the loading really fails
nadvornik
parents: 864
diff changeset
705 thumb_loader_std_set_fallback(tl);
2d8705f33da5 set fallback thumbnail pixbuf only if the loading really fails
nadvornik
parents: 864
diff changeset
706 return FALSE;
2d8705f33da5 set fallback thumbnail pixbuf only if the loading really fails
nadvornik
parents: 864
diff changeset
707 }
2d8705f33da5 set fallback thumbnail pixbuf only if the loading really fails
nadvornik
parents: 864
diff changeset
708 return TRUE;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
709 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
710
1009
dd311dae857a fixed thumbnail loader for the new raw preview interface
nadvornik
parents: 972
diff changeset
711 if (!thumb_loader_std_setup(tl, tl->fd))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
712 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
713 thumb_loader_std_save(tl, NULL);
876
2d8705f33da5 set fallback thumbnail pixbuf only if the loading really fails
nadvornik
parents: 864
diff changeset
714 thumb_loader_std_set_fallback(tl);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
715 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
716 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
717
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
718 return TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
719 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
720
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
721 void thumb_loader_std_free(ThumbLoaderStd *tl)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
722 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
723 if (!tl) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
724
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
725 thumb_loader_std_reset(tl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
726 g_free(tl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
727 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
728
864
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 845
diff changeset
729 GdkPixbuf *thumb_loader_std_get_pixbuf(ThumbLoaderStd *tl)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
730 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
731 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
732
845
06929cbcd796 renamed fd->pixbuf to fd->thumb_pixbuf
nadvornik
parents: 844
diff changeset
733 if (tl && tl->fd && tl->fd->thumb_pixbuf)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
734 {
845
06929cbcd796 renamed fd->pixbuf to fd->thumb_pixbuf
nadvornik
parents: 844
diff changeset
735 pixbuf = tl->fd->thumb_pixbuf;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
736 g_object_ref(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
737 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
738 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
739 {
864
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 845
diff changeset
740 pixbuf = pixbuf_fallback(NULL, tl->requested_width, tl->requested_height);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
741 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
742
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
743 return pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
744 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
745
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
746
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
747 typedef struct _ThumbValidate ThumbValidate;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
748 struct _ThumbValidate
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
749 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
750 ThumbLoaderStd *tl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
751 gchar *path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
752 gint days;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
753
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
754 void (*func_valid)(const gchar *path, gint valid, gpointer data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
755 gpointer data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
756
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
757 gint idle_id;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
758 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
759
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
760 static void thumb_loader_std_thumb_file_validate_free(ThumbValidate *tv)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
761 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
762 thumb_loader_std_free(tv->tl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
763 g_free(tv->path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
764 g_free(tv);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
765 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
766
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
767 void thumb_loader_std_thumb_file_validate_cancel(ThumbLoaderStd *tl)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
768 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
769 ThumbValidate *tv;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
770
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
771 if (!tl) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
772
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
773 tv = tl->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
774
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
775 if (tv->idle_id != -1) g_source_remove(tv->idle_id);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
776 tv->idle_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
777
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
778 thumb_loader_std_thumb_file_validate_free(tv);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
779 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
780
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
781 static void thumb_loader_std_thumb_file_validate_finish(ThumbValidate *tv, gint valid)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
782 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
783 if (tv->func_valid) tv->func_valid(tv->path, valid, tv->data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
784
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
785 thumb_loader_std_thumb_file_validate_free(tv);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
786 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
787
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
788 static void thumb_loader_std_thumb_file_validate_done_cb(ThumbLoaderStd *tl, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
789 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
790 ThumbValidate *tv = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
791 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
792 gint valid = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
793
864
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 845
diff changeset
794 /* this function is called on success, so the pixbuf should not be a fallback*/
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 845
diff changeset
795 pixbuf = thumb_loader_std_get_pixbuf(tv->tl);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
796 if (pixbuf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
797 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
798 const gchar *uri;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
799 const gchar *mtime_str;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
800
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
801 uri = gdk_pixbuf_get_option(pixbuf, THUMB_MARKER_URI);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
802 mtime_str = gdk_pixbuf_get_option(pixbuf, THUMB_MARKER_MTIME);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
803 if (uri && mtime_str)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
804 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
805 if (strncmp(uri, "file:", strlen("file:")) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
806 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
807 struct stat st;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
808 gchar *target;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
809
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
810 target = g_filename_from_uri(uri, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
811 if (stat(target, &st) == 0 &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
812 st.st_mtime == strtol(mtime_str, NULL, 10))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
813 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
814 valid = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
815 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
816 g_free(target);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
817 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
818 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
819 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
820 struct stat st;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
821
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
822 DEBUG_1("thumb uri foreign, doing day check: %s", uri);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
823
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
824 if (stat_utf8(tv->path, &st))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
825 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
826 time_t now;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
827
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
828 now = time(NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
829 if (st.st_atime >= now - (time_t)tv->days * 24 * 60 * 60)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
830 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
831 valid = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
832 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
833 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
834 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
835 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
836
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
837 g_object_unref(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
838 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
839
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
840 thumb_loader_std_thumb_file_validate_finish(tv, valid);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
841 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
842
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
843 static void thumb_loader_std_thumb_file_validate_error_cb(ThumbLoaderStd *tl, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
844 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
845 ThumbValidate *tv = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
846
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
847 thumb_loader_std_thumb_file_validate_finish(tv, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
848 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
849
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
850 static gint thumb_loader_std_thumb_file_validate_idle_cb(gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
851 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
852 ThumbValidate *tv = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
853
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
854 tv->idle_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
855 thumb_loader_std_thumb_file_validate_finish(tv, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
856
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
857 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
858 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
859
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
860 ThumbLoaderStd *thumb_loader_std_thumb_file_validate(const gchar *thumb_path, gint allowed_days,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
861 void (*func_valid)(const gchar *path, gint valid, gpointer data),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
862 gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
863 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
864 ThumbValidate *tv;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
865
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
866 tv = g_new0(ThumbValidate, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
867
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
868 tv->tl = thumb_loader_std_new(THUMB_SIZE_LARGE, THUMB_SIZE_LARGE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
869 thumb_loader_std_set_callbacks(tv->tl,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
870 thumb_loader_std_thumb_file_validate_done_cb,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
871 thumb_loader_std_thumb_file_validate_error_cb,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
872 NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
873 tv);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
874 thumb_loader_std_reset(tv->tl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
875
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
876 tv->path = g_strdup(thumb_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
877 tv->days = allowed_days;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
878 tv->func_valid = func_valid;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
879 tv->data = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
880
1009
dd311dae857a fixed thumbnail loader for the new raw preview interface
nadvornik
parents: 972
diff changeset
881 if (!thumb_loader_std_setup_path(tv->tl, thumb_path))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
882 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
883 tv->idle_id = g_idle_add(thumb_loader_std_thumb_file_validate_idle_cb, tv);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
884 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
885 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
886 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
887 tv->idle_id = -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
888 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
889
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
890 return tv->tl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
891 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
892
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
893 static void thumb_std_maint_remove_one(const gchar *source, const gchar *uri, gint local,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
894 const gchar *subfolder)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
895 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
896 gchar *thumb_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
897
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
898 thumb_path = thumb_std_cache_path(source,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
899 (local) ? filename_from_path(uri) : uri,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
900 local, subfolder);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
901 if (isfile(thumb_path))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
902 {
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
903 DEBUG_1("thumb removing: %s", thumb_path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
904 unlink_file(thumb_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
905 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
906 g_free(thumb_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
907 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
908
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
909 /* this also removes local thumbnails (the source is gone so it makes sense) */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
910 void thumb_std_maint_removed(const gchar *source)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
911 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
912 gchar *uri;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
913 gchar *sourcel;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
914
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
915 sourcel = path_from_utf8(source);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
916 uri = g_filename_to_uri(sourcel, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
917 g_free(sourcel);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
918
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
919 /* all this to remove a thumbnail? */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
920
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
921 thumb_std_maint_remove_one(source, uri, FALSE, THUMB_FOLDER_NORMAL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
922 thumb_std_maint_remove_one(source, uri, FALSE, THUMB_FOLDER_LARGE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
923 thumb_std_maint_remove_one(source, uri, FALSE, THUMB_FOLDER_FAIL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
924 thumb_std_maint_remove_one(source, uri, TRUE, THUMB_FOLDER_NORMAL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
925 thumb_std_maint_remove_one(source, uri, TRUE, THUMB_FOLDER_LARGE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
926
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
927 g_free(uri);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
928 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
929
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
930 typedef struct _TMaintMove TMaintMove;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
931 struct _TMaintMove
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
932 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
933 gchar *source;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
934 gchar *dest;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
935
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
936 ThumbLoaderStd *tl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
937 gchar *source_uri;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
938 gchar *thumb_path;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
939
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
940 gint pass;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
941 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
942
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
943 static GList *thumb_std_maint_move_list = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
944 static GList *thumb_std_maint_move_tail = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
945
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
946
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
947 static void thumb_std_maint_move_step(TMaintMove *tm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
948 static gint thumb_std_maint_move_idle(gpointer data);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
949
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
950
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
951 static void thumb_std_maint_move_validate_cb(const gchar *path, gint valid, gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
952 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
953 TMaintMove *tm = data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
954 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
955
864
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 845
diff changeset
956 /* this function is called on success, so the pixbuf should not be a fallback*/
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 845
diff changeset
957 pixbuf = thumb_loader_std_get_pixbuf(tm->tl);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
958 if (pixbuf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
959 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
960 const gchar *uri;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
961 const gchar *mtime_str;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
962
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
963 uri = gdk_pixbuf_get_option(pixbuf, THUMB_MARKER_URI);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
964 mtime_str = gdk_pixbuf_get_option(pixbuf, THUMB_MARKER_MTIME);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
965
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
966 if (uri && mtime_str && strcmp(uri, tm->source_uri) == 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
967 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
968 gchar *pathl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
969
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
970 /* The validation utility abuses ThumbLoader, and we
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
971 * abuse the utility just to load the thumbnail,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
972 * but the loader needs to look sane for the save to complete.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
973 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
974
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
975 tm->tl->cache_enable = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
976 tm->tl->cache_hit = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
977 tm->tl->cache_local = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
978
838
9bd49e725ad3 use FileData in thumb_loader
nadvornik
parents: 827
diff changeset
979 file_data_unref(tm->tl->fd);
9bd49e725ad3 use FileData in thumb_loader
nadvornik
parents: 827
diff changeset
980 tm->tl->fd = file_data_new_simple(tm->dest);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
981 tm->tl->source_mtime = strtol(mtime_str, NULL, 10);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
982
838
9bd49e725ad3 use FileData in thumb_loader
nadvornik
parents: 827
diff changeset
983 pathl = path_from_utf8(tm->tl->fd->path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
984 g_free(tm->tl->thumb_uri);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
985 tm->tl->thumb_uri = g_filename_to_uri(pathl, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
986 tm->tl->local_uri = filename_from_path(tm->tl->thumb_uri);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
987 g_free(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
988
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
989 g_free(tm->tl->thumb_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
990 tm->tl->thumb_path = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
991 tm->tl->thumb_path_local = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
992
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
993 DEBUG_1("thumb move attempting save:");
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
994
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
995 thumb_loader_std_save(tm->tl, pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
996 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
997
506
fc9c8a3e1a8b Handle the newline in DEBUG_N() macro instead of adding one
zas_
parents: 495
diff changeset
998 DEBUG_1("thumb move unlink: %s", tm->thumb_path);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
999 unlink_file(tm->thumb_path);
864
f40509d56fe3 added pixbuf_fallback function
nadvornik
parents: 845
diff changeset
1000 g_object_unref(pixbuf);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1001 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1002
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1003 thumb_std_maint_move_step(tm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1004 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1005
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1006 static void thumb_std_maint_move_step(TMaintMove *tm)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1007 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1008 const gchar *folder;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1009
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1010 tm->pass++;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1011 if (tm->pass > 2)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1012 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1013 g_free(tm->source);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1014 g_free(tm->dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1015 g_free(tm->source_uri);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1016 g_free(tm->thumb_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1017 g_free(tm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1018
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1019 if (thumb_std_maint_move_list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1020 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1021 g_idle_add_full(G_PRIORITY_LOW, thumb_std_maint_move_idle, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1022 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1023
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1024 return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1025 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1026
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1027 folder = (tm->pass == 1) ? THUMB_FOLDER_NORMAL : THUMB_FOLDER_LARGE;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 436
diff changeset
1028
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1029 g_free(tm->thumb_path);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1030 tm->thumb_path = thumb_std_cache_path(tm->source, tm->source_uri, FALSE, folder);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1031 tm->tl = thumb_loader_std_thumb_file_validate(tm->thumb_path, 0,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1032 thumb_std_maint_move_validate_cb, tm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1033 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1034
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1035 static gint thumb_std_maint_move_idle(gpointer data)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1036 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1037 TMaintMove *tm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1038 gchar *pathl;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1039
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1040 if (!thumb_std_maint_move_list) return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1041
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1042 tm = thumb_std_maint_move_list->data;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1043
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1044 thumb_std_maint_move_list = g_list_remove(thumb_std_maint_move_list, tm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1045 if (!thumb_std_maint_move_list) thumb_std_maint_move_tail = NULL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1046
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1047 pathl = path_from_utf8(tm->source);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1048 tm->source_uri = g_filename_to_uri(pathl, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1049 g_free(pathl);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1050
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1051 tm->pass = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1052
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1053 thumb_std_maint_move_step(tm);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1054
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1055 return FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1056 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1057
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1058 /* This will schedule a move of the thumbnail for source image to dest when idle.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1059 * We do this so that file renaming or moving speed is not sacrificed by
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1060 * moving the thumbnails at the same time because:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1061 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1062 * This cache design requires the tedious task of loading the png thumbnails and saving them.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1063 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1064 * The thumbnails are processed when the app is idle. If the app
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1065 * exits early well too bad - they can simply be regenerated from scratch.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1066 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1067 * This does not manage local thumbnails (fixme ?)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1068 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1069 void thumb_std_maint_moved(const gchar *source, const gchar *dest)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1070 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1071 TMaintMove *tm;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1072
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1073 tm = g_new0(TMaintMove, 1);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1074 tm->source = g_strdup(source);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1075 tm->dest = g_strdup(dest);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1076
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1077 if (!thumb_std_maint_move_list)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1078 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1079 g_idle_add_full(G_PRIORITY_LOW, thumb_std_maint_move_idle, NULL, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1080 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1081
827
e5172386f229 Revert patches 759 and 760.
zas_
parents: 717
diff changeset
1082 if (thumb_std_maint_move_tail)
e5172386f229 Revert patches 759 and 760.
zas_
parents: 717
diff changeset
1083 {
e5172386f229 Revert patches 759 and 760.
zas_
parents: 717
diff changeset
1084 thumb_std_maint_move_tail = g_list_append(thumb_std_maint_move_tail, tm);
e5172386f229 Revert patches 759 and 760.
zas_
parents: 717
diff changeset
1085 thumb_std_maint_move_tail = thumb_std_maint_move_tail->next;
e5172386f229 Revert patches 759 and 760.
zas_
parents: 717
diff changeset
1086 }
e5172386f229 Revert patches 759 and 760.
zas_
parents: 717
diff changeset
1087 else
e5172386f229 Revert patches 759 and 760.
zas_
parents: 717
diff changeset
1088 {
e5172386f229 Revert patches 759 and 760.
zas_
parents: 717
diff changeset
1089 thumb_std_maint_move_list = g_list_append(thumb_std_maint_move_list, tm);
e5172386f229 Revert patches 759 and 760.
zas_
parents: 717
diff changeset
1090 thumb_std_maint_move_tail = thumb_std_maint_move_list;
e5172386f229 Revert patches 759 and 760.
zas_
parents: 717
diff changeset
1091 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1092 }
1055
1646720364cf Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents: 1036
diff changeset
1093 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */