# HG changeset patch # User nadvornik # Date 1213734305 0 # Node ID add46f9c895ca50d6bbad40c1f5d512de5f8bca5 # Parent 94048d7843bab1279b854e100c1e8efd57ea5c96 more robust thumbs progress bar diff -r 94048d7843ba -r add46f9c895c src/typedefs.h --- a/src/typedefs.h Tue Jun 17 19:56:21 2008 +0000 +++ b/src/typedefs.h Tue Jun 17 20:25:05 2008 +0000 @@ -634,7 +634,6 @@ /* thumbs updates*/ gint thumbs_running; - gint thumbs_count; ThumbLoader *thumbs_loader; FileData *thumbs_filedata; diff -r 94048d7843ba -r add46f9c895c src/view_file.c --- a/src/view_file.c Tue Jun 17 19:56:21 2008 +0000 +++ b/src/view_file.c Tue Jun 17 20:25:05 2008 +0000 @@ -671,7 +671,6 @@ vf->sort_ascend = TRUE; vf->thumbs_running = FALSE; - vf->thumbs_count = 0; vf->thumbs_loader = NULL; vf->thumbs_filedata = NULL; diff -r 94048d7843ba -r add46f9c895c src/view_file_icon.c --- a/src/view_file_icon.c Tue Jun 17 19:56:21 2008 +0000 +++ b/src/view_file_icon.c Tue Jun 17 20:25:05 2008 +0000 @@ -1794,6 +1794,25 @@ static gint vficon_thumb_next(ViewFile *vf); +static gdouble vficon_thumb_progress(ViewFile *vf) +{ + gint count = 0; + gint done = 0; + + GList *work = vf->list; + while (work) + { + IconData *id = work->data; + FileData *fd = id->fd; + work = work->next; + + if (fd->pixbuf) done++; + count++; + } + DEBUG_1("thumb progress: %d of %d", done, count); + return (gdouble)done / count; +} + static void vficon_thumb_status(ViewFile *vf, gdouble val, const gchar *text) { if (vf->func_thumb_status) @@ -1806,7 +1825,6 @@ { vficon_thumb_status(vf, 0.0, NULL); - vf->thumbs_count = 0; vf->thumbs_running = FALSE; thumb_loader_free(vf->thumbs_loader); @@ -1826,7 +1844,7 @@ vficon_set_thumb(vf, fd); - vficon_thumb_status(vf, (gdouble)(vf->thumbs_count) / g_list_length(vf->list), _("Loading thumbs...")); + vficon_thumb_status(vf, vficon_thumb_progress(vf), _("Loading thumbs...")); } static void vficon_thumb_error_cb(ThumbLoader *tl, gpointer data) @@ -1913,8 +1931,6 @@ return FALSE; } - vf->thumbs_count++; - vf->thumbs_filedata = fd; thumb_loader_free(vf->thumbs_loader); diff -r 94048d7843ba -r add46f9c895c src/view_file_list.c --- a/src/view_file_list.c Tue Jun 17 19:56:21 2008 +0000 +++ b/src/view_file_list.c Tue Jun 17 20:25:05 2008 +0000 @@ -975,6 +975,36 @@ static gint vflist_thumb_next(ViewFile *vf); +static void vflist_thumb_progress_count(GList *list, gint *count, gint *done) +{ + GList *work = list; + while (work) + { + FileData *fd = work->data; + work = work->next; + + if (fd->pixbuf) (*done)++; + + if (fd->sidecar_files) + { + vflist_thumb_progress_count(fd->sidecar_files, count, done); + } + (*count)++; + } +} + +static gdouble vflist_thumb_progress(ViewFile *vf) +{ + gint count = 0; + gint done = 0; + + vflist_thumb_progress_count(vf->list, &count, &done); + + DEBUG_1("thumb progress: %d of %d", done, count); + return (gdouble)done / count; +} + + static void vflist_thumb_status(ViewFile *vf, gdouble val, const gchar *text) { if (vf->func_thumb_status) @@ -987,7 +1017,6 @@ { vflist_thumb_status(vf, 0.0, NULL); - vf->thumbs_count = 0; vf->thumbs_running = FALSE; thumb_loader_free(vf->thumbs_loader); @@ -1011,7 +1040,7 @@ 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); - vflist_thumb_status(vf, (gdouble)(vf->thumbs_count) / vflist_sidecar_list_count(vf->list), _("Loading thumbs...")); + vflist_thumb_status(vf, vflist_thumb_progress(vf), _("Loading thumbs...")); } static void vflist_thumb_error_cb(ThumbLoader *tl, gpointer data) @@ -1097,8 +1126,6 @@ return FALSE; } - vf->thumbs_count++; - vf->thumbs_filedata = fd; thumb_loader_free(vf->thumbs_loader);