? demos/testpixbuf-collection
? demos/gtk-demo/core.13768
Index: gdk-pixbuf/Makefile.am
===================================================================
RCS file: /cvs/gnome/gtk+/gdk-pixbuf/Makefile.am,v
retrieving revision 1.123
diff -u -r1.123 Makefile.am
--- gdk-pixbuf/Makefile.am	22 May 2002 19:37:30 -0000	1.123
+++ gdk-pixbuf/Makefile.am	20 Aug 2002 06:18:39 -0000
@@ -263,6 +263,7 @@
 	gdk-pixbuf-i18n.h	\
 	gdk-pixbuf.c		\
 	gdk-pixbuf-animation.c	\
+	gdk-pixbuf-collection.c	\
 	gdk-pixbuf-data.c	\
 	gdk-pixbuf-io.c		\
 	gdk-pixbuf-loader.c	\
Index: gdk-pixbuf/gdk-pixbuf-animation.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk-pixbuf/gdk-pixbuf-animation.c,v
retrieving revision 1.21
diff -u -r1.21 gdk-pixbuf-animation.c
--- gdk-pixbuf/gdk-pixbuf-animation.c	20 Dec 2001 23:09:29 -0000	1.21
+++ gdk-pixbuf/gdk-pixbuf-animation.c	20 Aug 2002 06:18:39 -0000
@@ -187,7 +187,7 @@
 		}
 
 		fseek (f, 0, SEEK_SET);
-		pixbuf = (* image_module->load) (f, error);
+		pixbuf = _gdk_pixbuf_generic_image_load (image_module, f, error);
 		fclose (f);
 
                 if (pixbuf == NULL && error != NULL && *error == NULL) {
Index: gdk-pixbuf/gdk-pixbuf-collection.c
===================================================================
RCS file: gdk-pixbuf/gdk-pixbuf-collection.c
diff -N gdk-pixbuf/gdk-pixbuf-collection.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gdk-pixbuf/gdk-pixbuf-collection.c	20 Aug 2002 06:18:39 -0000
@@ -0,0 +1,356 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/* GdkPixbuf library - Simple animation support
+ *
+ * Copyright (C) 1999 The Free Software Foundation
+ *
+ * Authors: Jonathan Blandford <jrb@redhat.com>
+ *          Havoc Pennington <hp@redhat.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <errno.h>
+#include "gdk-pixbuf-private.h"
+#include "gdk-pixbuf-io.h"
+
+typedef struct _GdkPixbufNonCollection GdkPixbufNonCollection;
+typedef struct _GdkPixbufNonCollectionClass GdkPixbufNonCollectionClass;
+
+#define GDK_TYPE_PIXBUF_NON_COLLECTION		(gdk_pixbuf_non_collection_get_type ())
+#define GDK_PIXBUF_NON_COLLECTION(object)	(G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF_NON_COLLECTION, GdkPixbufNonCollection))
+#define GDK_IS_PIXBUF_NON_COLLECTION(object)	(G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF_NON_COLLECTION))
+
+/* Private part of the GdkPixbufNonCollection structure */
+struct _GdkPixbufNonCollection {
+	GdkPixbufCollection parent_instance;
+
+	GdkPixbuf *pixbuf;
+};
+
+struct _GdkPixbufNonCollectionClass {
+	GdkPixbufCollectionClass parent_class;
+};
+
+static GType gdk_pixbuf_non_collection_get_type (void) G_GNUC_CONST;
+
+GType
+gdk_pixbuf_collection_get_type (void)
+{
+	static GType object_type = 0;
+
+	if (!object_type) {
+		static const GTypeInfo object_info = {
+			sizeof (GdkPixbufCollectionClass),
+                        (GBaseInitFunc) NULL,
+                        (GBaseFinalizeFunc) NULL,
+                        (GClassInitFunc) NULL,
+                        NULL,           /* class_finalize */
+                        NULL,           /* class_data */
+                        sizeof (GdkPixbufCollection),
+                        0,              /* n_preallocs */
+                        (GInstanceInitFunc) NULL,
+                };
+                
+                object_type = g_type_register_static (G_TYPE_OBJECT,
+                                                      "GdkPixbufCollection",
+                                                      &object_info, 0);
+        }
+	
+        return object_type;
+}
+
+GdkPixbufCollection *
+gdk_pixbuf_collection_new_from_file (const char *filename,
+				     GError    **error)
+{
+	GdkPixbufCollection *collection;
+	int size;
+	FILE *f;
+	guchar buffer[128];
+	GdkPixbufModule *image_module;
+
+	g_return_val_if_fail (filename != NULL, NULL);
+
+	f = fopen (filename, "rb");
+	if (!f) {
+                g_set_error (error,
+                             G_FILE_ERROR,
+                             g_file_error_from_errno (errno),
+                             _("Failed to open file '%s': %s"),
+                             filename, g_strerror (errno));
+		return NULL;
+        }
+
+	size = fread (&buffer, 1, sizeof (buffer), f);
+	if (size == 0) {
+                g_set_error (error,
+                             GDK_PIXBUF_ERROR,
+                             GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+                             _("Image file '%s' contains no data"),
+                             filename);
+                
+		fclose (f);
+		return NULL;
+	}
+
+	image_module = _gdk_pixbuf_get_module (buffer, size, filename, error);
+	if (!image_module) {
+		fclose (f);
+		return NULL;
+	}
+
+	if (image_module->module == NULL)
+                if (!_gdk_pixbuf_load_module (image_module, error)) {
+                        fclose (f);
+                        return NULL;
+                }
+
+	if (image_module->load_collection == NULL) {
+		GdkPixbuf *pixbuf;
+
+		/* Keep this logic in sync with gdk_pixbuf_new_from_file() */
+		fseek (f, 0, SEEK_SET);
+		pixbuf = _gdk_pixbuf_generic_image_load (image_module, f, error);
+		fclose (f);
+
+                if (pixbuf == NULL && error != NULL && *error == NULL) {
+                        /* I don't trust these crufty longjmp()'ing image libs
+                         * to maintain proper error invariants, and I don't
+                         * want user code to segfault as a result. We need to maintain
+                         * the invariant that error gets set if NULL is returned.
+                         */
+                        
+                        g_warning ("Bug! gdk-pixbuf loader '%s' didn't set an error on failure.",
+                                   image_module->module_name);
+                        g_set_error (error,
+                                     GDK_PIXBUF_ERROR,
+                                     GDK_PIXBUF_ERROR_FAILED,
+                                     _("Failed to load image '%s': reason not known, probably a corrupt image file"),
+                                     filename);
+                }
+                
+		if (pixbuf == NULL)
+                        return NULL;
+
+                collection = gdk_pixbuf_non_collection_new (pixbuf);
+
+                g_object_unref (pixbuf);
+	} else {
+		fseek (f, 0, SEEK_SET);
+
+		collection = (*image_module->load_collection) (f, error);
+		
+                if (collection == NULL && error != NULL && *error == NULL) {
+                        /* I don't trust these crufty longjmp()'ing
+                         * image libs to maintain proper error
+                         * invariants, and I don't want user code to
+                         * segfault as a result. We need to maintain
+                         * the invariant that error gets set if NULL
+                         * is returned.
+                         */
+                        
+                        g_warning ("Bug! gdk-pixbuf loader '%s' didn't set an error on failure.",
+                                   image_module->module_name);
+                        g_set_error (error,
+                                     GDK_PIXBUF_ERROR,
+                                     GDK_PIXBUF_ERROR_FAILED,
+                                     _("Failed to load collection '%s': reason not known, probably a corrupt file"),
+                                     filename);
+                }
+                
+		fclose (f);
+	}
+
+	return collection;
+}
+
+int
+gdk_pixbuf_collection_get_length (GdkPixbufCollection *collection)
+{
+	g_return_val_if_fail (GDK_IS_PIXBUF_COLLECTION (collection), -1);
+
+	return GDK_PIXBUF_COLLECTION_GET_CLASS (collection)->get_length (collection);
+}
+
+GdkPixbuf *
+gdk_pixbuf_collection_get_pixbuf (GdkPixbufCollection *collection,
+				  int                  i)
+{
+	g_return_val_if_fail (i >= 0, NULL);
+	g_return_val_if_fail (i < gdk_pixbuf_collection_get_length (collection), NULL);
+
+	return GDK_PIXBUF_COLLECTION_GET_CLASS (collection)->get_pixbuf (collection, i);
+}
+
+gint
+gdk_pixbuf_collection_get_pixbuf_width (GdkPixbufCollection *collection,
+					int                  i)
+{
+	g_return_val_if_fail (i >= 0, -1);
+	g_return_val_if_fail (i < gdk_pixbuf_collection_get_length (collection), -1);
+
+	return GDK_PIXBUF_COLLECTION_GET_CLASS (collection)->get_pixbuf_width (collection, i);
+}
+
+gint
+gdk_pixbuf_collection_get_pixbuf_height (GdkPixbufCollection *collection,
+					 int                  i)
+{
+	g_return_val_if_fail (i >= 0, -1);
+	g_return_val_if_fail (i < gdk_pixbuf_collection_get_length (collection), -1);
+
+	return GDK_PIXBUF_COLLECTION_GET_CLASS (collection)->get_pixbuf_height (collection, i);
+}
+
+gint
+gdk_pixbuf_collection_get_pixbuf_bpp (GdkPixbufCollection *collection,
+				      int                  i)
+{
+	g_return_val_if_fail (i >= 0, -1);
+	g_return_val_if_fail (i < gdk_pixbuf_collection_get_length (collection), -1);
+	
+	return GDK_PIXBUF_COLLECTION_GET_CLASS (collection)->get_pixbuf_bpp (collection, i);
+}
+
+static void       gdk_pixbuf_non_collection_class_init        (GdkPixbufNonCollectionClass *klass);
+static void       gdk_pixbuf_non_collection_finalize          (GObject                     *gobject);
+static gint       gdk_pixbuf_non_collection_get_length        (GdkPixbufCollection         *collection);
+static GdkPixbuf *gdk_pixbuf_non_collection_get_pixbuf        (GdkPixbufCollection         *collection,
+							       int                          i);
+static gint       gdk_pixbuf_non_collection_get_pixbuf_height (GdkPixbufCollection         *collection,
+							       int                          i);
+static gint       gdk_pixbuf_non_collection_get_pixbuf_width  (GdkPixbufCollection         *collection,
+							       int                          i);
+static gint       gdk_pixbuf_non_collection_get_pixbuf_bpp    (GdkPixbufCollection         *collection,
+							       int                          i);
+
+
+static gpointer non_parent_class;
+
+GType
+gdk_pixbuf_non_collection_get_type (void)
+{
+	static GType object_type = 0;
+
+	if (!object_type) {
+		static const GTypeInfo object_info = {
+			sizeof (GdkPixbufNonCollectionClass),
+			(GBaseInitFunc) NULL,
+                        (GBaseFinalizeFunc) NULL,
+                        (GClassInitFunc) gdk_pixbuf_non_collection_class_init,
+                        NULL,           /* class_finalize */
+                        NULL,           /* class_data */
+                        sizeof (GdkPixbufNonCollection),
+                        0,              /* n_preallocs */
+                        (GInstanceInitFunc) NULL,
+                };
+                
+                object_type = g_type_register_static (GDK_TYPE_PIXBUF_COLLECTION,
+                                                      "GdkPixbufNonCollection",
+                                                      &object_info, 0);
+        }
+        
+        return object_type;
+}
+			
+static void
+gdk_pixbuf_non_collection_class_init (GdkPixbufNonCollectionClass *klass)
+{
+        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+        GdkPixbufCollectionClass *collection_class = GDK_PIXBUF_COLLECTION_CLASS (klass);
+        
+        non_parent_class = g_type_class_peek_parent (klass);
+
+        object_class->finalize = gdk_pixbuf_non_collection_finalize;
+
+	collection_class->get_length = gdk_pixbuf_non_collection_get_length;
+	collection_class->get_pixbuf = gdk_pixbuf_non_collection_get_pixbuf;
+	collection_class->get_pixbuf_width = gdk_pixbuf_non_collection_get_pixbuf_width;
+	collection_class->get_pixbuf_height = gdk_pixbuf_non_collection_get_pixbuf_height;
+	collection_class->get_pixbuf_bpp = gdk_pixbuf_non_collection_get_pixbuf_bpp;
+}
+
+static void
+gdk_pixbuf_non_collection_finalize (GObject *object)
+{
+	GdkPixbufNonCollection *non_collection = GDK_PIXBUF_NON_COLLECTION (object);
+
+	if (non_collection->pixbuf)
+		g_object_unref (non_collection->pixbuf);
+
+	G_OBJECT_CLASS (non_parent_class)->finalize (object);
+}
+
+static gint
+gdk_pixbuf_non_collection_get_length (GdkPixbufCollection *collection)
+{
+	if (GDK_PIXBUF_NON_COLLECTION (collection)->pixbuf)
+		return 1;
+	else
+		return 0;
+}
+
+static gint
+gdk_pixbuf_non_collection_get_pixbuf_width (GdkPixbufCollection *collection,
+					     int                  i)
+{
+	return gdk_pixbuf_get_width (GDK_PIXBUF_NON_COLLECTION (collection)->pixbuf);
+}
+
+static gint
+gdk_pixbuf_non_collection_get_pixbuf_height (GdkPixbufCollection *collection,
+					     int                  i)
+{
+	return gdk_pixbuf_get_height (GDK_PIXBUF_NON_COLLECTION (collection)->pixbuf);
+}
+
+static gint
+gdk_pixbuf_non_collection_get_pixbuf_bpp (GdkPixbufCollection *collection,
+					  int                  i)
+{
+	GdkPixbufNonCollection *non_collection = GDK_PIXBUF_NON_COLLECTION (collection);
+	
+	return gdk_pixbuf_get_bits_per_sample (non_collection->pixbuf) * 8 *
+		(gdk_pixbuf_get_has_alpha (non_collection->pixbuf) ? 4 : 3);
+}
+
+static GdkPixbuf *
+gdk_pixbuf_non_collection_get_pixbuf (GdkPixbufCollection *collection,
+				      int                  i)
+{
+	GdkPixbufNonCollection *non_collection = GDK_PIXBUF_NON_COLLECTION (collection);
+
+	return non_collection->pixbuf;
+}
+
+
+GdkPixbufCollection *
+gdk_pixbuf_non_collection_new (GdkPixbuf *pixbuf)
+{
+	GdkPixbufNonCollection *non_collection;
+
+	non_collection = g_object_new (GDK_TYPE_PIXBUF_NON_COLLECTION, NULL);
+
+	non_collection->pixbuf = pixbuf;
+	if (pixbuf)
+		g_object_ref (pixbuf);
+
+	return GDK_PIXBUF_COLLECTION (non_collection);
+}
+
+
Index: gdk-pixbuf/gdk-pixbuf-io.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk-pixbuf/gdk-pixbuf-io.c,v
retrieving revision 1.70
diff -u -r1.70 gdk-pixbuf-io.c
--- gdk-pixbuf/gdk-pixbuf-io.c	7 Jul 2002 20:29:48 -0000	1.70
+++ gdk-pixbuf/gdk-pixbuf-io.c	20 Aug 2002 06:18:39 -0000
@@ -564,10 +564,10 @@
 	*((GdkPixbuf **)user_data) = pixbuf;
 }
 
-static GdkPixbuf *
-generic_image_load (GdkPixbufModule *module,
-		    FILE *f,
-		    GError **error)
+GdkPixbuf *
+_gdk_pixbuf_generic_image_load (GdkPixbufModule *module,
+				FILE *f,
+				GError **error)
 {
 	guchar buffer[4096];
 	size_t length;
@@ -663,7 +663,7 @@
                 }
 
 	fseek (f, 0, SEEK_SET);
-	pixbuf = generic_image_load (image_module, f, error);
+	pixbuf = _gdk_pixbuf_generic_image_load (image_module, f, error);
 	fclose (f);
 
         if (pixbuf == NULL && error != NULL && *error == NULL) {
Index: gdk-pixbuf/gdk-pixbuf-io.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk-pixbuf/gdk-pixbuf-io.h,v
retrieving revision 1.27
diff -u -r1.27 gdk-pixbuf-io.h
--- gdk-pixbuf/gdk-pixbuf-io.h	6 Jul 2002 23:10:45 -0000	1.27
+++ gdk-pixbuf/gdk-pixbuf-io.h	20 Aug 2002 06:18:39 -0000
@@ -78,6 +78,9 @@
 	GdkPixbufAnimation *(* load_animation) (FILE    *f,
                                                 GError **error);
 
+	/* Collection loading */
+	GdkPixbufCollection *(* load_collection) (FILE    *f,
+						  GError **error);
         gboolean (* save) (FILE      *f,
                            GdkPixbuf *pixbuf,
                            gchar    **param_keys,
@@ -94,6 +97,10 @@
                                                GError **error);
 gboolean _gdk_pixbuf_load_module (GdkPixbufModule *image_module,
                                   GError **error);
+
+GdkPixbuf *_gdk_pixbuf_generic_image_load (GdkPixbufModule *module,
+					   FILE *f,
+					   GError **error);
 
 
 
Index: gdk-pixbuf/gdk-pixbuf-private.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk-pixbuf/gdk-pixbuf-private.h,v
retrieving revision 1.10
diff -u -r1.10 gdk-pixbuf-private.h
--- gdk-pixbuf/gdk-pixbuf-private.h	5 Oct 2001 18:51:47 -0000	1.10
+++ gdk-pixbuf/gdk-pixbuf-private.h	20 Aug 2002 06:18:39 -0000
@@ -131,8 +131,36 @@
 
 GdkPixbufAnimation* gdk_pixbuf_non_anim_new (GdkPixbuf *pixbuf);
 
+typedef struct _GdkPixbufCollectionClass GdkPixbufCollectionClass;
+
+#define GDK_PIXBUF_COLLECTION_CLASS(klass)	(G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_PIXBUF_COLLECTION, GdkPixbufCollectionClass))
+#define GDK_IS_PIXBUF_COLLECTION_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_PIXBUF_COLLECTION))
+#define GDK_PIXBUF_COLLECTION_GET_CLASS(obj)	(G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_PIXBUF_COLLECTION, GdkPixbufCollectionClass))
+
+/* Private part of the GdkPixbufCollection structure */
+struct _GdkPixbufCollection {
+        GObject parent_instance;
+};
+
+struct _GdkPixbufCollectionClass {
+        GObjectClass parent_class;
+
+        gint       (* get_length)        (GdkPixbufCollection *collection);
+        GdkPixbuf *(* get_pixbuf)        (GdkPixbufCollection *collection,
+                                          int                  i);
+        gint       (* get_pixbuf_width)  (GdkPixbufCollection *collection,
+                                          int                  i);
+        gint       (* get_pixbuf_height) (GdkPixbufCollection *collection,
+                                          int                  i);
+        gint       (* get_pixbuf_bpp)    (GdkPixbufCollection *collection,
+                                          int                  i);
+};
+
+GdkPixbufCollection *gdk_pixbuf_non_collection_new (GdkPixbuf *pixbuf);
+
 
 
+        
 /*  key/value pairs that can be attached by the pixbuf loader  */
 
 gboolean gdk_pixbuf_set_option  (GdkPixbuf   *pixbuf,
Index: gdk-pixbuf/gdk-pixbuf.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk-pixbuf/gdk-pixbuf.h,v
retrieving revision 1.66
diff -u -r1.66 gdk-pixbuf.h
--- gdk-pixbuf/gdk-pixbuf.h	9 Jan 2002 16:36:20 -0000	1.66
+++ gdk-pixbuf/gdk-pixbuf.h	20 Aug 2002 06:18:40 -0000
@@ -53,6 +53,7 @@
 typedef struct _GdkPixbuf GdkPixbuf;
 typedef struct _GdkPixbufAnimation GdkPixbufAnimation;
 typedef struct _GdkPixbufAnimationIter GdkPixbufAnimationIter;
+typedef struct _GdkPixbufCollection GdkPixbufCollection;
 typedef struct _GdkPixbufFrame GdkPixbufFrame;
 
 #define GDK_TYPE_PIXBUF              (gdk_pixbuf_get_type ())
@@ -67,6 +68,10 @@
 #define GDK_PIXBUF_ANIMATION_ITER(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF_ANIMATION_ITER, GdkPixbufAnimationIter))
 #define GDK_IS_PIXBUF_ANIMATION_ITER(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF_ANIMATION_ITER))
 
+#define GDK_TYPE_PIXBUF_COLLECTION		(gdk_pixbuf_collection_get_type ())
+#define GDK_PIXBUF_COLLECTION(object)		(G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF_COLLECTION, GdkPixbufCollection))
+#define GDK_IS_PIXBUF_COLLECTION(object)	(G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF_COLLECTION))
+
 /* Handler that must free the pixel array */
 typedef void (* GdkPixbufDestroyNotify) (guchar *pixels, gpointer data);
 
@@ -281,6 +286,23 @@
 gboolean                gdk_pixbuf_animation_iter_advance                    (GdkPixbufAnimationIter *iter,
                                                                               const GTimeVal         *current_time);
 
+
+/* Collection support */
+
+GType                 gdk_pixbuf_collection_get_type      (void) G_GNUC_CONST;
+
+GdkPixbufCollection * gdk_pixbuf_collection_new_from_file (const char          *filename,
+							   GError             **error);
+
+int                   gdk_pixbuf_collection_get_length        (GdkPixbufCollection *collection);
+GdkPixbuf           * gdk_pixbuf_collection_get_pixbuf        (GdkPixbufCollection *collection,
+							       int                  i);
+gint                  gdk_pixbuf_collection_get_pixbuf_width  (GdkPixbufCollection *collection,
+							       int                  i);
+gint                  gdk_pixbuf_collection_get_pixbuf_height (GdkPixbufCollection *collection,
+							       int                  i);
+gint                  gdk_pixbuf_collection_get_pixbuf_bpp    (GdkPixbufCollection *collection,
+							       int                  i);
 
 
 
Index: demos/Makefile.am
===================================================================
RCS file: /cvs/gnome/gtk+/demos/Makefile.am,v
retrieving revision 1.22
diff -u -r1.22 Makefile.am
--- demos/Makefile.am	30 Jul 2002 20:00:16 -0000	1.22
+++ demos/Makefile.am	20 Aug 2002 06:18:40 -0000
@@ -26,6 +26,7 @@
 
 noinst_PROGRAMS = 		\
 	testpixbuf 		\
+	testpixbuf-collection	\
 	testpixbuf-drawable 	\
 	testanimation 		\
 	testpixbuf-save		\
@@ -45,6 +46,7 @@
 	        apple_red apple-red.png gnome_foot gnome-foot.png >$$curdir/test-inline-pixbufs.h)
 
 testpixbuf_DEPENDENCIES = $(DEPS)
+testpixbuf_collection_DEPENDENCIES = $(DEPS)
 testpixbuf_drawable_DEPENDENCIES = $(DEPS)
 testpixbuf_save_DEPENDENCIES = $(DEPS)
 testpixbuf_scale_DEPENDENCIES = $(DEPS)
@@ -52,6 +54,7 @@
 pixbuf_demo_DEPENDENCIES = $(DEPS)
 
 testpixbuf_LDADD = $(LDADDS)
+testpixbuf_collection_LDADD = $(LDADDS)
 testpixbuf_drawable_LDADD = $(LDADDS)
 testpixbuf_save_LDADD = $(LDADDS)
 testpixbuf_scale_LDADD = $(LDADDS)
@@ -60,6 +63,7 @@
 
 testpixbuf_SOURCES = testpixbuf.c pixbuf-init.c
 $(testpixbuf_OBJECTS): test-inline-pixbufs.h
+testpixbuf_collection_SOURCES = testpixbuf-collection.c
 testpixbuf_drawable_SOURCES = testpixbuf-drawable.c pixbuf-init.c
 testpixbuf_save_SOURCES = testpixbuf-save.c
 testpixbuf_scale_SOURCES = testpixbuf-scale.c pixbuf-init.c
Index: demos/testpixbuf-collection.c
===================================================================
RCS file: demos/testpixbuf-collection.c
diff -N demos/testpixbuf-collection.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ demos/testpixbuf-collection.c	20 Aug 2002 06:18:40 -0000
@@ -0,0 +1,94 @@
+/* testpixbuf-collection -- test program for gdk-pixbuf collection code
+ * Copyright (C) 2002 Anders Carlsson <andersca@gnu.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#include <config.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <gtk/gtk.h>
+
+int
+main (int argc, char **argv)
+{
+	GdkPixbufCollection *collection;
+	GError *error;
+	int i;
+	GtkWidget *window, *sw, *tree_view;
+	GtkListStore *list_store;
+	
+	gtk_init (&argc, &argv);
+
+	if (argc != 2) {
+		fprintf (stderr, "Usage: testpixbuf-collection FILE\n");
+		exit (1);
+	}
+
+	error = NULL;
+	collection = gdk_pixbuf_collection_new_from_file (argv[1], &error);
+	if (!collection) {
+		fprintf (stderr, "Cannot load image: %s\n",
+			 error->message);
+		g_error_free (error);
+		exit (1);
+	}
+
+	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+	g_signal_connect (window, "delete_event",
+			  G_CALLBACK (gtk_main_quit), NULL);
+
+	sw = gtk_scrolled_window_new (NULL, NULL);
+	gtk_container_add (GTK_CONTAINER (window), sw);
+
+	list_store = gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_STRING);
+	tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store));
+
+	gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
+						     -1, "Icon",
+						     gtk_cell_renderer_pixbuf_new (),
+						     "pixbuf", 0,
+						     NULL);
+
+	gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view),
+						     -1, "Info",
+						     gtk_cell_renderer_text_new (),
+						     "text", 1,
+						     NULL);
+	
+	for (i = 0; i < gdk_pixbuf_collection_get_length (collection); i++) {
+		GtkTreeIter iter;
+		char *str;
+		
+		gtk_list_store_append (list_store, &iter);
+		str = g_strdup_printf ("%dx%d (%d bpp)", gdk_pixbuf_collection_get_pixbuf_width (collection, i),
+				       gdk_pixbuf_collection_get_pixbuf_height (collection, i),
+				       gdk_pixbuf_collection_get_pixbuf_bpp (collection, i));
+		gtk_list_store_set (list_store, &iter,
+				    0, gdk_pixbuf_collection_get_pixbuf (collection, i),
+				    1, str,
+				    -1);
+		g_free (str);
+	}
+	
+	g_object_unref (list_store);
+	gtk_container_add (GTK_CONTAINER (sw), tree_view);
+	gtk_widget_show_all (window);
+
+	gtk_main ();
+	
+	return 0;
+}
+
