diff src/view_file_list.c @ 843:add46f9c895c

more robust thumbs progress bar
author nadvornik
date Tue, 17 Jun 2008 20:25:05 +0000
parents 9bd49e725ad3
children 06929cbcd796
line wrap: on
line diff
--- 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);