use FileData in thumb_loader
authorVladimir Nadvornik <nadvornik@suse.cz>
Sun, 15 Jun 2008 20:09:15 +0000 (20:09 +0000)
committerVladimir Nadvornik <nadvornik@suse.cz>
Sun, 15 Jun 2008 20:09:15 +0000 (20:09 +0000)
12 files changed:
src/cache_maint.c
src/collect-io.c
src/dupe.c
src/pan-view.c
src/search.c
src/thumb.c
src/thumb.h
src/thumb_standard.c
src/thumb_standard.h
src/typedefs.h
src/view_file_icon.c
src/view_file_list.c

index cf73d8a..412a990 100644 (file)
@@ -788,7 +788,7 @@ static gint cache_manager_render_file(CleanData *cd)
                                           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);
index 9b722fd..8a48bec 100644 (file)
@@ -289,7 +289,7 @@ static void collection_load_thumb_step(CollectionData *cd)
                                   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);
index 4396be3..2b52175 100644 (file)
@@ -1340,7 +1340,7 @@ static void dupe_thumb_step(DupeWindow *dw)
                                   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);
index 49ece45..a770553 100644 (file)
@@ -233,7 +233,7 @@ static gint pan_queue_step(PanWindow *pw)
                                           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;
index 86a9e1c..b2483c8 100644 (file)
@@ -720,9 +720,6 @@ static void search_result_thumb_do(SearchData *sd)
        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);
 }
 
@@ -795,7 +792,7 @@ static void search_result_thumb_step(SearchData *sd)
                                   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);
index 608f163..4dfcfae 100644 (file)
@@ -25,7 +25,7 @@
 
 
 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);
@@ -43,15 +43,15 @@ static gint thumb_loader_save_to_cache(ThumbLoader *tl)
        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);
@@ -59,13 +59,13 @@ static gint thumb_loader_save_to_cache(ThumbLoader *tl)
                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);
@@ -93,14 +93,14 @@ static gint thumb_loader_mark_failure(ThumbLoader *tl)
 
        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);
@@ -115,7 +115,7 @@ static gint thumb_loader_mark_failure(ThumbLoader *tl)
 
                        fclose(f);
 
-                       ut.actime = ut.modtime = filetime(tl->path);
+                       ut.actime = ut.modtime = filetime(tl->fd->path);
                        if (ut.modtime > 0)
                                {
                                utime(pathl, &ut);
@@ -148,12 +148,12 @@ static void thumb_loader_done_cb(ImageLoader *il, gpointer data)
        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;
                }
@@ -164,17 +164,17 @@ static void thumb_loader_done_cb(ImageLoader *il, gpointer data)
        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;
@@ -198,14 +198,22 @@ static void thumb_loader_done_cb(ImageLoader *il, gpointer data)
                        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;
                }
 
@@ -229,7 +237,7 @@ static void thumb_loader_error_cb(ImageLoader *il, gpointer data)
                return;
                }
 
-       DEBUG_1("thumb error: %s", tl->path);
+       DEBUG_1("thumb error: %s", tl->fd->path);
 
        image_loader_free(tl->il);
        tl->il = NULL;
@@ -253,10 +261,12 @@ static void thumb_loader_delay_done(ThumbLoader *tl)
        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)
                {
@@ -311,7 +321,7 @@ void thumb_loader_set_cache(ThumbLoader *tl, gint enable_cache, gint local, gint
 }
 
 
-gint thumb_loader_start(ThumbLoader *tl, const gchar *path)
+gint thumb_loader_start(ThumbLoader *tl, FileData *fd)
 {
        gchar *cache_path = NULL;
 
@@ -319,22 +329,22 @@ gint thumb_loader_start(ThumbLoader *tl, const gchar *path)
 
        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)
                                        {
@@ -355,8 +365,9 @@ gint thumb_loader_start(ThumbLoader *tl, const gchar *path)
 
        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;
@@ -371,7 +382,7 @@ gint thumb_loader_start(ThumbLoader *tl, const gchar *path)
                }
        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))
@@ -382,7 +393,7 @@ gint thumb_loader_start(ThumbLoader *tl, const gchar *path)
                        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 */
@@ -419,9 +430,9 @@ GdkPixbuf *thumb_loader_get_pixbuf(ThumbLoader *tl, gint with_fallback)
                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)
@@ -471,7 +482,7 @@ ThumbLoader *thumb_loader_new(gint width, gint height)
 
        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;
@@ -495,9 +506,8 @@ void thumb_loader_free(ThumbLoader *tl)
                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);
 
index 1095e45..d09152f 100644 (file)
@@ -23,7 +23,7 @@ void thumb_loader_set_callbacks(ThumbLoader *tl,
                                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);
index 5ddb7fe..5b47510 100644 (file)
@@ -19,6 +19,7 @@
 #include "md5-util.h"
 #include "pixbuf_util.h"
 #include "ui_fileops.h"
+#include "filedata.h"
 
 
 /*
@@ -77,9 +78,8 @@ ThumbLoaderStd *thumb_loader_std_new(gint width, gint height)
        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;
@@ -104,14 +104,11 @@ void thumb_loader_std_set_callbacks(ThumbLoaderStd *tl,
 
 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;
@@ -171,7 +168,7 @@ static gchar *thumb_loader_std_cache_path(ThumbLoaderStd *tl, gint local, GdkPix
        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)
                {
@@ -197,7 +194,7 @@ static gchar *thumb_loader_std_cache_path(ThumbLoaderStd *tl, gint local, GdkPix
                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);
 }
@@ -233,7 +230,7 @@ static gint thumb_loader_std_fail_check(ThumbLoaderStd *tl)
                        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);
                                }
 
@@ -317,7 +314,7 @@ static void thumb_loader_std_save(ThumbLoaderStd *tl, GdkPixbuf *pixbuf)
                        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);
@@ -331,7 +328,7 @@ static void thumb_loader_std_save(ThumbLoaderStd *tl, GdkPixbuf *pixbuf)
                }
        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 */
@@ -369,7 +366,7 @@ static void thumb_loader_std_save(ThumbLoaderStd *tl, GdkPixbuf *pixbuf)
                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);
                        }
 
@@ -451,7 +448,7 @@ static GdkPixbuf *thumb_loader_std_finish(ThumbLoaderStd *tl, GdkPixbuf *pixbuf,
 
                        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);
                        }
@@ -520,7 +517,7 @@ static gint thumb_loader_std_next_source(ThumbLoaderStd *tl, gint remove_broken)
                        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);
@@ -532,7 +529,7 @@ static void thumb_loader_std_done_cb(ImageLoader *il, gpointer data)
        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);
@@ -553,7 +550,11 @@ static void thumb_loader_std_done_cb(ImageLoader *il, gpointer data)
 
        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);
 }
@@ -569,7 +570,7 @@ static void thumb_loader_std_error_cb(ImageLoader *il, gpointer 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;
@@ -633,28 +634,28 @@ void thumb_loader_std_set_cache(ThumbLoaderStd *tl, gint enable_cache, gint loca
        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);
@@ -675,7 +676,7 @@ gint thumb_loader_std_start(ThumbLoaderStd *tl, const gchar *path)
                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;
@@ -696,9 +697,9 @@ GdkPixbuf *thumb_loader_std_get_pixbuf(ThumbLoaderStd *tl, gint with_fallback)
 {
        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)
@@ -963,11 +964,11 @@ static void thumb_std_maint_move_validate_cb(const gchar *path, gint valid, gpoi
                        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);
index 28fdba9..898eac9 100644 (file)
@@ -30,10 +30,8 @@ struct _ThumbLoaderStd
 {
        gint standard_loader;
 
-       GdkPixbuf *pixbuf;
        ImageLoader *il;
-
-       gchar *source_path;
+       FileData *fd;
 
        time_t source_mtime;
        off_t source_size;
@@ -70,7 +68,7 @@ void thumb_loader_std_set_callbacks(ThumbLoaderStd *tl,
                                    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);
index f75bc50..2293497 100644 (file)
@@ -226,9 +226,8 @@ struct _ThumbLoader
 {
        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;
index f3deb0f..09acead 100644 (file)
@@ -1488,7 +1488,7 @@ static void vficon_clear_store(ViewFile *vf)
        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;
@@ -1498,10 +1498,6 @@ static void vficon_set_thumb(ViewFile *vf, FileData *fd, GdkPixbuf *pb)
 
        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);
 }
@@ -1826,13 +1822,9 @@ static void vficon_thumb_stop(ViewFile *vf)
 
 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..."));
 }
@@ -1934,10 +1926,10 @@ static gint vficon_thumb_next(ViewFile *vf)
                                   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;
index 54ac7e2..4af7855 100644 (file)
@@ -1008,9 +1008,6 @@ static void vflist_thumb_do(ViewFile *vf, ThumbLoader *tl, FileData *fd)
 
        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);
 
@@ -1113,10 +1110,10 @@ static gint vflist_thumb_next(ViewFile *vf)
                                   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;