[gtk+] deprecated: Use the new macros for adding instance private data



commit 84186ef11be9cb8f46e1b762ae2b04d62b741065
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Fri Jul 5 00:08:37 2013 +0100

    deprecated: Use the new macros for adding instance private data
    
    https://bugzilla.gnome.org/show_bug.cgi?id=702996

 gtk/deprecated/gtkcolorsel.c        |    6 ++----
 gtk/deprecated/gtkcolorseldialog.c  |   14 +++++---------
 gtk/deprecated/gtkfontsel.c         |   15 ++++-----------
 gtk/deprecated/gtkhandlebox.c       |    8 ++------
 gtk/deprecated/gtkhsv.c             |    7 ++-----
 gtk/deprecated/gtkrc.c              |   15 +++++----------
 gtk/deprecated/gtkstyle.c           |   14 +++++---------
 gtk/deprecated/gtktable.c           |    8 ++------
 gtk/deprecated/gtktearoffmenuitem.c |   16 ++++------------
 9 files changed, 31 insertions(+), 72 deletions(-)
---
diff --git a/gtk/deprecated/gtkcolorsel.c b/gtk/deprecated/gtkcolorsel.c
index ae77a66..950bd39 100644
--- a/gtk/deprecated/gtkcolorsel.c
+++ b/gtk/deprecated/gtkcolorsel.c
@@ -297,7 +297,7 @@ static const guchar dropper_bits[] = {
   "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
   "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"};
 
-G_DEFINE_TYPE (GtkColorSelection, gtk_color_selection, GTK_TYPE_BOX)
+G_DEFINE_TYPE_WITH_PRIVATE (GtkColorSelection, gtk_color_selection, GTK_TYPE_BOX)
 
 static void
 gtk_color_selection_class_init (GtkColorSelectionClass *klass)
@@ -384,8 +384,6 @@ gtk_color_selection_class_init (GtkColorSelectionClass *klass)
                   NULL, NULL,
                   _gtk_marshal_VOID__VOID,
                   G_TYPE_NONE, 0);
-
-  g_type_class_add_private (gobject_class, sizeof (GtkColorSelectionPrivate));
 }
 
 static void
@@ -406,7 +404,7 @@ gtk_color_selection_init (GtkColorSelection *colorsel)
 
   gtk_widget_push_composite_child ();
 
-  priv = colorsel->private_data = G_TYPE_INSTANCE_GET_PRIVATE (colorsel, GTK_TYPE_COLOR_SELECTION, 
GtkColorSelectionPrivate);
+  priv = colorsel->private_data = gtk_color_selection_get_instance_private (colorsel);
   priv->changing = FALSE;
   priv->default_set = FALSE;
   priv->default_alpha_set = FALSE;
diff --git a/gtk/deprecated/gtkcolorseldialog.c b/gtk/deprecated/gtkcolorseldialog.c
index c97e1a8..7710c33 100644
--- a/gtk/deprecated/gtkcolorseldialog.c
+++ b/gtk/deprecated/gtkcolorseldialog.c
@@ -88,10 +88,10 @@ static GObject * gtk_color_selection_dialog_buildable_get_internal_child (GtkBui
                                                                          GtkBuilder   *builder,
                                                                          const gchar  *childname);
 
-G_DEFINE_TYPE_WITH_CODE (GtkColorSelectionDialog, gtk_color_selection_dialog,
-           GTK_TYPE_DIALOG,
-           G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
-                      gtk_color_selection_dialog_buildable_interface_init))
+G_DEFINE_TYPE_WITH_CODE (GtkColorSelectionDialog, gtk_color_selection_dialog, GTK_TYPE_DIALOG,
+                         G_ADD_PRIVATE (GtkColorSelectionDialog)
+                         G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
+                                                gtk_color_selection_dialog_buildable_interface_init))
 
 static GtkBuildableIface *parent_buildable_iface;
 
@@ -162,8 +162,6 @@ gtk_color_selection_dialog_class_init (GtkColorSelectionDialogClass *klass)
                                                     G_PARAM_READABLE));
 
   gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_COLOR_CHOOSER);
-
-  g_type_class_add_private (klass, sizeof (GtkColorSelectionDialogPrivate));
 }
 
 static void
@@ -173,9 +171,7 @@ gtk_color_selection_dialog_init (GtkColorSelectionDialog *colorseldiag)
   GtkDialog *dialog = GTK_DIALOG (colorseldiag);
   GtkWidget *action_area, *content_area;
 
-  colorseldiag->priv = G_TYPE_INSTANCE_GET_PRIVATE (colorseldiag,
-                                                    GTK_TYPE_COLOR_SELECTION_DIALOG,
-                                                    GtkColorSelectionDialogPrivate);
+  colorseldiag->priv = gtk_color_selection_dialog_get_instance_private (colorseldiag);
   priv = colorseldiag->priv;
 
   content_area = gtk_dialog_get_content_area (dialog);
diff --git a/gtk/deprecated/gtkfontsel.c b/gtk/deprecated/gtkfontsel.c
index 901f133..9badb42 100644
--- a/gtk/deprecated/gtkfontsel.c
+++ b/gtk/deprecated/gtkfontsel.c
@@ -222,7 +222,7 @@ static void     gtk_font_selection_ref_family            (GtkFontSelection *font
 static void     gtk_font_selection_ref_face              (GtkFontSelection *fontsel,
                                                          PangoFontFace    *face);
 
-G_DEFINE_TYPE (GtkFontSelection, gtk_font_selection, GTK_TYPE_BOX)
+G_DEFINE_TYPE_WITH_PRIVATE (GtkFontSelection, gtk_font_selection, GTK_TYPE_BOX)
 
 static void
 gtk_font_selection_class_init (GtkFontSelectionClass *klass)
@@ -251,8 +251,6 @@ gtk_font_selection_class_init (GtkFontSelectionClass *klass)
                                                         P_("The text to display in order to demonstrate the 
selected font"),
                                                         _(PREVIEW_TEXT),
                                                         GTK_PARAM_READWRITE));
-
-  g_type_class_add_private (klass, sizeof (GtkFontSelectionPrivate));
 }
 
 static void 
@@ -342,9 +340,7 @@ gtk_font_selection_init (GtkFontSelection *fontsel)
   GList *focus_chain = NULL;
   AtkObject *atk_obj;
 
-  fontsel->priv = G_TYPE_INSTANCE_GET_PRIVATE (fontsel,
-                                               GTK_TYPE_FONT_SELECTION,
-                                               GtkFontSelectionPrivate);
+  fontsel->priv = gtk_font_selection_get_instance_private (fontsel);
   priv = fontsel->priv;
 
   gtk_orientable_set_orientation (GTK_ORIENTABLE (fontsel),
@@ -1649,6 +1645,7 @@ static GObject * gtk_font_selection_dialog_buildable_get_internal_child (GtkBuil
 
 G_DEFINE_TYPE_WITH_CODE (GtkFontSelectionDialog, gtk_font_selection_dialog,
                         GTK_TYPE_DIALOG,
+                         G_ADD_PRIVATE (GtkFontSelectionDialog)
                         G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
                                                gtk_font_selection_dialog_buildable_interface_init))
 
@@ -1660,8 +1657,6 @@ gtk_font_selection_dialog_class_init (GtkFontSelectionDialogClass *klass)
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
   gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_FONT_CHOOSER);
-
-  g_type_class_add_private (klass, sizeof (GtkFontSelectionDialogPrivate));
 }
 
 static void
@@ -1671,9 +1666,7 @@ gtk_font_selection_dialog_init (GtkFontSelectionDialog *fontseldiag)
   GtkDialog *dialog = GTK_DIALOG (fontseldiag);
   GtkWidget *action_area, *content_area;
 
-  fontseldiag->priv = G_TYPE_INSTANCE_GET_PRIVATE (fontseldiag,
-                                                   GTK_TYPE_FONT_SELECTION_DIALOG,
-                                                   GtkFontSelectionDialogPrivate);
+  fontseldiag->priv = gtk_font_selection_dialog_get_instance_private (fontseldiag);
   priv = fontseldiag->priv;
 
   content_area = gtk_dialog_get_content_area (dialog);
diff --git a/gtk/deprecated/gtkhandlebox.c b/gtk/deprecated/gtkhandlebox.c
index b745200..8cfce5d 100644
--- a/gtk/deprecated/gtkhandlebox.c
+++ b/gtk/deprecated/gtkhandlebox.c
@@ -202,7 +202,7 @@ static void     gtk_handle_box_end_drag      (GtkHandleBox   *hb,
 
 static guint handle_box_signals[SIGNAL_LAST] = { 0 };
 
-G_DEFINE_TYPE (GtkHandleBox, gtk_handle_box, GTK_TYPE_BIN)
+G_DEFINE_TYPE_WITH_PRIVATE (GtkHandleBox, gtk_handle_box, GTK_TYPE_BIN)
 
 static void
 gtk_handle_box_class_init (GtkHandleBoxClass *class)
@@ -322,8 +322,6 @@ gtk_handle_box_class_init (GtkHandleBoxClass *class)
                  _gtk_marshal_VOID__OBJECT,
                  G_TYPE_NONE, 1,
                  GTK_TYPE_WIDGET);
-
-  g_type_class_add_private (gobject_class, sizeof (GtkHandleBoxPrivate));
 }
 
 static void
@@ -332,9 +330,7 @@ gtk_handle_box_init (GtkHandleBox *handle_box)
   GtkHandleBoxPrivate *priv;
   GtkStyleContext *context;
 
-  handle_box->priv = G_TYPE_INSTANCE_GET_PRIVATE (handle_box,
-                                                  GTK_TYPE_HANDLE_BOX,
-                                                  GtkHandleBoxPrivate);
+  handle_box->priv = gtk_handle_box_get_instance_private (handle_box);
   priv = handle_box->priv;
 
   gtk_widget_set_has_window (GTK_WIDGET (handle_box), TRUE);
diff --git a/gtk/deprecated/gtkhsv.c b/gtk/deprecated/gtkhsv.c
index ad09515..7f164d4 100644
--- a/gtk/deprecated/gtkhsv.c
+++ b/gtk/deprecated/gtkhsv.c
@@ -131,7 +131,7 @@ static void     gtk_hsv_move                 (GtkHSV             *hsv,
 
 static guint hsv_signals[LAST_SIGNAL];
 
-G_DEFINE_TYPE (GtkHSV, gtk_hsv, GTK_TYPE_WIDGET)
+G_DEFINE_TYPE_WITH_PRIVATE (GtkHSV, gtk_hsv, GTK_TYPE_WIDGET)
 
 /* Class initialization function for the HSV color selector */
 static void
@@ -208,8 +208,6 @@ gtk_hsv_class_init (GtkHSVClass *class)
   gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Left, 0,
                                 "move", 1,
                                 G_TYPE_ENUM, GTK_DIR_LEFT);
-
-  g_type_class_add_private (gobject_class, sizeof (GtkHSVPrivate));
 }
 
 static void
@@ -217,8 +215,7 @@ gtk_hsv_init (GtkHSV *hsv)
 {
   GtkHSVPrivate *priv;
 
-  priv = G_TYPE_INSTANCE_GET_PRIVATE (hsv, GTK_TYPE_HSV, GtkHSVPrivate);
-
+  priv = gtk_hsv_get_instance_private (hsv);
   hsv->priv = priv;
 
   gtk_widget_set_has_window (GTK_WIDGET (hsv), FALSE);
diff --git a/gtk/deprecated/gtkrc.c b/gtk/deprecated/gtkrc.c
index 568dc5c..15524cd 100644
--- a/gtk/deprecated/gtkrc.c
+++ b/gtk/deprecated/gtkrc.c
@@ -741,14 +741,11 @@ typedef struct
   } elt;
 } PathElt;
 
-#define GTK_RC_STYLE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_RC_STYLE, 
GtkRcStylePrivate))
-
-typedef struct _GtkRcStylePrivate GtkRcStylePrivate;
-
-struct _GtkRcStylePrivate
-{
+typedef struct {
   GSList *color_hashes;
-};
+} GtkRcStylePrivate;
+
+#define GTK_RC_STYLE_GET_PRIVATE(obj) ((GtkRcStylePrivate *) gtk_rc_style_get_instance_private ((GtkRcStyle 
*) (obj)))
 
 static void        gtk_rc_style_finalize             (GObject         *object);
 static void        gtk_rc_style_real_merge           (GtkRcStyle      *dest,
@@ -1093,7 +1090,7 @@ gtk_rc_parse (const gchar *filename)
 
 /* Handling of RC styles */
 
-G_DEFINE_TYPE (GtkRcStyle, gtk_rc_style, G_TYPE_OBJECT)
+G_DEFINE_TYPE_WITH_PRIVATE (GtkRcStyle, gtk_rc_style, G_TYPE_OBJECT)
 
 static void
 gtk_rc_style_init (GtkRcStyle *style)
@@ -1136,8 +1133,6 @@ gtk_rc_style_class_init (GtkRcStyleClass *klass)
   klass->create_rc_style = gtk_rc_style_real_create_rc_style;
   klass->merge = gtk_rc_style_real_merge;
   klass->create_style = gtk_rc_style_real_create_style;
-
-  g_type_class_add_private (object_class, sizeof (GtkRcStylePrivate));
 }
 
 static void
diff --git a/gtk/deprecated/gtkstyle.c b/gtk/deprecated/gtkstyle.c
index c7ea815..403e19a 100644
--- a/gtk/deprecated/gtkstyle.c
+++ b/gtk/deprecated/gtkstyle.c
@@ -81,14 +81,12 @@ typedef struct {
   GValue      value;
 } PropertyValue;
 
-#define GTK_STYLE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_STYLE, GtkStylePrivate))
-
-typedef struct _GtkStylePrivate GtkStylePrivate;
-
-struct _GtkStylePrivate {
+typedef struct {
   GtkStyleContext *context;
   gulong context_changed_id;
-};
+} GtkStylePrivate;
+
+#define GTK_STYLE_GET_PRIVATE(obj) ((GtkStylePrivate *) gtk_style_get_instance_private ((GtkStyle *) (obj)))
 
 enum {
   PROP_0,
@@ -373,7 +371,7 @@ static const GdkColor gtk_default_active_base =    { 0, GTK_VERY_DARK_GRAY };
 static guint realize_signal = 0;
 static guint unrealize_signal = 0;
 
-G_DEFINE_TYPE (GtkStyle, gtk_style, G_TYPE_OBJECT)
+G_DEFINE_TYPE_WITH_PRIVATE (GtkStyle, gtk_style, G_TYPE_OBJECT)
 
 /* --- functions --- */
 
@@ -466,8 +464,6 @@ gtk_style_class_init (GtkStyleClass *klass)
   klass->draw_resize_grip = gtk_default_draw_resize_grip;
   klass->draw_spinner = gtk_default_draw_spinner;
 
-  g_type_class_add_private (object_class, sizeof (GtkStylePrivate));
-
   g_object_class_install_property (object_class,
                                   PROP_CONTEXT,
                                   g_param_spec_object ("context",
diff --git a/gtk/deprecated/gtktable.c b/gtk/deprecated/gtktable.c
index 986c687..9191bc3 100644
--- a/gtk/deprecated/gtktable.c
+++ b/gtk/deprecated/gtktable.c
@@ -158,7 +158,7 @@ static void gtk_table_size_allocate_pass1 (GtkTable *table);
 static void gtk_table_size_allocate_pass2 (GtkTable *table);
 
 
-G_DEFINE_TYPE (GtkTable, gtk_table, GTK_TYPE_CONTAINER)
+G_DEFINE_TYPE_WITH_PRIVATE (GtkTable, gtk_table, GTK_TYPE_CONTAINER)
 
 static void
 gtk_table_class_init (GtkTableClass *class)
@@ -285,8 +285,6 @@ gtk_table_class_init (GtkTableClass *class)
                                                                 P_("Extra space to put between the child and 
its upper and lower neighbors, in pixels"),
                                                                 0, 65535, 0,
                                                                 GTK_PARAM_READWRITE));
-
-  g_type_class_add_private (class, sizeof (GtkTablePrivate));
 }
 
 static void
@@ -566,9 +564,7 @@ gtk_table_init (GtkTable *table)
 {
   GtkTablePrivate *priv;
 
-  table->priv = G_TYPE_INSTANCE_GET_PRIVATE (table,
-                                             GTK_TYPE_TABLE,
-                                             GtkTablePrivate);
+  table->priv = gtk_table_get_instance_private (table);
   priv = table->priv;
 
   gtk_widget_set_has_window (GTK_WIDGET (table), FALSE);
diff --git a/gtk/deprecated/gtktearoffmenuitem.c b/gtk/deprecated/gtktearoffmenuitem.c
index 9f19efd..c15102b 100644
--- a/gtk/deprecated/gtktearoffmenuitem.c
+++ b/gtk/deprecated/gtktearoffmenuitem.c
@@ -77,7 +77,7 @@ static void gtk_tearoff_menu_item_activate             (GtkMenuItem    *menu_ite
 static void gtk_tearoff_menu_item_parent_set           (GtkWidget      *widget,
                                                         GtkWidget      *previous);
 
-G_DEFINE_TYPE (GtkTearoffMenuItem, gtk_tearoff_menu_item, GTK_TYPE_MENU_ITEM)
+G_DEFINE_TYPE_WITH_PRIVATE (GtkTearoffMenuItem, gtk_tearoff_menu_item, GTK_TYPE_MENU_ITEM)
 
 /**
  * gtk_tearoff_menu_item_new:
@@ -112,21 +112,13 @@ gtk_tearoff_menu_item_class_init (GtkTearoffMenuItemClass *klass)
   gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_TEAR_OFF_MENU_ITEM);
 
   menu_item_class->activate = gtk_tearoff_menu_item_activate;
-
-  g_type_class_add_private (klass, sizeof (GtkTearoffMenuItemPrivate));
 }
 
 static void
-gtk_tearoff_menu_item_init (GtkTearoffMenuItem *tearoff_menu_item)
+gtk_tearoff_menu_item_init (GtkTearoffMenuItem *self)
 {
-  GtkTearoffMenuItemPrivate *priv;
-
-  tearoff_menu_item->priv = G_TYPE_INSTANCE_GET_PRIVATE (tearoff_menu_item,
-                                                         GTK_TYPE_TEAROFF_MENU_ITEM,
-                                                         GtkTearoffMenuItemPrivate);
-  priv = tearoff_menu_item->priv;
-
-  priv->torn_off = FALSE;
+  self->priv = gtk_tearoff_menu_item_get_instance_private (self);
+  self->priv->torn_off = FALSE;
 }
 
 static void


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