From 987256968b10a609c250177f41d2606eeb0c10a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Draszik?= Date: Sun, 13 Sep 2009 14:08:21 +0100 Subject: [PATCH] gdk/directfb: convert gdkgc-directfb to using G_DEFINE_TYPE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes https://bugzilla.gnome.org/show_bug.cgi?id=609199 Signed-off-by: Javier Jardón --- gdk/directfb/gdkgc-directfb.c | 66 +++++++++--------------------- gdk/directfb/gdkprivate-directfb.h | 10 ++--- 2 files changed, 25 insertions(+), 51 deletions(-) diff --git a/gdk/directfb/gdkgc-directfb.c b/gdk/directfb/gdkgc-directfb.c index 7348312006..202c27c5f1 100644 --- a/gdk/directfb/gdkgc-directfb.c +++ b/gdk/directfb/gdkgc-directfb.c @@ -57,49 +57,22 @@ static void gdk_directfb_gc_set_dashes (GdkGC *gc, gint8 dash_list[], gint n); -static void gdk_gc_directfb_class_init (GdkGCDirectFBClass *klass); + static void gdk_gc_directfb_finalize (GObject *object); +G_DEFINE_TYPE (GdkGCDirectFB, _gdk_gc_directfb, GDK_TYPE_GC) -static gpointer parent_class = NULL; - - -GType -gdk_gc_directfb_get_type (void) +static void +_gdk_gc_directfb_init (GdkGCDirectFB *directfb_gc) { - static GType object_type = 0; - - if (!object_type) - { - const GTypeInfo object_info = - { - sizeof (GdkGCDirectFBClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gdk_gc_directfb_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GdkGCDirectFB), - 0, /* n_preallocs */ - (GInstanceInitFunc) NULL, - }; - - object_type = g_type_register_static (GDK_TYPE_GC, - "GdkGCDirectFB", - &object_info, 0); - } - - return object_type; } static void -gdk_gc_directfb_class_init (GdkGCDirectFBClass *klass) +_gdk_gc_directfb_class_init (GdkGCDirectFBClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GdkGCClass *gc_class = GDK_GC_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); - object_class->finalize = gdk_gc_directfb_finalize; gc_class->get_values = gdk_directfb_gc_get_values; @@ -110,23 +83,22 @@ gdk_gc_directfb_class_init (GdkGCDirectFBClass *klass) static void gdk_gc_directfb_finalize (GObject *object) { - GdkGC *gc = GDK_GC (object); - GdkGCDirectFB *private = GDK_GC_DIRECTFB (gc); + GdkGCDirectFB *directfb_gc = GDK_GC_DIRECTFB (object); - if (private->clip_region.numRects) - temp_region_deinit (&private->clip_region); - if (private->values.clip_mask) - g_object_unref (private->values.clip_mask); - if (private->values.stipple) - g_object_unref (private->values.stipple); - if (private->values.tile) - g_object_unref (private->values.tile); + if (directfb_gc->clip_region.numRects) + temp_region_deinit (&directfb_gc->clip_region); + if (directfb_gc->values.clip_mask) + g_object_unref (directfb_gc->values.clip_mask); + if (directfb_gc->values.stipple) + g_object_unref (directfb_gc->values.stipple); + if (directfb_gc->values.tile) + g_object_unref (directfb_gc->values.tile); - if (G_OBJECT_CLASS (parent_class)->finalize) - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (_gdk_gc_directfb_parent_class)->finalize (object); } -GdkGC* + +GdkGC * _gdk_directfb_gc_new (GdkDrawable *drawable, GdkGCValues *values, GdkGCValuesMask values_mask) @@ -134,9 +106,11 @@ _gdk_directfb_gc_new (GdkDrawable *drawable, GdkGC *gc; GdkGCDirectFB *private; + /* NOTICE that the drawable here has to be the impl drawable, not the + publicly visible drawable. */ g_return_val_if_fail (GDK_IS_DRAWABLE_IMPL_DIRECTFB (drawable), NULL); - gc = GDK_GC (g_object_new (gdk_gc_directfb_get_type (), NULL)); + gc = GDK_GC (g_object_new (_gdk_gc_directfb_get_type (), NULL)); _gdk_gc_init (gc, drawable, values, values_mask); diff --git a/gdk/directfb/gdkprivate-directfb.h b/gdk/directfb/gdkprivate-directfb.h index ad7e7f5970..201a1e69fb 100644 --- a/gdk/directfb/gdkprivate-directfb.h +++ b/gdk/directfb/gdkprivate-directfb.h @@ -205,7 +205,7 @@ typedef struct } GdkImageDirectFB; -#define GDK_TYPE_GC_DIRECTFB (gdk_gc_directfb_get_type ()) +#define GDK_TYPE_GC_DIRECTFB (_gdk_gc_directfb_get_type ()) #define GDK_GC_DIRECTFB(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_GC_DIRECTFB, GdkGCDirectFB)) #define GDK_IS_GC_DIRECTFB(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_GC_DIRECTFB)) @@ -224,11 +224,11 @@ typedef struct GdkGCClass parent_class; } GdkGCDirectFBClass; -GType gdk_gc_directfb_get_type (void); +GType _gdk_gc_directfb_get_type (void); -GdkGC * _gdk_directfb_gc_new (GdkDrawable *drawable, - GdkGCValues *values, - GdkGCValuesMask values_mask); +GdkGC * _gdk_directfb_gc_new (GdkDrawable *drawable, + GdkGCValues *values, + GdkGCValuesMask values_mask); GdkImage* _gdk_directfb_copy_to_image (GdkDrawable *drawable, GdkImage *image,