widget: Add a GtkWidgetClassPrivate

As long as glib doesn't provide class privates, we'll have to ship our
own...
This commit is contained in:
Benjamin Otte 2011-06-18 09:11:11 +02:00 committed by Matthias Clasen
parent dfe5459437
commit 9ebcd66d43
2 changed files with 32 additions and 10 deletions

View File

@ -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

View File

@ -68,6 +68,7 @@ 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;
@ -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);