comparison src/view_file_icon.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
1792 *----------------------------------------------------------------------------- 1792 *-----------------------------------------------------------------------------
1793 */ 1793 */
1794 1794
1795 static gint vficon_thumb_next(ViewFile *vf); 1795 static gint vficon_thumb_next(ViewFile *vf);
1796 1796
1797 static gdouble vficon_thumb_progress(ViewFile *vf)
1798 {
1799 gint count = 0;
1800 gint done = 0;
1801
1802 GList *work = vf->list;
1803 while (work)
1804 {
1805 IconData *id = work->data;
1806 FileData *fd = id->fd;
1807 work = work->next;
1808
1809 if (fd->pixbuf) done++;
1810 count++;
1811 }
1812 DEBUG_1("thumb progress: %d of %d", done, count);
1813 return (gdouble)done / count;
1814 }
1815
1797 static void vficon_thumb_status(ViewFile *vf, gdouble val, const gchar *text) 1816 static void vficon_thumb_status(ViewFile *vf, gdouble val, const gchar *text)
1798 { 1817 {
1799 if (vf->func_thumb_status) 1818 if (vf->func_thumb_status)
1800 { 1819 {
1801 vf->func_thumb_status(vf, val, text, vf->data_thumb_status); 1820 vf->func_thumb_status(vf, val, text, vf->data_thumb_status);
1804 1823
1805 static void vficon_thumb_cleanup(ViewFile *vf) 1824 static void vficon_thumb_cleanup(ViewFile *vf)
1806 { 1825 {
1807 vficon_thumb_status(vf, 0.0, NULL); 1826 vficon_thumb_status(vf, 0.0, NULL);
1808 1827
1809 vf->thumbs_count = 0;
1810 vf->thumbs_running = FALSE; 1828 vf->thumbs_running = FALSE;
1811 1829
1812 thumb_loader_free(vf->thumbs_loader); 1830 thumb_loader_free(vf->thumbs_loader);
1813 vf->thumbs_loader = NULL; 1831 vf->thumbs_loader = NULL;
1814 1832
1824 { 1842 {
1825 if (!fd) return; 1843 if (!fd) return;
1826 1844
1827 vficon_set_thumb(vf, fd); 1845 vficon_set_thumb(vf, fd);
1828 1846
1829 vficon_thumb_status(vf, (gdouble)(vf->thumbs_count) / g_list_length(vf->list), _("Loading thumbs...")); 1847 vficon_thumb_status(vf, vficon_thumb_progress(vf), _("Loading thumbs..."));
1830 } 1848 }
1831 1849
1832 static void vficon_thumb_error_cb(ThumbLoader *tl, gpointer data) 1850 static void vficon_thumb_error_cb(ThumbLoader *tl, gpointer data)
1833 { 1851 {
1834 ViewFile *vf = data; 1852 ViewFile *vf = data;
1910 { 1928 {
1911 /* done */ 1929 /* done */
1912 vficon_thumb_cleanup(vf); 1930 vficon_thumb_cleanup(vf);
1913 return FALSE; 1931 return FALSE;
1914 } 1932 }
1915
1916 vf->thumbs_count++;
1917 1933
1918 vf->thumbs_filedata = fd; 1934 vf->thumbs_filedata = fd;
1919 1935
1920 thumb_loader_free(vf->thumbs_loader); 1936 thumb_loader_free(vf->thumbs_loader);
1921 1937