[gtk+/a11y] widget: Add a GtkWidgetClassPrivate



commit bb42133f3b1a3783427f7ba5859fd8ee905993b6
Author: Benjamin Otte <otte redhat com>
Date:   Sat Jun 18 09:11:11 2011 +0200

    widget: Add a GtkWidgetClassPrivate
    
    As long as glib doesn't provide class privates, we'll have to ship our
    own...

 gtk/gtkwidget.c |   22 +++++++++++++++++++++-
 gtk/gtkwidget.h |   20 +++++++++++---------
 2 files changed, 32 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 62cabd2..535a5a9 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -407,6 +407,11 @@ struct _GtkWidgetPrivate
 #endif /* G_ENABLE_DEBUG */
 };
 
+struct _GtkWidgetClassPrivate
+{
+  int dummy;
+};
+
 enum {
   DESTROY,
   SHOW,
@@ -533,6 +538,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);
@@ -739,7 +745,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 */
@@ -777,6 +783,18 @@ gtk_widget_get_type (void)
 }
 
 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,
 				  GParamSpec **pspecs)
@@ -3178,6 +3196,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 0641521..09d8a8e 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);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]