]> Pileus Git - ~andy/gtk/commitdiff
Convert GdkPixbuf to GObject, leaving it opaque (i.e. derivation is not
authorHavoc Pennington <hp@pobox.com>
Thu, 22 Jun 2000 15:36:12 +0000 (15:36 +0000)
committerHavoc Pennington <hp@src.gnome.org>
Thu, 22 Jun 2000 15:36:12 +0000 (15:36 +0000)
2000-06-21  Havoc Pennington  <hp@pobox.com>

* gdk-pixbuf.c: Convert GdkPixbuf to GObject, leaving it opaque
(i.e. derivation is not allowed, and there are no virtual methods
anyway).
(gdk_pixbuf_preinit): Call g_type_init() here.
(gdk_pixbuf_init): Add a user-friendly init function, for users
of standalone gdk-pixbuf

* gdk-pixbuf-animation.c: Convert to GObject, in the same
way GdkPixbufAnimation was done.

* gdk-pixbuf.h: Remove gdk_pixbuf_set_unref_handler() and
gdk_pixbuf_finalize() from API, since these are broken and don't
make sense with new GObject stuff.

2000-06-21  Havoc Pennington  <hp@pobox.com>

* gdk/gdkwindow.c (_gdk_window_destroy_hierarchy): Fix bug where
we didn't check window->bg_pixmap != GDK_NO_BG.

* gtk/gdk-pixbuf-loader.c: Change to reflect GObject-ification of
gdk-pixbuf

20 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
demos/testpixbuf.c
gdk-pixbuf/ChangeLog
gdk-pixbuf/gdk-pixbuf-animation.c
gdk-pixbuf/gdk-pixbuf-data.c
gdk-pixbuf/gdk-pixbuf-io.c
gdk-pixbuf/gdk-pixbuf-loader.c
gdk-pixbuf/gdk-pixbuf-private.h
gdk-pixbuf/gdk-pixbuf.c
gdk-pixbuf/gdk-pixbuf.h
gdk-pixbuf/io-gif.c
gdk-pixbuf/test-gdk-pixbuf.c
gdk/gdkwindow.c
gtk/gdk-pixbuf-loader.c

index c7c032512bd12283284b0ccdc2e038dc84304156..b428e7c78d3cb83442bb6d90bb7d0fd6fe4e40a3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2000-06-21  Havoc Pennington  <hp@pobox.com>
+
+       * gdk/gdkwindow.c (_gdk_window_destroy_hierarchy): Fix bug where
+       we didn't check window->bg_pixmap != GDK_NO_BG.
+
+       * gtk/gdk-pixbuf-loader.c: Change to reflect GObject-ification of
+       gdk-pixbuf
+
 Thu Jun 22 14:02:19 BST 2000  Tony Gale <gale@gtk.org>
 
        * docs/faq/gtk-faq.sgm: Move file to here.
index c7c032512bd12283284b0ccdc2e038dc84304156..b428e7c78d3cb83442bb6d90bb7d0fd6fe4e40a3 100644 (file)
@@ -1,3 +1,11 @@
+2000-06-21  Havoc Pennington  <hp@pobox.com>
+
+       * gdk/gdkwindow.c (_gdk_window_destroy_hierarchy): Fix bug where
+       we didn't check window->bg_pixmap != GDK_NO_BG.
+
+       * gtk/gdk-pixbuf-loader.c: Change to reflect GObject-ification of
+       gdk-pixbuf
+
 Thu Jun 22 14:02:19 BST 2000  Tony Gale <gale@gtk.org>
 
        * docs/faq/gtk-faq.sgm: Move file to here.
index c7c032512bd12283284b0ccdc2e038dc84304156..b428e7c78d3cb83442bb6d90bb7d0fd6fe4e40a3 100644 (file)
@@ -1,3 +1,11 @@
+2000-06-21  Havoc Pennington  <hp@pobox.com>
+
+       * gdk/gdkwindow.c (_gdk_window_destroy_hierarchy): Fix bug where
+       we didn't check window->bg_pixmap != GDK_NO_BG.
+
+       * gtk/gdk-pixbuf-loader.c: Change to reflect GObject-ification of
+       gdk-pixbuf
+
 Thu Jun 22 14:02:19 BST 2000  Tony Gale <gale@gtk.org>
 
        * docs/faq/gtk-faq.sgm: Move file to here.
index c7c032512bd12283284b0ccdc2e038dc84304156..b428e7c78d3cb83442bb6d90bb7d0fd6fe4e40a3 100644 (file)
@@ -1,3 +1,11 @@
+2000-06-21  Havoc Pennington  <hp@pobox.com>
+
+       * gdk/gdkwindow.c (_gdk_window_destroy_hierarchy): Fix bug where
+       we didn't check window->bg_pixmap != GDK_NO_BG.
+
+       * gtk/gdk-pixbuf-loader.c: Change to reflect GObject-ification of
+       gdk-pixbuf
+
 Thu Jun 22 14:02:19 BST 2000  Tony Gale <gale@gtk.org>
 
        * docs/faq/gtk-faq.sgm: Move file to here.
index c7c032512bd12283284b0ccdc2e038dc84304156..b428e7c78d3cb83442bb6d90bb7d0fd6fe4e40a3 100644 (file)
@@ -1,3 +1,11 @@
+2000-06-21  Havoc Pennington  <hp@pobox.com>
+
+       * gdk/gdkwindow.c (_gdk_window_destroy_hierarchy): Fix bug where
+       we didn't check window->bg_pixmap != GDK_NO_BG.
+
+       * gtk/gdk-pixbuf-loader.c: Change to reflect GObject-ification of
+       gdk-pixbuf
+
 Thu Jun 22 14:02:19 BST 2000  Tony Gale <gale@gtk.org>
 
        * docs/faq/gtk-faq.sgm: Move file to here.
index c7c032512bd12283284b0ccdc2e038dc84304156..b428e7c78d3cb83442bb6d90bb7d0fd6fe4e40a3 100644 (file)
@@ -1,3 +1,11 @@
+2000-06-21  Havoc Pennington  <hp@pobox.com>
+
+       * gdk/gdkwindow.c (_gdk_window_destroy_hierarchy): Fix bug where
+       we didn't check window->bg_pixmap != GDK_NO_BG.
+
+       * gtk/gdk-pixbuf-loader.c: Change to reflect GObject-ification of
+       gdk-pixbuf
+
 Thu Jun 22 14:02:19 BST 2000  Tony Gale <gale@gtk.org>
 
        * docs/faq/gtk-faq.sgm: Move file to here.
index c7c032512bd12283284b0ccdc2e038dc84304156..b428e7c78d3cb83442bb6d90bb7d0fd6fe4e40a3 100644 (file)
@@ -1,3 +1,11 @@
+2000-06-21  Havoc Pennington  <hp@pobox.com>
+
+       * gdk/gdkwindow.c (_gdk_window_destroy_hierarchy): Fix bug where
+       we didn't check window->bg_pixmap != GDK_NO_BG.
+
+       * gtk/gdk-pixbuf-loader.c: Change to reflect GObject-ification of
+       gdk-pixbuf
+
 Thu Jun 22 14:02:19 BST 2000  Tony Gale <gale@gtk.org>
 
        * docs/faq/gtk-faq.sgm: Move file to here.
index f4966fcba7c5521ff2d95b050588442d12dfa093..85dea5b7b78d7ba229ac0d49bf9b1c782cfd1ef8 100644 (file)
@@ -495,7 +495,7 @@ main (int argc, char **argv)
        GdkPixbufLoader *pixbuf_loader;
 
        pixbuf_init ();
-       
+
        gtk_init (&argc, &argv);
 
        gdk_rgb_set_verbose (TRUE);
index 5dfaaa848f93b124f14b93c1d54bb8838fb3d430..c014e6b93382159611381879fe4b0e09a0fc63cc 100644 (file)
@@ -1,3 +1,19 @@
+2000-06-21  Havoc Pennington  <hp@pobox.com>
+
+       * gdk-pixbuf.c: Convert GdkPixbuf to GObject, leaving it opaque
+       (i.e. derivation is not allowed, and there are no virtual methods
+       anyway).
+       (gdk_pixbuf_preinit): Call g_type_init() here.
+       (gdk_pixbuf_init): Add a user-friendly init function, for users
+       of standalone gdk-pixbuf
+
+       * gdk-pixbuf-animation.c: Convert to GObject, in the same
+       way GdkPixbufAnimation was done.
+       
+       * gdk-pixbuf.h: Remove gdk_pixbuf_set_unref_handler() and
+       gdk_pixbuf_finalize() from API, since these are broken and don't
+       make sense with new GObject stuff.
+
 Wed Jun 21 16:02:48 2000  Owen Taylor  <otaylor@redhat.com>
 
        * gdk-pixbuf-io.c (gdk_pixbuf_load_module): Add feature to
index beb5b29394626d9500e1b510cd831d2915be2e3e..fa6108b8999552bceb09b695d1f0915bca5965e9 100644 (file)
 #include "gdk-pixbuf-io.h"
 #include "gdk-pixbuf-private.h"
 
+static void gdk_pixbuf_animation_class_init (GdkPixbufAnimationClass *klass);
+static void gdk_pixbuf_animation_finalize   (GObject        *object);
+
+\f
+
+static gpointer parent_class;
+
+GType
+gdk_pixbuf_animation_get_type (void)
+{
+        static GType object_type = 0;
+
+        if (!object_type) {
+                static const GTypeInfo object_info = {
+                        sizeof (GdkPixbufAnimationClass),
+                        (GBaseInitFunc) NULL,
+                        (GBaseFinalizeFunc) NULL,
+                        (GClassInitFunc) gdk_pixbuf_animation_class_init,
+                        NULL,           /* class_finalize */
+                        NULL,           /* class_data */
+                        sizeof (GdkPixbufAnimation),
+                        0,              /* n_preallocs */
+                        (GInstanceInitFunc) NULL,
+                };
+      
+                object_type = g_type_register_static (G_TYPE_OBJECT,
+                                                      "GdkPixbufAnimation",
+                                                      &object_info);
+        }
+  
+        return object_type;
+}
+
+static void
+gdk_pixbuf_animation_class_init (GdkPixbufAnimationClass *klass)
+{
+        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+        
+        parent_class = g_type_class_peek_parent (klass);
+        
+        object_class->finalize = gdk_pixbuf_animation_finalize;
+}
+
+static void
+gdk_pixbuf_animation_finalize (GObject *object)
+{
+        GdkPixbufAnimation *animation = GDK_PIXBUF_ANIMATION (object);
+
+        GList *l;
+        GdkPixbufFrame *frame;
+        
+        for (l = animation->frames; l; l = l->next) {
+                frame = l->data;
+                gdk_pixbuf_unref (frame->pixbuf);
+                g_free (frame);
+        }
+        
+        g_list_free (animation->frames);
+        
+        G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
 \f
 
 /**
@@ -87,10 +149,8 @@ gdk_pixbuf_animation_new_from_file (const char *filename)
                pixbuf = (* image_module->load) (f);
                fclose (f);
 
-               if (pixbuf)
-                       g_assert (pixbuf->ref_count > 0);
-               else
-                       return NULL;
+               if (pixbuf == NULL)
+                        return NULL;
 
                frame = g_new (GdkPixbufFrame, 1);
                frame->pixbuf = pixbuf;
@@ -99,8 +159,8 @@ gdk_pixbuf_animation_new_from_file (const char *filename)
                frame->delay_time = -1;
                frame->action = GDK_PIXBUF_FRAME_RETAIN;
 
-               animation = g_new0 (GdkPixbufAnimation, 1);
-               animation->ref_count = 1;
+               animation = GDK_PIXBUF_ANIMATION (g_type_create_instance (GDK_TYPE_PIXBUF_ANIMATION));
+
                animation->n_frames = 1;
                animation->frames = g_list_prepend (NULL, frame);
                animation->width = gdk_pixbuf_get_width (pixbuf);
@@ -118,50 +178,28 @@ gdk_pixbuf_animation_new_from_file (const char *filename)
  * gdk_pixbuf_animation_ref:
  * @animation: An animation.
  *
- * Adds a reference to an animation.  It must be released afterwards using
- * gdk_pixbuf_animation_unref().
+ * Adds a reference to an animation. Deprecated; use
+ * g_object_ref(). The reference must be released afterwards using
+ * g_object_unref().
  *
  * Return value: The same as the @animation argument.
  **/
 GdkPixbufAnimation *
 gdk_pixbuf_animation_ref (GdkPixbufAnimation *animation)
 {
-       g_return_val_if_fail (animation != NULL, NULL);
-       g_return_val_if_fail (animation->ref_count > 0, NULL);
-
-       animation->ref_count++;
-       return animation;
+        return (GdkPixbufAnimation*) g_object_ref (G_OBJECT (animation));
 }
 
 /**
  * gdk_pixbuf_animation_unref:
  * @animation: An animation.
  * 
- * Removes a reference from an animation.  It will be destroyed when the
- * reference count drops to zero.  At that point, all the frames in the
- * animation will be freed and their corresponding pixbufs will be unreferenced.
+ * Removes a reference from an animation. Deprecated; use g_object_unref().
  **/
 void
 gdk_pixbuf_animation_unref (GdkPixbufAnimation *animation)
 {
-       g_return_if_fail (animation != NULL);
-       g_return_if_fail (animation->ref_count > 0);
-
-       animation->ref_count--;
-
-       if (animation->ref_count == 0) {
-               GList *l;
-               GdkPixbufFrame *frame;
-
-               for (l = animation->frames; l; l = l->next) {
-                       frame = l->data;
-                       gdk_pixbuf_unref (frame->pixbuf);
-                       g_free (frame);
-               }
-
-               g_list_free (animation->frames);
-               g_free (animation);
-       }
+        g_object_unref (G_OBJECT (animation));
 }
 
 /**
index 1ad122bc177c09b72b78214197c37ccf11c3ab55..f03d869bace36abbea39c0b33b1dec40d91674e9 100644 (file)
@@ -60,8 +60,8 @@ gdk_pixbuf_new_from_data (const guchar *data, GdkColorspace colorspace, gboolean
        g_return_val_if_fail (width > 0, NULL);
        g_return_val_if_fail (height > 0, NULL);
 
-       pixbuf = g_new0 (GdkPixbuf, 1);
-       pixbuf->ref_count = 1;
+       pixbuf = GDK_PIXBUF (g_type_create_instance (GDK_TYPE_PIXBUF));
+        
        pixbuf->colorspace = colorspace;
        pixbuf->n_channels = has_alpha ? 4 : 3;
        pixbuf->bits_per_sample = bits_per_sample;
index ca7f980ea25ff737d9720ec4f8f4faccabada2c5..5991010393cd2d8b939a044f1ecf8f444e1b0f09 100644 (file)
@@ -451,9 +451,6 @@ gdk_pixbuf_new_from_file (const char *filename)
        pixbuf = (* image_module->load) (f);
        fclose (f);
 
-       if (pixbuf)
-               g_assert (pixbuf->ref_count > 0);
-
        return pixbuf;
 }
 
index 884ce4cc8996a34d3262fc8f70042751dda7a000..9c59a423f5e811a4703773055bcf314da7b63964 100644 (file)
@@ -270,9 +270,9 @@ gdk_pixbuf_loader_frame_done (GdkPixbufFrame *frame, gpointer loader)
        priv->pixbuf = NULL;
 
        if (priv->animation == NULL) {
-               priv->animation = g_new0 (GdkPixbufAnimation, 1);
+               priv->animation = GDK_PIXBUF_ANIMATION (g_type_create_instance (GDK_TYPE_PIXBUF_ANIMATION));
+               
                priv->animation->n_frames = 0;
-               priv->animation->ref_count = 1;
                priv->animation->width  = gdk_pixbuf_get_width  (frame->pixbuf) + frame->x_offset;
                priv->animation->height = gdk_pixbuf_get_height (frame->pixbuf) + frame->y_offset;
        } else {
index 4595785a0284b043bc87bf24a117ad8be641d2ca..2aecb66234c54696f3d3db75f0e519e927bb74e2 100644 (file)
 
 \f
 
+typedef struct _GdkPixbufClass GdkPixbufClass;
+
+#define GDK_PIXBUF_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_PIXBUF, GdkPixbufClass))
+#define GDK_IS_PIXBUF_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_PIXBUF))
+#define GDK_PIXBUF_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_PIXBUF, GdkPixbufClass))
+
 /* Private part of the GdkPixbuf structure */
 struct _GdkPixbuf {
-       /* Reference count */
-       int ref_count;
+        GObject parent_instance;
 
        /* Color space */
        GdkColorspace colorspace;
@@ -59,16 +64,15 @@ struct _GdkPixbuf {
        /* User data for the destroy notification function */
        gpointer destroy_fn_data;
 
-       /* Last unref handler, determines whether the pixbuf should be finalized */
-       GdkPixbufLastUnref last_unref_fn;
-
-       /* User data for the last unref handler */
-       gpointer last_unref_fn_data;
-
        /* Do we have an alpha channel? */
        guint has_alpha : 1;
 };
 
+struct _GdkPixbufClass {
+        GObjectClass parent_class;
+
+};
+
 /* Private part of the GdkPixbufFrame structure */
 struct _GdkPixbufFrame {
        /* The pixbuf with this frame's image data */
@@ -85,10 +89,15 @@ struct _GdkPixbufFrame {
        GdkPixbufFrameAction action;
 };
 
+typedef struct _GdkPixbufAnimationClass GdkPixbufAnimationClass;
+
+#define GDK_PIXBUF_ANIMATION_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_PIXBUF_ANIMATION, GdkPixbufAnimationClass))
+#define GDK_IS_PIXBUF_ANIMATION_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_PIXBUF_ANIMATION))
+#define GDK_PIXBUF_ANIMATION_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_PIXBUF_ANIMATION, GdkPixbufAnimationClass))
+
 /* Private part of the GdkPixbufAnimation structure */
 struct _GdkPixbufAnimation {
-       /* Reference count */
-       int ref_count;
+        GObject parent_instance;
 
        /* Number of frames */
         int n_frames;
@@ -100,6 +109,12 @@ struct _GdkPixbufAnimation {
        int width, height;
 };
 
+struct _GdkPixbufAnimationClass {
+        GObjectClass parent_class;
+
+
+};
+
 \f
 
 #endif
index d42cfd159d2f1a9471c73ae33f538c88466984e6..50947ba8eade4eb45fde4a16bcb7d922574714ba 100644 (file)
 #include "gdk-pixbuf.h"
 #include "gdk-pixbuf-private.h"
 
+static void gdk_pixbuf_class_init  (GdkPixbufClass *klass);
+static void gdk_pixbuf_finalize    (GObject        *object);
+
 \f
 
-/* Reference counting */
+static gpointer parent_class;
+
+GType
+gdk_pixbuf_get_type (void)
+{
+        static GType object_type = 0;
+
+        if (!object_type) {
+                static const GTypeInfo object_info = {
+                        sizeof (GdkPixbufClass),
+                        (GBaseInitFunc) NULL,
+                        (GBaseFinalizeFunc) NULL,
+                        (GClassInitFunc) gdk_pixbuf_class_init,
+                        NULL,           /* class_finalize */
+                        NULL,           /* class_data */
+                        sizeof (GdkPixbuf),
+                        0,              /* n_preallocs */
+                        (GInstanceInitFunc) NULL,
+                };
+      
+                object_type = g_type_register_static (G_TYPE_OBJECT,
+                                                      "GdkPixbuf",
+                                                      &object_info);
+        }
+  
+        return object_type;
+}
+
+static void
+gdk_pixbuf_class_init (GdkPixbufClass *klass)
+{
+        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+        
+        parent_class = g_type_class_peek_parent (klass);
+        
+        object_class->finalize = gdk_pixbuf_finalize;
+}
+
+static void
+gdk_pixbuf_finalize (GObject *object)
+{
+        GdkPixbuf *pixbuf = GDK_PIXBUF (object);
+        
+        if (pixbuf->destroy_fn)
+                (* pixbuf->destroy_fn) (pixbuf->pixels, pixbuf->destroy_fn_data);
+        
+        G_OBJECT_CLASS (parent_class)->finalize (object);
+}
 
 /**
  * gdk_pixbuf_ref:
  * @pixbuf: A pixbuf.
  *
- * Adds a reference to a pixbuf.  It must be released afterwards using
- * gdk_pixbuf_unref().
+ * Adds a reference to a pixbuf. Deprecated; use g_object_ref().
  *
  * Return value: The same as the @pixbuf argument.
  **/
 GdkPixbuf *
 gdk_pixbuf_ref (GdkPixbuf *pixbuf)
 {
-       g_return_val_if_fail (pixbuf != NULL, NULL);
-       g_return_val_if_fail (pixbuf->ref_count > 0, NULL);
-
-       pixbuf->ref_count++;
-       return pixbuf;
+        return (GdkPixbuf *) g_object_ref (G_OBJECT(pixbuf));
 }
 
 /**
  * gdk_pixbuf_unref:
  * @pixbuf: A pixbuf.
  *
- * Removes a reference from a pixbuf.  If this is the last reference for the
- * @pixbuf, then its last unref handler function will be called; if no handler
- * has been defined, then the pixbuf will be finalized.
+ * Removes a reference from a pixbuf. Deprecated; use
+ * g_object_unref().
  *
- * See also: gdk_pixbuf_set_last_unref_handler().
  **/
 void
 gdk_pixbuf_unref (GdkPixbuf *pixbuf)
 {
-       g_return_if_fail (pixbuf != NULL);
-       g_return_if_fail (pixbuf->ref_count > 0);
-
-       if (pixbuf->ref_count > 1)
-               pixbuf->ref_count--;
-       else if (pixbuf->last_unref_fn)
-               (* pixbuf->last_unref_fn) (pixbuf, pixbuf->last_unref_fn_data);
-       else
-               gdk_pixbuf_finalize (pixbuf);
-}
-
-/**
- * gdk_pixbuf_set_last_unref_handler:
- * @pixbuf: A pixbuf.
- * @last_unref_fn: Handler function for the last unref.
- * @last_unref_fn_data: Closure data to pass to the last unref handler function.
- * 
- * Sets the handler function for the @pixbuf's last unref handler.  When
- * gdk_pixbuf_unref() is called on this pixbuf and it has a reference count of
- * 1, i.e. its last reference, then the last unref handler will be called.  This
- * function should determine whether to finalize the pixbuf or just continue.
- * If it wishes to finalize the pixbuf, it should do so by calling
- * gdk_pixbuf_finalize().
- *
- * See also: gdk_pixbuf_finalize().
- **/
-void
-gdk_pixbuf_set_last_unref_handler (GdkPixbuf *pixbuf, GdkPixbufLastUnref last_unref_fn,
-                                  gpointer last_unref_fn_data)
-{
-       g_return_if_fail (pixbuf != NULL);
-
-       pixbuf->last_unref_fn = last_unref_fn;
-       pixbuf->last_unref_fn_data = last_unref_fn_data;
-}
-
-/**
- * gdk_pixbuf_finalize:
- * @pixbuf: A pixbuf with a reference count of 1.
- * 
- * Finalizes a pixbuf by calling its destroy notification function to free the
- * pixel data and freeing the pixbuf itself.  This function is meant to be
- * called only from within a #GdkPixbufLastUnref handler function, and the
- * specified @pixbuf must have a reference count of 1, i.e. its last reference.
- **/
-void
-gdk_pixbuf_finalize (GdkPixbuf *pixbuf)
-{
-       g_return_if_fail (pixbuf != NULL);
-       g_return_if_fail (pixbuf->ref_count == 1);
-
-       if (pixbuf->destroy_fn)
-               (* pixbuf->destroy_fn) (pixbuf->pixels, pixbuf->destroy_fn_data);
-
-       g_free (pixbuf);
+        g_object_unref (G_OBJECT (pixbuf));
 }
 
 \f
@@ -357,9 +346,17 @@ const char *gdk_pixbuf_version = GDK_PIXBUF_VERSION;
 void
 gdk_pixbuf_preinit (gpointer app, gpointer modinfo)
 {
+        g_type_init ();
 }
 
 void
 gdk_pixbuf_postinit (gpointer app, gpointer modinfo)
 {
 }
+
+void
+gdk_pixbuf_init (void)
+{
+        gdk_pixbuf_preinit (NULL, NULL);
+        gdk_pixbuf_postinit (NULL, NULL);
+}
index 08087ccce6028adf053a13b570e2253523ca8116..04756b5b817dad14ed0a0231f7d7cb23463dcdb8 100644 (file)
@@ -32,6 +32,7 @@ extern "C" {
 
 #include <glib.h>
 #include <gdk-pixbuf/gdk-pixbuf-features.h>
+#include <gobject/gobject.h>
 
 \f
 
@@ -42,28 +43,30 @@ typedef enum {
 
 /* All of these are opaque structures */
 typedef struct _GdkPixbuf GdkPixbuf;
-typedef struct _GdkPixbufFrame GdkPixbufFrame;
 typedef struct _GdkPixbufAnimation GdkPixbufAnimation;
+typedef struct _GdkPixbufFrame GdkPixbufFrame;
+
+#define GDK_TYPE_PIXBUF              (gdk_pixbuf_get_type ())
+#define GDK_PIXBUF(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF, GdkPixbuf))
+#define GDK_IS_PIXBUF(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF))
+
+#define GDK_TYPE_PIXBUF_ANIMATION              (gdk_pixbuf_animation_get_type ())
+#define GDK_PIXBUF_ANIMATION(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF_ANIMATION, GdkPixbufAnimation))
+#define GDK_IS_PIXBUF_ANIMATION(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF_ANIMATION))
+
 
 /* Handler that must free the pixel array */
 typedef void (* GdkPixbufDestroyNotify) (guchar *pixels, gpointer data);
 
-/* Handler for the last unref operation */
-typedef void (* GdkPixbufLastUnref) (GdkPixbuf *pixbuf, gpointer data);
-
 \f
 
+GType gdk_pixbuf_get_type (void);
+
 /* Reference counting */
 
 GdkPixbuf *gdk_pixbuf_ref      (GdkPixbuf *pixbuf);
 void       gdk_pixbuf_unref    (GdkPixbuf *pixbuf);
 
-void       gdk_pixbuf_set_last_unref_handler (GdkPixbuf          *pixbuf,
-                                             GdkPixbufLastUnref  last_unref_fn,
-                                             gpointer            last_unref_fn_data);
-
-void       gdk_pixbuf_finalize (GdkPixbuf *pixbuf);
-
 /* GdkPixbuf accessors */
 
 GdkColorspace gdk_pixbuf_get_colorspace      (const GdkPixbuf *pixbuf);
@@ -192,6 +195,8 @@ typedef enum {
        GDK_PIXBUF_FRAME_REVERT
 } GdkPixbufFrameAction;
 
+GType               gdk_pixbuf_animation_get_type        (void);
+
 GdkPixbufAnimation *gdk_pixbuf_animation_new_from_file   (const char         *filename);
 
 GdkPixbufAnimation *gdk_pixbuf_animation_ref             (GdkPixbufAnimation *animation);
@@ -214,6 +219,8 @@ GdkPixbufFrameAction gdk_pixbuf_frame_get_action     (GdkPixbufFrame *frame);
 /* General (presently empty) initialization hooks, primarily for gnome-libs */
 void gdk_pixbuf_preinit  (gpointer app, gpointer modinfo);
 void gdk_pixbuf_postinit (gpointer app, gpointer modinfo);
+/* A more user-friendly init function */
+void gdk_pixbuf_init     (void);
 
 \f
 
index 4f3bc88788cfb6d55c18541cc60f69ddf0d125c9..7f429996923fb57ef439b21029e8629636e95f05 100644 (file)
@@ -1214,8 +1214,8 @@ gdk_pixbuf__gif_image_load_animation (FILE *file)
        g_return_val_if_fail (file != NULL, NULL);
 
        context = new_context ();
-       context->animation = g_new (GdkPixbufAnimation, 1);
-       context->animation->ref_count = 1;
+       context->animation = GDK_PIXBUF_ANIMATION (g_type_create_instance (GDK_TYPE_PIXBUF_ANIMATION));
+
        context->animation->n_frames = 0;
        context->animation->frames = NULL;
        context->animation->width = 0;
index 182703c97f8c63bcda729cab920cbf9ba0dfa73c..b4110731ddf43b133a21d9aa51f69d79a07f9282 100644 (file)
@@ -226,9 +226,11 @@ int
 main (int argc, char **argv)
 {
        int result;
-       
+
        result = EXIT_SUCCESS;
 
+       gdk_pixbuf_init ();
+       
        /* Run some tests. */
        if (!simple_composite_test ()) {
                result = EXIT_FAILURE;
index 0f4ce13c8c2eb1100ead439ddcb3a337645e3f27..e58b6a6f2f0c8bd65842a3557bffd836b2529b2f 100644 (file)
@@ -288,7 +288,9 @@ _gdk_window_destroy_hierarchy (GdkWindow *window,
          _gdk_window_clear_update_area (window);
          gdk_window_free_paint_stack (window);
          
-         if (private->bg_pixmap && private->bg_pixmap != GDK_PARENT_RELATIVE_BG)
+         if (private->bg_pixmap &&
+              private->bg_pixmap != GDK_PARENT_RELATIVE_BG &&
+              private->bg_pixmap != GDK_NO_BG)
            {
              gdk_pixmap_unref (private->bg_pixmap);
              private->bg_pixmap = NULL;
index 884ce4cc8996a34d3262fc8f70042751dda7a000..9c59a423f5e811a4703773055bcf314da7b63964 100644 (file)
@@ -270,9 +270,9 @@ gdk_pixbuf_loader_frame_done (GdkPixbufFrame *frame, gpointer loader)
        priv->pixbuf = NULL;
 
        if (priv->animation == NULL) {
-               priv->animation = g_new0 (GdkPixbufAnimation, 1);
+               priv->animation = GDK_PIXBUF_ANIMATION (g_type_create_instance (GDK_TYPE_PIXBUF_ANIMATION));
+               
                priv->animation->n_frames = 0;
-               priv->animation->ref_count = 1;
                priv->animation->width  = gdk_pixbuf_get_width  (frame->pixbuf) + frame->x_offset;
                priv->animation->height = gdk_pixbuf_get_height (frame->pixbuf) + frame->y_offset;
        } else {