comparison 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
comparison
equal deleted inserted replaced
842:94048d7843ba 843:add46f9c895c
973 *----------------------------------------------------------------------------- 973 *-----------------------------------------------------------------------------
974 */ 974 */
975 975
976 static gint vflist_thumb_next(ViewFile *vf); 976 static gint vflist_thumb_next(ViewFile *vf);
977 977
978 static void vflist_thumb_progress_count(GList *list, gint *count, gint *done)
979 {
980 GList *work = list;
981 while (work)
982 {
983 FileData *fd = work->data;
984 work = work->next;
985
986 if (fd->pixbuf) (*done)++;
987
988 if (fd->sidecar_files)
989 {
990 vflist_thumb_progress_count(fd->sidecar_files, count, done);
991 }
992 (*count)++;
993 }
994 }
995
996 static gdouble vflist_thumb_progress(ViewFile *vf)
997 {
998 gint count = 0;
999 gint done = 0;
1000
1001 vflist_thumb_progress_count(vf->list, &count, &done);
1002
1003 DEBUG_1("thumb progress: %d of %d", done, count);
1004 return (gdouble)done / count;
1005 }
1006
1007
978 static void vflist_thumb_status(ViewFile *vf, gdouble val, const gchar *text) 1008 static void vflist_thumb_status(ViewFile *vf, gdouble val, const gchar *text)
979 { 1009 {
980 if (vf->func_thumb_status) 1010 if (vf->func_thumb_status)
981 { 1011 {
982 vf->func_thumb_status(vf, val, text, vf->data_thumb_status); 1012 vf->func_thumb_status(vf, val, text, vf->data_thumb_status);
985 1015
986 static void vflist_thumb_cleanup(ViewFile *vf) 1016 static void vflist_thumb_cleanup(ViewFile *vf)
987 { 1017 {
988 vflist_thumb_status(vf, 0.0, NULL); 1018 vflist_thumb_status(vf, 0.0, NULL);
989 1019
990 vf->thumbs_count = 0;
991 vf->thumbs_running = FALSE; 1020 vf->thumbs_running = FALSE;
992 1021
993 thumb_loader_free(vf->thumbs_loader); 1022 thumb_loader_free(vf->thumbs_loader);
994 vf->thumbs_loader = NULL; 1023 vf->thumbs_loader = NULL;
995 1024
1009 if (!fd || vflist_find_row(vf, fd, &iter) < 0) return; 1038 if (!fd || vflist_find_row(vf, fd, &iter) < 0) return;
1010 1039
1011 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview))); 1040 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)));
1012 gtk_tree_store_set(store, &iter, FILE_COLUMN_THUMB, fd->pixbuf, -1); 1041 gtk_tree_store_set(store, &iter, FILE_COLUMN_THUMB, fd->pixbuf, -1);
1013 1042
1014 vflist_thumb_status(vf, (gdouble)(vf->thumbs_count) / vflist_sidecar_list_count(vf->list), _("Loading thumbs...")); 1043 vflist_thumb_status(vf, vflist_thumb_progress(vf), _("Loading thumbs..."));
1015 } 1044 }
1016 1045
1017 static void vflist_thumb_error_cb(ThumbLoader *tl, gpointer data) 1046 static void vflist_thumb_error_cb(ThumbLoader *tl, gpointer data)
1018 { 1047 {
1019 ViewFile *vf = data; 1048 ViewFile *vf = data;
1094 { 1123 {
1095 /* done */ 1124 /* done */
1096 vflist_thumb_cleanup(vf); 1125 vflist_thumb_cleanup(vf);
1097 return FALSE; 1126 return FALSE;
1098 } 1127 }
1099
1100 vf->thumbs_count++;
1101 1128
1102 vf->thumbs_filedata = fd; 1129 vf->thumbs_filedata = fd;
1103 1130
1104 thumb_loader_free(vf->thumbs_loader); 1131 thumb_loader_free(vf->thumbs_loader);
1105 1132