cache_manager_render_thumb_done_cb,
NULL, cd);
thumb_loader_set_cache((ThumbLoader *)cd->tl, TRUE, cd->local, TRUE);
- success = thumb_loader_start((ThumbLoader *)cd->tl, fd->path);
+ success = thumb_loader_start((ThumbLoader *)cd->tl, fd);
if (success)
{
gtk_entry_set_text(GTK_ENTRY(cd->progress), fd->path);
cd);
/* start it */
- if (!thumb_loader_start(cd->thumb_loader, ci->fd->path))
+ if (!thumb_loader_start(cd->thumb_loader, ci->fd))
{
/* error, handle it, do next */
DEBUG_1("error loading thumb for %s", ci->fd->path);
dw);
/* start it */
- if (!thumb_loader_start(dw->thumb_loader, di->fd->path))
+ if (!thumb_loader_start(dw->thumb_loader, di->fd))
{
/* error, handle it, do next */
DEBUG_1("error loading thumb for %s", di->fd->path);
pan_queue_thumb_done_cb,
NULL, pw);
- if (thumb_loader_start(pw->tl, pi->fd->path)) return FALSE;
+ if (thumb_loader_start(pw->tl, pi->fd)) return FALSE;
thumb_loader_free(pw->tl);
pw->tl = NULL;
if (!sd->thumb_loader || !sd->thumb_fd) return;
fd = sd->thumb_fd;
- if (fd->pixbuf) g_object_unref(fd->pixbuf);
- fd->pixbuf = thumb_loader_get_pixbuf(sd->thumb_loader, TRUE);
-
search_result_thumb_set(sd, fd, NULL);
}
search_result_thumb_done_cb,
NULL,
sd);
- if (!thumb_loader_start(sd->thumb_loader, mfd->fd->path))
+ if (!thumb_loader_start(sd->thumb_loader, mfd->fd))
{
search_result_thumb_do(sd);
search_result_thumb_step(sd);
static void thumb_loader_error_cb(ImageLoader *il, gpointer data);
-static void thumb_loader_setup(ThumbLoader *tl, gchar *path);
+static void thumb_loader_setup(ThumbLoader *tl, const gchar *path);
static gint normalize_thumb(gint *width, gint *height, gint max_w, gint max_h);
static GdkPixbuf *get_xv_thumbnail(gchar *thumb_filename, gint max_w, gint max_h);
gint success = FALSE;
mode_t mode = 0755;
- if (!tl || !tl->pixbuf) return FALSE;
+ if (!tl || !tl->fd || !tl->fd->pixbuf) return FALSE;
- cache_dir = cache_get_location(CACHE_TYPE_THUMB, tl->path, FALSE, &mode);
+ cache_dir = cache_get_location(CACHE_TYPE_THUMB, tl->fd->path, FALSE, &mode);
if (cache_ensure_dir_exists(cache_dir, mode))
{
gchar *cache_path;
gchar *pathl;
- gchar *name = g_strconcat(filename_from_path(tl->path), GQ_CACHE_EXT_THUMB, NULL);
+ gchar *name = g_strconcat(filename_from_path(tl->fd->path), GQ_CACHE_EXT_THUMB, NULL);
cache_path = g_build_filename(cache_dir, name, NULL);
g_free(name);
DEBUG_1("Saving thumb: %s", cache_path);
pathl = path_from_utf8(cache_path);
- success = pixbuf_to_file_as_png(tl->pixbuf, pathl);
+ success = pixbuf_to_file_as_png(tl->fd->pixbuf, pathl);
if (success)
{
struct utimbuf ut;
/* set thumb time to that of source file */
- ut.actime = ut.modtime = filetime(tl->path);
+ ut.actime = ut.modtime = filetime(tl->fd->path);
if (ut.modtime > 0)
{
utime(pathl, &ut);
if (!tl) return FALSE;
- cache_dir = cache_get_location(CACHE_TYPE_THUMB, tl->path, FALSE, &mode);
+ cache_dir = cache_get_location(CACHE_TYPE_THUMB, tl->fd->path, FALSE, &mode);
if (cache_ensure_dir_exists(cache_dir, mode))
{
gchar *cache_path;
gchar *pathl;
FILE *f;
- gchar *name = g_strconcat(filename_from_path(tl->path), GQ_CACHE_EXT_THUMB, NULL);
+ gchar *name = g_strconcat(filename_from_path(tl->fd->path), GQ_CACHE_EXT_THUMB, NULL);
cache_path = g_build_filename(cache_dir, name, NULL);
g_free(name);
fclose(f);
- ut.actime = ut.modtime = filetime(tl->path);
+ ut.actime = ut.modtime = filetime(tl->fd->path);
if (ut.modtime > 0)
{
utime(pathl, &ut);
gint pw, ph;
gint save;
- DEBUG_1("thumb done: %s", tl->path);
+ DEBUG_1("thumb done: %s", tl->fd->path);
pixbuf = image_loader_get_pixbuf(tl->il);
if (!pixbuf)
{
- DEBUG_1("...but no pixbuf: %s", tl->path);
+ DEBUG_1("...but no pixbuf: %s", tl->fd->path);
thumb_loader_error_cb(tl->il, tl);
return;
}
if (tl->cache_hit && pw != tl->max_w && ph != tl->max_h)
{
/* requested thumbnail size may have changed, load original */
- DEBUG_1("thumbnail size mismatch, regenerating: %s", tl->path);
+ DEBUG_1("thumbnail size mismatch, regenerating: %s", tl->fd->path);
tl->cache_hit = FALSE;
- thumb_loader_setup(tl, tl->path);
+ thumb_loader_setup(tl, tl->fd->path);
if (!image_loader_start(tl->il, thumb_loader_done_cb, tl))
{
image_loader_free(tl->il);
tl->il = NULL;
- DEBUG_1("regeneration failure: %s", tl->path);
+ DEBUG_1("regeneration failure: %s", tl->fd->path);
thumb_loader_error_cb(tl->il, tl);
}
return;
w = (double)h / ph * pw;
if (w < 1) w = 1;
}
-
- tl->pixbuf = gdk_pixbuf_scale_simple(pixbuf, w, h, (GdkInterpType)options->thumbnails.quality);
+
+ if (tl->fd)
+ {
+ if (tl->fd->pixbuf) g_object_unref(tl->fd->pixbuf);
+ tl->fd->pixbuf = gdk_pixbuf_scale_simple(pixbuf, w, h, (GdkInterpType)options->thumbnails.quality);
+ }
save = TRUE;
}
else
{
- tl->pixbuf = pixbuf;
- gdk_pixbuf_ref(tl->pixbuf);
+ if (tl->fd)
+ {
+ if (tl->fd->pixbuf) g_object_unref(tl->fd->pixbuf);
+ tl->fd->pixbuf = pixbuf;
+ gdk_pixbuf_ref(tl->fd->pixbuf);
+ }
save = il->shrunk;
}
return;
}
- DEBUG_1("thumb error: %s", tl->path);
+ DEBUG_1("thumb error: %s", tl->fd->path);
image_loader_free(tl->il);
tl->il = NULL;
if (tl->idle_done_id == -1) tl->idle_done_id = g_idle_add(thumb_loader_done_delay_cb, tl);
}
-static void thumb_loader_setup(ThumbLoader *tl, gchar *path)
+static void thumb_loader_setup(ThumbLoader *tl, const gchar *path)
{
+ FileData *fd = file_data_new_simple(path);
image_loader_free(tl->il);
- tl->il = image_loader_new(file_data_new_simple(path));
+ tl->il = image_loader_new(fd);
+ file_data_unref(fd);
if (options->thumbnails.fast)
{
}
-gint thumb_loader_start(ThumbLoader *tl, const gchar *path)
+gint thumb_loader_start(ThumbLoader *tl, FileData *fd)
{
gchar *cache_path = NULL;
if (tl->standard_loader)
{
- return thumb_loader_std_start((ThumbLoaderStd *)tl, path);
+ return thumb_loader_std_start((ThumbLoaderStd *)tl, fd);
}
- if (!tl->path && !path) return FALSE;
+ if (!tl->fd && !fd) return FALSE;
- if (!tl->path) tl->path = g_strdup(path);
+ if (!tl->fd) tl->fd = file_data_ref(fd);
if (tl->cache_enable)
{
- cache_path = cache_find_location(CACHE_TYPE_THUMB, tl->path);
+ cache_path = cache_find_location(CACHE_TYPE_THUMB, tl->fd->path);
if (cache_path)
{
- if (cache_time_valid(cache_path, tl->path))
+ if (cache_time_valid(cache_path, tl->fd->path))
{
- DEBUG_1("Found in cache:%s", tl->path);
+ DEBUG_1("Found in cache:%s", tl->fd->path);
if (filesize(cache_path) == 0)
{
if (!cache_path && options->thumbnails.use_xvpics)
{
- tl->pixbuf = get_xv_thumbnail(tl->path, tl->max_w, tl->max_h);
- if (tl->pixbuf)
+ if (tl->fd->pixbuf) g_object_unref(tl->fd->pixbuf);
+ tl->fd->pixbuf = get_xv_thumbnail(tl->fd->path, tl->max_w, tl->max_h);
+ if (tl->fd->pixbuf)
{
thumb_loader_delay_done(tl);
return TRUE;
}
else
{
- thumb_loader_setup(tl, tl->path);
+ thumb_loader_setup(tl, tl->fd->path);
}
if (!image_loader_start(tl->il, thumb_loader_done_cb, tl))
tl->cache_hit = FALSE;
log_printf("%s", _("Thumbnail image in cache failed to load, trying to recreate.\n"));
- thumb_loader_setup(tl, tl->path);
+ thumb_loader_setup(tl, tl->fd->path);
if (image_loader_start(tl->il, thumb_loader_done_cb, tl)) return TRUE;
}
/* mark failed thumbnail in cache with 0 byte file */
return thumb_loader_std_get_pixbuf((ThumbLoaderStd *)tl, with_fallback);
}
- if (tl && tl->pixbuf)
+ if (tl && tl->fd && tl->fd->pixbuf)
{
- pixbuf = tl->pixbuf;
+ pixbuf = tl->fd->pixbuf;
g_object_ref(pixbuf);
}
else if (with_fallback)
tl = g_new0(ThumbLoader, 1);
tl->standard_loader = FALSE;
- tl->path = NULL;
+ tl->fd = NULL;
tl->cache_enable = options->thumbnails.enable_caching;
tl->cache_hit = FALSE;
tl->percent_done = 0.0;
return;
}
- if (tl->pixbuf) gdk_pixbuf_unref(tl->pixbuf);
image_loader_free(tl->il);
- g_free(tl->path);
+ file_data_unref(tl->fd);
if (tl->idle_done_id != -1) g_source_remove(tl->idle_done_id);
gpointer data);
void thumb_loader_set_cache(ThumbLoader *tl, gint enable_cache, gint local, gint retry_failed);
-gint thumb_loader_start(ThumbLoader *tl, const gchar *path);
+gint thumb_loader_start(ThumbLoader *tl, FileData *fd);
void thumb_loader_free(ThumbLoader *tl);
GdkPixbuf *thumb_loader_get_pixbuf(ThumbLoader *tl, gint with_fallback);
#include "md5-util.h"
#include "pixbuf_util.h"
#include "ui_fileops.h"
+#include "filedata.h"
/*
tl->requested_width = width;
tl->requested_height = height;
- tl->pixbuf = NULL;
tl->il = NULL;
- tl->source_path = NULL;
+ tl->fd = NULL;
tl->cache_enable = options->thumbnails.enable_caching;
tl->cache_local = FALSE;
static void thumb_loader_std_reset(ThumbLoaderStd *tl)
{
- if (tl->pixbuf) g_object_unref(tl->pixbuf);
- tl->pixbuf = NULL;
-
image_loader_free(tl->il);
tl->il = NULL;
- g_free(tl->source_path);
- tl->source_path = NULL;
+ file_data_unref(tl->fd);
+ tl->fd = NULL;
g_free(tl->thumb_path);
tl->thumb_path = NULL;
const gchar *folder;
gint w, h;
- if (!tl->source_path || !tl->thumb_uri) return NULL;
+ if (!tl->fd || !tl->thumb_uri) return NULL;
if (pixbuf)
{
folder = THUMB_FOLDER_NORMAL;
}
- return thumb_std_cache_path(tl->source_path,
+ return thumb_std_cache_path(tl->fd->path,
(local) ? tl->local_uri : tl->thumb_uri,
local, folder);
}
if (mtime_str && strtol(mtime_str, NULL, 10) == tl->source_mtime)
{
result = TRUE;
- DEBUG_1("thumb fail valid: %s", tl->source_path);
+ DEBUG_1("thumb fail valid: %s", tl->fd->path);
DEBUG_1(" thumb: %s", fail_path);
}
struct stat st;
gchar *source_base;
- source_base = remove_level_from_path(tl->source_path);
+ source_base = remove_level_from_path(tl->fd->path);
if (stat_utf8(source_base, &st))
{
cache_ensure_dir_exists(base_path, st.st_mode);
}
g_free(base_path);
- DEBUG_1("thumb saving: %s", tl->source_path);
+ DEBUG_1("thumb saving: %s", tl->fd->path);
DEBUG_1(" saved: %s", tl->thumb_path);
/* save thumb, using a temp file then renaming into place */
g_free(tmp_path);
if (!success)
{
- DEBUG_1("thumb save failed: %s", tl->source_path);
+ DEBUG_1("thumb save failed: %s", tl->fd->path);
DEBUG_1(" thumb: %s", tl->thumb_path);
}
tl->cache_hit = FALSE;
- DEBUG_1("thumb copied: %s", tl->source_path);
+ DEBUG_1("thumb copied: %s", tl->fd->path);
thumb_loader_std_save(tl, pixbuf);
}
tl->thumb_path = NULL;
}
- if (thumb_loader_std_setup(tl, tl->source_path)) return TRUE;
+ if (thumb_loader_std_setup(tl, tl->fd->path)) return TRUE;
}
thumb_loader_std_save(tl, NULL);
ThumbLoaderStd *tl = data;
GdkPixbuf *pixbuf;
- DEBUG_1("thumb image done: %s", tl->source_path);
+ DEBUG_1("thumb image done: %s", tl->fd->path);
DEBUG_1(" from: %s", tl->il->path);
pixbuf = image_loader_get_pixbuf(tl->il);
tl->cache_hit = (tl->thumb_path != NULL);
- tl->pixbuf = thumb_loader_std_finish(tl, pixbuf, il->shrunk);
+ if (tl->fd)
+ {
+ if (tl->fd->pixbuf) g_object_unref(tl->fd->pixbuf);
+ tl->fd->pixbuf = thumb_loader_std_finish(tl, pixbuf, il->shrunk);
+ }
if (tl->func_done) tl->func_done(tl, tl->data);
}
return;
}
- DEBUG_1("thumb image error: %s", tl->source_path);
+ DEBUG_1("thumb image error: %s", tl->fd->path);
DEBUG_1(" from: %s", tl->il->fd->path);
if (thumb_loader_std_next_source(tl, TRUE)) return;
tl->cache_retry = retry_failed;
}
-gint thumb_loader_std_start(ThumbLoaderStd *tl, const gchar *path)
+gint thumb_loader_std_start(ThumbLoaderStd *tl, FileData *fd)
{
static gchar *thumb_cache = NULL;
struct stat st;
- if (!tl || !path) return FALSE;
+ if (!tl || !fd) return FALSE;
thumb_loader_std_reset(tl);
- if (!stat_utf8(path, &st)) return FALSE;
+ if (!stat_utf8(fd->path, &st)) return FALSE;
- tl->source_path = g_strdup(path);
+ tl->fd = file_data_ref(fd);
tl->source_mtime = st.st_mtime;
tl->source_size = st.st_size;
tl->source_mode = st.st_mode;
if (!thumb_cache) thumb_cache = g_build_filename(homedir(), THUMB_FOLDER_GLOBAL, NULL);
- if (strncmp(tl->source_path, thumb_cache, strlen(thumb_cache)) != 0)
+ if (strncmp(tl->fd->path, thumb_cache, strlen(thumb_cache)) != 0)
{
gchar *pathl;
- pathl = path_from_utf8(path);
+ pathl = path_from_utf8(fd->path);
tl->thumb_uri = g_filename_to_uri(pathl, NULL, NULL);
tl->local_uri = filename_from_path(tl->thumb_uri);
g_free(pathl);
return thumb_loader_std_next_source(tl, found);
}
- if (!thumb_loader_std_setup(tl, tl->source_path))
+ if (!thumb_loader_std_setup(tl, tl->fd->path))
{
thumb_loader_std_save(tl, NULL);
return FALSE;
{
GdkPixbuf *pixbuf;
- if (tl && tl->pixbuf)
+ if (tl && tl->fd && tl->fd->pixbuf)
{
- pixbuf = tl->pixbuf;
+ pixbuf = tl->fd->pixbuf;
g_object_ref(pixbuf);
}
else if (with_fallback)
tm->tl->cache_hit = FALSE;
tm->tl->cache_local = FALSE;
- g_free(tm->tl->source_path);
- tm->tl->source_path = g_strdup(tm->dest);
+ file_data_unref(tm->tl->fd);
+ tm->tl->fd = file_data_new_simple(tm->dest);
tm->tl->source_mtime = strtol(mtime_str, NULL, 10);
- pathl = path_from_utf8(tm->tl->source_path);
+ pathl = path_from_utf8(tm->tl->fd->path);
g_free(tm->tl->thumb_uri);
tm->tl->thumb_uri = g_filename_to_uri(pathl, NULL, NULL);
tm->tl->local_uri = filename_from_path(tm->tl->thumb_uri);
{
gint standard_loader;
- GdkPixbuf *pixbuf;
ImageLoader *il;
-
- gchar *source_path;
+ FileData *fd;
time_t source_mtime;
off_t source_size;
ThumbLoaderStdFunc func_progress,
gpointer data);
void thumb_loader_std_set_cache(ThumbLoaderStd *tl, gint enable_cache, gint local, gint retry_failed);
-gint thumb_loader_std_start(ThumbLoaderStd *tl, const gchar *path);
+gint thumb_loader_std_start(ThumbLoaderStd *tl, FileData *fd);
void thumb_loader_std_free(ThumbLoaderStd *tl);
GdkPixbuf *thumb_loader_std_get_pixbuf(ThumbLoaderStd *tl, gint with_fallback);
{
gint standard_loader;
- GdkPixbuf *pixbuf; /* contains final (scaled) image when done */
ImageLoader *il;
- gchar *path;
+ FileData *fd; /* fd->pixbuf contains final (scaled) image when done */
gint cache_enable;
gint cache_hit;
gtk_list_store_clear(GTK_LIST_STORE(store));
}
-static void vficon_set_thumb(ViewFile *vf, FileData *fd, GdkPixbuf *pb)
+static void vficon_set_thumb(ViewFile *vf, FileData *fd)
{
GtkTreeModel *store;
GtkTreeIter iter;
store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
- if (pb) g_object_ref(pb);
- if (fd->pixbuf) g_object_unref(fd->pixbuf);
- fd->pixbuf = pb;
-
gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &list, -1);
gtk_list_store_set(GTK_LIST_STORE(store), &iter, FILE_COLUMN_POINTER, list, -1);
}
static void vficon_thumb_do(ViewFile *vf, ThumbLoader *tl, FileData *fd)
{
- GdkPixbuf *pixbuf;
-
if (!fd) return;
- pixbuf = thumb_loader_get_pixbuf(tl, TRUE);
- vficon_set_thumb(vf, fd, pixbuf);
- g_object_unref(pixbuf);
+ vficon_set_thumb(vf, fd);
vficon_thumb_status(vf, (gdouble)(vf->thumbs_count) / g_list_length(vf->list), _("Loading thumbs..."));
}
NULL,
vf);
- if (!thumb_loader_start(vf->thumbs_loader, fd->path))
+ if (!thumb_loader_start(vf->thumbs_loader, fd))
{
/* set icon to unknown, continue */
- DEBUG_1("thumb loader start failed %s", vf->thumbs_loader->path);
+ DEBUG_1("thumb loader start failed %s", fd->path);
vficon_thumb_do(vf, vf->thumbs_loader, fd);
return TRUE;
if (!fd || vflist_find_row(vf, fd, &iter) < 0) return;
- if (fd->pixbuf) g_object_unref(fd->pixbuf);
- fd->pixbuf = thumb_loader_get_pixbuf(tl, TRUE);
-
store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)));
gtk_tree_store_set(store, &iter, FILE_COLUMN_THUMB, fd->pixbuf, -1);
NULL,
vf);
- if (!thumb_loader_start(vf->thumbs_loader, fd->path))
+ if (!thumb_loader_start(vf->thumbs_loader, fd))
{
/* set icon to unknown, continue */
- DEBUG_1("thumb loader start failed %s", vf->thumbs_loader->path);
+ DEBUG_1("thumb loader start failed %s", fd->path);
vflist_thumb_do(vf, vf->thumbs_loader, fd);
return TRUE;