From: Benjamin Otte Date: Sat, 18 Jun 2011 07:11:11 +0000 (+0200) Subject: widget: Add a GtkWidgetClassPrivate X-Git-Url: http://pileus.org/git/?a=commitdiff_plain;h=9ebcd66d4322081580c479ad2580800235f04baa;p=~andy%2Fgtk widget: Add a GtkWidgetClassPrivate As long as glib doesn't provide class privates, we'll have to ship our own... --- diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 05bc04ce3..e81f7f4c8 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -406,6 +406,11 @@ struct _GtkWidgetPrivate #endif /* G_ENABLE_DEBUG */ }; +struct _GtkWidgetClassPrivate +{ + int dummy; +}; + enum { DESTROY, SHOW, @@ -532,6 +537,7 @@ struct _GtkStateData }; /* --- prototypes --- */ +static void gtk_widget_base_class_init (gpointer g_class); static void gtk_widget_class_init (GtkWidgetClass *klass); static void gtk_widget_base_class_finalize (GtkWidgetClass *klass); static void gtk_widget_init (GtkWidget *widget); @@ -738,7 +744,7 @@ gtk_widget_get_type (void) const GTypeInfo widget_info = { sizeof (GtkWidgetClass), - NULL, /* base_init */ + gtk_widget_base_class_init, (GBaseFinalizeFunc) gtk_widget_base_class_finalize, (GClassInitFunc) gtk_widget_class_init, NULL, /* class_finalize */ @@ -775,6 +781,18 @@ gtk_widget_get_type (void) return widget_type; } +static void +gtk_widget_base_class_init (gpointer g_class) +{ + GtkWidgetClass *klass = g_class; + + if (GTK_IS_WIDGET_CLASS (g_type_class_peek_parent (klass))) + klass->priv = g_slice_dup (GtkWidgetClassPrivate, + GTK_WIDGET_CLASS (g_type_class_peek_parent (klass))->priv); + else + klass->priv = g_slice_new0 (GtkWidgetClassPrivate); +} + static void child_property_notify_dispatcher (GObject *object, guint n_pspecs, @@ -3177,6 +3195,8 @@ gtk_widget_base_class_finalize (GtkWidgetClass *klass) g_param_spec_unref (pspec); } g_list_free (list); + + g_slice_free (GtkWidgetClassPrivate, klass->priv); } static void diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index 064152112..09d8a8e0a 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -64,14 +64,15 @@ typedef enum /* forward declaration to avoid excessive includes (and concurrent includes) */ -typedef struct _GtkRequisition GtkRequisition; -typedef struct _GtkSelectionData GtkSelectionData; -typedef struct _GtkWidgetPrivate GtkWidgetPrivate; -typedef struct _GtkWidgetClass GtkWidgetClass; -typedef struct _GtkWidgetAuxInfo GtkWidgetAuxInfo; -typedef struct _GtkClipboard GtkClipboard; -typedef struct _GtkTooltip GtkTooltip; -typedef struct _GtkWindow GtkWindow; +typedef struct _GtkRequisition GtkRequisition; +typedef struct _GtkSelectionData GtkSelectionData; +typedef struct _GtkWidgetPrivate GtkWidgetPrivate; +typedef struct _GtkWidgetClass GtkWidgetClass; +typedef struct _GtkWidgetClassPrivate GtkWidgetClassPrivate; +typedef struct _GtkWidgetAuxInfo GtkWidgetAuxInfo; +typedef struct _GtkClipboard GtkClipboard; +typedef struct _GtkTooltip GtkTooltip; +typedef struct _GtkWindow GtkWindow; /** @@ -428,8 +429,9 @@ struct _GtkWidgetClass /*< private >*/ + GtkWidgetClassPrivate *priv; + /* Padding for future expansion */ - void (*_gtk_reserved1) (void); void (*_gtk_reserved2) (void); void (*_gtk_reserved3) (void); void (*_gtk_reserved4) (void);