]> Pileus Git - ~andy/gtk/blobdiff - demos/testpixbuf.c
contrib subdir
[~andy/gtk] / demos / testpixbuf.c
index c6d5a45c54a3489058edd6654099e9cea2826dbb..f118205e2153c802f4c402839ace0532ce33004a 100644 (file)
@@ -370,7 +370,8 @@ new_testrgb_window (GdkPixbuf *pixbuf, gchar *title)
        GtkWidget *button;
        GtkWidget *drawing_area;
        gint w, h;
+
+        g_return_val_if_fail (pixbuf != NULL, NULL);
        w = gdk_pixbuf_get_width (pixbuf);
        h = gdk_pixbuf_get_height (pixbuf);
 
@@ -427,18 +428,34 @@ static gint
 update_timeout(gpointer data)
 {
         ProgressFileStatus *status = data;
-       gboolean done;
-
-       done = TRUE;
+       gboolean done, error;
+        
+       done = FALSE;
+        error = FALSE;
        if (!feof(status->imagefile)) {
                gint nbytes;
 
                nbytes = fread(status->buf, 1, status->readlen, 
                               status->imagefile);
 
-               done = !gdk_pixbuf_loader_write (GDK_PIXBUF_LOADER (status->loader), status->buf, nbytes);
-                       
-       }
+
+                error = !gdk_pixbuf_loader_write (GDK_PIXBUF_LOADER (status->loader), status->buf, nbytes);
+                if (error) {
+                        G_BREAKPOINT();
+                }
+
+        } else { /* Really done */ 
+
+                GdkPixbuf *pixbuf = gdk_pixbuf_loader_get_pixbuf (status->loader); 
+                new_testrgb_window (pixbuf, "After progressive load"); 
+                done = TRUE; 
+
+        }
+
+        if (error) { 
+                g_warning ("Serious error writing to loader"); 
+                done = TRUE; 
+        } 
 
        if (done) {
                 gtk_widget_queue_draw(*status->rgbwin);