summaryrefslogtreecommitdiff
path: root/demos/testpixbuf.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@pobox.com>1999-10-27 19:42:34 +0000
committerHavoc Pennington <hp@src.gnome.org>1999-10-27 19:42:34 +0000
commitbe374ad560466f7d6a6aa5eac43ec422208a0a82 (patch)
tree29d4d71efa7f9232f1beeae9d777fa0d3f3cbad8 /demos/testpixbuf.c
parent9ee4ff5eeed7adc36c138e79f53f7799eac30a11 (diff)
downloadgtk+-be374ad560466f7d6a6aa5eac43ec422208a0a82.tar.gz
Display the progressive load
1999-10-27 Havoc Pennington <hp@pobox.com> * src/testpixbuf.c (main): Display the progressive load * src/io-png.c (setup_png_transformations): Break transformation code into separate function (png_info_callback): Use setup_png_transformations
Diffstat (limited to 'demos/testpixbuf.c')
-rw-r--r--demos/testpixbuf.c86
1 files changed, 70 insertions, 16 deletions
diff --git a/demos/testpixbuf.c b/demos/testpixbuf.c
index fc6d0aa397..83e1444ce1 100644
--- a/demos/testpixbuf.c
+++ b/demos/testpixbuf.c
@@ -351,7 +351,7 @@ config_func (GtkWidget *drawing_area, GdkEventConfigure *event, gpointer data)
#endif
}
-static void
+static GtkWidget*
new_testrgb_window (GdkPixbuf *pixbuf)
{
GtkWidget *window;
@@ -400,6 +400,33 @@ new_testrgb_window (GdkPixbuf *pixbuf)
gtk_widget_show (vbox);
gtk_widget_show (window);
+
+ return window;
+}
+
+static gint
+update_timeout(gpointer data)
+{
+ GtkWidget** window_loc = data;
+
+ if (*window_loc != NULL) {
+ gtk_widget_queue_draw(*window_loc);
+ }
+}
+
+static void
+progressive_prepared_callback(GdkPixbufLoader* loader, gpointer data)
+{
+ GtkWidget** retloc = data;
+ GdkPixbuf* pixbuf;
+
+ pixbuf = gdk_pixbuf_loader_get_pixbuf(loader);
+ g_assert(pixbuf != NULL);
+
+ gdk_pixbuf_ref(pixbuf); /* for the RGB window */
+ *retloc = new_testrgb_window(pixbuf);
+
+ return;
}
int
@@ -453,21 +480,48 @@ main (int argc, char **argv)
}
}
- pixbuf_loader = gdk_pixbuf_loader_new ();
- file = fopen (argv[1], "r");
- g_assert (file != NULL);
-
- while (TRUE) {
- val = fgetc (file);
- if (val == EOF)
- break;
- buf = (guint) val;
- if (gdk_pixbuf_loader_write (GDK_PIXBUF_LOADER (pixbuf_loader), &buf, 1) == FALSE)
- break;
- }
- gdk_pixbuf_loader_close (GDK_PIXBUF_LOADER (pixbuf_loader));
- gtk_object_destroy (pixbuf_loader);
- fclose (file);
+ {
+ GtkWidget* rgb_window = NULL;
+ guint timeout;
+
+ pixbuf_loader = gdk_pixbuf_loader_new ();
+
+ gtk_signal_connect(GTK_OBJECT(pixbuf_loader),
+ "area_prepared",
+ GTK_SIGNAL_FUNC(progressive_prepared_callback),
+ &rgb_window);
+
+ timeout = gtk_timeout_add(1000, update_timeout, &rgb_window);
+
+ file = fopen (argv[1], "r");
+ g_assert (file != NULL);
+
+ while (TRUE) {
+ val = fgetc (file);
+ if (val == EOF)
+ break;
+ buf = (guint) val;
+
+ fflush(stdout);
+
+ printf(".");
+ fflush(stdout);
+
+ if (gdk_pixbuf_loader_write (GDK_PIXBUF_LOADER (pixbuf_loader), &buf, 1) == FALSE)
+ break;
+
+ while (gtk_events_pending())
+ gtk_main_iteration();
+
+ }
+ gtk_timeout_remove(timeout);
+ gdk_pixbuf_loader_close (GDK_PIXBUF_LOADER (pixbuf_loader));
+ gtk_object_destroy (GTK_OBJECT(pixbuf_loader));
+ fclose (file);
+
+ if (rgb_window != NULL)
+ gtk_widget_queue_draw(rgb_window);
+ }
}