+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.
+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.
+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.
+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.
+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.
+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.
+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.
GdkPixbufLoader *pixbuf_loader;
pixbuf_init ();
-
+
gtk_init (&argc, &argv);
gdk_rgb_set_verbose (TRUE);
+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
#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
/**
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;
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);
* 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));
}
/**
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;
pixbuf = (* image_module->load) (f);
fclose (f);
- if (pixbuf)
- g_assert (pixbuf->ref_count > 0);
-
return pixbuf;
}
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 {
\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;
/* 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 */
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;
int width, height;
};
+struct _GdkPixbufAnimationClass {
+ GObjectClass parent_class;
+
+
+};
+
\f
#endif
#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
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);
+}
#include <glib.h>
#include <gdk-pixbuf/gdk-pixbuf-features.h>
+#include <gobject/gobject.h>
\f
/* 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);
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);
/* 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
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;
main (int argc, char **argv)
{
int result;
-
+
result = EXIT_SUCCESS;
+ gdk_pixbuf_init ();
+
/* Run some tests. */
if (!simple_composite_test ()) {
result = EXIT_FAILURE;
_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;
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 {