diff options
174 files changed, 706 insertions, 1389 deletions
diff --git a/gtk/extract-strings b/gtk/extract-strings Binary files differnew file mode 100755 index 0000000000..34a3653e51 --- /dev/null +++ b/gtk/extract-strings diff --git a/gtk/gtkaboutdialog.c b/gtk/gtkaboutdialog.c index 992b8682b8..70c3265430 100644 --- a/gtk/gtkaboutdialog.c +++ b/gtk/gtkaboutdialog.c @@ -175,9 +175,6 @@ struct _GtkAboutDialogPrivate #define CREDITS_PAGE_ID 1 #define LICENSE_PAGE_ID 2 -#define GTK_ABOUT_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_ABOUT_DIALOG, GtkAboutDialogPrivate)) - - enum { PROP_0, @@ -251,7 +248,7 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; -G_DEFINE_TYPE (GtkAboutDialog, gtk_about_dialog, GTK_TYPE_DIALOG) +G_DEFINE_TYPE_WITH_PRIVATE (GtkAboutDialog, gtk_about_dialog, GTK_TYPE_DIALOG) static void @@ -581,8 +578,6 @@ gtk_about_dialog_class_init (GtkAboutDialogClass *klass) gtk_widget_class_bind_callback (widget_class, text_view_key_press_event); gtk_widget_class_bind_callback (widget_class, text_view_visibility_notify_event); gtk_widget_class_bind_callback (widget_class, text_view_motion_notify_event); - - g_type_class_add_private (object_class, sizeof (GtkAboutDialogPrivate)); } static gboolean @@ -691,7 +686,7 @@ gtk_about_dialog_init (GtkAboutDialog *about) GtkAboutDialogPrivate *priv; /* Data */ - priv = GTK_ABOUT_DIALOG_GET_PRIVATE (about); + priv = gtk_about_dialog_get_instance_private (about); about->priv = priv; priv->name = NULL; diff --git a/gtk/gtkaccelgroup.c b/gtk/gtkaccelgroup.c index c2d91028fd..60bd1ee534 100644 --- a/gtk/gtkaccelgroup.c +++ b/gtk/gtkaccelgroup.c @@ -87,7 +87,7 @@ enum { PROP_MODIFIER_MASK, }; -G_DEFINE_TYPE (GtkAccelGroup, gtk_accel_group, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE (GtkAccelGroup, gtk_accel_group, G_TYPE_OBJECT) /* --- functions --- */ static void @@ -167,8 +167,6 @@ gtk_accel_group_class_init (GtkAccelGroupClass *class) G_TYPE_UINT, GDK_TYPE_MODIFIER_TYPE, G_TYPE_CLOSURE); - - g_type_class_add_private (object_class, sizeof (GtkAccelGroupPrivate)); } static void @@ -225,9 +223,7 @@ gtk_accel_group_init (GtkAccelGroup *accel_group) { GtkAccelGroupPrivate *priv; - accel_group->priv = G_TYPE_INSTANCE_GET_PRIVATE (accel_group, - GTK_TYPE_ACCEL_GROUP, - GtkAccelGroupPrivate); + accel_group->priv = gtk_accel_group_get_instance_private (accel_group); priv = accel_group->priv; priv->lock_count = 0; diff --git a/gtk/gtkaccellabel.c b/gtk/gtkaccellabel.c index d8bb7e96fa..0747f574e2 100644 --- a/gtk/gtkaccellabel.c +++ b/gtk/gtkaccellabel.c @@ -129,7 +129,7 @@ static void gtk_accel_label_get_preferred_width (GtkWidget *wi gint *nat_width); -G_DEFINE_TYPE (GtkAccelLabel, gtk_accel_label, GTK_TYPE_LABEL) +G_DEFINE_TYPE_WITH_PRIVATE (GtkAccelLabel, gtk_accel_label, GTK_TYPE_LABEL) static void gtk_accel_label_class_init (GtkAccelLabelClass *class) @@ -196,8 +196,6 @@ gtk_accel_label_class_init (GtkAccelLabelClass *class) P_("The widget to be monitored for accelerator changes"), GTK_TYPE_WIDGET, GTK_PARAM_READWRITE)); - - g_type_class_add_private (gobject_class, sizeof (GtkAccelLabelPrivate)); } static void @@ -253,9 +251,7 @@ gtk_accel_label_init (GtkAccelLabel *accel_label) { GtkAccelLabelPrivate *priv; - accel_label->priv = G_TYPE_INSTANCE_GET_PRIVATE (accel_label, - GTK_TYPE_ACCEL_LABEL, - GtkAccelLabelPrivate); + accel_label->priv = gtk_accel_label_get_instance_private (accel_label); priv = accel_label->priv; priv->accel_padding = 3; diff --git a/gtk/gtkaccessible.c b/gtk/gtkaccessible.c index 27d88ca00e..85fe68c166 100644 --- a/gtk/gtkaccessible.c +++ b/gtk/gtkaccessible.c @@ -52,7 +52,7 @@ enum { static void gtk_accessible_real_connect_widget_destroyed (GtkAccessible *accessible); -G_DEFINE_TYPE (GtkAccessible, gtk_accessible, ATK_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE (GtkAccessible, gtk_accessible, ATK_TYPE_OBJECT) static void gtk_accessible_set_property (GObject *object, @@ -96,9 +96,7 @@ gtk_accessible_get_property (GObject *object, static void gtk_accessible_init (GtkAccessible *accessible) { - accessible->priv = G_TYPE_INSTANCE_GET_PRIVATE (accessible, - GTK_TYPE_ACCESSIBLE, - GtkAccessiblePrivate); + accessible->priv = gtk_accessible_get_instance_private (accessible); } static AtkStateSet * @@ -159,8 +157,6 @@ gtk_accessible_class_init (GtkAccessibleClass *klass) P_("The widget referenced by this accessible."), GTK_TYPE_WIDGET, G_PARAM_READWRITE)); - - g_type_class_add_private (klass, sizeof (GtkAccessiblePrivate)); } /** diff --git a/gtk/gtkaction.c b/gtk/gtkaction.c index 20041134d2..1aaddf0351 100644 --- a/gtk/gtkaction.c +++ b/gtk/gtkaction.c @@ -163,6 +163,7 @@ static void gtk_action_buildable_set_name (GtkBuildable *buildable, static const gchar* gtk_action_buildable_get_name (GtkBuildable *buildable); G_DEFINE_TYPE_WITH_CODE (GtkAction, gtk_action, G_TYPE_OBJECT, + G_ADD_PRIVATE (GtkAction) G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_action_buildable_init)) @@ -514,17 +515,13 @@ gtk_action_class_init (GtkActionClass *klass) G_STRUCT_OFFSET (GtkActionClass, activate), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - - g_type_class_add_private (gobject_class, sizeof (GtkActionPrivate)); } static void gtk_action_init (GtkAction *action) { - action->private_data = G_TYPE_INSTANCE_GET_PRIVATE (action, - GTK_TYPE_ACTION, - GtkActionPrivate); + action->private_data = gtk_action_get_instance_private (action); action->private_data->name = NULL; action->private_data->label = NULL; diff --git a/gtk/gtkactiongroup.c b/gtk/gtkactiongroup.c index e3439a690d..01c2d53370 100644 --- a/gtk/gtkactiongroup.c +++ b/gtk/gtkactiongroup.c @@ -171,53 +171,19 @@ static void gtk_action_group_buildable_custom_tag_end (GtkBuildable *buildable, const gchar *tagname, gpointer *user_data); -GType -gtk_action_group_get_type (void) -{ - static GType type = 0; - - if (!type) - { - const GTypeInfo type_info = - { - sizeof (GtkActionGroupClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_action_group_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkActionGroup), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_action_group_init, - }; - - const GInterfaceInfo buildable_info = - { - (GInterfaceInitFunc) gtk_action_group_buildable_init, - NULL, - NULL - }; - - type = g_type_register_static (G_TYPE_OBJECT, I_("GtkActionGroup"), - &type_info, 0); - - g_type_add_interface_static (type, - GTK_TYPE_BUILDABLE, - &buildable_info); - } - return type; -} - -static GObjectClass *parent_class = NULL; static guint action_group_signals[LAST_SIGNAL] = { 0 }; +G_DEFINE_TYPE_WITH_CODE (GtkActionGroup, gtk_action_group, G_TYPE_OBJECT, + G_ADD_PRIVATE (GtkActionGroup) + G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, + gtk_action_group_buildable_init)) + static void gtk_action_group_class_init (GtkActionGroupClass *klass) { GObjectClass *gobject_class; gobject_class = G_OBJECT_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); gobject_class->finalize = gtk_action_group_finalize; gobject_class->set_property = gtk_action_group_set_property; @@ -381,8 +347,6 @@ gtk_action_group_class_init (GtkActionGroupClass *klass) _gtk_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GTK_TYPE_ACTION); - - g_type_class_add_private (gobject_class, sizeof (GtkActionGroupPrivate)); } @@ -396,22 +360,16 @@ remove_action (GtkAction *action) static void gtk_action_group_init (GtkActionGroup *action_group) { - GtkActionGroupPrivate *private; - - action_group->priv = G_TYPE_INSTANCE_GET_PRIVATE (action_group, - GTK_TYPE_ACTION_GROUP, - GtkActionGroupPrivate); - private = action_group->priv; - - private->name = NULL; - private->sensitive = TRUE; - private->visible = TRUE; - private->actions = g_hash_table_new_full (g_str_hash, g_str_equal, - NULL, - (GDestroyNotify) remove_action); - private->translate_func = NULL; - private->translate_data = NULL; - private->translate_notify = NULL; + action_group->priv = gtk_action_group_get_instance_private (action_group); + action_group->priv->name = NULL; + action_group->priv->sensitive = TRUE; + action_group->priv->visible = TRUE; + action_group->priv->actions = g_hash_table_new_full (g_str_hash, g_str_equal, + NULL, + (GDestroyNotify) remove_action); + action_group->priv->translate_func = NULL; + action_group->priv->translate_data = NULL; + action_group->priv->translate_notify = NULL; } static void @@ -592,24 +550,18 @@ gtk_action_group_new (const gchar *name) static void gtk_action_group_finalize (GObject *object) { - GtkActionGroup *self; - GtkActionGroupPrivate *private; - - self = GTK_ACTION_GROUP (object); - private = self->priv; + GtkActionGroup *self = GTK_ACTION_GROUP (object); - g_free (private->name); - private->name = NULL; + g_free (self->priv->name); - g_hash_table_destroy (private->actions); - private->actions = NULL; + g_hash_table_destroy (self->priv->actions); - g_clear_object (&private->accel_group); + g_clear_object (&self->priv->accel_group); - if (private->translate_notify) - private->translate_notify (private->translate_data); + if (self->priv->translate_notify != NULL) + self->priv->translate_notify (self->priv->translate_data); - parent_class->finalize (object); + G_OBJECT_CLASS (gtk_action_group_parent_class)->finalize (object); } static void diff --git a/gtk/gtkadjustment.c b/gtk/gtkadjustment.c index f8dda30c4f..52580ee02e 100644 --- a/gtk/gtkadjustment.c +++ b/gtk/gtkadjustment.c @@ -94,7 +94,7 @@ static guint adjustment_signals[LAST_SIGNAL] = { 0 }; static guint64 adjustment_changed_stamp = 0; /* protected by global gdk lock */ -G_DEFINE_TYPE (GtkAdjustment, gtk_adjustment, G_TYPE_INITIALLY_UNOWNED) +G_DEFINE_TYPE_WITH_PRIVATE (GtkAdjustment, gtk_adjustment, G_TYPE_INITIALLY_UNOWNED) static void gtk_adjustment_class_init (GtkAdjustmentClass *class) @@ -246,16 +246,12 @@ gtk_adjustment_class_init (GtkAdjustmentClass *class) NULL, NULL, _gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); - - g_type_class_add_private (class, sizeof (GtkAdjustmentPrivate)); } static void gtk_adjustment_init (GtkAdjustment *adjustment) { - adjustment->priv = G_TYPE_INSTANCE_GET_PRIVATE (adjustment, - GTK_TYPE_ADJUSTMENT, - GtkAdjustmentPrivate); + adjustment->priv = gtk_adjustment_get_instance_private (adjustment); } static void diff --git a/gtk/gtkalignment.c b/gtk/gtkalignment.c index bb5eb4a331..3f4a0de153 100644 --- a/gtk/gtkalignment.c +++ b/gtk/gtkalignment.c @@ -115,7 +115,7 @@ static void gtk_alignment_get_preferred_height_and_baseline_for_width (GtkWidget gint *minimum_baseline, gint *natural_baseline); -G_DEFINE_TYPE (GtkAlignment, gtk_alignment, GTK_TYPE_BIN) +G_DEFINE_TYPE_WITH_PRIVATE (GtkAlignment, gtk_alignment, GTK_TYPE_BIN) static void gtk_alignment_class_init (GtkAlignmentClass *class) @@ -242,8 +242,6 @@ gtk_alignment_class_init (GtkAlignmentClass *class) G_MAXINT, 0, GTK_PARAM_READWRITE)); - - g_type_class_add_private (gobject_class, sizeof (GtkAlignmentPrivate)); } static void @@ -251,9 +249,7 @@ gtk_alignment_init (GtkAlignment *alignment) { GtkAlignmentPrivate *priv; - alignment->priv = G_TYPE_INSTANCE_GET_PRIVATE (alignment, - GTK_TYPE_ALIGNMENT, - GtkAlignmentPrivate); + alignment->priv = gtk_alignment_get_instance_private (alignment); priv = alignment->priv; gtk_widget_set_has_window (GTK_WIDGET (alignment), FALSE); diff --git a/gtk/gtkappchooserbutton.c b/gtk/gtkappchooserbutton.c index 133ce34932..12e44d33f3 100644 --- a/gtk/gtkappchooserbutton.c +++ b/gtk/gtkappchooserbutton.c @@ -101,10 +101,6 @@ static void real_insert_separator (GtkAppChooserButton *self, static guint signals[NUM_SIGNALS] = { 0, }; -G_DEFINE_TYPE_WITH_CODE (GtkAppChooserButton, gtk_app_chooser_button, GTK_TYPE_COMBO_BOX, - G_IMPLEMENT_INTERFACE (GTK_TYPE_APP_CHOOSER, - app_chooser_iface_init)); - struct _GtkAppChooserButtonPrivate { GtkListStore *store; @@ -117,6 +113,11 @@ struct _GtkAppChooserButtonPrivate { GHashTable *custom_item_names; }; +G_DEFINE_TYPE_WITH_CODE (GtkAppChooserButton, gtk_app_chooser_button, GTK_TYPE_COMBO_BOX, + G_ADD_PRIVATE (GtkAppChooserButton) + G_IMPLEMENT_INTERFACE (GTK_TYPE_APP_CHOOSER, + app_chooser_iface_init)); + static gboolean row_separator_func (GtkTreeModel *model, GtkTreeIter *iter, @@ -670,15 +671,12 @@ gtk_app_chooser_button_class_init (GtkAppChooserButtonClass *klass) _gtk_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); - - g_type_class_add_private (klass, sizeof (GtkAppChooserButtonPrivate)); } static void gtk_app_chooser_button_init (GtkAppChooserButton *self) { - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTK_TYPE_APP_CHOOSER_BUTTON, - GtkAppChooserButtonPrivate); + self->priv = gtk_app_chooser_button_get_instance_private (self); self->priv->custom_item_names = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); diff --git a/gtk/gtkappchooserdialog.c b/gtk/gtkappchooserdialog.c index ce7cfeed57..29b1627d02 100644 --- a/gtk/gtkappchooserdialog.c +++ b/gtk/gtkappchooserdialog.c @@ -90,6 +90,7 @@ enum { static void gtk_app_chooser_dialog_iface_init (GtkAppChooserIface *iface); G_DEFINE_TYPE_WITH_CODE (GtkAppChooserDialog, gtk_app_chooser_dialog, GTK_TYPE_DIALOG, + G_ADD_PRIVATE (GtkAppChooserDialog) G_IMPLEMENT_INTERFACE (GTK_TYPE_APP_CHOOSER, gtk_app_chooser_dialog_iface_init)); @@ -665,15 +666,12 @@ gtk_app_chooser_dialog_class_init (GtkAppChooserDialogClass *klass) gtk_widget_class_bind_child (widget_class, GtkAppChooserDialogPrivate, show_more_button); gtk_widget_class_bind_child (widget_class, GtkAppChooserDialogPrivate, inner_box); gtk_widget_class_bind_callback (widget_class, show_more_button_clicked_cb); - - g_type_class_add_private (klass, sizeof (GtkAppChooserDialogPrivate)); } static void gtk_app_chooser_dialog_init (GtkAppChooserDialog *self) { - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTK_TYPE_APP_CHOOSER_DIALOG, - GtkAppChooserDialogPrivate); + self->priv = gtk_app_chooser_dialog_get_instance_private (self); gtk_widget_init_template (GTK_WIDGET (self)); diff --git a/gtk/gtkappchooseronlinepk.c b/gtk/gtkappchooseronlinepk.c index 5b70a5d75c..85722b280d 100644 --- a/gtk/gtkappchooseronlinepk.c +++ b/gtk/gtkappchooseronlinepk.c @@ -34,8 +34,18 @@ static void app_chooser_online_iface_init (GtkAppChooserOnlineInterface *iface); static void app_chooser_online_pk_async_initable_init (GAsyncInitableIface *iface); +struct _GtkAppChooserOnlinePkPrivate { + GSimpleAsyncResult *init_result; + guint watch_id; + + GDBusProxy *proxy; + GSimpleAsyncResult *result; + GtkWindow *parent; +}; + G_DEFINE_TYPE_WITH_CODE (GtkAppChooserOnlinePk, gtk_app_chooser_online_pk, G_TYPE_OBJECT, + G_ADD_PRIVATE (GtkAppChooserOnlinePk) G_IMPLEMENT_INTERFACE (G_TYPE_ASYNC_INITABLE, app_chooser_online_pk_async_initable_init) G_IMPLEMENT_INTERFACE (GTK_TYPE_APP_CHOOSER_ONLINE, @@ -44,15 +54,6 @@ G_DEFINE_TYPE_WITH_CODE (GtkAppChooserOnlinePk, gtk_app_chooser_online_pk, g_define_type_id, "packagekit", 10)); -struct _GtkAppChooserOnlinePkPrivate { - GSimpleAsyncResult *init_result; - guint watch_id; - - GDBusProxy *proxy; - GSimpleAsyncResult *result; - GtkWindow *parent; -}; - static void gtk_app_chooser_online_pk_dispose (GObject *obj) { @@ -70,15 +71,12 @@ gtk_app_chooser_online_pk_class_init (GtkAppChooserOnlinePkClass *klass) GObjectClass *oclass = G_OBJECT_CLASS (klass); oclass->dispose = gtk_app_chooser_online_pk_dispose; - - g_type_class_add_private (klass, sizeof (GtkAppChooserOnlinePkPrivate)); } static void gtk_app_chooser_online_pk_init (GtkAppChooserOnlinePk *self) { - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTK_TYPE_APP_CHOOSER_ONLINE_PK, - GtkAppChooserOnlinePkPrivate); + self->priv = gtk_app_chooser_online_pk_get_instance_private (self); } static gboolean diff --git a/gtk/gtkappchooserwidget.c b/gtk/gtkappchooserwidget.c index a655fadf07..83cab70d1a 100644 --- a/gtk/gtkappchooserwidget.c +++ b/gtk/gtkappchooserwidget.c @@ -126,6 +126,7 @@ static guint signals[N_SIGNALS] = { 0, }; static void gtk_app_chooser_widget_iface_init (GtkAppChooserIface *iface); G_DEFINE_TYPE_WITH_CODE (GtkAppChooserWidget, gtk_app_chooser_widget, GTK_TYPE_BOX, + G_ADD_PRIVATE (GtkAppChooserWidget) G_IMPLEMENT_INTERFACE (GTK_TYPE_APP_CHOOSER, gtk_app_chooser_widget_iface_init)); @@ -1093,8 +1094,6 @@ gtk_app_chooser_widget_class_init (GtkAppChooserWidgetClass *klass) gtk_widget_class_bind_callback (widget_class, refresh_and_emit_app_selected); gtk_widget_class_bind_callback (widget_class, program_list_selection_activated); gtk_widget_class_bind_callback (widget_class, widget_button_press_event_cb); - - g_type_class_add_private (klass, sizeof (GtkAppChooserWidgetPrivate)); } static void @@ -1103,8 +1102,7 @@ gtk_app_chooser_widget_init (GtkAppChooserWidget *self) GtkTreeSelection *selection; GtkTreeModel *sort; - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTK_TYPE_APP_CHOOSER_WIDGET, - GtkAppChooserWidgetPrivate); + self->priv = gtk_app_chooser_widget_get_instance_private (self); gtk_widget_init_template (GTK_WIDGET (self)); diff --git a/gtk/gtkapplication.c b/gtk/gtkapplication.c index d605846572..ed638a7673 100644 --- a/gtk/gtkapplication.c +++ b/gtk/gtkapplication.c @@ -137,8 +137,6 @@ enum { PROP_ACTIVE_WINDOW }; -G_DEFINE_TYPE (GtkApplication, gtk_application, G_TYPE_APPLICATION) - struct _GtkApplicationPrivate { GList *windows; @@ -176,6 +174,8 @@ struct _GtkApplicationPrivate #endif }; +G_DEFINE_TYPE_WITH_PRIVATE (GtkApplication, gtk_application, G_TYPE_APPLICATION) + #ifdef GDK_WINDOWING_X11 static void gtk_application_x11_publish_menu (GtkApplication *application, @@ -492,9 +492,7 @@ gtk_application_after_emit (GApplication *application, static void gtk_application_init (GtkApplication *application) { - application->priv = G_TYPE_INSTANCE_GET_PRIVATE (application, - GTK_TYPE_APPLICATION, - GtkApplicationPrivate); + application->priv = gtk_application_get_instance_private (application); #ifdef GDK_WINDOWING_X11 application->priv->next_id = 1; @@ -689,8 +687,6 @@ gtk_application_class_init (GtkApplicationClass *class) class->window_added = gtk_application_window_added; class->window_removed = gtk_application_window_removed; - g_type_class_add_private (class, sizeof (GtkApplicationPrivate)); - /** * GtkApplication::window-added: * @application: the #GtkApplication which emitted the signal diff --git a/gtk/gtkapplicationwindow.c b/gtk/gtkapplicationwindow.c index 10fc58860b..7797eb8729 100644 --- a/gtk/gtkapplicationwindow.c +++ b/gtk/gtkapplicationwindow.c @@ -598,6 +598,7 @@ gtk_application_window_map_iface_init (GActionMapInterface *iface) } G_DEFINE_TYPE_WITH_CODE (GtkApplicationWindow, gtk_application_window, GTK_TYPE_WINDOW, + G_ADD_PRIVATE (GtkApplicationWindow) G_IMPLEMENT_INTERFACE (G_TYPE_ACTION_GROUP, gtk_application_window_group_iface_init) G_IMPLEMENT_INTERFACE (G_TYPE_ACTION_MAP, gtk_application_window_map_iface_init)) @@ -946,7 +947,7 @@ gtk_application_window_dispose (GObject *object) static void gtk_application_window_init (GtkApplicationWindow *window) { - window->priv = G_TYPE_INSTANCE_GET_PRIVATE (window, GTK_TYPE_APPLICATION_WINDOW, GtkApplicationWindowPrivate); + window->priv = gtk_application_window_get_instance_private (window); window->priv->actions = gtk_application_window_actions_new (window); window->priv->app_menu_section = g_menu_new (); @@ -1007,7 +1008,6 @@ gtk_application_window_class_init (GtkApplicationWindowClass *class) "menubar at the top of the window"), TRUE, G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE); g_object_class_install_properties (object_class, N_PROPS, gtk_application_window_properties); - g_type_class_add_private (class, sizeof (GtkApplicationWindowPrivate)); } /** diff --git a/gtk/gtkarrow.c b/gtk/gtkarrow.c index 43a1d59132..e397644157 100644 --- a/gtk/gtkarrow.c +++ b/gtk/gtkarrow.c @@ -85,8 +85,7 @@ static void gtk_arrow_get_preferred_height (GtkWidget *widg gint *minimum_size, gint *natural_size); -G_DEFINE_TYPE (GtkArrow, gtk_arrow, GTK_TYPE_MISC) - +G_DEFINE_TYPE_WITH_PRIVATE (GtkArrow, gtk_arrow, GTK_TYPE_MISC) static void gtk_arrow_class_init (GtkArrowClass *class) @@ -129,8 +128,6 @@ gtk_arrow_class_init (GtkArrowClass *class) 0.0, 1.0, 0.7, GTK_PARAM_READABLE)); - g_type_class_add_private (class, sizeof (GtkArrowPrivate)); - gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_ARROW_ACCESSIBLE); } @@ -187,17 +184,12 @@ gtk_arrow_get_property (GObject *object, static void gtk_arrow_init (GtkArrow *arrow) { - GtkArrowPrivate *priv; - - arrow->priv = G_TYPE_INSTANCE_GET_PRIVATE (arrow, - GTK_TYPE_ARROW, - GtkArrowPrivate); - priv = arrow->priv; + arrow->priv = gtk_arrow_get_instance_private (arrow); gtk_widget_set_has_window (GTK_WIDGET (arrow), FALSE); - priv->arrow_type = GTK_ARROW_RIGHT; - priv->shadow_type = GTK_SHADOW_OUT; + arrow->priv->arrow_type = GTK_ARROW_RIGHT; + arrow->priv->shadow_type = GTK_SHADOW_OUT; } static void diff --git a/gtk/gtkaspectframe.c b/gtk/gtkaspectframe.c index 4b77af282a..e9e76361ae 100644 --- a/gtk/gtkaspectframe.c +++ b/gtk/gtkaspectframe.c @@ -85,7 +85,7 @@ static void gtk_aspect_frame_compute_child_allocation (GtkFrame *fram #define MAX_RATIO 10000.0 #define MIN_RATIO 0.0001 -G_DEFINE_TYPE (GtkAspectFrame, gtk_aspect_frame, GTK_TYPE_FRAME) +G_DEFINE_TYPE_WITH_PRIVATE (GtkAspectFrame, gtk_aspect_frame, GTK_TYPE_FRAME) static void gtk_aspect_frame_class_init (GtkAspectFrameClass *class) @@ -129,24 +129,17 @@ gtk_aspect_frame_class_init (GtkAspectFrameClass *class) P_("Force aspect ratio to match that of the frame's child"), TRUE, GTK_PARAM_READWRITE)); - - g_type_class_add_private (class, sizeof (GtkAspectFramePrivate)); } static void gtk_aspect_frame_init (GtkAspectFrame *aspect_frame) { - GtkAspectFramePrivate *priv; - - aspect_frame->priv = G_TYPE_INSTANCE_GET_PRIVATE (aspect_frame, - GTK_TYPE_ASPECT_FRAME, - GtkAspectFramePrivate); - priv = aspect_frame->priv; + aspect_frame->priv = gtk_aspect_frame_get_instance_private (aspect_frame); - priv->xalign = 0.5; - priv->yalign = 0.5; - priv->ratio = 1.0; - priv->obey_child = TRUE; + aspect_frame->priv->xalign = 0.5; + aspect_frame->priv->yalign = 0.5; + aspect_frame->priv->ratio = 1.0; + aspect_frame->priv->obey_child = TRUE; } static void diff --git a/gtk/gtkassistant.c b/gtk/gtkassistant.c index c9166f8a3c..c06b0d877f 100644 --- a/gtk/gtkassistant.c +++ b/gtk/gtkassistant.c @@ -213,6 +213,7 @@ static guint signals [LAST_SIGNAL] = { 0 }; G_DEFINE_TYPE_WITH_CODE (GtkAssistant, gtk_assistant, GTK_TYPE_WINDOW, + G_ADD_PRIVATE (GtkAssistant) G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_assistant_buildable_interface_init)) @@ -450,8 +451,6 @@ gtk_assistant_class_init (GtkAssistantClass *class) gtk_widget_class_bind_callback (widget_class, on_assistant_back); gtk_widget_class_bind_callback (widget_class, on_assistant_cancel); gtk_widget_class_bind_callback (widget_class, on_assistant_last); - - g_type_class_add_private (gobject_class, sizeof (GtkAssistantPrivate)); } static gint @@ -995,9 +994,8 @@ gtk_assistant_init (GtkAssistant *assistant) { GtkAssistantPrivate *priv; - assistant->priv = G_TYPE_INSTANCE_GET_PRIVATE (assistant, - GTK_TYPE_ASSISTANT, - GtkAssistantPrivate); + assistant->priv = gtk_assistant_get_instance_private (assistant); + priv = assistant->priv; priv->pages = NULL; priv->current_page = NULL; diff --git a/gtk/gtkbbox.c b/gtk/gtkbbox.c index b4348f1a66..22ca734d8f 100644 --- a/gtk/gtkbbox.c +++ b/gtk/gtkbbox.c @@ -130,7 +130,7 @@ static void gtk_button_box_get_child_property (GtkContainer *container, #define DEFAULT_CHILD_IPAD_Y 0 #define DEFAULT_LAYOUT_STYLE GTK_BUTTONBOX_EDGE -G_DEFINE_TYPE (GtkButtonBox, gtk_button_box, GTK_TYPE_BOX) +G_DEFINE_TYPE_WITH_PRIVATE (GtkButtonBox, gtk_button_box, GTK_TYPE_BOX) static void gtk_button_box_class_init (GtkButtonBoxClass *class) @@ -220,22 +220,15 @@ gtk_button_box_class_init (GtkButtonBoxClass *class) P_("If TRUE, the child will not be subject to homogeneous sizing"), FALSE, GTK_PARAM_READWRITE)); - - g_type_class_add_private (class, sizeof (GtkButtonBoxPrivate)); } static void gtk_button_box_init (GtkButtonBox *button_box) { - GtkButtonBoxPrivate *priv; - - button_box->priv = G_TYPE_INSTANCE_GET_PRIVATE (button_box, - GTK_TYPE_BUTTON_BOX, - GtkButtonBoxPrivate); - priv = button_box->priv; + button_box->priv = gtk_button_box_get_instance_private (button_box); + button_box->priv->layout_style = DEFAULT_LAYOUT_STYLE; gtk_box_set_spacing (GTK_BOX (button_box), 0); - priv->layout_style = DEFAULT_LAYOUT_STYLE; } static void diff --git a/gtk/gtkbin.c b/gtk/gtkbin.c index b64f54156d..86d1742cb8 100644 --- a/gtk/gtkbin.c +++ b/gtk/gtkbin.c @@ -73,7 +73,7 @@ static void gtk_bin_get_preferred_height_for_width (GtkWidget static void gtk_bin_size_allocate (GtkWidget *widget, GtkAllocation *allocation); -G_DEFINE_ABSTRACT_TYPE (GtkBin, gtk_bin, GTK_TYPE_CONTAINER) +G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GtkBin, gtk_bin, GTK_TYPE_CONTAINER) static void gtk_bin_class_init (GtkBinClass *class) @@ -91,23 +91,14 @@ gtk_bin_class_init (GtkBinClass *class) container_class->remove = gtk_bin_remove; container_class->forall = gtk_bin_forall; container_class->child_type = gtk_bin_child_type; - - g_type_class_add_private (class, sizeof (GtkBinPrivate)); } static void gtk_bin_init (GtkBin *bin) { - GtkBinPrivate *priv; - - bin->priv = G_TYPE_INSTANCE_GET_PRIVATE (bin, - GTK_TYPE_BIN, - GtkBinPrivate); - priv = bin->priv; + bin->priv = gtk_bin_get_instance_private (bin); gtk_widget_set_has_window (GTK_WIDGET (bin), FALSE); - - priv->child = NULL; } diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c index 94e89073cc..cbf7591a4f 100644 --- a/gtk/gtkbox.c +++ b/gtk/gtkbox.c @@ -208,8 +208,8 @@ static void gtk_box_get_preferred_height_and_baseline_for_width (GtkWidget G_DEFINE_TYPE_WITH_CODE (GtkBox, gtk_box, GTK_TYPE_CONTAINER, - G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, - NULL)) + G_ADD_PRIVATE (GtkBox) + G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL)) static void gtk_box_class_init (GtkBoxClass *class) @@ -332,8 +332,6 @@ gtk_box_class_init (GtkBoxClass *class) -1, G_MAXINT, 0, GTK_PARAM_READWRITE)); - g_type_class_add_private (object_class, sizeof (GtkBoxPrivate)); - gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_FILLER); } @@ -342,9 +340,7 @@ gtk_box_init (GtkBox *box) { GtkBoxPrivate *private; - box->priv = G_TYPE_INSTANCE_GET_PRIVATE (box, - GTK_TYPE_BOX, - GtkBoxPrivate); + box->priv = gtk_box_get_instance_private (box); private = box->priv; gtk_widget_set_has_window (GTK_WIDGET (box), FALSE); diff --git a/gtk/gtkbubblewindow.c b/gtk/gtkbubblewindow.c index f468878080..ec54d98aa2 100644 --- a/gtk/gtkbubblewindow.c +++ b/gtk/gtkbubblewindow.c @@ -72,7 +72,7 @@ struct _GtkBubbleWindowPrivate guint final_position : 2; }; -G_DEFINE_TYPE (GtkBubbleWindow, _gtk_bubble_window, GTK_TYPE_WINDOW) +G_DEFINE_TYPE_WITH_PRIVATE (GtkBubbleWindow, _gtk_bubble_window, GTK_TYPE_WINDOW) static void _gtk_bubble_window_init (GtkBubbleWindow *window) @@ -82,9 +82,7 @@ _gtk_bubble_window_init (GtkBubbleWindow *window) GdkVisual *visual; widget = GTK_WIDGET (window); - window->priv = G_TYPE_INSTANCE_GET_PRIVATE (window, - GTK_TYPE_BUBBLE_WINDOW, - GtkBubbleWindowPrivate); + window->priv = _gtk_bubble_window_get_instance_private (window); gtk_window_set_default_size (GTK_WINDOW (window), TAIL_GAP_WIDTH, TAIL_GAP_WIDTH); gtk_widget_set_app_paintable (widget, TRUE); @@ -867,8 +865,6 @@ _gtk_bubble_window_class_init (GtkBubbleWindowClass *klass) P_("Position to place the bubble window"), GTK_TYPE_POSITION_TYPE, GTK_POS_TOP, GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - - g_type_class_add_private (klass, sizeof (GtkBubbleWindowPrivate)); } static void diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c index 09045a73b8..a8ceb576cd 100644 --- a/gtk/gtkbuilder.c +++ b/gtk/gtkbuilder.c @@ -288,7 +288,7 @@ struct _GtkBuilderPrivate GType template_type; }; -G_DEFINE_TYPE (GtkBuilder, gtk_builder, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE (GtkBuilder, gtk_builder, G_TYPE_OBJECT) static void gtk_builder_class_init (GtkBuilderClass *klass) @@ -320,15 +320,12 @@ gtk_builder_class_init (GtkBuilderClass *klass) P_("The translation domain used by gettext"), NULL, GTK_PARAM_READWRITE)); - - g_type_class_add_private (gobject_class, sizeof (GtkBuilderPrivate)); } static void gtk_builder_init (GtkBuilder *builder) { - builder->priv = G_TYPE_INSTANCE_GET_PRIVATE (builder, GTK_TYPE_BUILDER, - GtkBuilderPrivate); + builder->priv = gtk_builder_get_instance_private (builder); builder->priv->domain = NULL; builder->priv->objects = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c index 268a2ccb4a..26ce7039b3 100644 --- a/gtk/gtkbutton.c +++ b/gtk/gtkbutton.c @@ -190,6 +190,7 @@ static guint button_signals[LAST_SIGNAL] = { 0 }; G_GNUC_BEGIN_IGNORE_DEPRECATIONS; G_DEFINE_TYPE_WITH_CODE (GtkButton, gtk_button, GTK_TYPE_BIN, + G_ADD_PRIVATE (GtkButton) G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIONABLE, gtk_button_actionable_iface_init) G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE, gtk_button_activatable_interface_init)) @@ -584,8 +585,6 @@ gtk_button_class_init (GtkButtonClass *klass) 2, GTK_PARAM_READABLE)); - g_type_class_add_private (gobject_class, sizeof (GtkButtonPrivate)); - gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_BUTTON_ACCESSIBLE); } @@ -595,9 +594,7 @@ gtk_button_init (GtkButton *button) GtkButtonPrivate *priv; GtkStyleContext *context; - button->priv = G_TYPE_INSTANCE_GET_PRIVATE (button, - GTK_TYPE_BUTTON, - GtkButtonPrivate); + button->priv = gtk_button_get_instance_private (button); priv = button->priv; gtk_widget_set_can_focus (GTK_WIDGET (button), TRUE); diff --git a/gtk/gtkcalendar.c b/gtk/gtkcalendar.c index cfceb08a15..588a905dc2 100644 --- a/gtk/gtkcalendar.c +++ b/gtk/gtkcalendar.c @@ -313,8 +313,6 @@ struct _GtkCalendarPrivate gint detail_overflow[6]; }; -#define GTK_CALENDAR_GET_PRIVATE(widget) (GTK_CALENDAR (widget)->priv) - static void gtk_calendar_finalize (GObject *calendar); static void gtk_calendar_destroy (GtkWidget *widget); static void gtk_calendar_set_property (GObject *object, @@ -413,7 +411,7 @@ static gint calendar_get_inner_border (GtkCalendar *calendar); static char *default_abbreviated_dayname[7]; static char *default_monthname[12]; -G_DEFINE_TYPE (GtkCalendar, gtk_calendar, GTK_TYPE_WIDGET) +G_DEFINE_TYPE_WITH_PRIVATE (GtkCalendar, gtk_calendar, GTK_TYPE_WIDGET) static void gtk_calendar_class_init (GtkCalendarClass *class) @@ -750,8 +748,6 @@ gtk_calendar_class_init (GtkCalendarClass *class) NULL, NULL, _gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); - - g_type_class_add_private (gobject_class, sizeof (GtkCalendarPrivate)); } static void @@ -778,9 +774,7 @@ gtk_calendar_init (GtkCalendar *calendar) gchar *week_start; #endif - priv = calendar->priv = G_TYPE_INSTANCE_GET_PRIVATE (calendar, - GTK_TYPE_CALENDAR, - GtkCalendarPrivate); + priv = calendar->priv = gtk_calendar_get_instance_private (calendar); gtk_widget_set_can_focus (widget, TRUE); gtk_widget_set_has_window (widget, FALSE); @@ -933,7 +927,7 @@ gtk_calendar_init (GtkCalendar *calendar) static void calendar_queue_refresh (GtkCalendar *calendar) { - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar); + GtkCalendarPrivate *priv = calendar->priv; if (!(priv->detail_func) || !(priv->display_flags & GTK_CALENDAR_SHOW_DETAILS) || @@ -1142,7 +1136,7 @@ calendar_row_height (GtkCalendar *calendar) { GtkCalendarPrivate *priv = calendar->priv; - return (GTK_CALENDAR_GET_PRIVATE (calendar)->main_h - CALENDAR_MARGIN + return (priv->main_h - CALENDAR_MARGIN - ((priv->display_flags & GTK_CALENDAR_SHOW_DAY_NAMES) ? calendar_get_ysep (calendar) : CALENDAR_MARGIN)) / 6; } @@ -1176,7 +1170,7 @@ calendar_left_x_for_column (GtkCalendar *calendar, week_width = 0; } - width = GTK_CALENDAR_GET_PRIVATE (calendar)->day_width; + width = calendar->priv->day_width; if (priv->display_flags & GTK_CALENDAR_SHOW_WEEK_NUMBERS) x_left = week_width + calendar_xsep + (width + DAY_XSEP) * column; else @@ -1199,7 +1193,7 @@ calendar_column_from_x (GtkCalendar *calendar, for (c = 0; c < 7; c++) { x_left = calendar_left_x_for_column (calendar, c); - x_right = x_left + GTK_CALENDAR_GET_PRIVATE (calendar)->day_width; + x_right = x_left + calendar->priv->day_width; if (event_x >= x_left && event_x < x_right) { @@ -1269,7 +1263,7 @@ calendar_arrow_rectangle (GtkCalendar *calendar, GdkRectangle *rect) { GtkWidget *widget = GTK_WIDGET (calendar); - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar); + GtkCalendarPrivate *priv = calendar->priv; GtkAllocation allocation; GtkStyleContext *context; GtkStateFlags state; @@ -1333,7 +1327,7 @@ calendar_day_rectangle (GtkCalendar *calendar, gint col, GdkRectangle *rect) { - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar); + GtkCalendarPrivate *priv = calendar->priv; rect->x = calendar_left_x_for_column (calendar, col); rect->y = calendar_top_y_for_row (calendar, row); @@ -1398,7 +1392,7 @@ gtk_calendar_finalize (GObject *object) static void gtk_calendar_destroy (GtkWidget *widget) { - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget); + GtkCalendarPrivate *priv = GTK_CALENDAR (widget)->priv; calendar_stop_spinning (GTK_CALENDAR (widget)); @@ -1563,7 +1557,7 @@ static void calendar_realize_arrows (GtkCalendar *calendar) { GtkWidget *widget = GTK_WIDGET (calendar); - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar); + GtkCalendarPrivate *priv = calendar->priv; GdkWindowAttr attributes; gint attributes_mask; gint i; @@ -1607,7 +1601,7 @@ calendar_realize_arrows (GtkCalendar *calendar) static void calendar_unrealize_arrows (GtkCalendar *calendar) { - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar); + GtkCalendarPrivate *priv = calendar->priv; gint i; for (i = 0; i < 4; i++) @@ -1661,7 +1655,7 @@ calendar_get_ysep (GtkCalendar *calendar) static void gtk_calendar_realize (GtkWidget *widget) { - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget); + GtkCalendarPrivate *priv = GTK_CALENDAR (widget)->priv; GdkWindowAttr attributes; gint attributes_mask; gint inner_border = calendar_get_inner_border (GTK_CALENDAR (widget)); @@ -1712,7 +1706,7 @@ gtk_calendar_realize (GtkWidget *widget) static void gtk_calendar_unrealize (GtkWidget *widget) { - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget); + GtkCalendarPrivate *priv = GTK_CALENDAR (widget)->priv; calendar_unrealize_arrows (GTK_CALENDAR (widget)); @@ -1729,7 +1723,7 @@ gtk_calendar_unrealize (GtkWidget *widget) static void calendar_map_arrows (GtkCalendar *calendar) { - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar); + GtkCalendarPrivate *priv = calendar->priv; gint i; for (i = 0; i < 4; i++) @@ -1742,7 +1736,7 @@ calendar_map_arrows (GtkCalendar *calendar) static void calendar_unmap_arrows (GtkCalendar *calendar) { - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar); + GtkCalendarPrivate *priv = calendar->priv; gint i; for (i = 0; i < 4; i++) @@ -1755,7 +1749,7 @@ calendar_unmap_arrows (GtkCalendar *calendar) static void gtk_calendar_map (GtkWidget *widget) { - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget); + GtkCalendarPrivate *priv = GTK_CALENDAR (widget)->priv; GTK_WIDGET_CLASS (gtk_calendar_parent_class)->map (widget); @@ -1767,7 +1761,7 @@ gtk_calendar_map (GtkWidget *widget) static void gtk_calendar_unmap (GtkWidget *widget) { - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget); + GtkCalendarPrivate *priv = GTK_CALENDAR (widget)->priv; calendar_unmap_arrows (GTK_CALENDAR (widget)); @@ -1781,7 +1775,7 @@ gtk_calendar_get_detail (GtkCalendar *calendar, gint row, gint column) { - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar); + GtkCalendarPrivate *priv = GTK_CALENDAR (calendar)->priv; gint year, month; if (priv->detail_func == NULL) @@ -1814,8 +1808,8 @@ gtk_calendar_query_tooltip (GtkWidget *widget, gboolean keyboard_mode, GtkTooltip *tooltip) { - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget); GtkCalendar *calendar = GTK_CALENDAR (widget); + GtkCalendarPrivate *priv = calendar->priv; gchar *detail = NULL; GdkRectangle day_rect; gint row, col; @@ -1857,7 +1851,7 @@ gtk_calendar_size_request (GtkWidget *widget, GtkRequisition *requisition) { GtkCalendar *calendar = GTK_CALENDAR (widget); - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget); + GtkCalendarPrivate *priv = calendar->priv; GtkStyleContext *context; GtkStateFlags state; GtkBorder padding; @@ -2127,7 +2121,7 @@ gtk_calendar_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GtkCalendar *calendar = GTK_CALENDAR (widget); - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget); + GtkCalendarPrivate *priv = calendar->priv; GtkStyleContext *context; GtkStateFlags state; GtkBorder padding; @@ -2209,7 +2203,7 @@ static void calendar_paint_header (GtkCalendar *calendar, cairo_t *cr) { GtkWidget *widget = GTK_WIDGET (calendar); - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar); + GtkCalendarPrivate *priv = calendar->priv; GtkAllocation allocation; GtkStyleContext *context; GtkStateFlags state; @@ -2322,7 +2316,7 @@ calendar_paint_day_names (GtkCalendar *calendar, cairo_t *cr) { GtkWidget *widget = GTK_WIDGET (calendar); - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar); + GtkCalendarPrivate *priv = calendar->priv; GtkStyleContext *context; GtkStateFlags state; GtkBorder padding; @@ -2418,7 +2412,7 @@ calendar_paint_week_numbers (GtkCalendar *calendar, cairo_t *cr) { GtkWidget *widget = GTK_WIDGET (calendar); - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar); + GtkCalendarPrivate *priv = calendar->priv; GtkStyleContext *context; GtkStateFlags state; GtkBorder padding; @@ -2570,7 +2564,7 @@ calendar_paint_day (GtkCalendar *calendar, gint col) { GtkWidget *widget = GTK_WIDGET (calendar); - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar); + GtkCalendarPrivate *priv = calendar->priv; GtkStyleContext *context; GtkStateFlags state = 0; gchar *detail; @@ -2738,7 +2732,7 @@ static void calendar_invalidate_arrow (GtkCalendar *calendar, guint arrow) { - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar); + GtkCalendarPrivate *priv = calendar->priv; if (priv->display_flags & GTK_CALENDAR_SHOW_HEADING && priv->arrow_win[arrow]) @@ -2761,7 +2755,7 @@ calendar_paint_arrow (GtkCalendar *calendar, guint arrow) { GtkWidget *widget = GTK_WIDGET (calendar); - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget); + GtkCalendarPrivate *priv = calendar->priv; GtkStyleContext *context; GtkStateFlags state; GdkRectangle rect; @@ -2809,7 +2803,7 @@ gtk_calendar_draw (GtkWidget *widget, cairo_t *cr) { GtkCalendar *calendar = GTK_CALENDAR (widget); - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget); + GtkCalendarPrivate *priv = calendar->priv; int i; if (gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget))) @@ -2881,7 +2875,7 @@ static gboolean calendar_timer (gpointer data) { GtkCalendar *calendar = data; - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar); + GtkCalendarPrivate *priv = calendar->priv; gboolean retval = FALSE; if (priv->timer) @@ -2913,7 +2907,7 @@ static void calendar_start_spinning (GtkCalendar *calendar, gint click_child) { - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar); + GtkCalendarPrivate *priv = calendar->priv; priv->click_child = click_child; @@ -2936,7 +2930,7 @@ calendar_start_spinning (GtkCalendar *calendar, static void calendar_stop_spinning (GtkCalendar *calendar) { - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar); + GtkCalendarPrivate *priv = calendar->priv; if (priv->timer) { @@ -2951,7 +2945,7 @@ calendar_main_button_press (GtkCalendar *calendar, GdkEventButton *event) { GtkWidget *widget = GTK_WIDGET (calendar); - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar); + GtkCalendarPrivate *priv = calendar->priv; gint x, y; gint win_x, win_y; gint row, col; @@ -3010,7 +3004,7 @@ gtk_calendar_button_press (GtkWidget *widget, GdkEventButton *event) { GtkCalendar *calendar = GTK_CALENDAR (widget); - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget); + GtkCalendarPrivate *priv = calendar->priv; gint arrow = -1; if (event->window == priv->main_win) @@ -3045,7 +3039,7 @@ gtk_calendar_button_release (GtkWidget *widget, GdkEventButton *event) { GtkCalendar *calendar = GTK_CALENDAR (widget); - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget); + GtkCalendarPrivate *priv = calendar->priv; if (event->button == GDK_BUTTON_PRIMARY) { @@ -3062,7 +3056,7 @@ static gboolean gtk_calendar_motion_notify (GtkWidget *widget, GdkEventMotion *event) { - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget); + GtkCalendarPrivate *priv = GTK_CALENDAR (widget)->priv; if (priv->in_drag) { @@ -3090,7 +3084,7 @@ gtk_calendar_enter_notify (GtkWidget *widget, GdkEventCrossing *event) { GtkCalendar *calendar = GTK_CALENDAR (widget); - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget); + GtkCalendarPrivate *priv = calendar->priv; if (event->window == priv->arrow_win[ARROW_MONTH_LEFT]) { @@ -3124,7 +3118,7 @@ gtk_calendar_leave_notify (GtkWidget *widget, GdkEventCrossing *event) { GtkCalendar *calendar = GTK_CALENDAR (widget); - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget); + GtkCalendarPrivate *priv = calendar->priv; if (event->window == priv->arrow_win[ARROW_MONTH_LEFT]) { @@ -3332,7 +3326,7 @@ gtk_calendar_state_flags_changed (GtkWidget *widget, GtkStateFlags previous_state) { GtkCalendar *calendar = GTK_CALENDAR (widget); - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget); + GtkCalendarPrivate *priv = calendar->priv; if (!gtk_widget_is_sensitive (widget)) { @@ -3353,13 +3347,12 @@ static gboolean gtk_calendar_focus_out (GtkWidget *widget, GdkEventFocus *event) { - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget); GtkCalendar *calendar = GTK_CALENDAR (widget); calendar_queue_refresh (calendar); calendar_stop_spinning (calendar); - priv->in_drag = 0; + calendar->priv->in_drag = 0; return FALSE; } @@ -3414,7 +3407,7 @@ gtk_calendar_drag_leave (GtkWidget *widget, GdkDragContext *context, guint time) { - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget); + GtkCalendarPrivate *priv = GTK_CALENDAR (widget)->priv; priv->drag_highlight = 0; gtk_drag_unhighlight (widget); @@ -3428,7 +3421,7 @@ gtk_calendar_drag_motion (GtkWidget *widget, gint y, guint time) { - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget); + GtkCalendarPrivate *priv = GTK_CALENDAR (widget)->priv; GdkAtom target; if (!priv->drag_highlight) @@ -3599,7 +3592,7 @@ gtk_calendar_set_display_options (GtkCalendar *calendar, GtkCalendarDisplayOptions flags) { GtkWidget *widget = GTK_WIDGET (calendar); - GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar); + GtkCalendarPrivate *priv = calendar->priv; gint resize = 0; GtkCalendarDisplayOptions old_flags; @@ -3929,7 +3922,7 @@ gtk_calendar_set_detail_func (GtkCalendar *calendar, g_return_if_fail (GTK_IS_CALENDAR (calendar)); - priv = GTK_CALENDAR_GET_PRIVATE (calendar); + priv = calendar->priv; if (priv->detail_func_destroy) priv->detail_func_destroy (priv->detail_func_user_data); @@ -3961,7 +3954,7 @@ gtk_calendar_set_detail_width_chars (GtkCalendar *calendar, g_return_if_fail (GTK_IS_CALENDAR (calendar)); - priv = GTK_CALENDAR_GET_PRIVATE (calendar); + priv = calendar->priv; if (chars != priv->detail_width_chars) { @@ -3989,7 +3982,7 @@ gtk_calendar_set_detail_height_rows (GtkCalendar *calendar, g_return_if_fail (GTK_IS_CALENDAR (calendar)); - priv = GTK_CALENDAR_GET_PRIVATE (calendar); + priv = calendar->priv; if (rows != priv->detail_height_rows) { @@ -4014,7 +4007,8 @@ gint gtk_calendar_get_detail_width_chars (GtkCalendar *calendar) { g_return_val_if_fail (GTK_IS_CALENDAR (calendar), 0); - return GTK_CALENDAR_GET_PRIVATE (calendar)->detail_width_chars; + + return calendar->priv->detail_width_chars; } /** @@ -4032,5 +4026,6 @@ gint gtk_calendar_get_detail_height_rows (GtkCalendar *calendar) { g_return_val_if_fail (GTK_IS_CALENDAR (calendar), 0); - return GTK_CALENDAR_GET_PRIVATE (calendar)->detail_height_rows; + + return calendar->priv->detail_height_rows; } diff --git a/gtk/gtkcellarea.c b/gtk/gtkcellarea.c index 715e4ae207..b7bad3d559 100644 --- a/gtk/gtkcellarea.c +++ b/gtk/gtkcellarea.c @@ -616,6 +616,7 @@ static guint cell_area_signals[LAST_SIGNAL] = { 0 }; #define PARAM_SPEC_SET_PARAM_ID(pspec, id) ((pspec)->param_id = (id)) G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GtkCellArea, gtk_cell_area, G_TYPE_INITIALLY_UNOWNED, + G_ADD_PRIVATE (GtkCellArea) G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_LAYOUT, gtk_cell_area_cell_layout_init) G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, @@ -626,9 +627,7 @@ gtk_cell_area_init (GtkCellArea *area) { GtkCellAreaPrivate *priv; - area->priv = G_TYPE_INSTANCE_GET_PRIVATE (area, - GTK_TYPE_CELL_AREA, - GtkCellAreaPrivate); + area->priv = gtk_cell_area_get_instance_private (area); priv = area->priv; priv->cell_info = g_hash_table_new_full (g_direct_hash, @@ -846,8 +845,6 @@ gtk_cell_area_class_init (GtkCellAreaClass *class) /* Pool for Cell Properties */ if (!cell_property_pool) cell_property_pool = g_param_spec_pool_new (FALSE); - - g_type_class_add_private (object_class, sizeof (GtkCellAreaPrivate)); } /************************************************************* diff --git a/gtk/gtkcellareabox.c b/gtk/gtkcellareabox.c index 94915e209c..fbb202a536 100644 --- a/gtk/gtkcellareabox.c +++ b/gtk/gtkcellareabox.c @@ -235,18 +235,17 @@ enum { }; G_DEFINE_TYPE_WITH_CODE (GtkCellAreaBox, gtk_cell_area_box, GTK_TYPE_CELL_AREA, + G_ADD_PRIVATE (GtkCellAreaBox) G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_LAYOUT, gtk_cell_area_box_cell_layout_init) - G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL)); + G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL)) static void gtk_cell_area_box_init (GtkCellAreaBox *box) { GtkCellAreaBoxPrivate *priv; - box->priv = G_TYPE_INSTANCE_GET_PRIVATE (box, - GTK_TYPE_CELL_AREA_BOX, - GtkCellAreaBoxPrivate); + box->priv = gtk_cell_area_box_get_instance_private (box); priv = box->priv; priv->orientation = GTK_ORIENTATION_HORIZONTAL; @@ -383,8 +382,6 @@ gtk_cell_area_box_class_init (GtkCellAreaBoxClass *class) "reference to the start or end of the cell area"), GTK_TYPE_PACK_TYPE, GTK_PACK_START, GTK_PARAM_READWRITE)); - - g_type_class_add_private (object_class, sizeof (GtkCellAreaBoxPrivate)); } diff --git a/gtk/gtkcellareaboxcontext.c b/gtk/gtkcellareaboxcontext.c index d00316578a..00aad38f1b 100644 --- a/gtk/gtkcellareaboxcontext.c +++ b/gtk/gtkcellareaboxcontext.c @@ -80,7 +80,7 @@ struct _GtkCellAreaBoxContextPrivate gboolean *align; }; -G_DEFINE_TYPE (GtkCellAreaBoxContext, _gtk_cell_area_box_context, GTK_TYPE_CELL_AREA_CONTEXT); +G_DEFINE_TYPE_WITH_PRIVATE (GtkCellAreaBoxContext, _gtk_cell_area_box_context, GTK_TYPE_CELL_AREA_CONTEXT) static void free_cache_array (GArray *array) @@ -167,9 +167,7 @@ _gtk_cell_area_box_context_init (GtkCellAreaBoxContext *box_context) { GtkCellAreaBoxContextPrivate *priv; - box_context->priv = G_TYPE_INSTANCE_GET_PRIVATE (box_context, - GTK_TYPE_CELL_AREA_BOX_CONTEXT, - GtkCellAreaBoxContextPrivate); + box_context->priv = _gtk_cell_area_box_context_get_instance_private (box_context); priv = box_context->priv; priv->base_widths = g_array_new (FALSE, TRUE, sizeof (CachedSize)); @@ -193,8 +191,6 @@ _gtk_cell_area_box_context_class_init (GtkCellAreaBoxContextClass *class) context_class->reset = _gtk_cell_area_box_context_reset; context_class->get_preferred_height_for_width = _gtk_cell_area_box_context_get_preferred_height_for_width; context_class->get_preferred_width_for_height = _gtk_cell_area_box_context_get_preferred_width_for_height; - - g_type_class_add_private (object_class, sizeof (GtkCellAreaBoxContextPrivate)); } /************************************************************* diff --git a/gtk/gtkcellareacontext.c b/gtk/gtkcellareacontext.c index f464c3ab30..e90abc737e 100644 --- a/gtk/gtkcellareacontext.c +++ b/gtk/gtkcellareacontext.c @@ -80,14 +80,12 @@ enum { PROP_NAT_HEIGHT }; -G_DEFINE_TYPE (GtkCellAreaContext, gtk_cell_area_context, G_TYPE_OBJECT); +G_DEFINE_TYPE_WITH_PRIVATE (GtkCellAreaContext, gtk_cell_area_context, G_TYPE_OBJECT) static void gtk_cell_area_context_init (GtkCellAreaContext *context) { - context->priv = G_TYPE_INSTANCE_GET_PRIVATE (context, - GTK_TYPE_CELL_AREA_CONTEXT, - GtkCellAreaContextPrivate); + context->priv = gtk_cell_area_context_get_instance_private (context); } static void @@ -194,8 +192,6 @@ gtk_cell_area_context_class_init (GtkCellAreaContextClass *class) G_MAXINT, -1, G_PARAM_READABLE)); - - g_type_class_add_private (object_class, sizeof (GtkCellAreaContextPrivate)); } /************************************************************* diff --git a/gtk/gtkcellrenderer.c b/gtk/gtkcellrenderer.c index 9f4b4e203f..3ebe9ae5c0 100644 --- a/gtk/gtkcellrenderer.c +++ b/gtk/gtkcellrenderer.c @@ -164,16 +164,21 @@ enum { LAST_SIGNAL }; +static gint GtkCellRenderer_private_offset; static guint cell_renderer_signals[LAST_SIGNAL] = { 0 }; +static inline gpointer +gtk_cell_renderer_get_instance_private (GtkCellRenderer *self) +{ + return (G_STRUCT_MEMBER_P (self, GtkCellRenderer_private_offset)); +} + static void gtk_cell_renderer_init (GtkCellRenderer *cell) { GtkCellRendererPrivate *priv; - cell->priv = G_TYPE_INSTANCE_GET_PRIVATE (cell, - GTK_TYPE_CELL_RENDERER, - GtkCellRendererPrivate); + cell->priv = gtk_cell_renderer_get_instance_private (cell); priv = cell->priv; priv->mode = GTK_CELL_RENDERER_MODE_INERT; @@ -427,7 +432,8 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class) P_("Cell background set"), P_("Whether the cell background color is set")); - g_type_class_add_private (class, sizeof (GtkCellRendererPrivate)); + if (GtkCellRenderer_private_offset != 0) + g_type_class_adjust_private_offset (class, &GtkCellRenderer_private_offset); gtk_cell_renderer_class_set_accessible_type (class, GTK_TYPE_RENDERER_CELL_ACCESSIBLE); } @@ -463,6 +469,8 @@ gtk_cell_renderer_get_type (void) cell_renderer_type = g_type_register_static (G_TYPE_INITIALLY_UNOWNED, "GtkCellRenderer", &cell_renderer_info, G_TYPE_FLAG_ABSTRACT); + GtkCellRenderer_private_offset = + g_type_add_instance_private (cell_renderer_type, sizeof (GtkCellRendererPrivate)); g_type_add_class_private (cell_renderer_type, sizeof (GtkCellRendererClassPrivate)); } diff --git a/gtk/gtkcellrendereraccel.c b/gtk/gtkcellrendereraccel.c index 32f385ea59..a953361964 100644 --- a/gtk/gtkcellrendereraccel.c +++ b/gtk/gtkcellrendereraccel.c @@ -104,16 +104,14 @@ struct _GtkCellRendererAccelPrivate static guint signals[LAST_SIGNAL] = { 0 }; -G_DEFINE_TYPE (GtkCellRendererAccel, gtk_cell_renderer_accel, GTK_TYPE_CELL_RENDERER_TEXT) +G_DEFINE_TYPE_WITH_PRIVATE (GtkCellRendererAccel, gtk_cell_renderer_accel, GTK_TYPE_CELL_RENDERER_TEXT) static void gtk_cell_renderer_accel_init (GtkCellRendererAccel *cell_accel) { gchar *text; - cell_accel->priv = G_TYPE_INSTANCE_GET_PRIVATE (cell_accel, - GTK_TYPE_CELL_RENDERER_ACCEL, - GtkCellRendererAccelPrivate); + cell_accel->priv = gtk_cell_renderer_accel_get_instance_private (cell_accel); text = convert_keysym_state_to_string (cell_accel, 0, 0, 0); g_object_set (cell_accel, "text", text, NULL); @@ -247,8 +245,6 @@ gtk_cell_renderer_accel_class_init (GtkCellRendererAccelClass *cell_accel_class) g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); - - g_type_class_add_private (cell_accel_class, sizeof (GtkCellRendererAccelPrivate)); } diff --git a/gtk/gtkcellrenderercombo.c b/gtk/gtkcellrenderercombo.c index 0518d14307..cc1c44608d 100644 --- a/gtk/gtkcellrenderercombo.c +++ b/gtk/gtkcellrenderercombo.c @@ -100,7 +100,7 @@ static guint cell_renderer_combo_signals[LAST_SIGNAL] = { 0, }; #define GTK_CELL_RENDERER_COMBO_PATH "gtk-cell-renderer-combo-path" -G_DEFINE_TYPE (GtkCellRendererCombo, gtk_cell_renderer_combo, GTK_TYPE_CELL_RENDERER_TEXT) +G_DEFINE_TYPE_WITH_PRIVATE (GtkCellRendererCombo, gtk_cell_renderer_combo, GTK_TYPE_CELL_RENDERER_TEXT) static void gtk_cell_renderer_combo_class_init (GtkCellRendererComboClass *klass) @@ -204,8 +204,6 @@ gtk_cell_renderer_combo_class_init (GtkCellRendererComboClass *klass) G_TYPE_NONE, 2, G_TYPE_STRING, GTK_TYPE_TREE_ITER); - - g_type_class_add_private (klass, sizeof (GtkCellRendererComboPrivate)); } static void @@ -213,9 +211,7 @@ gtk_cell_renderer_combo_init (GtkCellRendererCombo *self) { GtkCellRendererComboPrivate *priv; - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - GTK_TYPE_CELL_RENDERER_COMBO, - GtkCellRendererComboPrivate); + self->priv = gtk_cell_renderer_combo_get_instance_private (self); priv = self->priv; priv->model = NULL; diff --git a/gtk/gtkcellrendererpixbuf.c b/gtk/gtkcellrendererpixbuf.c index c45a73025c..19c372518f 100644 --- a/gtk/gtkcellrendererpixbuf.c +++ b/gtk/gtkcellrendererpixbuf.c @@ -98,19 +98,16 @@ struct _GtkCellRendererPixbufPrivate gchar *stock_detail; }; - -G_DEFINE_TYPE (GtkCellRendererPixbuf, gtk_cell_renderer_pixbuf, GTK_TYPE_CELL_RENDERER) - +G_DEFINE_TYPE_WITH_PRIVATE (GtkCellRendererPixbuf, gtk_cell_renderer_pixbuf, GTK_TYPE_CELL_RENDERER) static void gtk_cell_renderer_pixbuf_init (GtkCellRendererPixbuf *cellpixbuf) { GtkCellRendererPixbufPrivate *priv; - cellpixbuf->priv = G_TYPE_INSTANCE_GET_PRIVATE (cellpixbuf, - GTK_TYPE_CELL_RENDERER_PIXBUF, - GtkCellRendererPixbufPrivate); + cellpixbuf->priv = gtk_cell_renderer_pixbuf_get_instance_private (cellpixbuf); priv = cellpixbuf->priv; + priv->icon_helper = _gtk_icon_helper_new (); priv->icon_size = GTK_ICON_SIZE_MENU; } @@ -263,8 +260,6 @@ gtk_cell_renderer_pixbuf_class_init (GtkCellRendererPixbufClass *class) - g_type_class_add_private (object_class, sizeof (GtkCellRendererPixbufPrivate)); - gtk_cell_renderer_class_set_accessible_type (cell_class, GTK_TYPE_IMAGE_CELL_ACCESSIBLE); } diff --git a/gtk/gtkcellrendererprogress.c b/gtk/gtkcellrendererprogress.c index 2e4b9b31c3..331254c8c2 100644 --- a/gtk/gtkcellrendererprogress.c +++ b/gtk/gtkcellrendererprogress.c @@ -107,6 +107,7 @@ static void gtk_cell_renderer_progress_render (GtkCellRenderer *ce G_DEFINE_TYPE_WITH_CODE (GtkCellRendererProgress, gtk_cell_renderer_progress, GTK_TYPE_CELL_RENDERER, + G_ADD_PRIVATE (GtkCellRendererProgress) G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL)) static void @@ -225,9 +226,6 @@ gtk_cell_renderer_progress_class_init (GtkCellRendererProgressClass *klass) P_("Invert the direction in which the progress bar grows"), FALSE, GTK_PARAM_READWRITE)); - - g_type_class_add_private (object_class, - sizeof (GtkCellRendererProgressPrivate)); } static void @@ -235,9 +233,7 @@ gtk_cell_renderer_progress_init (GtkCellRendererProgress *cellprogress) { GtkCellRendererProgressPrivate *priv; - cellprogress->priv = G_TYPE_INSTANCE_GET_PRIVATE (cellprogress, - GTK_TYPE_CELL_RENDERER_PROGRESS, - GtkCellRendererProgressPrivate); + cellprogress->priv = gtk_cell_renderer_progress_get_instance_private (cellprogress); priv = cellprogress->priv; priv->value = 0; diff --git a/gtk/gtkcellrendererspin.c b/gtk/gtkcellrendererspin.c index d1c1148b6c..1cea3a57d7 100644 --- a/gtk/gtkcellrendererspin.c +++ b/gtk/gtkcellrendererspin.c @@ -84,7 +84,7 @@ enum { #define GTK_CELL_RENDERER_SPIN_PATH "gtk-cell-renderer-spin-path" -G_DEFINE_TYPE (GtkCellRendererSpin, gtk_cell_renderer_spin, GTK_TYPE_CELL_RENDERER_TEXT) +G_DEFINE_TYPE_WITH_PRIVATE (GtkCellRendererSpin, gtk_cell_renderer_spin, GTK_TYPE_CELL_RENDERER_TEXT) static void @@ -144,8 +144,6 @@ gtk_cell_renderer_spin_class_init (GtkCellRendererSpinClass *klass) P_("The number of decimal places to display"), 0, 20, 0, GTK_PARAM_READWRITE)); - - g_type_class_add_private (object_class, sizeof (GtkCellRendererSpinPrivate)); } static void @@ -153,9 +151,7 @@ gtk_cell_renderer_spin_init (GtkCellRendererSpin *self) { GtkCellRendererSpinPrivate *priv; - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - GTK_TYPE_CELL_RENDERER_SPIN, - GtkCellRendererSpinPrivate); + self->priv = gtk_cell_renderer_spin_get_instance_private (self); priv = self->priv; priv->adjustment = NULL; diff --git a/gtk/gtkcellrendererspinner.c b/gtk/gtkcellrendererspinner.c index 075b817603..00c8ae875b 100644 --- a/gtk/gtkcellrendererspinner.c +++ b/gtk/gtkcellrendererspinner.c @@ -99,7 +99,7 @@ static void gtk_cell_renderer_spinner_render (GtkCellRenderer *cell, const GdkRectangle *cell_area, GtkCellRendererState flags); -G_DEFINE_TYPE (GtkCellRendererSpinner, gtk_cell_renderer_spinner, GTK_TYPE_CELL_RENDERER) +G_DEFINE_TYPE_WITH_PRIVATE (GtkCellRendererSpinner, gtk_cell_renderer_spinner, GTK_TYPE_CELL_RENDERER) static void gtk_cell_renderer_spinner_class_init (GtkCellRendererSpinnerClass *klass) @@ -159,17 +159,12 @@ gtk_cell_renderer_spinner_class_init (GtkCellRendererSpinnerClass *klass) GTK_TYPE_ICON_SIZE, GTK_ICON_SIZE_MENU, G_PARAM_READWRITE)); - - g_type_class_add_private (object_class, sizeof (GtkCellRendererSpinnerPrivate)); } static void gtk_cell_renderer_spinner_init (GtkCellRendererSpinner *cell) { - cell->priv = G_TYPE_INSTANCE_GET_PRIVATE (cell, - GTK_TYPE_CELL_RENDERER_SPINNER, - GtkCellRendererSpinnerPrivate); - + cell->priv = gtk_cell_renderer_spinner_get_instance_private (cell); cell->priv->pulse = 0; cell->priv->old_icon_size = GTK_ICON_SIZE_INVALID; cell->priv->icon_size = GTK_ICON_SIZE_MENU; diff --git a/gtk/gtkcellrenderertext.c b/gtk/gtkcellrenderertext.c index 3399bb2be0..30ecda489f 100644 --- a/gtk/gtkcellrenderertext.c +++ b/gtk/gtkcellrenderertext.c @@ -204,7 +204,7 @@ struct _GtkCellRendererTextPrivate gulong entry_menu_popdown_timeout; }; -G_DEFINE_TYPE (GtkCellRendererText, gtk_cell_renderer_text, GTK_TYPE_CELL_RENDERER) +G_DEFINE_TYPE_WITH_PRIVATE (GtkCellRendererText, gtk_cell_renderer_text, GTK_TYPE_CELL_RENDERER) static void gtk_cell_renderer_text_init (GtkCellRendererText *celltext) @@ -212,9 +212,7 @@ gtk_cell_renderer_text_init (GtkCellRendererText *celltext) GtkCellRendererTextPrivate *priv; GtkCellRenderer *cell = GTK_CELL_RENDERER (celltext); - celltext->priv = G_TYPE_INSTANCE_GET_PRIVATE (celltext, - GTK_TYPE_CELL_RENDERER_TEXT, - GtkCellRendererTextPrivate); + celltext->priv = gtk_cell_renderer_text_get_instance_private (celltext); priv = celltext->priv; gtk_cell_renderer_set_alignment (cell, 0.0, 0.5); @@ -729,8 +727,6 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class) G_TYPE_STRING, G_TYPE_STRING); - g_type_class_add_private (object_class, sizeof (GtkCellRendererTextPrivate)); - gtk_cell_renderer_class_set_accessible_type (cell_class, GTK_TYPE_TEXT_CELL_ACCESSIBLE); } diff --git a/gtk/gtkcellrenderertoggle.c b/gtk/gtkcellrenderertoggle.c index f94ff2a71a..bee988e39d 100644 --- a/gtk/gtkcellrenderertoggle.c +++ b/gtk/gtkcellrenderertoggle.c @@ -96,7 +96,7 @@ struct _GtkCellRendererTogglePrivate }; -G_DEFINE_TYPE (GtkCellRendererToggle, gtk_cell_renderer_toggle, GTK_TYPE_CELL_RENDERER) +G_DEFINE_TYPE_WITH_PRIVATE (GtkCellRendererToggle, gtk_cell_renderer_toggle, GTK_TYPE_CELL_RENDERER) static void @@ -104,9 +104,7 @@ gtk_cell_renderer_toggle_init (GtkCellRendererToggle *celltoggle) { GtkCellRendererTogglePrivate *priv; - celltoggle->priv = G_TYPE_INSTANCE_GET_PRIVATE (celltoggle, - GTK_TYPE_CELL_RENDERER_TOGGLE, - GtkCellRendererTogglePrivate); + celltoggle->priv = gtk_cell_renderer_toggle_get_instance_private (celltoggle); priv = celltoggle->priv; priv->activatable = TRUE; @@ -194,8 +192,6 @@ gtk_cell_renderer_toggle_class_init (GtkCellRendererToggleClass *class) G_TYPE_NONE, 1, G_TYPE_STRING); - g_type_class_add_private (object_class, sizeof (GtkCellRendererTogglePrivate)); - gtk_cell_renderer_class_set_accessible_type (cell_class, GTK_TYPE_BOOLEAN_CELL_ACCESSIBLE); } diff --git a/gtk/gtkcellview.c b/gtk/gtkcellview.c index d5d33ede32..ce36676c7d 100644 --- a/gtk/gtkcellview.c +++ b/gtk/gtkcellview.c @@ -153,12 +153,13 @@ enum PROP_FIT_MODEL }; -G_DEFINE_TYPE_WITH_CODE (GtkCellView, gtk_cell_view, GTK_TYPE_WIDGET, +G_DEFINE_TYPE_WITH_CODE (GtkCellView, gtk_cell_view, GTK_TYPE_WIDGET, + G_ADD_PRIVATE (GtkCellView) G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_LAYOUT, gtk_cell_view_cell_layout_init) G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_cell_view_buildable_init) - G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL)); + G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL)) static void gtk_cell_view_class_init (GtkCellViewClass *klass) @@ -322,8 +323,6 @@ gtk_cell_view_class_init (GtkCellViewClass *klass) ADD_SET_PROP ("background-set", PROP_BACKGROUND_SET, P_("Background set"), P_("Whether this tag affects the background color")); - - g_type_class_add_private (gobject_class, sizeof (GtkCellViewPrivate)); } static void @@ -533,16 +532,10 @@ gtk_cell_view_set_property (GObject *object, static void gtk_cell_view_init (GtkCellView *cellview) { - GtkCellViewPrivate *priv; - - cellview->priv = G_TYPE_INSTANCE_GET_PRIVATE (cellview, - GTK_TYPE_CELL_VIEW, - GtkCellViewPrivate); - priv = cellview->priv; + cellview->priv = gtk_cell_view_get_instance_private (cellview); + cellview->priv->orientation = GTK_ORIENTATION_HORIZONTAL; gtk_widget_set_has_window (GTK_WIDGET (cellview), FALSE); - - priv->orientation = GTK_ORIENTATION_HORIZONTAL; } static void diff --git a/gtk/gtkcheckmenuitem.c b/gtk/gtkcheckmenuitem.c index 64167a0284..e29d88e2c8 100644 --- a/gtk/gtkcheckmenuitem.c +++ b/gtk/gtkcheckmenuitem.c @@ -97,6 +97,7 @@ static guint check_menu_item_signals[LAST_SIGNAL] = { 0 }; G_GNUC_BEGIN_IGNORE_DEPRECATIONS; G_DEFINE_TYPE_WITH_CODE (GtkCheckMenuItem, gtk_check_menu_item, GTK_TYPE_MENU_ITEM, + G_ADD_PRIVATE (GtkCheckMenuItem) G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE, gtk_check_menu_item_activatable_interface_init)) G_GNUC_END_IGNORE_DEPRECATIONS; @@ -176,8 +177,6 @@ gtk_check_menu_item_class_init (GtkCheckMenuItemClass *klass) NULL, NULL, _gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); - - g_type_class_add_private (klass, sizeof (GtkCheckMenuItemPrivate)); } static void @@ -482,14 +481,8 @@ gtk_check_menu_item_get_draw_as_radio (GtkCheckMenuItem *check_menu_item) static void gtk_check_menu_item_init (GtkCheckMenuItem *check_menu_item) { - GtkCheckMenuItemPrivate *priv; - - check_menu_item->priv = G_TYPE_INSTANCE_GET_PRIVATE (check_menu_item, - GTK_TYPE_CHECK_MENU_ITEM, - GtkCheckMenuItemPrivate); - priv = check_menu_item->priv; - - priv->active = FALSE; + check_menu_item->priv = gtk_check_menu_item_get_instance_private (check_menu_item); + check_menu_item->priv->active = FALSE; } static gint diff --git a/gtk/gtkcolorbutton.c b/gtk/gtkcolorbutton.c index f607bf5244..ae9afd14e2 100644 --- a/gtk/gtkcolorbutton.c +++ b/gtk/gtkcolorbutton.c @@ -136,6 +136,7 @@ static const GtkTargetEntry drop_types[] = { { "application/x-color", 0, 0 } }; static void gtk_color_button_iface_init (GtkColorChooserInterface *iface); G_DEFINE_TYPE_WITH_CODE (GtkColorButton, gtk_color_button, GTK_TYPE_BUTTON, + G_ADD_PRIVATE (GtkColorButton) G_IMPLEMENT_INTERFACE (GTK_TYPE_COLOR_CHOOSER, gtk_color_button_iface_init)) @@ -257,8 +258,6 @@ gtk_color_button_class_init (GtkColorButtonClass *klass) NULL, NULL, _gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); - - g_type_class_add_private (gobject_class, sizeof (GtkColorButtonPrivate)); } static gboolean @@ -427,9 +426,7 @@ gtk_color_button_init (GtkColorButton *button) PangoRectangle rect; /* Create the widgets */ - button->priv = G_TYPE_INSTANCE_GET_PRIVATE (button, - GTK_TYPE_COLOR_BUTTON, - GtkColorButtonPrivate); + button->priv = gtk_color_button_get_instance_private (button); button->priv->draw_area = gtk_drawing_area_new (); layout = gtk_widget_create_pango_layout (GTK_WIDGET (button), "Black"); diff --git a/gtk/gtkcolorchooserdialog.c b/gtk/gtkcolorchooserdialog.c index 51851aa7ec..b8c18487e0 100644 --- a/gtk/gtkcolorchooserdialog.c +++ b/gtk/gtkcolorchooserdialog.c @@ -58,6 +58,7 @@ enum static void gtk_color_chooser_dialog_iface_init (GtkColorChooserInterface *iface); G_DEFINE_TYPE_WITH_CODE (GtkColorChooserDialog, gtk_color_chooser_dialog, GTK_TYPE_DIALOG, + G_ADD_PRIVATE (GtkColorChooserDialog) G_IMPLEMENT_INTERFACE (GTK_TYPE_COLOR_CHOOSER, gtk_color_chooser_dialog_iface_init)) @@ -100,9 +101,7 @@ selected_cb (GtkButton *button, static void gtk_color_chooser_dialog_init (GtkColorChooserDialog *cc) { - cc->priv = G_TYPE_INSTANCE_GET_PRIVATE (cc, - GTK_TYPE_COLOR_CHOOSER_DIALOG, - GtkColorChooserDialogPrivate); + cc->priv = gtk_color_chooser_dialog_get_instance_private (cc); gtk_widget_init_template (GTK_WIDGET (cc)); } @@ -209,8 +208,6 @@ gtk_color_chooser_dialog_class_init (GtkColorChooserDialogClass *class) gtk_widget_class_bind_callback (widget_class, selected_cb); gtk_widget_class_bind_callback (widget_class, propagate_notify); gtk_widget_class_bind_callback (widget_class, color_activated_cb); - - g_type_class_add_private (class, sizeof (GtkColorChooserDialogPrivate)); } static void diff --git a/gtk/gtkcolorchooserwidget.c b/gtk/gtkcolorchooserwidget.c index 8e6cf2c82e..71bdc89dc0 100644 --- a/gtk/gtkcolorchooserwidget.c +++ b/gtk/gtkcolorchooserwidget.c @@ -87,6 +87,7 @@ enum static void gtk_color_chooser_widget_iface_init (GtkColorChooserInterface *iface); G_DEFINE_TYPE_WITH_CODE (GtkColorChooserWidget, gtk_color_chooser_widget, GTK_TYPE_BOX, + G_ADD_PRIVATE (GtkColorChooserWidget) G_IMPLEMENT_INTERFACE (GTK_TYPE_COLOR_CHOOSER, gtk_color_chooser_widget_iface_init)) @@ -502,7 +503,7 @@ gtk_color_chooser_widget_init (GtkColorChooserWidget *cc) AtkObject *atk_obj; gchar *text, *name; - cc->priv = G_TYPE_INSTANCE_GET_PRIVATE (cc, GTK_TYPE_COLOR_CHOOSER_WIDGET, GtkColorChooserWidgetPrivate); + cc->priv = gtk_color_chooser_widget_get_instance_private (cc); cc->priv->use_alpha = TRUE; @@ -677,8 +678,6 @@ gtk_color_chooser_widget_class_init (GtkColorChooserWidgetClass *class) g_object_class_install_property (object_class, PROP_SHOW_EDITOR, g_param_spec_boolean ("show-editor", P_("Show editor"), P_("Show editor"), FALSE, GTK_PARAM_READWRITE)); - - g_type_class_add_private (object_class, sizeof (GtkColorChooserWidgetPrivate)); } /* GtkColorChooser implementation {{{1 */ diff --git a/gtk/gtkcoloreditor.c b/gtk/gtkcoloreditor.c index d3925c56ce..855cbcbe42 100644 --- a/gtk/gtkcoloreditor.c +++ b/gtk/gtkcoloreditor.c @@ -81,6 +81,7 @@ enum static void gtk_color_editor_iface_init (GtkColorChooserInterface *iface); G_DEFINE_TYPE_WITH_CODE (GtkColorEditor, gtk_color_editor, GTK_TYPE_BOX, + G_ADD_PRIVATE (GtkColorEditor) G_IMPLEMENT_INTERFACE (GTK_TYPE_COLOR_CHOOSER, gtk_color_editor_iface_init)) @@ -344,9 +345,7 @@ gtk_color_editor_init (GtkColorEditor *editor) { GdkRGBA transparent = { 0, 0, 0, 0 }; - editor->priv = G_TYPE_INSTANCE_GET_PRIVATE (editor, - GTK_TYPE_COLOR_EDITOR, - GtkColorEditorPrivate); + editor->priv = gtk_color_editor_get_instance_private (editor); editor->priv->use_alpha = TRUE; g_type_ensure (GTK_TYPE_COLOR_SCALE); @@ -493,8 +492,6 @@ gtk_color_editor_class_init (GtkColorEditorClass *class) gtk_widget_class_bind_callback (widget_class, entry_apply); gtk_widget_class_bind_callback (widget_class, entry_focus_out); gtk_widget_class_bind_callback (widget_class, popup_edit); - - g_type_class_add_private (class, sizeof (GtkColorEditorPrivate)); } static void diff --git a/gtk/gtkcolorplane.c b/gtk/gtkcolorplane.c index 3a500115ed..78d5707a59 100644 --- a/gtk/gtkcolorplane.c +++ b/gtk/gtkcolorplane.c @@ -44,7 +44,7 @@ enum { PROP_V_ADJUSTMENT }; -G_DEFINE_TYPE (GtkColorPlane, gtk_color_plane, GTK_TYPE_DRAWING_AREA) +G_DEFINE_TYPE_WITH_PRIVATE (GtkColorPlane, gtk_color_plane, GTK_TYPE_DRAWING_AREA) static void sv_to_xy (GtkColorPlane *plane, @@ -428,9 +428,7 @@ gtk_color_plane_init (GtkColorPlane *plane) { AtkObject *atk_obj; - plane->priv = G_TYPE_INSTANCE_GET_PRIVATE (plane, - GTK_TYPE_COLOR_PLANE, - GtkColorPlanePrivate); + plane->priv = gtk_color_plane_get_instance_private (plane); gtk_widget_set_can_focus (GTK_WIDGET (plane), TRUE); gtk_widget_set_events (GTK_WIDGET (plane), GDK_KEY_PRESS_MASK @@ -552,8 +550,6 @@ gtk_color_plane_class_init (GtkColorPlaneClass *class) GTK_TYPE_ADJUSTMENT, G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); - - g_type_class_add_private (class, sizeof (GtkColorPlanePrivate)); } GtkWidget * @@ -561,13 +557,9 @@ gtk_color_plane_new (GtkAdjustment *h_adj, GtkAdjustment *s_adj, GtkAdjustment *v_adj) { - GtkColorPlane *plane; - - plane = (GtkColorPlane *) g_object_new (GTK_TYPE_COLOR_PLANE, - "h-adjustment", h_adj, - "s-adjustment", s_adj, - "v-adjustment", v_adj, - NULL); - - return (GtkWidget *)plane; + return g_object_new (GTK_TYPE_COLOR_PLANE, + "h-adjustment", h_adj, + "s-adjustment", s_adj, + "v-adjustment", v_adj, + NULL); } diff --git a/gtk/gtkcolorscale.c b/gtk/gtkcolorscale.c index 88e4459b59..2226ba04e5 100644 --- a/gtk/gtkcolorscale.c +++ b/gtk/gtkcolorscale.c @@ -46,7 +46,7 @@ enum PROP_SCALE_TYPE }; -G_DEFINE_TYPE (GtkColorScale, gtk_color_scale, GTK_TYPE_SCALE) +G_DEFINE_TYPE_WITH_PRIVATE (GtkColorScale, gtk_color_scale, GTK_TYPE_SCALE) static void gtk_color_scale_get_trough_size (GtkColorScale *scale, @@ -248,9 +248,8 @@ scale_draw (GtkWidget *widget, static void gtk_color_scale_init (GtkColorScale *scale) { - scale->priv = G_TYPE_INSTANCE_GET_PRIVATE (scale, - GTK_TYPE_COLOR_SCALE, - GtkColorScalePrivate); + scale->priv = gtk_color_scale_get_instance_private (scale); + gtk_widget_add_events (GTK_WIDGET (scale), GDK_TOUCH_MASK); } @@ -383,8 +382,6 @@ gtk_color_scale_class_init (GtkColorScaleClass *class) g_param_spec_int ("scale-type", P_("Scale type"), P_("Scale type"), 0, 1, 0, GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_type_class_add_private (class, sizeof (GtkColorScalePrivate)); } void @@ -401,9 +398,9 @@ GtkWidget * gtk_color_scale_new (GtkAdjustment *adjustment, GtkColorScaleType type) { - return (GtkWidget *) g_object_new (GTK_TYPE_COLOR_SCALE, - "adjustment", adjustment, - "draw-value", FALSE, - "scale-type", type, - NULL); + return g_object_new (GTK_TYPE_COLOR_SCALE, + "adjustment", adjustment, + "draw-value", FALSE, + "scale-type", type, + NULL); } diff --git a/gtk/gtkcolorswatch.c b/gtk/gtkcolorswatch.c index 8770f19e02..a4073fd781 100644 --- a/gtk/gtkcolorswatch.c +++ b/gtk/gtkcolorswatch.c @@ -65,20 +65,17 @@ enum static guint signals[LAST_SIGNAL]; -G_DEFINE_TYPE (GtkColorSwatch, gtk_color_swatch, GTK_TYPE_WIDGET) +G_DEFINE_TYPE_WITH_PRIVATE (GtkColorSwatch, gtk_color_swatch, GTK_TYPE_WIDGET) static void gtk_color_swatch_init (GtkColorSwatch *swatch) { - swatch->priv = G_TYPE_INSTANCE_GET_PRIVATE (swatch, - GTK_TYPE_COLOR_SWATCH, - GtkColorSwatchPrivate); + swatch->priv = gtk_color_swatch_get_instance_private (swatch); + swatch->priv->use_alpha = TRUE; + swatch->priv->selectable = TRUE; gtk_widget_set_can_focus (GTK_WIDGET (swatch), TRUE); gtk_widget_set_has_window (GTK_WIDGET (swatch), FALSE); - - swatch->priv->use_alpha = TRUE; - swatch->priv->selectable = TRUE; } #define INTENSITY(r, g, b) ((r) * 0.30 + (g) * 0.59 + (b) * 0.11) @@ -782,8 +779,6 @@ gtk_color_swatch_class_init (GtkColorSwatchClass *class) g_param_spec_boolean ("selectable", P_("Selectable"), P_("Whether the swatch is selectable"), TRUE, GTK_PARAM_READWRITE)); - g_type_class_add_private (object_class, sizeof (GtkColorSwatchPrivate)); - gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_COLOR_SWATCH_ACCESSIBLE); } diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c index 794cd00dd3..c5ecb293e4 100644 --- a/gtk/gtkcombobox.c +++ b/gtk/gtkcombobox.c @@ -472,6 +472,7 @@ static void gtk_combo_box_direction_changed (GtkWidget *widg GtkTextDirection previous_direction); G_DEFINE_TYPE_WITH_CODE (GtkComboBox, gtk_combo_box, GTK_TYPE_BIN, + G_ADD_PRIVATE (GtkComboBox) G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_LAYOUT, gtk_combo_box_cell_layout_init) G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_EDITABLE, @@ -1070,8 +1071,6 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass) GTK_SHADOW_NONE, GTK_PARAM_READABLE)); - g_type_class_add_private (object_class, sizeof (GtkComboBoxPrivate)); - gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_COMBO_BOX_ACCESSIBLE); } @@ -1102,9 +1101,7 @@ gtk_combo_box_init (GtkComboBox *combo_box) { GtkComboBoxPrivate *priv; - combo_box->priv = G_TYPE_INSTANCE_GET_PRIVATE (combo_box, - GTK_TYPE_COMBO_BOX, - GtkComboBoxPrivate); + combo_box->priv = gtk_combo_box_get_instance_private (combo_box); priv = combo_box->priv; priv->wrap_width = 0; diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c index 2d6d2df9e4..989a36f307 100644 --- a/gtk/gtkcontainer.c +++ b/gtk/gtkcontainer.c @@ -356,6 +356,7 @@ static guint vadjustment_key_id = 0; static const gchar hadjustment_key[] = "gtk-hadjustment"; static guint hadjustment_key_id = 0; static guint container_signals[LAST_SIGNAL] = { 0 }; +static gint GtkContainer_private_offset; static GtkWidgetClass *parent_class = NULL; extern GParamSpecPool *_gtk_widget_child_property_pool; extern GObjectNotifyContext *_gtk_widget_child_property_notify_context; @@ -363,6 +364,12 @@ static GtkBuildableIface *parent_buildable_iface; /* --- functions --- */ +static inline gpointer +gtk_container_get_instance_private (GtkContainer *self) +{ + return G_STRUCT_MEMBER_P (self, GtkContainer_private_offset); +} + GType gtk_container_get_type (void) { @@ -395,6 +402,9 @@ gtk_container_get_type (void) g_type_register_static (GTK_TYPE_WIDGET, I_("GtkContainer"), &container_info, G_TYPE_FLAG_ABSTRACT); + GtkContainer_private_offset = + g_type_add_instance_private (container_type, sizeof (GtkContainerPrivate)); + g_type_add_interface_static (container_type, GTK_TYPE_BUILDABLE, &buildable_info); @@ -526,7 +536,8 @@ gtk_container_class_init (GtkContainerClass *class) G_TYPE_NONE, 1, GTK_TYPE_WIDGET); - g_type_class_add_private (class, sizeof (GtkContainerPrivate)); + if (GtkContainer_private_offset != 0) + g_type_class_adjust_private_offset (class, &GtkContainer_private_offset); gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_CONTAINER_ACCESSIBLE); } @@ -1348,9 +1359,7 @@ gtk_container_init (GtkContainer *container) { GtkContainerPrivate *priv; - container->priv = G_TYPE_INSTANCE_GET_PRIVATE (container, - GTK_TYPE_CONTAINER, - GtkContainerPrivate); + container->priv = gtk_container_get_instance_private (container); priv = container->priv; priv->focus_child = NULL; diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index a480dfb97a..e8245587e0 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1047,6 +1047,7 @@ gtk_css_provider_error_quark (void) } G_DEFINE_TYPE_EXTENDED (GtkCssProvider, gtk_css_provider, G_TYPE_OBJECT, 0, + G_ADD_PRIVATE (GtkCssProvider) G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER, gtk_css_style_provider_iface_init) G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER_PRIVATE, @@ -1116,8 +1117,6 @@ gtk_css_provider_class_init (GtkCssProviderClass *klass) object_class->finalize = gtk_css_provider_finalize; klass->parsing_error = gtk_css_provider_parsing_error; - - g_type_class_add_private (object_class, sizeof (GtkCssProviderPrivate)); } static void @@ -1387,9 +1386,7 @@ gtk_css_provider_init (GtkCssProvider *css_provider) { GtkCssProviderPrivate *priv; - priv = css_provider->priv = G_TYPE_INSTANCE_GET_PRIVATE (css_provider, - GTK_TYPE_CSS_PROVIDER, - GtkCssProviderPrivate); + priv = css_provider->priv = gtk_css_provider_get_instance_private (css_provider); priv->rulesets = g_array_new (FALSE, FALSE, sizeof (GtkCssRuleset)); diff --git a/gtk/gtkcustompaperunixdialog.c b/gtk/gtkcustompaperunixdialog.c index f637e131ab..713bb7e0bc 100644 --- a/gtk/gtkcustompaperunixdialog.c +++ b/gtk/gtkcustompaperunixdialog.c @@ -86,7 +86,7 @@ enum { }; -G_DEFINE_TYPE (GtkCustomPaperUnixDialog, gtk_custom_paper_unix_dialog, GTK_TYPE_DIALOG) +G_DEFINE_TYPE_WITH_PRIVATE (GtkCustomPaperUnixDialog, gtk_custom_paper_unix_dialog, GTK_TYPE_DIALOG) static void gtk_custom_paper_unix_dialog_finalize (GObject *object); @@ -269,13 +269,7 @@ _gtk_print_save_custom_papers (GtkListStore *store) static void gtk_custom_paper_unix_dialog_class_init (GtkCustomPaperUnixDialogClass *class) { - GObjectClass *object_class; - - object_class = (GObjectClass *) class; - - object_class->finalize = gtk_custom_paper_unix_dialog_finalize; - - g_type_class_add_private (class, sizeof (GtkCustomPaperUnixDialogPrivate)); + G_OBJECT_CLASS (class)->finalize = gtk_custom_paper_unix_dialog_finalize; } static void @@ -294,9 +288,7 @@ gtk_custom_paper_unix_dialog_init (GtkCustomPaperUnixDialog *dialog) GtkCustomPaperUnixDialogPrivate *priv; GtkTreeIter iter; - dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (dialog, - GTK_TYPE_CUSTOM_PAPER_UNIX_DIALOG, - GtkCustomPaperUnixDialogPrivate); + dialog->priv = gtk_custom_paper_unix_dialog_get_instance_private (dialog); priv = dialog->priv; priv->print_backends = NULL; diff --git a/gtk/gtkdialog.c b/gtk/gtkdialog.c index cd20b8d551..28e9480d9b 100644 --- a/gtk/gtkdialog.c +++ b/gtk/gtkdialog.c @@ -223,17 +223,16 @@ enum { static guint dialog_signals[LAST_SIGNAL]; G_DEFINE_TYPE_WITH_CODE (GtkDialog, gtk_dialog, GTK_TYPE_WINDOW, + G_ADD_PRIVATE (GtkDialog) G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_dialog_buildable_interface_init)) static void gtk_dialog_class_init (GtkDialogClass *class) { - GObjectClass *gobject_class; GtkWidgetClass *widget_class; GtkBindingSet *binding_set; - gobject_class = G_OBJECT_CLASS (class); widget_class = GTK_WIDGET_CLASS (class); widget_class->map = gtk_dialog_map; @@ -243,8 +242,6 @@ gtk_dialog_class_init (GtkDialogClass *class) class->close = gtk_dialog_close; - g_type_class_add_private (gobject_class, sizeof (GtkDialogPrivate)); - /** * GtkDialog::response: * @dialog: the object on which the signal is emitted @@ -371,9 +368,7 @@ update_spacings (GtkDialog *dialog) static void gtk_dialog_init (GtkDialog *dialog) { - dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (dialog, - GTK_TYPE_DIALOG, - GtkDialogPrivate); + dialog->priv = gtk_dialog_get_instance_private (dialog); gtk_widget_init_template (GTK_WIDGET (dialog)); diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 25dd4b0ad6..581a7b3287 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -642,6 +642,7 @@ static void buffer_disconnect_signals (GtkEntry *entry); static GtkEntryBuffer *get_buffer (GtkEntry *entry); G_DEFINE_TYPE_WITH_CODE (GtkEntry, gtk_entry, GTK_TYPE_WIDGET, + G_ADD_PRIVATE (GtkEntry) G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE, gtk_entry_editable_init) G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_EDITABLE, @@ -1994,7 +1995,6 @@ gtk_entry_class_init (GtkEntryClass *class) GTK_PARAM_READABLE | G_PARAM_DEPRECATED)); - g_type_class_add_private (gobject_class, sizeof (GtkEntryPrivate)); test_touchscreen = g_getenv ("GTK_TEST_TOUCHSCREEN") != NULL; gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_ENTRY_ACCESSIBLE); @@ -2590,9 +2590,7 @@ gtk_entry_init (GtkEntry *entry) GtkStyleContext *context; GtkEntryPrivate *priv; - entry->priv = G_TYPE_INSTANCE_GET_PRIVATE (entry, - GTK_TYPE_ENTRY, - GtkEntryPrivate); + entry->priv = gtk_entry_get_instance_private (entry); priv = entry->priv; gtk_widget_set_can_focus (GTK_WIDGET (entry), TRUE); diff --git a/gtk/gtkentrybuffer.c b/gtk/gtkentrybuffer.c index 2190a10f71..067048ff97 100644 --- a/gtk/gtkentrybuffer.c +++ b/gtk/gtkentrybuffer.c @@ -76,7 +76,7 @@ struct _GtkEntryBufferPrivate gint max_length; }; -G_DEFINE_TYPE (GtkEntryBuffer, gtk_entry_buffer, G_TYPE_OBJECT); +G_DEFINE_TYPE_WITH_PRIVATE (GtkEntryBuffer, gtk_entry_buffer, G_TYPE_OBJECT) /* -------------------------------------------------------------------------------- * DEFAULT IMPLEMENTATIONS OF TEXT BUFFER @@ -245,7 +245,7 @@ gtk_entry_buffer_init (GtkEntryBuffer *buffer) { GtkEntryBufferPrivate *pv; - pv = buffer->priv = G_TYPE_INSTANCE_GET_PRIVATE (buffer, GTK_TYPE_ENTRY_BUFFER, GtkEntryBufferPrivate); + pv = buffer->priv = gtk_entry_buffer_get_instance_private (buffer); pv->normal_text = NULL; pv->normal_text_chars = 0; @@ -335,8 +335,6 @@ gtk_entry_buffer_class_init (GtkEntryBufferClass *klass) klass->inserted_text = gtk_entry_buffer_real_inserted_text; klass->deleted_text = gtk_entry_buffer_real_deleted_text; - g_type_class_add_private (gobject_class, sizeof (GtkEntryBufferPrivate)); - /** * GtkEntryBuffer:text: * diff --git a/gtk/gtkentrycompletion.c b/gtk/gtkentrycompletion.c index b0bf1c8695..582287a422 100644 --- a/gtk/gtkentrycompletion.c +++ b/gtk/gtkentrycompletion.c @@ -189,6 +189,7 @@ static guint entry_completion_signals[LAST_SIGNAL] = { 0 }; static void gtk_entry_completion_buildable_init (GtkBuildableIface *iface); G_DEFINE_TYPE_WITH_CODE (GtkEntryCompletion, gtk_entry_completion, G_TYPE_OBJECT, + G_ADD_PRIVATE (GtkEntryCompletion) G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_LAYOUT, gtk_entry_completion_cell_layout_init) G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, @@ -452,8 +453,6 @@ gtk_entry_completion_class_init (GtkEntryCompletionClass *klass) P_("The GtkCellArea used to layout cells"), GTK_TYPE_CELL_AREA, GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_type_class_add_private (object_class, sizeof (GtkEntryCompletionPrivate)); } @@ -488,9 +487,7 @@ gtk_entry_completion_init (GtkEntryCompletion *completion) GtkEntryCompletionPrivate *priv; /* yes, also priv, need to keep the code readable */ - completion->priv = G_TYPE_INSTANCE_GET_PRIVATE (completion, - GTK_TYPE_ENTRY_COMPLETION, - GtkEntryCompletionPrivate); + completion->priv = gtk_entry_completion_get_instance_private (completion); priv = completion->priv; priv->minimum_key_length = 1; diff --git a/gtk/gtkeventbox.c b/gtk/gtkeventbox.c index b696d1b1e3..4ed207e758 100644 --- a/gtk/gtkeventbox.c +++ b/gtk/gtkeventbox.c @@ -84,7 +84,7 @@ static void gtk_event_box_get_property (GObject *object, GValue *value, GParamSpec *pspec); -G_DEFINE_TYPE (GtkEventBox, gtk_event_box, GTK_TYPE_BIN) +G_DEFINE_TYPE_WITH_PRIVATE (GtkEventBox, gtk_event_box, GTK_TYPE_BIN) static void gtk_event_box_class_init (GtkEventBoxClass *class) @@ -122,23 +122,15 @@ gtk_event_box_class_init (GtkEventBoxClass *class) P_("Whether the event-trapping window of the eventbox is above the window of the child widget as opposed to below it."), FALSE, GTK_PARAM_READWRITE)); - - g_type_class_add_private (class, sizeof (GtkEventBoxPrivate)); } static void gtk_event_box_init (GtkEventBox *event_box) { - GtkEventBoxPrivate *priv; - gtk_widget_set_has_window (GTK_WIDGET (event_box), TRUE); - priv = G_TYPE_INSTANCE_GET_PRIVATE (event_box, - GTK_TYPE_EVENT_BOX, - GtkEventBoxPrivate); - - event_box->priv = priv; - priv->above_child = FALSE; + event_box->priv = gtk_event_box_get_instance_private (event_box); + event_box->priv->above_child = FALSE; } /** diff --git a/gtk/gtkexpander.c b/gtk/gtkexpander.c index 6f6a196a6f..dac07465b2 100644 --- a/gtk/gtkexpander.c +++ b/gtk/gtkexpander.c @@ -228,6 +228,7 @@ static void gtk_expander_get_preferred_width_for_height (GtkWidget * gint *natural_height); G_DEFINE_TYPE_WITH_CODE (GtkExpander, gtk_expander, GTK_TYPE_BIN, + G_ADD_PRIVATE (GtkExpander) G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_expander_buildable_init)) @@ -272,8 +273,6 @@ gtk_expander_class_init (GtkExpanderClass *klass) klass->activate = gtk_expander_activate; - g_type_class_add_private (klass, sizeof (GtkExpanderPrivate)); - g_object_class_install_property (gobject_class, PROP_EXPANDED, g_param_spec_boolean ("expanded", @@ -383,9 +382,7 @@ gtk_expander_init (GtkExpander *expander) { GtkExpanderPrivate *priv; - expander->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (expander, - GTK_TYPE_EXPANDER, - GtkExpanderPrivate); + expander->priv = priv = gtk_expander_get_instance_private (expander); gtk_widget_set_can_focus (GTK_WIDGET (expander), TRUE); gtk_widget_set_has_window (GTK_WIDGET (expander), FALSE); diff --git a/gtk/gtkfilechooserbutton.c b/gtk/gtkfilechooserbutton.c index c69870e8f2..6259b08664 100644 --- a/gtk/gtkfilechooserbutton.c +++ b/gtk/gtkfilechooserbutton.c @@ -352,9 +352,10 @@ static guint file_chooser_button_signals[LAST_SIGNAL] = { 0 }; * GType Declaration * * ******************* */ -G_DEFINE_TYPE_WITH_CODE (GtkFileChooserButton, gtk_file_chooser_button, GTK_TYPE_BOX, { \ - G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_CHOOSER, gtk_file_chooser_button_file_chooser_iface_init) \ -}) +G_DEFINE_TYPE_WITH_CODE (GtkFileChooserButton, gtk_file_chooser_button, GTK_TYPE_BOX, + G_ADD_PRIVATE (GtkFileChooserButton) + G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_CHOOSER, + gtk_file_chooser_button_file_chooser_iface_init)) /* ***************** * @@ -482,8 +483,6 @@ gtk_file_chooser_button_class_init (GtkFileChooserButtonClass * class) gtk_widget_class_bind_callback (widget_class, button_clicked_cb); gtk_widget_class_bind_callback (widget_class, combo_box_changed_cb); gtk_widget_class_bind_callback (widget_class, combo_box_notify_popup_shown_cb); - - g_type_class_add_private (class, sizeof (GtkFileChooserButtonPrivate)); } static void @@ -492,9 +491,7 @@ gtk_file_chooser_button_init (GtkFileChooserButton *button) GtkFileChooserButtonPrivate *priv; GtkTargetList *target_list; - priv = button->priv = G_TYPE_INSTANCE_GET_PRIVATE (button, - GTK_TYPE_FILE_CHOOSER_BUTTON, - GtkFileChooserButtonPrivate); + priv = button->priv = gtk_file_chooser_button_get_instance_private (button); priv->icon_size = FALLBACK_ICON_SIZE; priv->focus_on_click = TRUE; diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c index d1e4ceafd7..33b5178d0b 100644 --- a/gtk/gtkfilechooserdefault.c +++ b/gtk/gtkfilechooserdefault.c @@ -546,6 +546,7 @@ static void unset_file_system_backend (GtkFileChooserDefault *impl); G_DEFINE_TYPE_WITH_CODE (GtkFileChooserDefault, _gtk_file_chooser_default, GTK_TYPE_BOX, + G_ADD_PRIVATE (GtkFileChooserDefault) G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_CHOOSER, gtk_file_chooser_default_iface_init) G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_CHOOSER_EMBED, @@ -7472,8 +7473,6 @@ _gtk_file_chooser_default_class_init (GtkFileChooserDefaultClass *class) _gtk_file_chooser_install_properties (gobject_class); - g_type_class_add_private (gobject_class, sizeof (GtkFileChooserDefaultPrivate)); - /* Bind class to template */ gtk_widget_class_set_template_from_resource (widget_class, @@ -7596,9 +7595,7 @@ _gtk_file_chooser_default_init (GtkFileChooserDefault *impl) #ifdef PROFILE_FILE_CHOOSER access ("MARK: *** CREATE FILE CHOOSER", F_OK); #endif - impl->priv = G_TYPE_INSTANCE_GET_PRIVATE (impl, - GTK_TYPE_FILE_CHOOSER_DEFAULT, - GtkFileChooserDefaultPrivate); + impl->priv = _gtk_file_chooser_default_get_instance_private (impl); priv = impl->priv; priv->local_only = TRUE; diff --git a/gtk/gtkfilechooserdialog.c b/gtk/gtkfilechooserdialog.c index f3e521db54..1136c2c8ef 100644 --- a/gtk/gtkfilechooserdialog.c +++ b/gtk/gtkfilechooserdialog.c @@ -201,8 +201,6 @@ struct _GtkFileChooserDialogPrivate gboolean response_requested; }; -#define GTK_FILE_CHOOSER_DIALOG_GET_PRIVATE(o) (GTK_FILE_CHOOSER_DIALOG (o)->priv) - static void gtk_file_chooser_dialog_set_property (GObject *object, guint prop_id, const GValue *value, @@ -225,6 +223,7 @@ static void response_cb (GtkDialog *dialog, gint response_id); G_DEFINE_TYPE_WITH_CODE (GtkFileChooserDialog, gtk_file_chooser_dialog, GTK_TYPE_DIALOG, + G_ADD_PRIVATE (GtkFileChooserDialog) G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_CHOOSER, _gtk_file_chooser_delegate_iface_init)) @@ -254,23 +253,18 @@ gtk_file_chooser_dialog_class_init (GtkFileChooserDialogClass *class) gtk_widget_class_bind_callback (widget_class, file_chooser_widget_file_activated); gtk_widget_class_bind_callback (widget_class, file_chooser_widget_default_size_changed); gtk_widget_class_bind_callback (widget_class, file_chooser_widget_response_requested); - - g_type_class_add_private (class, sizeof (GtkFileChooserDialogPrivate)); } static void gtk_file_chooser_dialog_init (GtkFileChooserDialog *dialog) { - GtkFileChooserDialogPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (dialog, - GTK_TYPE_FILE_CHOOSER_DIALOG, - GtkFileChooserDialogPrivate); - dialog->priv = priv; + dialog->priv = gtk_file_chooser_dialog_get_instance_private (dialog); dialog->priv->response_requested = FALSE; gtk_widget_init_template (GTK_WIDGET (dialog)); _gtk_file_chooser_set_delegate (GTK_FILE_CHOOSER (dialog), - GTK_FILE_CHOOSER (priv->widget)); + GTK_FILE_CHOOSER (dialog->priv->widget)); } static gboolean @@ -345,7 +339,7 @@ file_chooser_widget_default_size_changed (GtkWidget *widget, gint default_width, default_height; GtkRequisition req, widget_req; - priv = GTK_FILE_CHOOSER_DIALOG_GET_PRIVATE (dialog); + priv = gtk_file_chooser_dialog_get_instance_private (dialog); /* Unset any previously set size */ gtk_widget_set_size_request (GTK_WIDGET (dialog), -1, -1); @@ -430,7 +424,9 @@ gtk_file_chooser_dialog_set_property (GObject *object, GParamSpec *pspec) { - GtkFileChooserDialogPrivate *priv = GTK_FILE_CHOOSER_DIALOG_GET_PRIVATE (object); + GtkFileChooserDialogPrivate *priv; + + priv = gtk_file_chooser_dialog_get_instance_private (GTK_FILE_CHOOSER_DIALOG (object)); switch (prop_id) { @@ -446,7 +442,9 @@ gtk_file_chooser_dialog_get_property (GObject *object, GValue *value, GParamSpec *pspec) { - GtkFileChooserDialogPrivate *priv = GTK_FILE_CHOOSER_DIALOG_GET_PRIVATE (object); + GtkFileChooserDialogPrivate *priv; + + priv = gtk_file_chooser_dialog_get_instance_private (GTK_FILE_CHOOSER_DIALOG (object)); g_object_get_property (G_OBJECT (priv->widget), pspec->name, value); } @@ -479,7 +477,7 @@ static void gtk_file_chooser_dialog_map (GtkWidget *widget) { GtkFileChooserDialog *dialog = GTK_FILE_CHOOSER_DIALOG (widget); - GtkFileChooserDialogPrivate *priv = GTK_FILE_CHOOSER_DIALOG_GET_PRIVATE (dialog); + GtkFileChooserDialogPrivate *priv = dialog->priv; ensure_default_response (dialog); @@ -528,7 +526,7 @@ response_cb (GtkDialog *dialog, { GtkFileChooserDialogPrivate *priv; - priv = GTK_FILE_CHOOSER_DIALOG_GET_PRIVATE (dialog); + priv = gtk_file_chooser_dialog_get_instance_private (GTK_FILE_CHOOSER_DIALOG (dialog)); /* Act only on response IDs we recognize */ if (is_stock_accept_response_id (response_id) diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c index bce30977ba..92618fa572 100644 --- a/gtk/gtkfilechooserwidget.c +++ b/gtk/gtkfilechooserwidget.c @@ -50,8 +50,6 @@ struct _GtkFileChooserWidgetPrivate GtkWidget *impl; }; -#define GTK_FILE_CHOOSER_WIDGET_GET_PRIVATE(o) (GTK_FILE_CHOOSER_WIDGET (o)->priv) - static GObject* gtk_file_chooser_widget_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_params); @@ -65,6 +63,7 @@ static void gtk_file_chooser_widget_get_property (GObject *obj GParamSpec *pspec); G_DEFINE_TYPE_WITH_CODE (GtkFileChooserWidget, gtk_file_chooser_widget, GTK_TYPE_BOX, + G_ADD_PRIVATE (GtkFileChooserWidget) G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_CHOOSER, _gtk_file_chooser_delegate_iface_init) G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_CHOOSER_EMBED, @@ -80,18 +79,14 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class) gobject_class->get_property = gtk_file_chooser_widget_get_property; _gtk_file_chooser_install_properties (gobject_class); - - g_type_class_add_private (class, sizeof (GtkFileChooserWidgetPrivate)); } static void -gtk_file_chooser_widget_init (GtkFileChooserWidget *chooser_widget) +gtk_file_chooser_widget_init (GtkFileChooserWidget *self) { - GtkFileChooserWidgetPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (chooser_widget, - GTK_TYPE_FILE_CHOOSER_WIDGET, - GtkFileChooserWidgetPrivate); - chooser_widget->priv = priv; - gtk_orientable_set_orientation (GTK_ORIENTABLE (chooser_widget), + self->priv = gtk_file_chooser_widget_get_instance_private (self); + + gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_VERTICAL); } @@ -106,7 +101,7 @@ gtk_file_chooser_widget_constructor (GType type, object = G_OBJECT_CLASS (gtk_file_chooser_widget_parent_class)->constructor (type, n_construct_properties, construct_params); - priv = GTK_FILE_CHOOSER_WIDGET_GET_PRIVATE (object); + priv = gtk_file_chooser_widget_get_instance_private (GTK_FILE_CHOOSER_WIDGET (object)); priv->impl = _gtk_file_chooser_default_new (); @@ -128,7 +123,9 @@ gtk_file_chooser_widget_set_property (GObject *object, const GValue *value, GParamSpec *pspec) { - GtkFileChooserWidgetPrivate *priv = GTK_FILE_CHOOSER_WIDGET_GET_PRIVATE (object); + GtkFileChooserWidgetPrivate *priv; + + priv = gtk_file_chooser_widget_get_instance_private (GTK_FILE_CHOOSER_WIDGET (object)); switch (prop_id) { @@ -144,7 +141,9 @@ gtk_file_chooser_widget_get_property (GObject *object, GValue *value, GParamSpec *pspec) { - GtkFileChooserWidgetPrivate *priv = GTK_FILE_CHOOSER_WIDGET_GET_PRIVATE (object); + GtkFileChooserWidgetPrivate *priv; + + priv = gtk_file_chooser_widget_get_instance_private (GTK_FILE_CHOOSER_WIDGET (object)); g_object_get_property (G_OBJECT (priv->impl), pspec->name, value); } diff --git a/gtk/gtkfilesystem.c b/gtk/gtkfilesystem.c index f1e041d2c3..65cca3f75a 100644 --- a/gtk/gtkfilesystem.c +++ b/gtk/gtkfilesystem.c @@ -93,7 +93,7 @@ struct AsyncFuncData gpointer data; }; -G_DEFINE_TYPE (GtkFileSystem, _gtk_file_system, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE (GtkFileSystem, _gtk_file_system, G_TYPE_OBJECT) /* GtkFileSystem methods */ @@ -151,8 +151,6 @@ _gtk_file_system_class_init (GtkFileSystemClass *class) NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - - g_type_class_add_private (object_class, sizeof (GtkFileSystemPrivate)); } static gboolean @@ -336,10 +334,7 @@ _gtk_file_system_init (GtkFileSystem *file_system) DEBUG ("init"); - file_system->priv = G_TYPE_INSTANCE_GET_PRIVATE (file_system, - GTK_TYPE_FILE_SYSTEM, - GtkFileSystemPrivate); - priv = file_system->priv; + file_system->priv = priv = _gtk_file_system_get_instance_private (file_system); /* Volumes */ priv->volume_monitor = g_volume_monitor_get (); diff --git a/gtk/gtkfixed.c b/gtk/gtkfixed.c index 14c35afc84..ec3467ffe3 100644 --- a/gtk/gtkfixed.c +++ b/gtk/gtkfixed.c @@ -120,7 +120,7 @@ static void gtk_fixed_get_child_property (GtkContainer *container, GValue *value, GParamSpec *pspec); -G_DEFINE_TYPE (GtkFixed, gtk_fixed, GTK_TYPE_CONTAINER) +G_DEFINE_TYPE_WITH_PRIVATE (GtkFixed, gtk_fixed, GTK_TYPE_CONTAINER) static void gtk_fixed_class_init (GtkFixedClass *class) @@ -159,8 +159,6 @@ gtk_fixed_class_init (GtkFixedClass *class) P_("Y position of child widget"), G_MININT, G_MAXINT, 0, GTK_PARAM_READWRITE)); - - g_type_class_add_private (class, sizeof (GtkFixedPrivate)); } static GType @@ -172,7 +170,7 @@ gtk_fixed_child_type (GtkContainer *container) static void gtk_fixed_init (GtkFixed *fixed) { - fixed->priv = G_TYPE_INSTANCE_GET_PRIVATE (fixed, GTK_TYPE_FIXED, GtkFixedPrivate); + fixed->priv = gtk_fixed_get_instance_private (fixed); gtk_widget_set_has_window (GTK_WIDGET (fixed), FALSE); diff --git a/gtk/gtkfontbutton.c b/gtk/gtkfontbutton.c index 3576364e26..529a13dcc3 100644 --- a/gtk/gtkfontbutton.c +++ b/gtk/gtkfontbutton.c @@ -398,6 +398,7 @@ gtk_font_button_font_chooser_iface_init (GtkFontChooserIface *iface) } G_DEFINE_TYPE_WITH_CODE (GtkFontButton, gtk_font_button, GTK_TYPE_BUTTON, + G_ADD_PRIVATE (GtkFontButton) G_IMPLEMENT_INTERFACE (GTK_TYPE_FONT_CHOOSER, gtk_font_button_font_chooser_iface_init)) @@ -547,16 +548,12 @@ gtk_font_button_class_init (GtkFontButtonClass *klass) gtk_widget_class_bind_child (widget_class, GtkFontButtonPrivate, font_label); gtk_widget_class_bind_child (widget_class, GtkFontButtonPrivate, size_label); gtk_widget_class_bind_child (widget_class, GtkFontButtonPrivate, font_size_box); - - g_type_class_add_private (gobject_class, sizeof (GtkFontButtonPrivate)); } static void gtk_font_button_init (GtkFontButton *font_button) { - font_button->priv = G_TYPE_INSTANCE_GET_PRIVATE (font_button, - GTK_TYPE_FONT_BUTTON, - GtkFontButtonPrivate); + font_button->priv = gtk_font_button_get_instance_private (font_button); /* Initialize fields */ font_button->priv->use_font = FALSE; diff --git a/gtk/gtkfontchooserdialog.c b/gtk/gtkfontchooserdialog.c index d1209ded9f..80750a307c 100644 --- a/gtk/gtkfontchooserdialog.c +++ b/gtk/gtkfontchooserdialog.c @@ -68,6 +68,7 @@ static GObject *gtk_font_chooser_dialog_buildable_get_internal_child (GtkBuildab const gchar *childname); G_DEFINE_TYPE_WITH_CODE (GtkFontChooserDialog, gtk_font_chooser_dialog, GTK_TYPE_DIALOG, + G_ADD_PRIVATE (GtkFontChooserDialog) G_IMPLEMENT_INTERFACE (GTK_TYPE_FONT_CHOOSER, _gtk_font_chooser_delegate_iface_init) G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, @@ -139,8 +140,6 @@ gtk_font_chooser_dialog_class_init (GtkFontChooserDialogClass *klass) gtk_widget_class_bind_child (widget_class, GtkFontChooserDialogPrivate, select_button); gtk_widget_class_bind_child (widget_class, GtkFontChooserDialogPrivate, cancel_button); gtk_widget_class_bind_callback (widget_class, font_activated_cb); - - g_type_class_add_private (klass, sizeof (GtkFontChooserDialogPrivate)); } static void @@ -148,9 +147,7 @@ gtk_font_chooser_dialog_init (GtkFontChooserDialog *fontchooserdiag) { GtkFontChooserDialogPrivate *priv; - fontchooserdiag->priv = G_TYPE_INSTANCE_GET_PRIVATE (fontchooserdiag, - GTK_TYPE_FONT_CHOOSER_DIALOG, - GtkFontChooserDialogPrivate); + fontchooserdiag->priv = gtk_font_chooser_dialog_get_instance_private (fontchooserdiag); priv = fontchooserdiag->priv; gtk_widget_init_template (GTK_WIDGET (fontchooserdiag)); diff --git a/gtk/gtkfontchooserwidget.c b/gtk/gtkfontchooserwidget.c index 28fcd44e6f..a5d66d24e2 100644 --- a/gtk/gtkfontchooserwidget.c +++ b/gtk/gtkfontchooserwidget.c @@ -167,6 +167,7 @@ static void gtk_font_chooser_widget_cell_data_func (GtkTreeViewColum static void gtk_font_chooser_widget_iface_init (GtkFontChooserIface *iface); G_DEFINE_TYPE_WITH_CODE (GtkFontChooserWidget, gtk_font_chooser_widget, GTK_TYPE_BOX, + G_ADD_PRIVATE (GtkFontChooserWidget) G_IMPLEMENT_INTERFACE (GTK_TYPE_FONT_CHOOSER, gtk_font_chooser_widget_iface_init)) @@ -494,8 +495,6 @@ gtk_font_chooser_widget_class_init (GtkFontChooserWidgetClass *klass) gtk_widget_class_bind_callback (widget_class, row_inserted_cb); gtk_widget_class_bind_callback (widget_class, row_deleted_cb); gtk_widget_class_bind_callback (widget_class, size_change_cb); - - g_type_class_add_private (klass, sizeof (GtkFontChooserWidgetPrivate)); } static void @@ -503,10 +502,7 @@ gtk_font_chooser_widget_init (GtkFontChooserWidget *fontchooser) { GtkFontChooserWidgetPrivate *priv; - fontchooser->priv = G_TYPE_INSTANCE_GET_PRIVATE (fontchooser, - GTK_TYPE_FONT_CHOOSER_WIDGET, - GtkFontChooserWidgetPrivate); - + fontchooser->priv = gtk_font_chooser_widget_get_instance_private (fontchooser); priv = fontchooser->priv; gtk_widget_init_template (GTK_WIDGET (fontchooser)); diff --git a/gtk/gtkframe.c b/gtk/gtkframe.c index 2e01d951e3..e5c1aad511 100644 --- a/gtk/gtkframe.c +++ b/gtk/gtkframe.c @@ -147,6 +147,7 @@ static void gtk_frame_get_preferred_width_for_height(GtkWidget *layout G_DEFINE_TYPE_WITH_CODE (GtkFrame, gtk_frame, GTK_TYPE_BIN, + G_ADD_PRIVATE (GtkFrame) G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_frame_buildable_init)) @@ -220,8 +221,6 @@ gtk_frame_class_init (GtkFrameClass *class) class->compute_child_allocation = gtk_frame_real_compute_child_allocation; - g_type_class_add_private (class, sizeof (GtkFramePrivate)); - gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_FRAME_ACCESSIBLE); } @@ -251,9 +250,7 @@ gtk_frame_init (GtkFrame *frame) GtkFramePrivate *priv; GtkStyleContext *context; - frame->priv = G_TYPE_INSTANCE_GET_PRIVATE (frame, - GTK_TYPE_FRAME, - GtkFramePrivate); + frame->priv = gtk_frame_get_instance_private (frame); priv = frame->priv; priv->label_widget = NULL; diff --git a/gtk/gtkgrid.c b/gtk/gtkgrid.c index a1183e892d..7e7f7a7aef 100644 --- a/gtk/gtkgrid.c +++ b/gtk/gtkgrid.c @@ -164,6 +164,7 @@ enum }; G_DEFINE_TYPE_WITH_CODE (GtkGrid, gtk_grid, GTK_TYPE_CONTAINER, + G_ADD_PRIVATE (GtkGrid) G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL)) @@ -377,7 +378,7 @@ gtk_grid_init (GtkGrid *grid) { GtkGridPrivate *priv; - grid->priv = G_TYPE_INSTANCE_GET_PRIVATE (grid, GTK_TYPE_GRID, GtkGridPrivate); + grid->priv = gtk_grid_get_instance_private (grid); priv = grid->priv; gtk_widget_set_has_window (GTK_WIDGET (grid), FALSE); @@ -1771,8 +1772,6 @@ gtk_grid_class_init (GtkGridClass *class) P_("The number of rows that a child spans"), 1, G_MAXINT, 1, GTK_PARAM_READWRITE)); - - g_type_class_add_private (class, sizeof (GtkGridPrivate)); } /** diff --git a/gtk/gtkheaderbar.c b/gtk/gtkheaderbar.c index 2ca658ecda..a803ddab1f 100644 --- a/gtk/gtkheaderbar.c +++ b/gtk/gtkheaderbar.c @@ -89,6 +89,7 @@ enum { static void gtk_header_bar_buildable_init (GtkBuildableIface *iface); G_DEFINE_TYPE_WITH_CODE (GtkHeaderBar, gtk_header_bar, GTK_TYPE_CONTAINER, + G_ADD_PRIVATE (GtkHeaderBar) G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_header_bar_buildable_init)); @@ -136,7 +137,7 @@ get_css_padding_and_border (GtkWidget *widget, static void init_sizing_box (GtkHeaderBar *bar) { - GtkHeaderBarPrivate *priv = bar->priv; + GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar); GtkWidget *w; /* We use this box to always request size for the two labels (title @@ -204,7 +205,7 @@ _gtk_header_bar_create_title_box (const char *title, static void construct_label_box (GtkHeaderBar *bar) { - GtkHeaderBarPrivate *priv = bar->priv; + GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar); g_assert (priv->label_box == NULL); @@ -221,8 +222,7 @@ gtk_header_bar_init (GtkHeaderBar *bar) GtkStyleContext *context; GtkHeaderBarPrivate *priv; - priv = G_TYPE_INSTANCE_GET_PRIVATE (bar, GTK_TYPE_HEADER_BAR, GtkHeaderBarPrivate); - bar->priv = priv; + priv = gtk_header_bar_get_instance_private (bar); gtk_widget_set_has_window (GTK_WIDGET (bar), FALSE); gtk_widget_set_redraw_on_allocate (GTK_WIDGET (bar), FALSE); @@ -246,12 +246,13 @@ gtk_header_bar_init (GtkHeaderBar *bar) static gint count_visible_children (GtkHeaderBar *bar) { + GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar); GList *l; Child *child; gint n; n = 0; - for (l = bar->priv->children; l; l = l->next) + for (l = priv->children; l; l = l->next) { child = l->data; if (gtk_widget_get_visible (child->widget)) @@ -298,7 +299,7 @@ gtk_header_bar_get_size (GtkWidget *widget, gint *natural_size) { GtkHeaderBar *bar = GTK_HEADER_BAR (widget); - GtkHeaderBarPrivate *priv = bar->priv; + GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar); GList *l; gint nvis_children; gint minimum, natural; @@ -360,7 +361,7 @@ gtk_header_bar_compute_size_for_orientation (GtkWidget *widget, gint *natural_size) { GtkHeaderBar *bar = GTK_HEADER_BAR (widget); - GtkHeaderBarPrivate *priv = bar->priv; + GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar); GList *children; gint required_size = 0; gint required_natural = 0; @@ -432,7 +433,7 @@ gtk_header_bar_compute_size_for_opposing_orientation (GtkWidget *widget, gint *natural_size) { GtkHeaderBar *bar = GTK_HEADER_BAR (widget); - GtkHeaderBarPrivate *priv = bar->priv; + GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar); Child *child; GList *children; gint nvis_children; @@ -576,7 +577,7 @@ gtk_header_bar_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GtkHeaderBar *bar = GTK_HEADER_BAR (widget); - GtkHeaderBarPrivate *priv = bar->priv; + GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar); GtkRequestedSize *sizes; gint width, height; gint nvis_children; @@ -743,13 +744,11 @@ void gtk_header_bar_set_title (GtkHeaderBar *bar, const gchar *title) { - GtkHeaderBarPrivate *priv; + GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar); gchar *new_title; g_return_if_fail (GTK_IS_HEADER_BAR (bar)); - priv = bar->priv; - new_title = g_strdup (title); g_free (priv->title); priv->title = new_title; @@ -778,9 +777,11 @@ gtk_header_bar_set_title (GtkHeaderBar *bar, const gchar * gtk_header_bar_get_title (GtkHeaderBar *bar) { + GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar); + g_return_val_if_fail (GTK_IS_HEADER_BAR (bar), NULL); - return bar->priv->title; + return priv->title; } /** @@ -801,13 +802,11 @@ void gtk_header_bar_set_subtitle (GtkHeaderBar *bar, const gchar *subtitle) { - GtkHeaderBarPrivate *priv; + GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar); gchar *new_subtitle; g_return_if_fail (GTK_IS_HEADER_BAR (bar)); - priv = bar->priv; - new_subtitle = g_strdup (subtitle); g_free (priv->subtitle); priv->subtitle = new_subtitle; @@ -837,9 +836,11 @@ gtk_header_bar_set_subtitle (GtkHeaderBar *bar, const gchar * gtk_header_bar_get_subtitle (GtkHeaderBar *bar) { + GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar); + g_return_val_if_fail (GTK_IS_HEADER_BAR (bar), NULL); - return bar->priv->subtitle; + return priv->subtitle; } /** @@ -859,14 +860,12 @@ void gtk_header_bar_set_custom_title (GtkHeaderBar *bar, GtkWidget *title_widget) { - GtkHeaderBarPrivate *priv; + GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar); g_return_if_fail (GTK_IS_HEADER_BAR (bar)); if (title_widget) g_return_if_fail (GTK_IS_WIDGET (title_widget)); - priv = bar->priv; - /* No need to do anything if the custom widget stays the same */ if (priv->custom_title == title_widget) return; @@ -924,18 +923,20 @@ gtk_header_bar_set_custom_title (GtkHeaderBar *bar, GtkWidget * gtk_header_bar_get_custom_title (GtkHeaderBar *bar) { + GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar); + g_return_val_if_fail (GTK_IS_HEADER_BAR (bar), NULL); - return bar->priv->custom_title; + return priv->custom_title; } static void gtk_header_bar_finalize (GObject *object) { - GtkHeaderBar *bar = GTK_HEADER_BAR (object); + GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (GTK_HEADER_BAR (object)); - g_free (bar->priv->title); - g_free (bar->priv->subtitle); + g_free (priv->title); + g_free (priv->subtitle); G_OBJECT_CLASS (gtk_header_bar_parent_class)->finalize (object); } @@ -947,7 +948,7 @@ gtk_header_bar_get_property (GObject *object, GParamSpec *pspec) { GtkHeaderBar *bar = GTK_HEADER_BAR (object); - GtkHeaderBarPrivate *priv = bar->priv; + GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar); switch (prop_id) { @@ -988,7 +989,7 @@ gtk_header_bar_set_property (GObject *object, GParamSpec *pspec) { GtkHeaderBar *bar = GTK_HEADER_BAR (object); - GtkHeaderBarPrivate *priv = bar->priv; + GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar); switch (prop_id) { @@ -1030,6 +1031,7 @@ gtk_header_bar_pack (GtkHeaderBar *bar, GtkWidget *widget, GtkPackType pack_type) { + GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar); Child *child; g_return_if_fail (gtk_widget_get_parent (widget) == NULL); @@ -1038,7 +1040,7 @@ gtk_header_bar_pack (GtkHeaderBar *bar, child->widget = widget; child->pack_type = pack_type; - bar->priv->children = g_list_append (bar->priv->children, child); + priv->children = g_list_append (priv->children, child); gtk_widget_freeze_child_notify (widget); gtk_widget_set_parent (widget, GTK_WIDGET (bar)); @@ -1058,10 +1060,11 @@ static GList * find_child_link (GtkHeaderBar *bar, GtkWidget *widget) { + GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar); GList *l; Child *child; - for (l = bar->priv->children; l; l = l->next) + for (l = priv->children; l; l = l->next) { child = l->data; if (child->widget == widget) @@ -1076,6 +1079,7 @@ gtk_header_bar_remove (GtkContainer *container, GtkWidget *widget) { GtkHeaderBar *bar = GTK_HEADER_BAR (container); + GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar); GList *l; Child *child; @@ -1084,7 +1088,7 @@ gtk_header_bar_remove (GtkContainer *container, { child = l->data; gtk_widget_unparent (child->widget); - bar->priv->children = g_list_delete_link (bar->priv->children, l); + priv->children = g_list_delete_link (priv->children, l); g_free (child); gtk_widget_queue_resize (GTK_WIDGET (container)); } @@ -1097,7 +1101,7 @@ gtk_header_bar_forall (GtkContainer *container, gpointer callback_data) { GtkHeaderBar *bar = GTK_HEADER_BAR (container); - GtkHeaderBarPrivate *priv = bar->priv; + GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar); Child *child; GList *children; @@ -1139,10 +1143,12 @@ gtk_header_bar_get_child_property (GtkContainer *container, GValue *value, GParamSpec *pspec) { + GtkHeaderBar *bar = GTK_HEADER_BAR (container); + GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar); GList *l; Child *child; - l = find_child_link (GTK_HEADER_BAR (container), widget); + l = find_child_link (bar, widget); if (l == NULL) { g_param_value_set_default (pspec, value); @@ -1158,7 +1164,7 @@ gtk_header_bar_get_child_property (GtkContainer *container, break; case CHILD_PROP_POSITION: - g_value_set_int (value, g_list_position (GTK_HEADER_BAR (container)->priv->children, l)); + g_value_set_int (value, g_list_position (priv->children, l)); break; default: @@ -1356,8 +1362,6 @@ gtk_header_bar_class_init (GtkHeaderBarClass *class) DEFAULT_VPADDING, GTK_PARAM_READWRITE)); - g_type_class_add_private (object_class, sizeof (GtkHeaderBarPrivate)); - gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_FILLER); } diff --git a/gtk/gtkheaderbar.h b/gtk/gtkheaderbar.h index bee9d80f99..0437ba0251 100644 --- a/gtk/gtkheaderbar.h +++ b/gtk/gtkheaderbar.h @@ -42,9 +42,6 @@ typedef struct _GtkHeaderBarClass GtkHeaderBarClass; struct _GtkHeaderBar { GtkContainer container; - - /*< private >*/ - GtkHeaderBarPrivate *priv; }; struct _GtkHeaderBarClass diff --git a/gtk/gtkiconfactory.c b/gtk/gtkiconfactory.c index ab65682b22..c9528304e6 100644 --- a/gtk/gtkiconfactory.c +++ b/gtk/gtkiconfactory.c @@ -212,6 +212,7 @@ static GtkIconSize icon_size_register_intern (const gchar *name, any_direction, any_state, any_size } G_DEFINE_TYPE_WITH_CODE (GtkIconFactory, gtk_icon_factory, G_TYPE_OBJECT, + G_ADD_PRIVATE (GtkIconFactory) G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_icon_factory_buildable_init)) @@ -220,9 +221,7 @@ gtk_icon_factory_init (GtkIconFactory *factory) { GtkIconFactoryPrivate *priv; - factory->priv = G_TYPE_INSTANCE_GET_PRIVATE (factory, - GTK_TYPE_ICON_FACTORY, - GtkIconFactoryPrivate); + factory->priv = gtk_icon_factory_get_instance_private (factory); priv = factory->priv; priv->icons = g_hash_table_new (g_str_hash, g_str_equal); @@ -235,8 +234,6 @@ gtk_icon_factory_class_init (GtkIconFactoryClass *klass) GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->finalize = gtk_icon_factory_finalize; - - g_type_class_add_private (klass, sizeof (GtkIconFactoryPrivate)); } static void diff --git a/gtk/gtkiconhelper.c b/gtk/gtkiconhelper.c index 0e38073592..a516d27542 100644 --- a/gtk/gtkiconhelper.c +++ b/gtk/gtkiconhelper.c @@ -22,8 +22,6 @@ #include <math.h> #include "gtkiconhelperprivate.h" -G_DEFINE_TYPE (GtkIconHelper, _gtk_icon_helper, G_TYPE_OBJECT) - struct _GtkIconHelperPrivate { GtkImageType storage_type; @@ -54,6 +52,8 @@ struct _GtkIconHelperPrivate { gint last_surface_scale; }; +G_DEFINE_TYPE_WITH_PRIVATE (GtkIconHelper, _gtk_icon_helper, G_TYPE_OBJECT) + void _gtk_icon_helper_clear (GtkIconHelper *self) { @@ -130,14 +130,12 @@ _gtk_icon_helper_class_init (GtkIconHelperClass *klass) oclass = G_OBJECT_CLASS (klass); oclass->finalize = gtk_icon_helper_finalize; - - g_type_class_add_private (klass, sizeof (GtkIconHelperPrivate)); } static void _gtk_icon_helper_init (GtkIconHelper *self) { - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTK_TYPE_ICON_HELPER, GtkIconHelperPrivate); + self->priv = _gtk_icon_helper_get_instance_private (self); self->priv->storage_type = GTK_IMAGE_EMPTY; self->priv->icon_size = GTK_ICON_SIZE_INVALID; diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c index e88d519a3a..9cd192a6d4 100644 --- a/gtk/gtkicontheme.c +++ b/gtk/gtkicontheme.c @@ -433,7 +433,7 @@ icon_info_key_equal (gconstpointer _a, return a->icon_names[i] == NULL && b->icon_names[i] == NULL; } -G_DEFINE_TYPE (GtkIconTheme, gtk_icon_theme, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE (GtkIconTheme, gtk_icon_theme, G_TYPE_OBJECT) /** * gtk_icon_theme_new: @@ -539,8 +539,6 @@ gtk_icon_theme_class_init (GtkIconThemeClass *klass) NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - - g_type_class_add_private (klass, sizeof (GtkIconThemePrivate)); } @@ -741,9 +739,7 @@ gtk_icon_theme_init (GtkIconTheme *icon_theme) const gchar * const *xdg_data_dirs; int i, j; - priv = G_TYPE_INSTANCE_GET_PRIVATE (icon_theme, - GTK_TYPE_ICON_THEME, - GtkIconThemePrivate); + priv = gtk_icon_theme_get_instance_private (icon_theme); icon_theme->priv = priv; priv->info_cache = g_hash_table_new_full (icon_info_key_hash, icon_info_key_equal, NULL, diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c index 0c6dc038ce..049ccce4ca 100644 --- a/gtk/gtkiconview.c +++ b/gtk/gtkiconview.c @@ -321,6 +321,7 @@ static void gtk_icon_view_buildable_custom_tag_end (GtkBuildable *buildab static guint icon_view_signals[LAST_SIGNAL] = { 0 }; G_DEFINE_TYPE_WITH_CODE (GtkIconView, gtk_icon_view, GTK_TYPE_CONTAINER, + G_ADD_PRIVATE (GtkIconView) G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_LAYOUT, gtk_icon_view_cell_layout_init) G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, @@ -337,8 +338,6 @@ gtk_icon_view_class_init (GtkIconViewClass *klass) binding_set = gtk_binding_set_by_class (klass); - g_type_class_add_private (klass, sizeof (GtkIconViewPrivate)); - gobject_class = (GObjectClass *) klass; widget_class = (GtkWidgetClass *) klass; container_class = (GtkContainerClass *) klass; @@ -958,9 +957,7 @@ gtk_icon_view_cell_layout_init (GtkCellLayoutIface *iface) static void gtk_icon_view_init (GtkIconView *icon_view) { - icon_view->priv = G_TYPE_INSTANCE_GET_PRIVATE (icon_view, - GTK_TYPE_ICON_VIEW, - GtkIconViewPrivate); + icon_view->priv = gtk_icon_view_get_instance_private (icon_view); icon_view->priv->width = 0; icon_view->priv->height = 0; diff --git a/gtk/gtkimage.c b/gtk/gtkimage.c index 5817572906..0fd4ce0d6c 100644 --- a/gtk/gtkimage.c +++ b/gtk/gtkimage.c @@ -200,7 +200,7 @@ enum PROP_USE_FALLBACK }; -G_DEFINE_TYPE (GtkImage, gtk_image, GTK_TYPE_MISC) +G_DEFINE_TYPE_WITH_PRIVATE (GtkImage, gtk_image, GTK_TYPE_MISC) static void gtk_image_class_init (GtkImageClass *class) @@ -387,8 +387,6 @@ gtk_image_class_init (GtkImageClass *class) FALSE, GTK_PARAM_READWRITE)); - g_type_class_add_private (class, sizeof (GtkImagePrivate)); - gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_IMAGE_ACCESSIBLE); } @@ -397,9 +395,7 @@ gtk_image_init (GtkImage *image) { GtkImagePrivate *priv; - image->priv = G_TYPE_INSTANCE_GET_PRIVATE (image, - GTK_TYPE_IMAGE, - GtkImagePrivate); + image->priv = gtk_image_get_instance_private (image); priv = image->priv; gtk_widget_set_has_window (GTK_WIDGET (image), FALSE); diff --git a/gtk/gtkimagemenuitem.c b/gtk/gtkimagemenuitem.c index 33defb36b5..d377618557 100644 --- a/gtk/gtkimagemenuitem.c +++ b/gtk/gtkimagemenuitem.c @@ -121,6 +121,7 @@ static void gtk_image_menu_item_sync_action_properties (GtkActivatable G_DEFINE_TYPE_WITH_CODE (GtkImageMenuItem, gtk_image_menu_item, GTK_TYPE_MENU_ITEM, + G_ADD_PRIVATE (GtkImageMenuItem) G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE, gtk_image_menu_item_activatable_interface_init)) @@ -220,7 +221,6 @@ gtk_image_menu_item_class_init (GtkImageMenuItemClass *klass) GTK_TYPE_ACCEL_GROUP, GTK_PARAM_WRITABLE | G_PARAM_DEPRECATED)); - g_type_class_add_private (klass, sizeof (GtkImageMenuItemPrivate)); } static void @@ -228,9 +228,7 @@ gtk_image_menu_item_init (GtkImageMenuItem *image_menu_item) { GtkImageMenuItemPrivate *priv; - image_menu_item->priv = G_TYPE_INSTANCE_GET_PRIVATE (image_menu_item, - GTK_TYPE_IMAGE_MENU_ITEM, - GtkImageMenuItemPrivate); + image_menu_item->priv = gtk_image_menu_item_get_instance_private (image_menu_item); priv = image_menu_item->priv; priv->image = NULL; diff --git a/gtk/gtkimcontext.c b/gtk/gtkimcontext.c index 68d77e93bf..37790b58cf 100644 --- a/gtk/gtkimcontext.c +++ b/gtk/gtkimcontext.c @@ -145,7 +145,7 @@ static void gtk_im_context_set_property (GObject *obj, GParamSpec *pspec); -G_DEFINE_ABSTRACT_TYPE (GtkIMContext, gtk_im_context, G_TYPE_OBJECT) +G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GtkIMContext, gtk_im_context, G_TYPE_OBJECT) /** * GtkIMContextClass: @@ -341,7 +341,6 @@ gtk_im_context_class_init (GtkIMContextClass *klass) GTK_INPUT_HINT_NONE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - g_type_class_add_private (klass, sizeof (GtkIMContextPrivate)); g_object_class_install_properties (object_class, LAST_PROPERTY, properties); } @@ -759,7 +758,7 @@ gtk_im_context_get_property (GObject *obj, GValue *value, GParamSpec *pspec) { - GtkIMContextPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (obj, GTK_TYPE_IM_CONTEXT, GtkIMContextPrivate); + GtkIMContextPrivate *priv = gtk_im_context_get_instance_private (GTK_IM_CONTEXT (obj)); switch (property_id) { @@ -781,7 +780,7 @@ gtk_im_context_set_property (GObject *obj, const GValue *value, GParamSpec *pspec) { - GtkIMContextPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (obj, GTK_TYPE_IM_CONTEXT, GtkIMContextPrivate); + GtkIMContextPrivate *priv = gtk_im_context_get_instance_private (GTK_IM_CONTEXT (obj)); switch (property_id) { diff --git a/gtk/gtkimcontextsimple.c b/gtk/gtkimcontextsimple.c index 87debf226b..0c293ffd53 100644 --- a/gtk/gtkimcontextsimple.c +++ b/gtk/gtkimcontextsimple.c @@ -112,7 +112,7 @@ static void gtk_im_context_simple_get_preedit_string (GtkIMContext PangoAttrList **attrs, gint *cursor_pos); -G_DEFINE_TYPE (GtkIMContextSimple, gtk_im_context_simple, GTK_TYPE_IM_CONTEXT) +G_DEFINE_TYPE_WITH_PRIVATE (GtkIMContextSimple, gtk_im_context_simple, GTK_TYPE_IM_CONTEXT) static void gtk_im_context_simple_class_init (GtkIMContextSimpleClass *class) @@ -124,16 +124,12 @@ gtk_im_context_simple_class_init (GtkIMContextSimpleClass *class) im_context_class->reset = gtk_im_context_simple_reset; im_context_class->get_preedit_string = gtk_im_context_simple_get_preedit_string; gobject_class->finalize = gtk_im_context_simple_finalize; - - g_type_class_add_private (class, sizeof (GtkIMContextSimplePrivate)); } static void gtk_im_context_simple_init (GtkIMContextSimple *im_context_simple) { - im_context_simple->priv = G_TYPE_INSTANCE_GET_PRIVATE (im_context_simple, - GTK_TYPE_IM_CONTEXT_SIMPLE, - GtkIMContextSimplePrivate); + im_context_simple->priv = gtk_im_context_simple_get_instance_private (im_context_simple); } static void diff --git a/gtk/gtkimmulticontext.c b/gtk/gtkimmulticontext.c index 4fc9cf15c1..9d2a1ad0a2 100644 --- a/gtk/gtkimmulticontext.c +++ b/gtk/gtkimmulticontext.c @@ -106,7 +106,7 @@ static void propagate_purpose (GtkIMMulticontext *context); static const gchar *global_context_id = NULL; -G_DEFINE_TYPE (GtkIMMulticontext, gtk_im_multicontext, GTK_TYPE_IM_CONTEXT) +G_DEFINE_TYPE_WITH_PRIVATE (GtkIMMulticontext, gtk_im_multicontext, GTK_TYPE_IM_CONTEXT) static void gtk_im_multicontext_class_init (GtkIMMulticontextClass *class) @@ -128,8 +128,6 @@ gtk_im_multicontext_class_init (GtkIMMulticontextClass *class) im_context_class->get_surrounding = gtk_im_multicontext_get_surrounding; gobject_class->finalize = gtk_im_multicontext_finalize; - - g_type_class_add_private (gobject_class, sizeof (GtkIMMulticontextPrivate)); } static void @@ -137,7 +135,7 @@ gtk_im_multicontext_init (GtkIMMulticontext *multicontext) { GtkIMMulticontextPrivate *priv; - multicontext->priv = G_TYPE_INSTANCE_GET_PRIVATE (multicontext, GTK_TYPE_IM_MULTICONTEXT, GtkIMMulticontextPrivate); + multicontext->priv = gtk_im_multicontext_get_instance_private (multicontext); priv = multicontext->priv; priv->slave = NULL; diff --git a/gtk/gtkinfobar.c b/gtk/gtkinfobar.c index 15d71ce561..837caa542e 100644 --- a/gtk/gtkinfobar.c +++ b/gtk/gtkinfobar.c @@ -181,6 +181,7 @@ static void gtk_info_bar_buildable_custom_finished (GtkBuildable *build G_DEFINE_TYPE_WITH_CODE (GtkInfoBar, gtk_info_bar, GTK_TYPE_BOX, + G_ADD_PRIVATE (GtkInfoBar) G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_info_bar_buildable_interface_init)) @@ -532,8 +533,6 @@ gtk_info_bar_class_init (GtkInfoBarClass *klass) gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/gtkinfobar.ui"); gtk_widget_class_bind_child_internal (widget_class, GtkInfoBarPrivate, content_area); gtk_widget_class_bind_child_internal (widget_class, GtkInfoBarPrivate, action_area); - - g_type_class_add_private (object_class, sizeof (GtkInfoBarPrivate)); } static void @@ -541,9 +540,7 @@ gtk_info_bar_init (GtkInfoBar *info_bar) { GtkWidget *widget = GTK_WIDGET (info_bar); - info_bar->priv = G_TYPE_INSTANCE_GET_PRIVATE (info_bar, - GTK_TYPE_INFO_BAR, - GtkInfoBarPrivate); + info_bar->priv = gtk_info_bar_get_instance_private (info_bar); gtk_widget_set_redraw_on_allocate (widget, TRUE); diff --git a/gtk/gtkinvisible.c b/gtk/gtkinvisible.c index 27ca2502cb..903ea02130 100644 --- a/gtk/gtkinvisible.c +++ b/gtk/gtkinvisible.c @@ -74,7 +74,7 @@ static GObject *gtk_invisible_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_params); -G_DEFINE_TYPE (GtkInvisible, gtk_invisible, GTK_TYPE_WIDGET) +G_DEFINE_TYPE_WITH_PRIVATE (GtkInvisible, gtk_invisible, GTK_TYPE_WIDGET) static void gtk_invisible_class_init (GtkInvisibleClass *class) @@ -102,8 +102,6 @@ gtk_invisible_class_init (GtkInvisibleClass *class) P_("The screen where this window will be displayed"), GDK_TYPE_SCREEN, GTK_PARAM_READWRITE)); - - g_type_class_add_private (class, sizeof (GtkInvisiblePrivate)); } static void @@ -111,9 +109,7 @@ gtk_invisible_init (GtkInvisible *invisible) { GtkInvisiblePrivate *priv; - invisible->priv = G_TYPE_INSTANCE_GET_PRIVATE (invisible, - GTK_TYPE_INVISIBLE, - GtkInvisiblePrivate); + invisible->priv = gtk_invisible_get_instance_private (invisible); priv = invisible->priv; gtk_widget_set_has_window (GTK_WIDGET (invisible), TRUE); diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index 752d728d47..36fe5c86dc 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -528,6 +528,7 @@ static void gtk_label_get_preferred_height_and_baseline_for_width (GtkWidget static GtkBuildableIface *buildable_parent_iface = NULL; G_DEFINE_TYPE_WITH_CODE (GtkLabel, gtk_label, GTK_TYPE_MISC, + G_ADD_PRIVATE (GtkLabel) G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_label_buildable_interface_init)) @@ -1077,8 +1078,6 @@ gtk_label_class_init (GtkLabelClass *class) gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Enter, 0, "activate-current-link", 0); - g_type_class_add_private (class, sizeof (GtkLabelPrivate)); - gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_LABEL_ACCESSIBLE); } @@ -1222,9 +1221,7 @@ gtk_label_init (GtkLabel *label) { GtkLabelPrivate *priv; - label->priv = G_TYPE_INSTANCE_GET_PRIVATE (label, - GTK_TYPE_LABEL, - GtkLabelPrivate); + label->priv = gtk_label_get_instance_private (label); priv = label->priv; gtk_widget_set_has_window (GTK_WIDGET (label), FALSE); diff --git a/gtk/gtklayout.c b/gtk/gtklayout.c index 73cdb62f2a..969865d3d5 100644 --- a/gtk/gtklayout.c +++ b/gtk/gtklayout.c @@ -161,6 +161,7 @@ static void gtk_layout_set_hadjustment_values (GtkLayout *layout); static void gtk_layout_set_vadjustment_values (GtkLayout *layout); G_DEFINE_TYPE_WITH_CODE (GtkLayout, gtk_layout, GTK_TYPE_CONTAINER, + G_ADD_PRIVATE (GtkLayout) G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE, NULL)) /* Public interface @@ -696,8 +697,6 @@ gtk_layout_class_init (GtkLayoutClass *class) container_class->add = gtk_layout_add; container_class->remove = gtk_layout_remove; container_class->forall = gtk_layout_forall; - - g_type_class_add_private (class, sizeof (GtkLayoutPrivate)); } static void @@ -831,9 +830,7 @@ gtk_layout_init (GtkLayout *layout) { GtkLayoutPrivate *priv; - layout->priv = G_TYPE_INSTANCE_GET_PRIVATE (layout, - GTK_TYPE_LAYOUT, - GtkLayoutPrivate); + layout->priv = gtk_layout_get_instance_private (layout); priv = layout->priv; priv->children = NULL; diff --git a/gtk/gtklevelbar.c b/gtk/gtklevelbar.c index fff48919e8..744ee2cd22 100644 --- a/gtk/gtklevelbar.c +++ b/gtk/gtklevelbar.c @@ -110,13 +110,6 @@ #define STYLE_CLASS_FILL_BLOCK "fill-block" #define STYLE_CLASS_EMPTY_FILL_BLOCK "empty-fill-block" -static void gtk_level_bar_buildable_init (GtkBuildableIface *iface); - -G_DEFINE_TYPE_WITH_CODE (GtkLevelBar, gtk_level_bar, GTK_TYPE_WIDGET, - G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL) - G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, - gtk_level_bar_buildable_init)) - enum { PROP_VALUE = 1, PROP_MIN_VALUE, @@ -157,6 +150,14 @@ struct _GtkLevelBarPrivate { static void gtk_level_bar_set_value_internal (GtkLevelBar *self, gdouble value); +static void gtk_level_bar_buildable_init (GtkBuildableIface *iface); + +G_DEFINE_TYPE_WITH_CODE (GtkLevelBar, gtk_level_bar, GTK_TYPE_WIDGET, + G_ADD_PRIVATE (GtkLevelBar) + G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL) + G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, + gtk_level_bar_buildable_init)) + static GtkLevelBarOffset * gtk_level_bar_offset_new (const gchar *name, gdouble value) @@ -1024,7 +1025,6 @@ gtk_level_bar_class_init (GtkLevelBarClass *klass) 1, G_MAXINT, DEFAULT_BLOCK_SIZE, G_PARAM_READWRITE)); - g_type_class_add_private (klass, sizeof (GtkLevelBarPrivate)); g_object_class_install_properties (oclass, LAST_PROPERTY, properties); gtk_widget_class_set_accessible_type (wclass, GTK_TYPE_LEVEL_BAR_ACCESSIBLE); @@ -1035,7 +1035,7 @@ gtk_level_bar_init (GtkLevelBar *self) { GtkStyleContext *context; - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTK_TYPE_LEVEL_BAR, GtkLevelBarPrivate); + self->priv = gtk_level_bar_get_instance_private (self); context = gtk_widget_get_style_context (GTK_WIDGET (self)); gtk_style_context_add_class (context, GTK_STYLE_CLASS_LEVEL_BAR); diff --git a/gtk/gtklinkbutton.c b/gtk/gtklinkbutton.c index 2e0636646a..e3af4bd52a 100644 --- a/gtk/gtklinkbutton.c +++ b/gtk/gtklinkbutton.c @@ -136,7 +136,7 @@ static const GdkColor default_visited_link_color = { 0, 0x5555, 0x1a1a, 0x8b8b } static guint link_signals[LAST_SIGNAL] = { 0, }; -G_DEFINE_TYPE (GtkLinkButton, gtk_link_button, GTK_TYPE_BUTTON) +G_DEFINE_TYPE_WITH_PRIVATE (GtkLinkButton, gtk_link_button, GTK_TYPE_BUTTON) static void gtk_link_button_class_init (GtkLinkButtonClass *klass) @@ -190,8 +190,6 @@ gtk_link_button_class_init (GtkLinkButtonClass *klass) P_("Whether this link has been visited."), FALSE, G_PARAM_READWRITE)); - - g_type_class_add_private (gobject_class, sizeof (GtkLinkButtonPrivate)); /** * GtkLinkButton::activate-link: @@ -222,9 +220,7 @@ gtk_link_button_class_init (GtkLinkButtonClass *klass) static void gtk_link_button_init (GtkLinkButton *link_button) { - link_button->priv = G_TYPE_INSTANCE_GET_PRIVATE (link_button, - GTK_TYPE_LINK_BUTTON, - GtkLinkButtonPrivate); + link_button->priv = gtk_link_button_get_instance_private (link_button); gtk_button_set_relief (GTK_BUTTON (link_button), GTK_RELIEF_NONE); diff --git a/gtk/gtkliststore.c b/gtk/gtkliststore.c index b64876bdd5..7407e667dd 100644 --- a/gtk/gtkliststore.c +++ b/gtk/gtkliststore.c @@ -307,6 +307,7 @@ static void gtk_list_store_buildable_custom_tag_end (GtkBuildable *buildable gpointer *data); G_DEFINE_TYPE_WITH_CODE (GtkListStore, gtk_list_store, G_TYPE_OBJECT, + G_ADD_PRIVATE (GtkListStore) G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, gtk_list_store_tree_model_init) G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_DRAG_SOURCE, @@ -327,8 +328,6 @@ gtk_list_store_class_init (GtkListStoreClass *class) object_class = (GObjectClass*) class; object_class->finalize = gtk_list_store_finalize; - - g_type_class_add_private (class, sizeof (GtkListStorePrivate)); } static void @@ -386,9 +385,7 @@ gtk_list_store_init (GtkListStore *list_store) { GtkListStorePrivate *priv; - list_store->priv = G_TYPE_INSTANCE_GET_PRIVATE (list_store, - GTK_TYPE_LIST_STORE, - GtkListStorePrivate); + list_store->priv = gtk_list_store_get_instance_private (list_store); priv = list_store->priv; priv->seq = g_sequence_new (NULL); diff --git a/gtk/gtklockbutton.c b/gtk/gtklockbutton.c index b8a162139d..475bbe6735 100644 --- a/gtk/gtklockbutton.c +++ b/gtk/gtklockbutton.c @@ -94,7 +94,7 @@ static void on_permission_changed (GPermission *permission, GParamSpec *pspec, gpointer user_data); -G_DEFINE_TYPE (GtkLockButton, gtk_lock_button, GTK_TYPE_BUTTON); +G_DEFINE_TYPE_WITH_PRIVATE (GtkLockButton, gtk_lock_button, GTK_TYPE_BUTTON) static void gtk_lock_button_finalize (GObject *object) @@ -221,9 +221,7 @@ gtk_lock_button_init (GtkLockButton *button) GtkLockButtonPrivate *priv; gchar *names[3]; - button->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (button, - GTK_TYPE_LOCK_BUTTON, - GtkLockButtonPrivate); + button->priv = priv = gtk_lock_button_get_instance_private (button); gtk_widget_init_template (GTK_WIDGET (button)); @@ -253,8 +251,6 @@ gtk_lock_button_class_init (GtkLockButtonClass *klass) button_class->clicked = gtk_lock_button_clicked; - g_type_class_add_private (klass, sizeof (GtkLockButtonPrivate)); - g_object_class_install_property (gobject_class, PROP_PERMISSION, g_param_spec_object ("permission", P_("Permission"), diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c index feed5e30e9..ece083dcab 100644 --- a/gtk/gtkmenu.c +++ b/gtk/gtkmenu.c @@ -310,7 +310,7 @@ static const gchar attach_data_key[] = "gtk-menu-attach-data"; static guint menu_signals[LAST_SIGNAL] = { 0 }; -G_DEFINE_TYPE (GtkMenu, gtk_menu, GTK_TYPE_MENU_SHELL) +G_DEFINE_TYPE_WITH_PRIVATE (GtkMenu, gtk_menu, GTK_TYPE_MENU_SHELL) static void menu_queue_resize (GtkMenu *menu) @@ -871,8 +871,6 @@ gtk_menu_class_init (GtkMenuClass *class) GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_PAGE_DOWN); - g_type_class_add_private (gobject_class, sizeof (GtkMenuPrivate)); - gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_MENU_ACCESSIBLE); } @@ -1071,7 +1069,7 @@ gtk_menu_init (GtkMenu *menu) GtkMenuPrivate *priv; GtkStyleContext *context; - priv = G_TYPE_INSTANCE_GET_PRIVATE (menu, GTK_TYPE_MENU, GtkMenuPrivate); + priv = gtk_menu_get_instance_private (menu); menu->priv = priv; diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c index f93afa497f..24872af261 100644 --- a/gtk/gtkmenubar.c +++ b/gtk/gtkmenubar.c @@ -102,7 +102,7 @@ static void gtk_menu_bar_move_current (GtkMenuShell *menu_shell, static GtkShadowType get_shadow_type (GtkMenuBar *menubar); -G_DEFINE_TYPE (GtkMenuBar, gtk_menu_bar, GTK_TYPE_MENU_SHELL) +G_DEFINE_TYPE_WITH_PRIVATE (GtkMenuBar, gtk_menu_bar, GTK_TYPE_MENU_SHELL) static void gtk_menu_bar_class_init (GtkMenuBarClass *class) @@ -237,8 +237,6 @@ gtk_menu_bar_class_init (GtkMenuBarClass *class) 0, GTK_PARAM_READABLE | G_PARAM_DEPRECATED)); - - g_type_class_add_private (gobject_class, sizeof (GtkMenuBarPrivate)); } static void @@ -246,9 +244,7 @@ gtk_menu_bar_init (GtkMenuBar *menu_bar) { GtkStyleContext *context; - menu_bar->priv = G_TYPE_INSTANCE_GET_PRIVATE (menu_bar, - GTK_TYPE_MENU_BAR, - GtkMenuBarPrivate); + menu_bar->priv = gtk_menu_bar_get_instance_private (menu_bar); context = gtk_widget_get_style_context (GTK_WIDGET (menu_bar)); gtk_style_context_add_class (context, GTK_STYLE_CLASS_MENUBAR); diff --git a/gtk/gtkmenubutton.c b/gtk/gtkmenubutton.c index 95b2bc73b1..3c852b6140 100644 --- a/gtk/gtkmenubutton.c +++ b/gtk/gtkmenubutton.c @@ -174,7 +174,7 @@ enum PROP_DIRECTION }; -G_DEFINE_TYPE(GtkMenuButton, gtk_menu_button, GTK_TYPE_TOGGLE_BUTTON) +G_DEFINE_TYPE_WITH_PRIVATE (GtkMenuButton, gtk_menu_button, GTK_TYPE_TOGGLE_BUTTON) static void gtk_menu_button_dispose (GObject *object); @@ -488,8 +488,6 @@ gtk_menu_button_class_init (GtkMenuButtonClass *klass) GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass); GtkToggleButtonClass *toggle_button_class = GTK_TOGGLE_BUTTON_CLASS (klass); - g_type_class_add_private (klass, sizeof (GtkMenuButtonPrivate)); - gobject_class->set_property = gtk_menu_button_set_property; gobject_class->get_property = gtk_menu_button_get_property; gobject_class->dispose = gtk_menu_button_dispose; @@ -581,7 +579,7 @@ gtk_menu_button_init (GtkMenuButton *menu_button) { GtkMenuButtonPrivate *priv; - priv = G_TYPE_INSTANCE_GET_PRIVATE (menu_button, GTK_TYPE_MENU_BUTTON, GtkMenuButtonPrivate); + priv = gtk_menu_button_get_instance_private (menu_button); menu_button->priv = priv; priv->arrow_type = GTK_ARROW_DOWN; diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c index 56afcd6c57..f300bb4b1f 100644 --- a/gtk/gtkmenuitem.c +++ b/gtk/gtkmenuitem.c @@ -215,6 +215,7 @@ static GtkBuildableIface *parent_buildable_iface; G_GNUC_BEGIN_IGNORE_DEPRECATIONS; G_DEFINE_TYPE_WITH_CODE (GtkMenuItem, gtk_menu_item, GTK_TYPE_BIN, + G_ADD_PRIVATE (GtkMenuItem) G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_menu_item_buildable_interface_init) G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE, @@ -538,8 +539,6 @@ gtk_menu_item_class_init (GtkMenuItemClass *klass) P_("The minimum desired width of the menu item in characters"), 0, G_MAXINT, 12, GTK_PARAM_READABLE)); - - g_type_class_add_private (klass, sizeof (GtkMenuItemPrivate)); } static void @@ -548,9 +547,7 @@ gtk_menu_item_init (GtkMenuItem *menu_item) GtkStyleContext *context; GtkMenuItemPrivate *priv; - priv = G_TYPE_INSTANCE_GET_PRIVATE (menu_item, - GTK_TYPE_MENU_ITEM, - GtkMenuItemPrivate); + priv = gtk_menu_item_get_instance_private (menu_item); menu_item->priv = priv; gtk_widget_set_has_window (GTK_WIDGET (menu_item), FALSE); diff --git a/gtk/gtkmenushell.c b/gtk/gtkmenushell.c index 01366b7a6b..dd5ef2f770 100644 --- a/gtk/gtkmenushell.c +++ b/gtk/gtkmenushell.c @@ -207,7 +207,7 @@ static gboolean gtk_menu_shell_real_move_selected (GtkMenuShell *menu_shell, static guint menu_shell_signals[LAST_SIGNAL] = { 0 }; -G_DEFINE_ABSTRACT_TYPE (GtkMenuShell, gtk_menu_shell, GTK_TYPE_CONTAINER) +G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GtkMenuShell, gtk_menu_shell, GTK_TYPE_CONTAINER) static void gtk_menu_shell_class_init (GtkMenuShellClass *klass) @@ -455,8 +455,6 @@ gtk_menu_shell_class_init (GtkMenuShellClass *klass) GTK_PARAM_READWRITE)); gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_MENU_SHELL_ACCESSIBLE); - - g_type_class_add_private (object_class, sizeof (GtkMenuShellPrivate)); } static GType @@ -468,13 +466,8 @@ gtk_menu_shell_child_type (GtkContainer *container) static void gtk_menu_shell_init (GtkMenuShell *menu_shell) { - GtkMenuShellPrivate *priv; - - priv = G_TYPE_INSTANCE_GET_PRIVATE (menu_shell, - GTK_TYPE_MENU_SHELL, - GtkMenuShellPrivate); - menu_shell->priv = priv; - priv->take_focus = TRUE; + menu_shell->priv = gtk_menu_shell_get_instance_private (menu_shell); + menu_shell->priv->take_focus = TRUE; } static void diff --git a/gtk/gtkmenutoolbutton.c b/gtk/gtkmenutoolbutton.c index 6d9c1faf35..93a630d86b 100644 --- a/gtk/gtkmenutoolbutton.c +++ b/gtk/gtkmenutoolbutton.c @@ -100,6 +100,7 @@ static gint signals[LAST_SIGNAL]; static GtkBuildableIface *parent_buildable_iface; G_DEFINE_TYPE_WITH_CODE (GtkMenuToolButton, gtk_menu_tool_button, GTK_TYPE_TOOL_BUTTON, + G_ADD_PRIVATE (GtkMenuToolButton) G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_menu_tool_button_buildable_interface_init)) @@ -272,8 +273,6 @@ gtk_menu_tool_button_class_init (GtkMenuToolButtonClass *klass) P_("The dropdown menu"), GTK_TYPE_MENU, GTK_PARAM_READWRITE)); - - g_type_class_add_private (object_class, sizeof (GtkMenuToolButtonPrivate)); } static void @@ -283,9 +282,7 @@ gtk_menu_tool_button_init (GtkMenuToolButton *button) GtkWidget *arrow_button; GtkWidget *real_button; - button->priv = G_TYPE_INSTANCE_GET_PRIVATE (button, - GTK_TYPE_MENU_TOOL_BUTTON, - GtkMenuToolButtonPrivate); + button->priv = gtk_menu_tool_button_get_instance_private (button); gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (button), FALSE); diff --git a/gtk/gtkmessagedialog.c b/gtk/gtkmessagedialog.c index a864f746d8..57504b0989 100644 --- a/gtk/gtkmessagedialog.c +++ b/gtk/gtkmessagedialog.c @@ -136,6 +136,7 @@ enum { }; G_DEFINE_TYPE_WITH_CODE (GtkMessageDialog, gtk_message_dialog, GTK_TYPE_DIALOG, + G_ADD_PRIVATE (GtkMessageDialog) G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_message_dialog_buildable_interface_init)) @@ -299,8 +300,6 @@ gtk_message_dialog_class_init (GtkMessageDialogClass *class) gtk_widget_class_bind_child (widget_class, GtkMessageDialogPrivate, label); gtk_widget_class_bind_child (widget_class, GtkMessageDialogPrivate, secondary_label); gtk_widget_class_bind_child_internal (widget_class, GtkMessageDialogPrivate, message_area); - - g_type_class_add_private (gobject_class, sizeof (GtkMessageDialogPrivate)); } static void @@ -308,9 +307,7 @@ gtk_message_dialog_init (GtkMessageDialog *dialog) { GtkMessageDialogPrivate *priv; - dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (dialog, - GTK_TYPE_MESSAGE_DIALOG, - GtkMessageDialogPrivate); + dialog->priv = gtk_message_dialog_get_instance_private (dialog); priv = dialog->priv; priv->has_primary_markup = FALSE; diff --git a/gtk/gtkmisc.c b/gtk/gtkmisc.c index 4bd162ccda..7debb69cda 100644 --- a/gtk/gtkmisc.c +++ b/gtk/gtkmisc.c @@ -81,7 +81,7 @@ static void gtk_misc_get_property (GObject *object, GParamSpec *pspec); -G_DEFINE_ABSTRACT_TYPE (GtkMisc, gtk_misc, GTK_TYPE_WIDGET) +G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GtkMisc, gtk_misc, GTK_TYPE_WIDGET) static void gtk_misc_class_init (GtkMiscClass *class) @@ -136,8 +136,6 @@ gtk_misc_class_init (GtkMiscClass *class) G_MAXINT, 0, GTK_PARAM_READWRITE)); - - g_type_class_add_private (class, sizeof (GtkMiscPrivate)); } static void @@ -145,9 +143,7 @@ gtk_misc_init (GtkMisc *misc) { GtkMiscPrivate *priv; - misc->priv = G_TYPE_INSTANCE_GET_PRIVATE (misc, - GTK_TYPE_MISC, - GtkMiscPrivate); + misc->priv = gtk_misc_get_instance_private (misc); priv = misc->priv; priv->xalign = 0.5; diff --git a/gtk/gtkmodifierstyle.c b/gtk/gtkmodifierstyle.c index 4d3cc35194..88cd0d5905 100644 --- a/gtk/gtkmodifierstyle.c +++ b/gtk/gtkmodifierstyle.c @@ -40,6 +40,7 @@ static void gtk_modifier_style_provider_private_init (GtkStyleProviderPrivateInt static void gtk_modifier_style_finalize (GObject *object); G_DEFINE_TYPE_EXTENDED (GtkModifierStyle, _gtk_modifier_style, G_TYPE_OBJECT, 0, + G_ADD_PRIVATE (GtkModifierStyle) G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER, gtk_modifier_style_provider_init) G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER_PRIVATE, @@ -61,8 +62,6 @@ _gtk_modifier_style_class_init (GtkModifierStyleClass *klass) 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - - g_type_class_add_private (object_class, sizeof (GtkModifierStylePrivate)); } static void @@ -70,9 +69,7 @@ _gtk_modifier_style_init (GtkModifierStyle *modifier_style) { GtkModifierStylePrivate *priv; - priv = modifier_style->priv = G_TYPE_INSTANCE_GET_PRIVATE (modifier_style, - GTK_TYPE_MODIFIER_STYLE, - GtkModifierStylePrivate); + priv = modifier_style->priv = _gtk_modifier_style_get_instance_private (modifier_style); priv->color_properties = g_hash_table_new_full (g_str_hash, g_str_equal, diff --git a/gtk/gtkmountoperation.c b/gtk/gtkmountoperation.c index d1b72a51aa..3d566b5c50 100644 --- a/gtk/gtkmountoperation.c +++ b/gtk/gtkmountoperation.c @@ -102,16 +102,6 @@ static void gtk_mount_operation_show_processes (GMountOperation *op, static void gtk_mount_operation_aborted (GMountOperation *op); -G_DEFINE_TYPE (GtkMountOperation, gtk_mount_operation, G_TYPE_MOUNT_OPERATION); - -enum { - PROP_0, - PROP_PARENT, - PROP_IS_SHOWING, - PROP_SCREEN - -}; - struct _GtkMountOperationPrivate { GtkWindow *parent_window; GtkDialog *dialog; @@ -139,14 +129,22 @@ struct _GtkMountOperationPrivate { GtkListStore *process_list_store; }; +enum { + PROP_0, + PROP_PARENT, + PROP_IS_SHOWING, + PROP_SCREEN + +}; + +G_DEFINE_TYPE_WITH_PRIVATE (GtkMountOperation, gtk_mount_operation, G_TYPE_MOUNT_OPERATION) + static void gtk_mount_operation_class_init (GtkMountOperationClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GMountOperationClass *mount_op_class = G_MOUNT_OPERATION_CLASS (klass); - g_type_class_add_private (klass, sizeof (GtkMountOperationPrivate)); - object_class->finalize = gtk_mount_operation_finalize; object_class->get_property = gtk_mount_operation_get_property; object_class->set_property = gtk_mount_operation_set_property; @@ -186,9 +184,7 @@ gtk_mount_operation_init (GtkMountOperation *operation) { gchar *name_owner; - operation->priv = G_TYPE_INSTANCE_GET_PRIVATE (operation, - GTK_TYPE_MOUNT_OPERATION, - GtkMountOperationPrivate); + operation->priv = gtk_mount_operation_get_instance_private (operation); operation->priv->handler = _gtk_mount_operation_handler_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 4838ec7190..2b4d832e67 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -527,6 +527,7 @@ static void gtk_notebook_buildable_add_child (GtkBuildable *buildable, static guint notebook_signals[LAST_SIGNAL] = { 0 }; G_DEFINE_TYPE_WITH_CODE (GtkNotebook, gtk_notebook, GTK_TYPE_CONTAINER, + G_ADD_PRIVATE (GtkNotebook) G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_notebook_buildable_init)) @@ -1149,8 +1150,6 @@ gtk_notebook_class_init (GtkNotebookClass *class) add_tab_bindings (binding_set, GDK_CONTROL_MASK, GTK_DIR_TAB_FORWARD); add_tab_bindings (binding_set, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD); - g_type_class_add_private (class, sizeof (GtkNotebookPrivate)); - gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_NOTEBOOK_ACCESSIBLE); } @@ -1163,9 +1162,7 @@ gtk_notebook_init (GtkNotebook *notebook) gtk_widget_set_can_focus (GTK_WIDGET (notebook), TRUE); gtk_widget_set_has_window (GTK_WIDGET (notebook), FALSE); - notebook->priv = G_TYPE_INSTANCE_GET_PRIVATE (notebook, - GTK_TYPE_NOTEBOOK, - GtkNotebookPrivate); + notebook->priv = gtk_notebook_get_instance_private (notebook); priv = notebook->priv; priv->cur_page = NULL; diff --git a/gtk/gtknumerableicon.c b/gtk/gtknumerableicon.c index 1d5768f11f..45c9b0e579 100644 --- a/gtk/gtknumerableicon.c +++ b/gtk/gtknumerableicon.c @@ -93,7 +93,7 @@ enum { static GParamSpec *properties[NUM_PROPERTIES] = { NULL, }; -G_DEFINE_TYPE (GtkNumerableIcon, gtk_numerable_icon, G_TYPE_EMBLEMED_ICON); +G_DEFINE_TYPE_WITH_PRIVATE (GtkNumerableIcon, gtk_numerable_icon, G_TYPE_EMBLEMED_ICON) static gint get_surface_size (cairo_surface_t *surface) @@ -636,8 +636,6 @@ gtk_numerable_icon_class_init (GtkNumerableIconClass *klass) oclass->dispose = gtk_numerable_icon_dispose; oclass->finalize = gtk_numerable_icon_finalize; - g_type_class_add_private (klass, sizeof (GtkNumerableIconPrivate)); - properties[PROP_COUNT] = g_param_spec_int ("count", P_("Icon's count"), @@ -682,9 +680,7 @@ gtk_numerable_icon_init (GtkNumerableIcon *self) GdkRGBA bg; GdkRGBA fg; - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - GTK_TYPE_NUMERABLE_ICON, - GtkNumerableIconPrivate); + self->priv = gtk_numerable_icon_get_instance_private (self); gdk_rgba_parse (&bg, DEFAULT_BACKGROUND); gdk_rgba_parse (&fg, DEFAULT_FOREGROUND); diff --git a/gtk/gtkoverlay.c b/gtk/gtkoverlay.c index c06f8e0365..59eefbf8fe 100644 --- a/gtk/gtkoverlay.c +++ b/gtk/gtkoverlay.c @@ -79,6 +79,7 @@ static guint signals[LAST_SIGNAL] = { 0 }; static void gtk_overlay_buildable_init (GtkBuildableIface *iface); G_DEFINE_TYPE_WITH_CODE (GtkOverlay, gtk_overlay, GTK_TYPE_BIN, + G_ADD_PRIVATE (GtkOverlay) G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_overlay_buildable_init)) @@ -654,14 +655,12 @@ gtk_overlay_class_init (GtkOverlayClass *klass) G_TYPE_BOOLEAN, 2, GTK_TYPE_WIDGET, GDK_TYPE_RECTANGLE | G_SIGNAL_TYPE_STATIC_SCOPE); - - g_type_class_add_private (object_class, sizeof (GtkOverlayPrivate)); } static void gtk_overlay_init (GtkOverlay *overlay) { - overlay->priv = G_TYPE_INSTANCE_GET_PRIVATE (overlay, GTK_TYPE_OVERLAY, GtkOverlayPrivate); + overlay->priv = gtk_overlay_get_instance_private (overlay); gtk_widget_set_has_window (GTK_WIDGET (overlay), FALSE); } diff --git a/gtk/gtkpagesetupunixdialog.c b/gtk/gtkpagesetupunixdialog.c index df6b214dbd..d8f1be8cb1 100644 --- a/gtk/gtkpagesetupunixdialog.c +++ b/gtk/gtkpagesetupunixdialog.c @@ -102,7 +102,7 @@ enum { PAGE_SETUP_LIST_N_COLS }; -G_DEFINE_TYPE (GtkPageSetupUnixDialog, gtk_page_setup_unix_dialog, GTK_TYPE_DIALOG) +G_DEFINE_TYPE_WITH_PRIVATE (GtkPageSetupUnixDialog, gtk_page_setup_unix_dialog, GTK_TYPE_DIALOG) static void gtk_page_setup_unix_dialog_finalize (GObject *object); static void fill_paper_sizes_from_printer (GtkPageSetupUnixDialog *dialog, @@ -177,8 +177,6 @@ gtk_page_setup_unix_dialog_class_init (GtkPageSetupUnixDialogClass *class) gtk_widget_class_bind_callback (widget_class, printer_changed_callback); gtk_widget_class_bind_callback (widget_class, paper_size_changed); - - g_type_class_add_private (class, sizeof (GtkPageSetupUnixDialogPrivate)); } static void @@ -188,9 +186,7 @@ gtk_page_setup_unix_dialog_init (GtkPageSetupUnixDialog *dialog) GtkTreeIter iter; gchar *tmp; - priv = dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (dialog, - GTK_TYPE_PAGE_SETUP_UNIX_DIALOG, - GtkPageSetupUnixDialogPrivate); + priv = dialog->priv = gtk_page_setup_unix_dialog_get_instance_private (dialog); priv->print_backends = NULL; diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c index e85521c13e..b929e4ac8d 100644 --- a/gtk/gtkpaned.c +++ b/gtk/gtkpaned.c @@ -258,6 +258,7 @@ static void gtk_paned_grab_notify (GtkWidget *widget, G_DEFINE_TYPE_WITH_CODE (GtkPaned, gtk_paned, GTK_TYPE_CONTAINER, + G_ADD_PRIVATE (GtkPaned) G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL)) @@ -652,7 +653,6 @@ gtk_paned_class_init (GtkPanedClass *class) add_move_binding (binding_set, GDK_KEY_End, 0, GTK_SCROLL_END); add_move_binding (binding_set, GDK_KEY_KP_End, 0, GTK_SCROLL_END); - g_type_class_add_private (object_class, sizeof (GtkPanedPrivate)); gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_PANED_ACCESSIBLE); } @@ -681,7 +681,7 @@ gtk_paned_init (GtkPaned *paned) */ gtk_widget_set_redraw_on_allocate (GTK_WIDGET (paned), FALSE); - paned->priv = G_TYPE_INSTANCE_GET_PRIVATE (paned, GTK_TYPE_PANED, GtkPanedPrivate); + paned->priv = gtk_paned_get_instance_private (paned); priv = paned->priv; priv->orientation = GTK_ORIENTATION_HORIZONTAL; diff --git a/gtk/gtkpathbar.c b/gtk/gtkpathbar.c index a00a4a413d..10767b9098 100644 --- a/gtk/gtkpathbar.c +++ b/gtk/gtkpathbar.c @@ -111,7 +111,7 @@ struct _ButtonData */ #define BUTTON_IS_FAKE_ROOT(button) ((button)->type == HOME_BUTTON) -G_DEFINE_TYPE (GtkPathBar, gtk_path_bar, GTK_TYPE_CONTAINER) +G_DEFINE_TYPE_WITH_PRIVATE (GtkPathBar, gtk_path_bar, GTK_TYPE_CONTAINER) static void gtk_path_bar_finalize (GObject *object); static void gtk_path_bar_dispose (GObject *object); @@ -179,9 +179,7 @@ on_slider_unmap (GtkWidget *widget, static void gtk_path_bar_init (GtkPathBar *path_bar) { - path_bar->priv = G_TYPE_INSTANCE_GET_PRIVATE (path_bar, - GTK_TYPE_PATH_BAR, - GtkPathBarPrivate); + path_bar->priv = gtk_path_bar_get_instance_private (path_bar); gtk_widget_init_template (GTK_WIDGET (path_bar)); @@ -270,8 +268,6 @@ gtk_path_bar_class_init (GtkPathBarClass *path_bar_class) gtk_widget_class_bind_callback (widget_class, gtk_path_bar_scroll_up); gtk_widget_class_bind_callback (widget_class, gtk_path_bar_scroll_down); gtk_widget_class_bind_callback (widget_class, on_slider_unmap); - - g_type_class_add_private (gobject_class, sizeof (GtkPathBarPrivate)); } diff --git a/gtk/gtkplug.c b/gtk/gtkplug.c index c93adebe0e..788be1a71e 100644 --- a/gtk/gtkplug.c +++ b/gtk/gtkplug.c @@ -130,7 +130,7 @@ enum { static guint plug_signals[LAST_SIGNAL] = { 0 }; -G_DEFINE_TYPE (GtkPlug, gtk_plug, GTK_TYPE_WINDOW) +G_DEFINE_TYPE_WITH_PRIVATE (GtkPlug, gtk_plug, GTK_TYPE_WINDOW) static void gtk_plug_get_property (GObject *object, @@ -233,16 +233,12 @@ gtk_plug_class_init (GtkPlugClass *class) NULL, NULL, _gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); - - g_type_class_add_private (class, sizeof (GtkPlugPrivate)); } static void gtk_plug_init (GtkPlug *plug) { - plug->priv = G_TYPE_INSTANCE_GET_PRIVATE (plug, - GTK_TYPE_PLUG, - GtkPlugPrivate); + plug->priv = gtk_plug_get_instance_private (plug); } /** diff --git a/gtk/gtkpressandhold.c b/gtk/gtkpressandhold.c index cabdc342d5..0b4f35d049 100644 --- a/gtk/gtkpressandhold.c +++ b/gtk/gtkpressandhold.c @@ -51,15 +51,12 @@ enum static guint signals[LAST_SIGNAL]; -G_DEFINE_TYPE (GtkPressAndHold, gtk_press_and_hold, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE (GtkPressAndHold, gtk_press_and_hold, G_TYPE_OBJECT) static void gtk_press_and_hold_init (GtkPressAndHold *pah) { - pah->priv = G_TYPE_INSTANCE_GET_PRIVATE (pah, - GTK_TYPE_PRESS_AND_HOLD, - GtkPressAndHoldPrivate); - + pah->priv = gtk_press_and_hold_get_instance_private (pah); pah->priv->hold_time = 1000; pah->priv->drag_threshold = 8; } @@ -151,8 +148,6 @@ gtk_press_and_hold_class_init (GtkPressAndHoldClass *class) g_object_class_install_property (object_class, PROP_DRAG_THRESHOLD, g_param_spec_int ("drag-threshold", P_("Drag Threshold"), P_("Drag Threshold (in pixels)"), 1, G_MAXINT, 8, GTK_PARAM_READWRITE)); - - g_type_class_add_private (object_class, sizeof (GtkPressAndHoldPrivate)); } static void diff --git a/gtk/gtkprintbackend.c b/gtk/gtkprintbackend.c index dcfe9a7204..fc2a210022 100644 --- a/gtk/gtkprintbackend.c +++ b/gtk/gtkprintbackend.c @@ -342,7 +342,7 @@ gtk_print_backend_load_modules (void) * GtkPrintBackend * *****************************************/ -G_DEFINE_TYPE (GtkPrintBackend, gtk_print_backend, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE (GtkPrintBackend, gtk_print_backend, G_TYPE_OBJECT) static void fallback_printer_request_details (GtkPrinter *printer); static gboolean fallback_printer_mark_conflicts (GtkPrinter *printer, @@ -391,8 +391,6 @@ gtk_print_backend_class_init (GtkPrintBackendClass *class) GTK_PRINT_BACKEND_STATUS_UNAVAILABLE, GTK_PRINT_BACKEND_STATUS_UNKNOWN, GTK_PARAM_READWRITE)); - - g_type_class_add_private (class, sizeof (GtkPrintBackendPrivate)); signals[PRINTER_LIST_CHANGED] = g_signal_new (I_("printer-list-changed"), @@ -449,9 +447,7 @@ gtk_print_backend_init (GtkPrintBackend *backend) { GtkPrintBackendPrivate *priv; - priv = backend->priv = G_TYPE_INSTANCE_GET_PRIVATE (backend, - GTK_TYPE_PRINT_BACKEND, - GtkPrintBackendPrivate); + priv = backend->priv = gtk_print_backend_get_instance_private (backend); priv->printers = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, diff --git a/gtk/gtkprinter.c b/gtk/gtkprinter.c index fac0136fe5..d8097363aa 100644 --- a/gtk/gtkprinter.c +++ b/gtk/gtkprinter.c @@ -102,7 +102,7 @@ static void gtk_printer_get_property (GObject *object, GValue *value, GParamSpec *pspec); -G_DEFINE_TYPE (GtkPrinter, gtk_printer, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE (GtkPrinter, gtk_printer, G_TYPE_OBJECT) static void gtk_printer_class_init (GtkPrinterClass *class) @@ -115,8 +115,6 @@ gtk_printer_class_init (GtkPrinterClass *class) object_class->set_property = gtk_printer_set_property; object_class->get_property = gtk_printer_get_property; - g_type_class_add_private (class, sizeof (GtkPrinterPrivate)); - g_object_class_install_property (G_OBJECT_CLASS (class), PROP_NAME, g_param_spec_string ("name", @@ -240,9 +238,7 @@ gtk_printer_init (GtkPrinter *printer) { GtkPrinterPrivate *priv; - priv = printer->priv = G_TYPE_INSTANCE_GET_PRIVATE (printer, - GTK_TYPE_PRINTER, - GtkPrinterPrivate); + priv = printer->priv = gtk_printer_get_instance_private (printer); priv->name = NULL; priv->location = NULL; diff --git a/gtk/gtkprinteroptionwidget.c b/gtk/gtkprinteroptionwidget.c index f538607123..4fa951ff7f 100644 --- a/gtk/gtkprinteroptionwidget.c +++ b/gtk/gtkprinteroptionwidget.c @@ -38,9 +38,6 @@ #include "gtkprinteroptionwidget.h" -#define GTK_PRINTER_OPTION_WIDGET_GET_PRIVATE(o) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_PRINTER_OPTION_WIDGET, GtkPrinterOptionWidgetPrivate)) - /* This defines the max file length that the file chooser * button should display. The total length will be * FILENAME_LENGTH_MAX+3 because the truncated name is prefixed @@ -86,7 +83,7 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; -G_DEFINE_TYPE (GtkPrinterOptionWidget, gtk_printer_option_widget, GTK_TYPE_BOX) +G_DEFINE_TYPE_WITH_PRIVATE (GtkPrinterOptionWidget, gtk_printer_option_widget, GTK_TYPE_BOX) static void gtk_printer_option_widget_set_property (GObject *object, guint prop_id, @@ -114,8 +111,6 @@ gtk_printer_option_widget_class_init (GtkPrinterOptionWidgetClass *class) widget_class->mnemonic_activate = gtk_printer_option_widget_mnemonic_activate; - g_type_class_add_private (class, sizeof (GtkPrinterOptionWidgetPrivate)); - signals[CHANGED] = g_signal_new ("changed", G_TYPE_FROM_CLASS (class), @@ -138,7 +133,7 @@ gtk_printer_option_widget_class_init (GtkPrinterOptionWidgetClass *class) static void gtk_printer_option_widget_init (GtkPrinterOptionWidget *widget) { - widget->priv = GTK_PRINTER_OPTION_WIDGET_GET_PRIVATE (widget); + widget->priv = gtk_printer_option_widget_get_instance_private (widget); gtk_box_set_spacing (GTK_BOX (widget), 12); } diff --git a/gtk/gtkprintjob.c b/gtk/gtkprintjob.c index 439b668626..918ece56a8 100644 --- a/gtk/gtkprintjob.c +++ b/gtk/gtkprintjob.c @@ -86,9 +86,6 @@ struct _GtkPrintJobPrivate guint reverse : 1; }; -#define GTK_PRINT_JOB_GET_PRIVATE(o) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_PRINT_JOB, GtkPrintJobPrivate)) - static void gtk_print_job_finalize (GObject *object); static void gtk_print_job_set_property (GObject *object, guint prop_id, @@ -118,7 +115,7 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; -G_DEFINE_TYPE (GtkPrintJob, gtk_print_job, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE (GtkPrintJob, gtk_print_job, G_TYPE_OBJECT) static void gtk_print_job_class_init (GtkPrintJobClass *class) @@ -131,8 +128,6 @@ gtk_print_job_class_init (GtkPrintJobClass *class) object_class->set_property = gtk_print_job_set_property; object_class->get_property = gtk_print_job_get_property; - g_type_class_add_private (class, sizeof (GtkPrintJobPrivate)); - g_object_class_install_property (object_class, PROP_TITLE, g_param_spec_string ("title", @@ -204,7 +199,7 @@ gtk_print_job_init (GtkPrintJob *job) { GtkPrintJobPrivate *priv; - priv = job->priv = GTK_PRINT_JOB_GET_PRIVATE (job); + priv = job->priv = gtk_print_job_get_instance_private (job); priv->spool_io = NULL; diff --git a/gtk/gtkprintoperation.c b/gtk/gtkprintoperation.c index 3fd4f93dc7..58d49a1b12 100644 --- a/gtk/gtkprintoperation.c +++ b/gtk/gtkprintoperation.c @@ -158,6 +158,7 @@ static void clamp_page_ranges (PrintPagesData *data); G_DEFINE_TYPE_WITH_CODE (GtkPrintOperation, gtk_print_operation, G_TYPE_OBJECT, + G_ADD_PRIVATE (GtkPrintOperation) G_IMPLEMENT_INTERFACE (GTK_TYPE_PRINT_OPERATION_PREVIEW, preview_iface_init)) @@ -224,9 +225,7 @@ gtk_print_operation_init (GtkPrintOperation *operation) GtkPrintOperationPrivate *priv; const char *appname; - priv = operation->priv = G_TYPE_INSTANCE_GET_PRIVATE (operation, - GTK_TYPE_PRINT_OPERATION, - GtkPrintOperationPrivate); + priv = operation->priv = gtk_print_operation_get_instance_private (operation); priv->status = GTK_PRINT_STATUS_INITIAL; priv->status_string = g_strdup (""); @@ -736,8 +735,6 @@ gtk_print_operation_class_init (GtkPrintOperationClass *class) class->preview = gtk_print_operation_preview_handler; class->create_custom_widget = gtk_print_operation_create_custom_widget; class->done = gtk_print_operation_done; - - g_type_class_add_private (gobject_class, sizeof (GtkPrintOperationPrivate)); /** * GtkPrintOperation::done: diff --git a/gtk/gtkprintunixdialog.c b/gtk/gtkprintunixdialog.c index 9f0065f067..db0c5599e5 100644 --- a/gtk/gtkprintunixdialog.c +++ b/gtk/gtkprintunixdialog.c @@ -374,6 +374,7 @@ struct GtkPrintUnixDialogPrivate }; G_DEFINE_TYPE_WITH_CODE (GtkPrintUnixDialog, gtk_print_unix_dialog, GTK_TYPE_DIALOG, + G_ADD_PRIVATE (GtkPrintUnixDialog) G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_print_unix_dialog_buildable_init)) @@ -560,8 +561,6 @@ gtk_print_unix_dialog_class_init (GtkPrintUnixDialogClass *class) gtk_widget_class_bind_callback (widget_class, update_number_up_layout); gtk_widget_class_bind_callback (widget_class, redraw_page_layout_preview); gtk_widget_class_bind_callback (widget_class, draw_page_cb); - - g_type_class_add_private (class, sizeof (GtkPrintUnixDialogPrivate)); } /* Returns a toplevel GtkWindow, or NULL if none */ @@ -727,9 +726,7 @@ gtk_print_unix_dialog_init (GtkPrintUnixDialog *dialog) GtkPrintUnixDialogPrivate *priv; GtkTreeSortable *sort; - dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (dialog, - GTK_TYPE_PRINT_UNIX_DIALOG, - GtkPrintUnixDialogPrivate); + dialog->priv = gtk_print_unix_dialog_get_instance_private (dialog); priv = dialog->priv; priv->print_backends = NULL; diff --git a/gtk/gtkprogressbar.c b/gtk/gtkprogressbar.c index 932980a33e..39e438876f 100644 --- a/gtk/gtkprogressbar.c +++ b/gtk/gtkprogressbar.c @@ -122,6 +122,7 @@ static void gtk_progress_bar_set_orientation (GtkProgressBar *progress, GtkOrientation orientation); G_DEFINE_TYPE_WITH_CODE (GtkProgressBar, gtk_progress_bar, GTK_TYPE_WIDGET, + G_ADD_PRIVATE (GtkProgressBar) G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL)) static void @@ -286,8 +287,6 @@ gtk_progress_bar_class_init (GtkProgressBarClass *class) 1, G_MAXINT, MIN_VERTICAL_BAR_HEIGHT, G_PARAM_READWRITE)); - g_type_class_add_private (class, sizeof (GtkProgressBarPrivate)); - gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_PROGRESS_BAR_ACCESSIBLE); } @@ -296,9 +295,7 @@ gtk_progress_bar_init (GtkProgressBar *pbar) { GtkProgressBarPrivate *priv; - pbar->priv = G_TYPE_INSTANCE_GET_PRIVATE (pbar, - GTK_TYPE_PROGRESS_BAR, - GtkProgressBarPrivate); + pbar->priv = gtk_progress_bar_get_instance_private (pbar); priv = pbar->priv; priv->orientation = GTK_ORIENTATION_HORIZONTAL; diff --git a/gtk/gtkquery.c b/gtk/gtkquery.c index daf81e9644..63830ca2ec 100644 --- a/gtk/gtkquery.c +++ b/gtk/gtkquery.c @@ -31,7 +31,7 @@ struct _GtkQueryPrivate GList *mime_types; }; -G_DEFINE_TYPE (GtkQuery, _gtk_query, G_TYPE_OBJECT); +G_DEFINE_TYPE_WITH_PRIVATE (GtkQuery, _gtk_query, G_TYPE_OBJECT) static void finalize (GObject *object) @@ -52,14 +52,12 @@ _gtk_query_class_init (GtkQueryClass *class) gobject_class = G_OBJECT_CLASS (class); gobject_class->finalize = finalize; - - g_type_class_add_private (gobject_class, sizeof (GtkQueryPrivate)); } static void _gtk_query_init (GtkQuery *query) { - query->priv = G_TYPE_INSTANCE_GET_PRIVATE (query, GTK_TYPE_QUERY, GtkQueryPrivate); + query->priv = _gtk_query_get_instance_private (query); } GtkQuery * diff --git a/gtk/gtkradioaction.c b/gtk/gtkradioaction.c index 3fb226a0e7..6b3c657fc2 100644 --- a/gtk/gtkradioaction.c +++ b/gtk/gtkradioaction.c @@ -80,7 +80,7 @@ static void gtk_radio_action_activate (GtkAction *action); static GtkWidget *create_menu_item (GtkAction *action); -G_DEFINE_TYPE (GtkRadioAction, gtk_radio_action, GTK_TYPE_TOGGLE_ACTION) +G_DEFINE_TYPE_WITH_PRIVATE (GtkRadioAction, gtk_radio_action, GTK_TYPE_TOGGLE_ACTION) static guint radio_action_signals[LAST_SIGNAL] = { 0 }; @@ -181,17 +181,12 @@ gtk_radio_action_class_init (GtkRadioActionClass *klass) G_STRUCT_OFFSET (GtkRadioActionClass, changed), NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GTK_TYPE_RADIO_ACTION); - - g_type_class_add_private (gobject_class, sizeof (GtkRadioActionPrivate)); } static void gtk_radio_action_init (GtkRadioAction *action) { - action->private_data = G_TYPE_INSTANCE_GET_PRIVATE (action, - GTK_TYPE_RADIO_ACTION, - GtkRadioActionPrivate); - + action->private_data = gtk_radio_action_get_instance_private (action); action->private_data->group = g_slist_prepend (NULL, action); action->private_data->value = 0; diff --git a/gtk/gtkradiobutton.c b/gtk/gtkradiobutton.c index ca221edf3d..b4f375cffb 100644 --- a/gtk/gtkradiobutton.c +++ b/gtk/gtkradiobutton.c @@ -132,7 +132,7 @@ static void gtk_radio_button_get_property (GObject *object, GValue *value, GParamSpec *pspec); -G_DEFINE_TYPE (GtkRadioButton, gtk_radio_button, GTK_TYPE_CHECK_BUTTON) +G_DEFINE_TYPE_WITH_PRIVATE (GtkRadioButton, gtk_radio_button, GTK_TYPE_CHECK_BUTTON) static guint group_changed_signal = 0; @@ -194,8 +194,6 @@ gtk_radio_button_class_init (GtkRadioButtonClass *class) _gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); - g_type_class_add_private (class, sizeof (GtkRadioButtonPrivate)); - gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_RADIO_BUTTON_ACCESSIBLE); } @@ -204,9 +202,7 @@ gtk_radio_button_init (GtkRadioButton *radio_button) { GtkRadioButtonPrivate *priv; - radio_button->priv = G_TYPE_INSTANCE_GET_PRIVATE (radio_button, - GTK_TYPE_RADIO_BUTTON, - GtkRadioButtonPrivate); + radio_button->priv = gtk_radio_button_get_instance_private (radio_button); priv = radio_button->priv; gtk_widget_set_receives_default (GTK_WIDGET (radio_button), FALSE); diff --git a/gtk/gtkradiomenuitem.c b/gtk/gtkradiomenuitem.c index f9737aba2d..d59eb04b60 100644 --- a/gtk/gtkradiomenuitem.c +++ b/gtk/gtkradiomenuitem.c @@ -89,7 +89,7 @@ static void gtk_radio_menu_item_get_property (GObject *object, static guint group_changed_signal = 0; -G_DEFINE_TYPE (GtkRadioMenuItem, gtk_radio_menu_item, GTK_TYPE_CHECK_MENU_ITEM) +G_DEFINE_TYPE_WITH_PRIVATE (GtkRadioMenuItem, gtk_radio_menu_item, GTK_TYPE_CHECK_MENU_ITEM) /** * gtk_radio_menu_item_new: @@ -430,8 +430,6 @@ gtk_radio_menu_item_class_init (GtkRadioMenuItemClass *klass) NULL, NULL, _gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); - - g_type_class_add_private (klass, sizeof (GtkRadioMenuItemPrivate)); } static void @@ -439,9 +437,7 @@ gtk_radio_menu_item_init (GtkRadioMenuItem *radio_menu_item) { GtkRadioMenuItemPrivate *priv; - radio_menu_item->priv = G_TYPE_INSTANCE_GET_PRIVATE (radio_menu_item, - GTK_TYPE_RADIO_MENU_ITEM, - GtkRadioMenuItemPrivate); + radio_menu_item->priv = gtk_radio_menu_item_get_instance_private (radio_menu_item); priv = radio_menu_item->priv; priv->group = g_slist_prepend (NULL, radio_menu_item); diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c index 4a42597b4d..9ef4ff362b 100644 --- a/gtk/gtkrange.c +++ b/gtk/gtkrange.c @@ -280,6 +280,7 @@ static gboolean gtk_range_key_press (GtkWidget *range, G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GtkRange, gtk_range, GTK_TYPE_WIDGET, + G_ADD_PRIVATE (GtkRange) G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL)) @@ -606,8 +607,6 @@ gtk_range_class_init (GtkRangeClass *class) 0.0, 1.0, 0.5, GTK_PARAM_READABLE)); - g_type_class_add_private (class, sizeof (GtkRangePrivate)); - gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_RANGE_ACCESSIBLE); } @@ -713,9 +712,7 @@ gtk_range_init (GtkRange *range) { GtkRangePrivate *priv; - range->priv = G_TYPE_INSTANCE_GET_PRIVATE (range, - GTK_TYPE_RANGE, - GtkRangePrivate); + range->priv = gtk_range_get_instance_private (range); priv = range->priv; gtk_widget_set_has_window (GTK_WIDGET (range), FALSE); diff --git a/gtk/gtkrecentaction.c b/gtk/gtkrecentaction.c index e9ffe5707a..f61dfa98ff 100644 --- a/gtk/gtkrecentaction.c +++ b/gtk/gtkrecentaction.c @@ -88,6 +88,7 @@ static void gtk_recent_chooser_iface_init (GtkRecentChooserIface *iface); G_DEFINE_TYPE_WITH_CODE (GtkRecentAction, gtk_recent_action, GTK_TYPE_ACTION, + G_ADD_PRIVATE (GtkRecentAction) G_IMPLEMENT_INTERFACE (GTK_TYPE_RECENT_CHOOSER, gtk_recent_chooser_iface_init)); @@ -613,8 +614,6 @@ gtk_recent_action_class_init (GtkRecentActionClass *klass) GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GtkActionClass *action_class = GTK_ACTION_CLASS (klass); - g_type_class_add_private (klass, sizeof (GtkRecentActionPrivate)); - gobject_class->finalize = gtk_recent_action_finalize; gobject_class->dispose = gtk_recent_action_dispose; gobject_class->set_property = gtk_recent_action_set_property; @@ -655,9 +654,7 @@ gtk_recent_action_init (GtkRecentAction *action) { GtkRecentActionPrivate *priv; - action->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (action, - GTK_TYPE_RECENT_ACTION, - GtkRecentActionPrivate); + action->priv = priv = gtk_recent_action_get_instance_private (action); priv->show_numbers = FALSE; priv->show_icons = TRUE; diff --git a/gtk/gtkrecentchooserdefault.c b/gtk/gtkrecentchooserdefault.c index 32014bf86d..c1d15d2feb 100644 --- a/gtk/gtkrecentchooserdefault.c +++ b/gtk/gtkrecentchooserdefault.c @@ -291,6 +291,7 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS; G_DEFINE_TYPE_WITH_CODE (GtkRecentChooserDefault, _gtk_recent_chooser_default, GTK_TYPE_BOX, + G_ADD_PRIVATE (GtkRecentChooserDefault) G_IMPLEMENT_INTERFACE (GTK_TYPE_RECENT_CHOOSER, gtk_recent_chooser_iface_init) G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE, @@ -366,8 +367,6 @@ _gtk_recent_chooser_default_class_init (GtkRecentChooserDefaultClass *klass) gtk_widget_class_bind_callback (widget_class, recent_view_drag_begin_cb); gtk_widget_class_bind_callback (widget_class, recent_view_drag_data_get_cb); gtk_widget_class_bind_callback (widget_class, recent_view_query_tooltip_cb); - - g_type_class_add_private (gobject_class, sizeof (GtkRecentChooserDefaultPrivate)); } static void @@ -375,9 +374,7 @@ _gtk_recent_chooser_default_init (GtkRecentChooserDefault *impl) { GtkRecentChooserDefaultPrivate *priv; - impl->priv = priv = - G_TYPE_INSTANCE_GET_PRIVATE (impl, GTK_TYPE_RECENT_CHOOSER_DEFAULT, - GtkRecentChooserDefaultPrivate); + impl->priv = priv = _gtk_recent_chooser_default_get_instance_private (impl); /* by default, we use the global manager */ priv->local_manager = FALSE; diff --git a/gtk/gtkrecentchooserdialog.c b/gtk/gtkrecentchooserdialog.c index e6b7db684a..97309651ef 100644 --- a/gtk/gtkrecentchooserdialog.c +++ b/gtk/gtkrecentchooserdialog.c @@ -101,6 +101,7 @@ static void gtk_recent_chooser_dialog_get_property (GObject *object, G_DEFINE_TYPE_WITH_CODE (GtkRecentChooserDialog, gtk_recent_chooser_dialog, GTK_TYPE_DIALOG, + G_ADD_PRIVATE (GtkRecentChooserDialog) G_IMPLEMENT_INTERFACE (GTK_TYPE_RECENT_CHOOSER, _gtk_recent_chooser_delegate_iface_init)) @@ -115,20 +116,16 @@ gtk_recent_chooser_dialog_class_init (GtkRecentChooserDialogClass *klass) gobject_class->finalize = gtk_recent_chooser_dialog_finalize; _gtk_recent_chooser_install_properties (gobject_class); - - g_type_class_add_private (klass, sizeof (GtkRecentChooserDialogPrivate)); } static void gtk_recent_chooser_dialog_init (GtkRecentChooserDialog *dialog) { + GtkRecentChooserDialogPrivate *priv; GtkWidget *content_area, *action_area; - - GtkRecentChooserDialogPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (dialog, - GTK_TYPE_RECENT_CHOOSER_DIALOG, - GtkRecentChooserDialogPrivate); GtkDialog *rc_dialog = GTK_DIALOG (dialog); - + + priv = gtk_recent_chooser_dialog_get_instance_private (dialog); dialog->priv = priv; content_area = gtk_dialog_get_content_area (rc_dialog); diff --git a/gtk/gtkrecentchoosermenu.c b/gtk/gtkrecentchoosermenu.c index 08e385805a..f1ce8479f9 100644 --- a/gtk/gtkrecentchoosermenu.c +++ b/gtk/gtkrecentchoosermenu.c @@ -188,6 +188,7 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS; G_DEFINE_TYPE_WITH_CODE (GtkRecentChooserMenu, gtk_recent_chooser_menu, GTK_TYPE_MENU, + G_ADD_PRIVATE (GtkRecentChooserMenu) G_IMPLEMENT_INTERFACE (GTK_TYPE_RECENT_CHOOSER, gtk_recent_chooser_iface_init) G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE, @@ -250,8 +251,6 @@ gtk_recent_chooser_menu_class_init (GtkRecentChooserMenuClass *klass) g_object_class_override_property (gobject_class, PROP_ACTIVATABLE_RELATED_ACTION, "related-action"); g_object_class_override_property (gobject_class, PROP_ACTIVATABLE_USE_ACTION_APPEARANCE, "use-action-appearance"); - - g_type_class_add_private (klass, sizeof (GtkRecentChooserMenuPrivate)); } static void @@ -259,10 +258,7 @@ gtk_recent_chooser_menu_init (GtkRecentChooserMenu *menu) { GtkRecentChooserMenuPrivate *priv; - menu->priv = G_TYPE_INSTANCE_GET_PRIVATE (menu, - GTK_TYPE_RECENT_CHOOSER_MENU, - GtkRecentChooserMenuPrivate); - + menu->priv = gtk_recent_chooser_menu_get_instance_private (menu); priv = menu->priv; priv->show_icons= TRUE; diff --git a/gtk/gtkrecentchooserwidget.c b/gtk/gtkrecentchooserwidget.c index 64f6df660f..d8fe8753e4 100644 --- a/gtk/gtkrecentchooserwidget.c +++ b/gtk/gtkrecentchooserwidget.c @@ -49,11 +49,6 @@ struct _GtkRecentChooserWidgetPrivate GtkWidget *chooser; }; -#define GTK_RECENT_CHOOSER_WIDGET_GET_PRIVATE(obj) (GTK_RECENT_CHOOSER_WIDGET (obj)->priv) - -static GObject *gtk_recent_chooser_widget_constructor (GType type, - guint n_params, - GObjectConstructParam *params); static void gtk_recent_chooser_widget_set_property (GObject *object, guint prop_id, const GValue *value, @@ -68,57 +63,21 @@ static void gtk_recent_chooser_widget_finalize (GObject *o G_DEFINE_TYPE_WITH_CODE (GtkRecentChooserWidget, gtk_recent_chooser_widget, GTK_TYPE_BOX, + G_ADD_PRIVATE (GtkRecentChooserWidget) G_IMPLEMENT_INTERFACE (GTK_TYPE_RECENT_CHOOSER, _gtk_recent_chooser_delegate_iface_init)) static void -gtk_recent_chooser_widget_class_init (GtkRecentChooserWidgetClass *klass) +gtk_recent_chooser_widget_constructed (GObject *gobject) { - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GtkRecentChooserWidget *self = GTK_RECENT_CHOOSER_WIDGET (gobject); - gobject_class->constructor = gtk_recent_chooser_widget_constructor; - gobject_class->set_property = gtk_recent_chooser_widget_set_property; - gobject_class->get_property = gtk_recent_chooser_widget_get_property; - gobject_class->finalize = gtk_recent_chooser_widget_finalize; + self->priv->chooser = _gtk_recent_chooser_default_new (self->priv->manager); - _gtk_recent_chooser_install_properties (gobject_class); - - g_type_class_add_private (klass, sizeof (GtkRecentChooserWidgetPrivate)); -} - - -static void -gtk_recent_chooser_widget_init (GtkRecentChooserWidget *widget) -{ - widget->priv = G_TYPE_INSTANCE_GET_PRIVATE (widget, GTK_TYPE_RECENT_CHOOSER_WIDGET, - GtkRecentChooserWidgetPrivate); - - gtk_orientable_set_orientation (GTK_ORIENTABLE (widget), - GTK_ORIENTATION_VERTICAL); -} - -static GObject * -gtk_recent_chooser_widget_constructor (GType type, - guint n_params, - GObjectConstructParam *params) -{ - GObject *object; - GtkRecentChooserWidgetPrivate *priv; - - object = G_OBJECT_CLASS (gtk_recent_chooser_widget_parent_class)->constructor (type, - n_params, - params); - - priv = GTK_RECENT_CHOOSER_WIDGET_GET_PRIVATE (object); - priv->chooser = _gtk_recent_chooser_default_new (priv->manager); - - - gtk_container_add (GTK_CONTAINER (object), priv->chooser); - gtk_widget_show (priv->chooser); - _gtk_recent_chooser_set_delegate (GTK_RECENT_CHOOSER (object), - GTK_RECENT_CHOOSER (priv->chooser)); - - return object; + gtk_container_add (GTK_CONTAINER (self), self->priv->chooser); + gtk_widget_show (self->priv->chooser); + _gtk_recent_chooser_set_delegate (GTK_RECENT_CHOOSER (self), + GTK_RECENT_CHOOSER (self->priv->chooser)); } static void @@ -129,7 +88,7 @@ gtk_recent_chooser_widget_set_property (GObject *object, { GtkRecentChooserWidgetPrivate *priv; - priv = GTK_RECENT_CHOOSER_WIDGET_GET_PRIVATE (object); + priv = gtk_recent_chooser_widget_get_instance_private (GTK_RECENT_CHOOSER_WIDGET (object)); switch (prop_id) { @@ -150,7 +109,7 @@ gtk_recent_chooser_widget_get_property (GObject *object, { GtkRecentChooserWidgetPrivate *priv; - priv = GTK_RECENT_CHOOSER_WIDGET_GET_PRIVATE (object); + priv = gtk_recent_chooser_widget_get_instance_private (GTK_RECENT_CHOOSER_WIDGET (object)); g_object_get_property (G_OBJECT (priv->chooser), pspec->name, value); } @@ -158,14 +117,35 @@ gtk_recent_chooser_widget_get_property (GObject *object, static void gtk_recent_chooser_widget_finalize (GObject *object) { - GtkRecentChooserWidgetPrivate *priv; - - priv = GTK_RECENT_CHOOSER_WIDGET_GET_PRIVATE (object); - priv->manager = NULL; + GtkRecentChooserWidget *self = GTK_RECENT_CHOOSER_WIDGET (object); + + self->priv->manager = NULL; G_OBJECT_CLASS (gtk_recent_chooser_widget_parent_class)->finalize (object); } +static void +gtk_recent_chooser_widget_class_init (GtkRecentChooserWidgetClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + + gobject_class->constructed = gtk_recent_chooser_widget_constructed; + gobject_class->set_property = gtk_recent_chooser_widget_set_property; + gobject_class->get_property = gtk_recent_chooser_widget_get_property; + gobject_class->finalize = gtk_recent_chooser_widget_finalize; + + _gtk_recent_chooser_install_properties (gobject_class); +} + +static void +gtk_recent_chooser_widget_init (GtkRecentChooserWidget *widget) +{ + widget->priv = gtk_recent_chooser_widget_get_instance_private (widget); + + gtk_orientable_set_orientation (GTK_ORIENTABLE (widget), + GTK_ORIENTATION_VERTICAL); +} + /* * Public API */ diff --git a/gtk/gtkrecentmanager.c b/gtk/gtkrecentmanager.c index 310efe0771..d2f4d68de7 100644 --- a/gtk/gtkrecentmanager.c +++ b/gtk/gtkrecentmanager.c @@ -230,7 +230,7 @@ static guint signal_changed = 0; static GtkRecentManager *recent_manager_singleton = NULL; -G_DEFINE_TYPE (GtkRecentManager, gtk_recent_manager, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE (GtkRecentManager, gtk_recent_manager, G_TYPE_OBJECT) static void filename_warning (const gchar *format, @@ -333,8 +333,6 @@ gtk_recent_manager_class_init (GtkRecentManagerClass *klass) G_TYPE_NONE, 0); klass->changed = gtk_recent_manager_real_changed; - - g_type_class_add_private (klass, sizeof (GtkRecentManagerPrivate)); } static void @@ -343,9 +341,7 @@ gtk_recent_manager_init (GtkRecentManager *manager) GtkRecentManagerPrivate *priv; GtkSettings *settings; - manager->priv = G_TYPE_INSTANCE_GET_PRIVATE (manager, - GTK_TYPE_RECENT_MANAGER, - GtkRecentManagerPrivate); + manager->priv = gtk_recent_manager_get_instance_private (manager); priv = manager->priv; priv->size = 0; diff --git a/gtk/gtkrevealer.c b/gtk/gtkrevealer.c index f3c584e566..e97572586c 100644 --- a/gtk/gtkrevealer.c +++ b/gtk/gtkrevealer.c @@ -108,8 +108,7 @@ static void gtk_revealer_real_get_preferred_width_for_height (GtkWidget gint *minimum_width, gint *natural_width); -G_DEFINE_TYPE_WITH_PRIVATE (GtkRevealer, gtk_revealer, GTK_TYPE_BIN); - +G_DEFINE_TYPE_WITH_PRIVATE (GtkRevealer, gtk_revealer, GTK_TYPE_BIN) static void gtk_revealer_init (GtkRevealer *revealer) diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c index 6abd82e1c6..46b7ceb703 100644 --- a/gtk/gtkscale.c +++ b/gtk/gtkscale.c @@ -163,6 +163,7 @@ static void gtk_scale_buildable_custom_finished (GtkBuildable *buildable, G_DEFINE_TYPE_WITH_CODE (GtkScale, gtk_scale, GTK_TYPE_RANGE, + G_ADD_PRIVATE (GtkScale) G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_scale_buildable_interface_init)) @@ -474,8 +475,6 @@ gtk_scale_class_init (GtkScaleClass *class) add_slider_binding (binding_set, GDK_KEY_KP_End, 0, GTK_SCROLL_END); - g_type_class_add_private (gobject_class, sizeof (GtkScalePrivate)); - gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_SCALE_ACCESSIBLE); } @@ -486,9 +485,7 @@ gtk_scale_init (GtkScale *scale) GtkRange *range = GTK_RANGE (scale); GtkStyleContext *context; - scale->priv = G_TYPE_INSTANCE_GET_PRIVATE (scale, - GTK_TYPE_SCALE, - GtkScalePrivate); + scale->priv = gtk_scale_get_instance_private (scale); priv = scale->priv; gtk_widget_set_can_focus (GTK_WIDGET (scale), TRUE); @@ -503,7 +500,7 @@ gtk_scale_init (GtkScale *scale) gtk_range_set_round_digits (range, priv->digits); gtk_range_set_flippable (range, - gtk_orientable_get_orientation (GTK_ORIENTABLE (range))== GTK_ORIENTATION_HORIZONTAL); + gtk_orientable_get_orientation (GTK_ORIENTABLE (range)) == GTK_ORIENTATION_HORIZONTAL); context = gtk_widget_get_style_context (GTK_WIDGET (scale)); gtk_style_context_add_class (context, GTK_STYLE_CLASS_SCALE); diff --git a/gtk/gtkscalebutton.c b/gtk/gtkscalebutton.c index 2a5c3d69bf..bc23e4d732 100644 --- a/gtk/gtkscalebutton.c +++ b/gtk/gtkscalebutton.c @@ -167,6 +167,7 @@ static void gtk_scale_button_update_icon (GtkScaleButton *button); static void gtk_scale_button_scale_value_changed(GtkRange *range); G_DEFINE_TYPE_WITH_CODE (GtkScaleButton, gtk_scale_button, GTK_TYPE_BUTTON, + G_ADD_PRIVATE (GtkScaleButton) G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL)) @@ -194,8 +195,6 @@ gtk_scale_button_class_init (GtkScaleButtonClass *klass) GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); GtkBindingSet *binding_set; - g_type_class_add_private (klass, sizeof (GtkScaleButtonPrivate)); - gobject_class->constructor = gtk_scale_button_constructor; gobject_class->finalize = gtk_scale_button_finalize; gobject_class->dispose = gtk_scale_button_dispose; @@ -385,9 +384,7 @@ gtk_scale_button_init (GtkScaleButton *button) { GtkScaleButtonPrivate *priv; - button->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (button, - GTK_TYPE_SCALE_BUTTON, - GtkScaleButtonPrivate); + button->priv = priv = gtk_scale_button_get_instance_private (button); priv->timeout = FALSE; priv->click_id = 0; diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c index 94ad7bb4a1..54672bc51a 100644 --- a/gtk/gtkscrolledwindow.c +++ b/gtk/gtkscrolledwindow.c @@ -281,8 +281,7 @@ static void gtk_scrolled_window_cancel_deceleration (GtkScrolledWindow *scrolled static guint signals[LAST_SIGNAL] = {0}; -G_DEFINE_TYPE (GtkScrolledWindow, gtk_scrolled_window, GTK_TYPE_BIN) - +G_DEFINE_TYPE_WITH_PRIVATE (GtkScrolledWindow, gtk_scrolled_window, GTK_TYPE_BIN) static void add_scroll_binding (GtkBindingSet *binding_set, @@ -562,8 +561,6 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class) add_tab_bindings (binding_set, GDK_CONTROL_MASK, GTK_DIR_TAB_FORWARD); add_tab_bindings (binding_set, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD); - g_type_class_add_private (class, sizeof (GtkScrolledWindowPrivate)); - gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_SCROLLED_WINDOW_ACCESSIBLE); } @@ -572,9 +569,8 @@ gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window) { GtkScrolledWindowPrivate *priv; - scrolled_window->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (scrolled_window, - GTK_TYPE_SCROLLED_WINDOW, - GtkScrolledWindowPrivate); + scrolled_window->priv = priv = + gtk_scrolled_window_get_instance_private (scrolled_window); gtk_widget_set_has_window (GTK_WIDGET (scrolled_window), FALSE); gtk_widget_set_can_focus (GTK_WIDGET (scrolled_window), TRUE); diff --git a/gtk/gtksearchbar.c b/gtk/gtksearchbar.c index 330fdb229e..caee68ed24 100644 --- a/gtk/gtksearchbar.c +++ b/gtk/gtksearchbar.c @@ -78,9 +78,7 @@ * Since: 3.10 */ -G_DEFINE_TYPE (GtkSearchBar, gtk_search_bar, GTK_TYPE_BIN) - -struct _GtkSearchBarPrivate { +typedef struct { /* Template widgets */ GtkWidget *revealer; GtkWidget *toolbar; @@ -89,7 +87,9 @@ struct _GtkSearchBarPrivate { GtkWidget *entry; gboolean reveal_child; -}; +} GtkSearchBarPrivate; + +G_DEFINE_TYPE_WITH_PRIVATE (GtkSearchBar, gtk_search_bar, GTK_TYPE_BIN) enum { PROP_0, @@ -141,13 +141,15 @@ entry_key_pressed_event_cb (GtkWidget *widget, GdkEvent *event, GtkSearchBar *bar) { + GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar); guint keyval; if (!gdk_event_get_keyval (event, &keyval) || keyval != GDK_KEY_Escape) return GDK_EVENT_PROPAGATE; - gtk_revealer_set_reveal_child (GTK_REVEALER (bar->priv->revealer), FALSE); + gtk_revealer_set_reveal_child (GTK_REVEALER (priv->revealer), FALSE); + return GDK_EVENT_STOP; } @@ -202,6 +204,7 @@ gboolean gtk_search_bar_handle_event (GtkSearchBar *bar, GdkEvent *event) { + GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar); guint keyval; gboolean handled; gboolean preedit_changed; @@ -209,7 +212,7 @@ gtk_search_bar_handle_event (GtkSearchBar *bar, gboolean res; char *old_text, *new_text; - if (!bar->priv->entry) + if (priv->entry == NULL) { g_warning ("The search bar does not have an entry connected to it. Call gtk_search_bar_connect_entry() to connect one."); return GDK_EVENT_PROPAGATE; @@ -219,30 +222,30 @@ gtk_search_bar_handle_event (GtkSearchBar *bar, * the event doesn't contain a key press, * or the event is a navigation or space bar key press */ - if (bar->priv->reveal_child || + if (priv->reveal_child || !gdk_event_get_keyval (event, &keyval) || is_keynav_event (event, keyval) || keyval == GDK_KEY_space) return GDK_EVENT_PROPAGATE; - if (!gtk_widget_get_realized (bar->priv->entry)) - gtk_widget_realize (bar->priv->entry); + if (!gtk_widget_get_realized (priv->entry)) + gtk_widget_realize (priv->entry); handled = GDK_EVENT_PROPAGATE; preedit_changed = FALSE; - preedit_change_id = g_signal_connect (bar->priv->entry, "preedit-changed", + preedit_change_id = g_signal_connect (priv->entry, "preedit-changed", G_CALLBACK (preedit_changed_cb), &preedit_changed); - old_text = g_strdup (gtk_entry_get_text (GTK_ENTRY (bar->priv->entry))); - res = gtk_widget_event (bar->priv->entry, event); - new_text = g_strdup (gtk_entry_get_text (GTK_ENTRY (bar->priv->entry))); + old_text = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->entry))); + res = gtk_widget_event (priv->entry, event); + new_text = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->entry))); - g_signal_handler_disconnect (bar->priv->entry, preedit_change_id); + g_signal_handler_disconnect (priv->entry, preedit_change_id); if ((res && g_strcmp0 (new_text, old_text) != 0) || preedit_changed) { handled = GDK_EVENT_STOP; - gtk_revealer_set_reveal_child (GTK_REVEALER (bar->priv->revealer), TRUE); + gtk_revealer_set_reveal_child (GTK_REVEALER (priv->revealer), TRUE); } g_free (old_text); @@ -256,18 +259,19 @@ reveal_child_changed_cb (GObject *object, GParamSpec *pspec, GtkSearchBar *bar) { + GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar); gboolean reveal_child; g_object_get (object, "reveal-child", &reveal_child, NULL); - if (reveal_child == bar->priv->reveal_child) + if (reveal_child == priv->reveal_child) return; - bar->priv->reveal_child = reveal_child; + priv->reveal_child = reveal_child; if (reveal_child) - _gtk_entry_grab_focus (GTK_ENTRY (bar->priv->entry), FALSE); + _gtk_entry_grab_focus (GTK_ENTRY (priv->entry), FALSE); else - gtk_entry_set_text (GTK_ENTRY (bar->priv->entry), ""); + gtk_entry_set_text (GTK_ENTRY (priv->entry), ""); g_object_notify (G_OBJECT (bar), "search-mode-enabled"); } @@ -276,7 +280,9 @@ static void close_button_clicked_cb (GtkWidget *button, GtkSearchBar *bar) { - gtk_revealer_set_reveal_child (GTK_REVEALER (bar->priv->revealer), FALSE); + GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar); + + gtk_revealer_set_reveal_child (GTK_REVEALER (priv->revealer), FALSE); } static void @@ -284,19 +290,20 @@ gtk_search_bar_add (GtkContainer *container, GtkWidget *child) { GtkSearchBar *bar = GTK_SEARCH_BAR (container); + GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar); /* When constructing the widget, we want the revealer to be added * as the first child of the search bar, as an implementation detail. * After that, the child added by the application should be added * to the toolbar's box_center. */ - if (bar->priv->box_center == NULL) + if (priv->box_center == NULL) { GTK_CONTAINER_CLASS (gtk_search_bar_parent_class)->add (container, child); } else { - gtk_container_add (GTK_CONTAINER (bar->priv->box_center), child); + gtk_container_add (GTK_CONTAINER (priv->box_center), child); /* If an entry is the only child, save the developer a couple of * lines of code */ @@ -334,11 +341,12 @@ gtk_search_bar_get_property (GObject *object, GParamSpec *pspec) { GtkSearchBar *bar = GTK_SEARCH_BAR (object); + GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar); switch (prop_id) { case PROP_SEARCH_MODE_ENABLED: - g_value_set_boolean (value, bar->priv->reveal_child); + g_value_set_boolean (value, priv->reveal_child); break; case PROP_SHOW_CLOSE_BUTTON: g_value_set_boolean (value, gtk_search_bar_get_show_close_button (bar)); @@ -353,12 +361,13 @@ static void gtk_search_bar_dispose (GObject *object) { GtkSearchBar *bar = GTK_SEARCH_BAR (object); + GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar); - if (bar->priv->entry) + if (priv->entry) { - g_signal_handlers_disconnect_by_func (bar->priv->entry, entry_key_pressed_event_cb, bar); - g_object_remove_weak_pointer (G_OBJECT (bar->priv->entry), (gpointer *) &bar->priv->entry); - bar->priv->entry = NULL; + g_signal_handlers_disconnect_by_func (priv->entry, entry_key_pressed_event_cb, bar); + g_object_remove_weak_pointer (G_OBJECT (priv->entry), (gpointer *) &priv->entry); + priv->entry = NULL; } G_OBJECT_CLASS (gtk_search_bar_parent_class)->dispose (object); @@ -408,24 +417,22 @@ gtk_search_bar_class_init (GtkSearchBarClass *klass) gtk_widget_class_bind_child_internal (widget_class, GtkSearchBarPrivate, revealer); gtk_widget_class_bind_child_internal (widget_class, GtkSearchBarPrivate, box_center); gtk_widget_class_bind_child_internal (widget_class, GtkSearchBarPrivate, close_button); - - g_type_class_add_private (klass, sizeof (GtkSearchBarPrivate)); } static void gtk_search_bar_init (GtkSearchBar *bar) { - bar->priv = G_TYPE_INSTANCE_GET_PRIVATE (bar, GTK_TYPE_SEARCH_BAR, GtkSearchBarPrivate); + GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar); gtk_widget_init_template (GTK_WIDGET (bar)); - gtk_widget_show_all (bar->priv->toolbar); + gtk_widget_show_all (priv->toolbar); - g_signal_connect (bar->priv->revealer, "notify::reveal-child", + g_signal_connect (priv->revealer, "notify::reveal-child", G_CALLBACK (reveal_child_changed_cb), bar); - gtk_widget_set_no_show_all (bar->priv->close_button, TRUE); - g_signal_connect (bar->priv->close_button, "clicked", + gtk_widget_set_no_show_all (priv->close_button, TRUE); + g_signal_connect (priv->close_button, "clicked", G_CALLBACK (close_button_clicked_cb), bar); }; @@ -462,21 +469,23 @@ void gtk_search_bar_connect_entry (GtkSearchBar *bar, GtkEntry *entry) { + GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar); + g_return_if_fail (GTK_IS_SEARCH_BAR (bar)); g_return_if_fail (entry == NULL || GTK_IS_ENTRY (entry)); - if (bar->priv->entry != NULL) + if (priv->entry != NULL) { - g_signal_handlers_disconnect_by_func (bar->priv->entry, entry_key_pressed_event_cb, bar); - g_object_remove_weak_pointer (G_OBJECT (bar->priv->entry), (gpointer *) &bar->priv->entry); - bar->priv->entry = NULL; + g_signal_handlers_disconnect_by_func (priv->entry, entry_key_pressed_event_cb, bar); + g_object_remove_weak_pointer (G_OBJECT (priv->entry), (gpointer *) &priv->entry); + priv->entry = NULL; } if (entry != NULL) { - bar->priv->entry = GTK_WIDGET (entry); - g_object_add_weak_pointer (G_OBJECT (bar->priv->entry), (gpointer *) &bar->priv->entry); - g_signal_connect (bar->priv->entry, "key-press-event", + priv->entry = GTK_WIDGET (entry); + g_object_add_weak_pointer (G_OBJECT (priv->entry), (gpointer *) &priv->entry); + g_signal_connect (priv->entry, "key-press-event", G_CALLBACK (entry_key_pressed_event_cb), bar); } } @@ -494,9 +503,11 @@ gtk_search_bar_connect_entry (GtkSearchBar *bar, gboolean gtk_search_bar_get_search_mode (GtkSearchBar *bar) { + GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar); + g_return_val_if_fail (GTK_IS_SEARCH_BAR (bar), FALSE); - return bar->priv->reveal_child; + return priv->reveal_child; } /** @@ -512,9 +523,11 @@ void gtk_search_bar_set_search_mode (GtkSearchBar *bar, gboolean search_mode) { + GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar); + g_return_if_fail (GTK_IS_SEARCH_BAR (bar)); - gtk_revealer_set_reveal_child (GTK_REVEALER (bar->priv->revealer), search_mode); + gtk_revealer_set_reveal_child (GTK_REVEALER (priv->revealer), search_mode); } /** @@ -530,9 +543,11 @@ gtk_search_bar_set_search_mode (GtkSearchBar *bar, gboolean gtk_search_bar_get_show_close_button (GtkSearchBar *bar) { + GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar); + g_return_val_if_fail (GTK_IS_SEARCH_BAR (bar), FALSE); - return gtk_widget_get_visible (bar->priv->close_button); + return gtk_widget_get_visible (priv->close_button); } /** @@ -551,7 +566,9 @@ void gtk_search_bar_set_show_close_button (GtkSearchBar *bar, gboolean visible) { + GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar); + g_return_if_fail (GTK_IS_SEARCH_BAR (bar)); - gtk_widget_set_visible (bar->priv->close_button, visible); + gtk_widget_set_visible (priv->close_button, visible); } diff --git a/gtk/gtksearchbar.h b/gtk/gtksearchbar.h index 93112d28fe..ea3ae851bc 100644 --- a/gtk/gtksearchbar.h +++ b/gtk/gtksearchbar.h @@ -44,15 +44,12 @@ G_BEGIN_DECLS #define GTK_SEARCH_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_SEARCH_BAR, GtkSearchBarClass)) typedef struct _GtkSearchBar GtkSearchBar; -typedef struct _GtkSearchBarPrivate GtkSearchBarPrivate; typedef struct _GtkSearchBarClass GtkSearchBarClass; struct _GtkSearchBar { /*< private >*/ GtkBin parent; - - GtkSearchBarPrivate *priv; }; struct _GtkSearchBarClass diff --git a/gtk/gtksearchenginequartz.c b/gtk/gtksearchenginequartz.c index 7281fcf9b2..fc8370d301 100644 --- a/gtk/gtksearchenginequartz.c +++ b/gtk/gtksearchenginequartz.c @@ -55,7 +55,7 @@ struct _GtkSearchEngineQuartzPrivate gboolean query_finished; }; -G_DEFINE_TYPE (GtkSearchEngineQuartz, _gtk_search_engine_quartz, GTK_TYPE_SEARCH_ENGINE); +G_DEFINE_TYPE_WITH_PRIVATE (GtkSearchEngineQuartz, _gtk_search_engine_quartz, GTK_TYPE_SEARCH_ENGINE) /* Implementation of the objective-C object */ @@ -229,8 +229,6 @@ _gtk_search_engine_quartz_class_init (GtkSearchEngineQuartzClass *class) engine_class->start = gtk_search_engine_quartz_start; engine_class->stop = gtk_search_engine_quartz_stop; engine_class->is_indexed = gtk_search_engine_quartz_is_indexed; - - g_type_class_add_private (gobject_class, sizeof (GtkSearchEngineQuartzPrivate)); } static void @@ -238,7 +236,7 @@ _gtk_search_engine_quartz_init (GtkSearchEngineQuartz *engine) { QUARTZ_POOL_ALLOC; - engine->priv = G_TYPE_INSTANCE_GET_PRIVATE (engine, GTK_TYPE_SEARCH_ENGINE_QUARTZ, GtkSearchEngineQuartzPrivate); + engine->priv = _gtk_search_engine_quartz_get_instance_private (engine); engine->priv->ns_query = [[NSMetadataQuery alloc] init]; engine->priv->receiver = [[ResultReceiver alloc] init]; diff --git a/gtk/gtksearchenginesimple.c b/gtk/gtksearchenginesimple.c index 8d0e07f44e..1b6aee496e 100644 --- a/gtk/gtksearchenginesimple.c +++ b/gtk/gtksearchenginesimple.c @@ -68,7 +68,7 @@ struct _GtkSearchEngineSimplePrivate }; -G_DEFINE_TYPE (GtkSearchEngineSimple, _gtk_search_engine_simple, GTK_TYPE_SEARCH_ENGINE); +G_DEFINE_TYPE_WITH_PRIVATE (GtkSearchEngineSimple, _gtk_search_engine_simple, GTK_TYPE_SEARCH_ENGINE) static void gtk_search_engine_simple_dispose (GObject *object) @@ -362,14 +362,12 @@ _gtk_search_engine_simple_class_init (GtkSearchEngineSimpleClass *class) engine_class->start = gtk_search_engine_simple_start; engine_class->stop = gtk_search_engine_simple_stop; engine_class->is_indexed = gtk_search_engine_simple_is_indexed; - - g_type_class_add_private (gobject_class, sizeof (GtkSearchEngineSimplePrivate)); } static void _gtk_search_engine_simple_init (GtkSearchEngineSimple *engine) { - engine->priv = G_TYPE_INSTANCE_GET_PRIVATE (engine, GTK_TYPE_SEARCH_ENGINE_SIMPLE, GtkSearchEngineSimplePrivate); + engine->priv = _gtk_search_engine_simple_get_instance_private (engine); } GtkSearchEngine * diff --git a/gtk/gtksearchenginetracker.c b/gtk/gtksearchenginetracker.c index eae66703e8..4c3348d7ea 100644 --- a/gtk/gtksearchenginetracker.c +++ b/gtk/gtksearchenginetracker.c @@ -63,7 +63,7 @@ struct _GtkSearchEngineTrackerPrivate gboolean query_pending; }; -G_DEFINE_TYPE (GtkSearchEngineTracker, _gtk_search_engine_tracker, GTK_TYPE_SEARCH_ENGINE); +G_DEFINE_TYPE_WITH_PRIVATE (GtkSearchEngineTracker, _gtk_search_engine_tracker, GTK_TYPE_SEARCH_ENGINE) static void finalize (GObject *object) @@ -449,17 +449,12 @@ _gtk_search_engine_tracker_class_init (GtkSearchEngineTrackerClass *class) engine_class->start = gtk_search_engine_tracker_start; engine_class->stop = gtk_search_engine_tracker_stop; engine_class->is_indexed = gtk_search_engine_tracker_is_indexed; - - g_type_class_add_private (gobject_class, - sizeof (GtkSearchEngineTrackerPrivate)); } static void _gtk_search_engine_tracker_init (GtkSearchEngineTracker *engine) { - engine->priv = G_TYPE_INSTANCE_GET_PRIVATE (engine, - GTK_TYPE_SEARCH_ENGINE_TRACKER, - GtkSearchEngineTrackerPrivate); + engine->priv = _gtk_search_engine_tracker_get_instance_private (engine); } diff --git a/gtk/gtksearchentry.c b/gtk/gtksearchentry.c index c29faab000..6179dc04d9 100644 --- a/gtk/gtksearchentry.c +++ b/gtk/gtksearchentry.c @@ -49,19 +49,19 @@ * Since: 3.6 */ -G_DEFINE_TYPE (GtkSearchEntry, gtk_search_entry, GTK_TYPE_ENTRY) - typedef struct { guint delayed_changed_id; gboolean in_timeout; } GtkSearchEntryPrivate; +G_DEFINE_TYPE_WITH_PRIVATE (GtkSearchEntry, gtk_search_entry, GTK_TYPE_ENTRY) + /* 150 mseconds of delay */ #define DELAYED_TIMEOUT_ID 150 /* This widget got created without a private structure, meaning * that we cannot now have one without breaking ABI */ -#define GET_PRIV(e) G_TYPE_INSTANCE_GET_PRIVATE (e, GTK_TYPE_SEARCH_ENTRY, GtkSearchEntryPrivate) +#define GET_PRIV(e) ((GtkSearchEntryPrivate *) gtk_search_entry_get_instance_private ((GtkSearchEntry *) (e))) static void gtk_search_entry_finalize (GObject *object) @@ -80,8 +80,6 @@ gtk_search_entry_class_init (GtkSearchEntryClass *klass) GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->finalize = gtk_search_entry_finalize; - - g_type_class_add_private (klass, sizeof (GtkSearchEntryPrivate)); } static void diff --git a/gtk/gtkseparator.c b/gtk/gtkseparator.c index 8e5bc71612..663c418b81 100644 --- a/gtk/gtkseparator.c +++ b/gtk/gtkseparator.c @@ -73,8 +73,8 @@ static gboolean gtk_separator_draw (GtkWidget *widget, G_DEFINE_TYPE_WITH_CODE (GtkSeparator, gtk_separator, GTK_TYPE_WIDGET, - G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, - NULL)) + G_ADD_PRIVATE (GtkSeparator) + G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL)) static void @@ -94,25 +94,18 @@ gtk_separator_class_init (GtkSeparatorClass *class) gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_SEPARATOR); g_object_class_override_property (object_class, PROP_ORIENTATION, "orientation"); - - g_type_class_add_private (object_class, sizeof (GtkSeparatorPrivate)); } static void gtk_separator_init (GtkSeparator *separator) { - GtkSeparatorPrivate *private; GtkStyleContext *context; - separator->priv = G_TYPE_INSTANCE_GET_PRIVATE (separator, - GTK_TYPE_SEPARATOR, - GtkSeparatorPrivate); - private = separator->priv; + separator->priv = gtk_separator_get_instance_private (separator); + separator->priv->orientation = GTK_ORIENTATION_HORIZONTAL; gtk_widget_set_has_window (GTK_WIDGET (separator), FALSE); - private->orientation = GTK_ORIENTATION_HORIZONTAL; - context = gtk_widget_get_style_context (GTK_WIDGET (separator)); gtk_style_context_add_class (context, GTK_STYLE_CLASS_SEPARATOR); } diff --git a/gtk/gtkseparatortoolitem.c b/gtk/gtkseparatortoolitem.c index 33a003a8ef..6199cdd063 100644 --- a/gtk/gtkseparatortoolitem.c +++ b/gtk/gtkseparatortoolitem.c @@ -85,7 +85,7 @@ static gboolean gtk_separator_tool_item_button_event (GtkWidget GdkEventButton *event); -G_DEFINE_TYPE (GtkSeparatorToolItem, gtk_separator_tool_item, GTK_TYPE_TOOL_ITEM) +G_DEFINE_TYPE_WITH_PRIVATE (GtkSeparatorToolItem, gtk_separator_tool_item, GTK_TYPE_TOOL_ITEM) static gint get_space_size (GtkToolItem *tool_item) @@ -142,9 +142,6 @@ gtk_separator_tool_item_class_init (GtkSeparatorToolItemClass *class) P_("Whether the separator is drawn, or just blank"), TRUE, GTK_PARAM_READWRITE)); - - - g_type_class_add_private (object_class, sizeof (GtkSeparatorToolItemPrivate)); } static void @@ -152,9 +149,7 @@ gtk_separator_tool_item_init (GtkSeparatorToolItem *separator_item) { GtkStyleContext *context; - separator_item->priv = G_TYPE_INSTANCE_GET_PRIVATE (separator_item, - GTK_TYPE_SEPARATOR_TOOL_ITEM, - GtkSeparatorToolItemPrivate); + separator_item->priv = gtk_separator_tool_item_get_instance_private (separator_item); separator_item->priv->draw = TRUE; gtk_widget_set_has_window (GTK_WIDGET (separator_item), FALSE); diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c index e092fcef16..4627926578 100644 --- a/gtk/gtksettings.c +++ b/gtk/gtksettings.c @@ -260,6 +260,7 @@ static guint class_n_properties = 0; G_DEFINE_TYPE_EXTENDED (GtkSettings, gtk_settings, G_TYPE_OBJECT, 0, + G_ADD_PRIVATE (GtkSettings) G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER, gtk_settings_provider_iface_init) G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER_PRIVATE, @@ -276,11 +277,9 @@ gtk_settings_init (GtkSettings *settings) const gchar * const *config_dirs; const gchar *config_dir; - priv = G_TYPE_INSTANCE_GET_PRIVATE (settings, - GTK_TYPE_SETTINGS, - GtkSettingsPrivate); - + priv = gtk_settings_get_instance_private (settings); settings->priv = priv; + g_datalist_init (&priv->queued_settings); object_list = g_slist_prepend (object_list, settings); @@ -1546,8 +1545,6 @@ gtk_settings_class_init (GtkSettingsClass *class) GTK_PARAM_READWRITE), NULL); g_assert (result == PROP_RECENT_FILES_ENABLED); - - g_type_class_add_private (class, sizeof (GtkSettingsPrivate)); } static void diff --git a/gtk/gtksizegroup.c b/gtk/gtksizegroup.c index f84ed47f48..bb949c65ec 100644 --- a/gtk/gtksizegroup.c +++ b/gtk/gtksizegroup.c @@ -151,6 +151,11 @@ G_STATIC_ASSERT (GTK_SIZE_GROUP_HORIZONTAL == (1 << GTK_ORIENTATION_HORIZONTAL)) G_STATIC_ASSERT (GTK_SIZE_GROUP_VERTICAL == (1 << GTK_ORIENTATION_VERTICAL)); G_STATIC_ASSERT (GTK_SIZE_GROUP_BOTH == (GTK_SIZE_GROUP_HORIZONTAL | GTK_SIZE_GROUP_VERTICAL)); +G_DEFINE_TYPE_WITH_CODE (GtkSizeGroup, gtk_size_group, G_TYPE_OBJECT, + G_ADD_PRIVATE (GtkSizeGroup) + G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, + gtk_size_group_buildable_init)) + static void add_widget_to_closure (GHashTable *widgets, GHashTable *groups, @@ -343,8 +348,6 @@ gtk_size_group_class_init (GtkSizeGroupClass *klass) "when determining the size of the group"), FALSE, GTK_PARAM_READWRITE)); - - g_type_class_add_private (klass, sizeof (GtkSizeGroupPrivate)); } static void @@ -352,9 +355,7 @@ gtk_size_group_init (GtkSizeGroup *size_group) { GtkSizeGroupPrivate *priv; - size_group->priv = G_TYPE_INSTANCE_GET_PRIVATE (size_group, - GTK_TYPE_SIZE_GROUP, - GtkSizeGroupPrivate); + size_group->priv = gtk_size_group_get_instance_private (size_group); priv = size_group->priv; priv->widgets = NULL; @@ -369,10 +370,6 @@ gtk_size_group_buildable_init (GtkBuildableIface *iface) iface->custom_finished = gtk_size_group_buildable_custom_finished; } -G_DEFINE_TYPE_WITH_CODE (GtkSizeGroup, gtk_size_group, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, - gtk_size_group_buildable_init)) - static void gtk_size_group_set_property (GObject *object, guint prop_id, diff --git a/gtk/gtksocket.c b/gtk/gtksocket.c index c497f5065e..f87c31dbd1 100644 --- a/gtk/gtksocket.c +++ b/gtk/gtksocket.c @@ -176,7 +176,7 @@ enum { static guint socket_signals[LAST_SIGNAL] = { 0 }; -G_DEFINE_TYPE (GtkSocket, gtk_socket, GTK_TYPE_CONTAINER) +G_DEFINE_TYPE_WITH_PRIVATE (GtkSocket, gtk_socket, GTK_TYPE_CONTAINER) static void gtk_socket_finalize (GObject *object) @@ -255,8 +255,6 @@ gtk_socket_class_init (GtkSocketClass *class) _gtk_boolean_handled_accumulator, NULL, _gtk_marshal_BOOLEAN__VOID, G_TYPE_BOOLEAN, 0); - - g_type_class_add_private (gobject_class, sizeof (GtkSocketPrivate)); } static void @@ -264,10 +262,9 @@ gtk_socket_init (GtkSocket *socket) { GtkSocketPrivate *priv; - priv = G_TYPE_INSTANCE_GET_PRIVATE (socket, - GTK_TYPE_SOCKET, - GtkSocketPrivate); + priv = gtk_socket_get_instance_private (socket); socket->priv = priv; + priv->request_width = 0; priv->request_height = 0; priv->current_width = 0; diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c index ccdccd47fa..7af3c48367 100644 --- a/gtk/gtkspinbutton.c +++ b/gtk/gtkspinbutton.c @@ -291,6 +291,7 @@ static void gtk_spin_button_default_output (GtkSpinButton *spin_button); static guint spinbutton_signals[LAST_SIGNAL] = {0}; G_DEFINE_TYPE_WITH_CODE (GtkSpinButton, gtk_spin_button, GTK_TYPE_ENTRY, + G_ADD_PRIVATE (GtkSpinButton) G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL) G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE, gtk_spin_button_editable_init)) @@ -537,8 +538,6 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class) add_spin_binding (binding_set, GDK_KEY_Page_Up, GDK_CONTROL_MASK, GTK_SCROLL_END); add_spin_binding (binding_set, GDK_KEY_Page_Down, GDK_CONTROL_MASK, GTK_SCROLL_START); - g_type_class_add_private (class, sizeof (GtkSpinButtonPrivate)); - gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_SPIN_BUTTON_ACCESSIBLE); } @@ -653,9 +652,7 @@ gtk_spin_button_init (GtkSpinButton *spin_button) GtkSpinButtonPrivate *priv; GtkStyleContext *context; - spin_button->priv = G_TYPE_INSTANCE_GET_PRIVATE (spin_button, - GTK_TYPE_SPIN_BUTTON, - GtkSpinButtonPrivate); + spin_button->priv = gtk_spin_button_get_instance_private (spin_button); priv = spin_button->priv; priv->adjustment = NULL; diff --git a/gtk/gtkspinner.c b/gtk/gtkspinner.c index 06840c88fe..50ae61341e 100644 --- a/gtk/gtkspinner.c +++ b/gtk/gtkspinner.c @@ -84,7 +84,7 @@ static void gtk_spinner_get_preferred_height (GtkWidget *widget, gint *natural_size); -G_DEFINE_TYPE (GtkSpinner, gtk_spinner, GTK_TYPE_WIDGET) +G_DEFINE_TYPE_WITH_PRIVATE (GtkSpinner, gtk_spinner, GTK_TYPE_WIDGET) static void gtk_spinner_class_init (GtkSpinnerClass *klass) @@ -93,7 +93,6 @@ gtk_spinner_class_init (GtkSpinnerClass *klass) GtkWidgetClass *widget_class; gobject_class = G_OBJECT_CLASS(klass); - g_type_class_add_private (gobject_class, sizeof (GtkSpinnerPrivate)); gobject_class->get_property = gtk_spinner_get_property; gobject_class->set_property = gtk_spinner_set_property; @@ -158,13 +157,9 @@ gtk_spinner_set_property (GObject *object, static void gtk_spinner_init (GtkSpinner *spinner) { - GtkSpinnerPrivate *priv; GtkStyleContext *context; - priv = G_TYPE_INSTANCE_GET_PRIVATE (spinner, - GTK_TYPE_SPINNER, - GtkSpinnerPrivate); - spinner->priv = priv; + spinner->priv = gtk_spinner_get_instance_private (spinner); gtk_widget_set_has_window (GTK_WIDGET (spinner), FALSE); diff --git a/gtk/gtkstack.c b/gtk/gtkstack.c index c4f64b68b0..01e943e495 100644 --- a/gtk/gtkstack.c +++ b/gtk/gtkstack.c @@ -172,7 +172,7 @@ static gint get_bin_window_x (GtkStack *stack, static gint get_bin_window_y (GtkStack *stack, GtkAllocation *allocation); -G_DEFINE_TYPE_WITH_PRIVATE(GtkStack, gtk_stack, GTK_TYPE_CONTAINER); +G_DEFINE_TYPE_WITH_PRIVATE (GtkStack, gtk_stack, GTK_TYPE_CONTAINER) static void gtk_stack_init (GtkStack *stack) diff --git a/gtk/gtkstackswitcher.c b/gtk/gtkstackswitcher.c index 833dfde7e1..aba86139ee 100644 --- a/gtk/gtkstackswitcher.c +++ b/gtk/gtkstackswitcher.c @@ -53,7 +53,7 @@ enum { PROP_STACK }; -G_DEFINE_TYPE (GtkStackSwitcher, gtk_stack_switcher, GTK_TYPE_BOX); +G_DEFINE_TYPE_WITH_PRIVATE (GtkStackSwitcher, gtk_stack_switcher, GTK_TYPE_BOX) static void gtk_stack_switcher_init (GtkStackSwitcher *switcher) @@ -61,7 +61,7 @@ gtk_stack_switcher_init (GtkStackSwitcher *switcher) GtkStyleContext *context; GtkStackSwitcherPrivate *priv; - priv = G_TYPE_INSTANCE_GET_PRIVATE (switcher, GTK_TYPE_STACK_SWITCHER, GtkStackSwitcherPrivate); + priv = gtk_stack_switcher_get_instance_private (switcher); switcher->priv = priv; priv->stack = NULL; @@ -427,8 +427,6 @@ gtk_stack_switcher_class_init (GtkStackSwitcherClass *class) GTK_TYPE_STACK, GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - - g_type_class_add_private (object_class, sizeof (GtkStackSwitcherPrivate)); } /** @@ -443,5 +441,5 @@ gtk_stack_switcher_class_init (GtkStackSwitcherClass *class) GtkWidget * gtk_stack_switcher_new (void) { - return GTK_WIDGET (g_object_new (GTK_TYPE_STACK_SWITCHER, NULL)); + return g_object_new (GTK_TYPE_STACK_SWITCHER, NULL); } diff --git a/gtk/gtkstatusbar.c b/gtk/gtkstatusbar.c index f5398b9cce..643fbe06b0 100644 --- a/gtk/gtkstatusbar.c +++ b/gtk/gtkstatusbar.c @@ -116,7 +116,7 @@ static void gtk_statusbar_hierarchy_changed (GtkWidget *widget, static guint statusbar_signals[SIGNAL_LAST] = { 0 }; -G_DEFINE_TYPE (GtkStatusbar, gtk_statusbar, GTK_TYPE_BOX); +G_DEFINE_TYPE_WITH_PRIVATE (GtkStatusbar, gtk_statusbar, GTK_TYPE_BOX) static void gtk_statusbar_class_init (GtkStatusbarClass *class) @@ -184,8 +184,6 @@ gtk_statusbar_class_init (GtkStatusbarClass *class) gtk_widget_class_bind_child (widget_class, GtkStatusbarPrivate, frame); gtk_widget_class_bind_child (widget_class, GtkStatusbarPrivate, label); - g_type_class_add_private (class, sizeof (GtkStatusbarPrivate)); - gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_STATUSBAR_ACCESSIBLE); } @@ -195,9 +193,7 @@ gtk_statusbar_init (GtkStatusbar *statusbar) GtkStatusbarPrivate *priv; GtkShadowType shadow_type; - statusbar->priv = G_TYPE_INSTANCE_GET_PRIVATE (statusbar, - GTK_TYPE_STATUSBAR, - GtkStatusbarPrivate); + statusbar->priv = gtk_statusbar_get_instance_private (statusbar); priv = statusbar->priv; priv->seq_context_id = 1; diff --git a/gtk/gtkstatusicon.c b/gtk/gtkstatusicon.c index 04bb456376..dd21d4bb1f 100644 --- a/gtk/gtkstatusicon.c +++ b/gtk/gtkstatusicon.c @@ -200,7 +200,7 @@ static gboolean gtk_status_icon_button_release (GtkStatusIcon *status_icon, static void gtk_status_icon_reset_image_data (GtkStatusIcon *status_icon); static void gtk_status_icon_update_image (GtkStatusIcon *status_icon); -G_DEFINE_TYPE (GtkStatusIcon, gtk_status_icon, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE (GtkStatusIcon, gtk_status_icon, G_TYPE_OBJECT) static void gtk_status_icon_class_init (GtkStatusIconClass *class) @@ -637,8 +637,6 @@ gtk_status_icon_class_init (GtkStatusIconClass *class) G_TYPE_INT, G_TYPE_BOOLEAN, GTK_TYPE_TOOLTIP); - - g_type_class_add_private (class, sizeof (GtkStatusIconPrivate)); } #ifdef GDK_WINDOWING_WIN32 @@ -836,8 +834,7 @@ gtk_status_icon_init (GtkStatusIcon *status_icon) { GtkStatusIconPrivate *priv; - priv = G_TYPE_INSTANCE_GET_PRIVATE (status_icon, GTK_TYPE_STATUS_ICON, - GtkStatusIconPrivate); + priv = gtk_status_icon_get_instance_private (status_icon); status_icon->priv = priv; priv->icon_helper = _gtk_icon_helper_new (); diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index d70aa56a47..890688c1b9 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -408,7 +408,7 @@ static StyleData *style_data_lookup (GtkStyleContext *context); static void gtk_style_context_disconnect_update (GtkStyleContext *context); static void gtk_style_context_connect_update (GtkStyleContext *context); -G_DEFINE_TYPE (GtkStyleContext, gtk_style_context, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE (GtkStyleContext, gtk_style_context, G_TYPE_OBJECT) static void gtk_style_context_real_changed (GtkStyleContext *context) @@ -476,8 +476,6 @@ gtk_style_context_class_init (GtkStyleContextClass *klass) P_("The parent style context"), GTK_TYPE_STYLE_CONTEXT, GTK_PARAM_READWRITE)); - - g_type_class_add_private (object_class, sizeof (GtkStyleContextPrivate)); } static StyleData * @@ -715,9 +713,8 @@ gtk_style_context_init (GtkStyleContext *style_context) { GtkStyleContextPrivate *priv; - priv = style_context->priv = G_TYPE_INSTANCE_GET_PRIVATE (style_context, - GTK_TYPE_STYLE_CONTEXT, - GtkStyleContextPrivate); + priv = style_context->priv = + gtk_style_context_get_instance_private (style_context); priv->style_data = g_hash_table_new_full (style_info_hash, style_info_equal, diff --git a/gtk/gtkstyleproperties.c b/gtk/gtkstyleproperties.c index 9788006b16..2e385b3ef6 100644 --- a/gtk/gtkstyleproperties.c +++ b/gtk/gtkstyleproperties.c @@ -83,11 +83,12 @@ static void gtk_style_properties_provider_private_init (GtkStyleProviderPrivateI static void gtk_style_properties_finalize (GObject *object); -G_DEFINE_TYPE_EXTENDED (GtkStyleProperties, gtk_style_properties, G_TYPE_OBJECT, 0, - G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER, - gtk_style_properties_provider_init) - G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER_PRIVATE, - gtk_style_properties_provider_private_init)); +G_DEFINE_TYPE_WITH_CODE (GtkStyleProperties, gtk_style_properties, G_TYPE_OBJECT, + G_ADD_PRIVATE (GtkStyleProperties) + G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER, + gtk_style_properties_provider_init) + G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER_PRIVATE, + gtk_style_properties_provider_private_init)); static void gtk_style_properties_class_init (GtkStylePropertiesClass *klass) @@ -95,8 +96,6 @@ gtk_style_properties_class_init (GtkStylePropertiesClass *klass) GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->finalize = gtk_style_properties_finalize; - - g_type_class_add_private (object_class, sizeof (GtkStylePropertiesPrivate)); } static PropertyData * @@ -253,14 +252,9 @@ property_data_match_state (PropertyData *data, static void gtk_style_properties_init (GtkStyleProperties *props) { - GtkStylePropertiesPrivate *priv; - - priv = props->priv = G_TYPE_INSTANCE_GET_PRIVATE (props, - GTK_TYPE_STYLE_PROPERTIES, - GtkStylePropertiesPrivate); - - priv->properties = g_hash_table_new_full (NULL, NULL, NULL, - (GDestroyNotify) property_data_free); + props->priv = gtk_style_properties_get_instance_private (props); + props->priv->properties = g_hash_table_new_full (NULL, NULL, NULL, + (GDestroyNotify) property_data_free); } static void diff --git a/gtk/gtkswitch.c b/gtk/gtkswitch.c index 17264d69f4..c296fe7f6f 100644 --- a/gtk/gtkswitch.c +++ b/gtk/gtkswitch.c @@ -97,6 +97,7 @@ static void gtk_switch_activatable_interface_init (GtkActivatableIface *iface); G_GNUC_BEGIN_IGNORE_DEPRECATIONS; G_DEFINE_TYPE_WITH_CODE (GtkSwitch, gtk_switch, GTK_TYPE_WIDGET, + G_ADD_PRIVATE (GtkSwitch) G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIONABLE, gtk_switch_actionable_iface_init) G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE, @@ -809,8 +810,6 @@ gtk_switch_class_init (GtkSwitchClass *klass) GObjectClass *gobject_class = G_OBJECT_CLASS (klass); gpointer activatable_iface; - g_type_class_add_private (klass, sizeof (GtkSwitchPrivate)); - G_GNUC_BEGIN_IGNORE_DEPRECATIONS; activatable_iface = g_type_default_interface_peek (GTK_TYPE_ACTIVATABLE); G_GNUC_END_IGNORE_DEPRECATIONS; @@ -900,7 +899,7 @@ gtk_switch_class_init (GtkSwitchClass *klass) static void gtk_switch_init (GtkSwitch *self) { - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTK_TYPE_SWITCH, GtkSwitchPrivate); + self->priv = gtk_switch_get_instance_private (self); self->priv->use_action_appearance = TRUE; gtk_widget_set_has_window (GTK_WIDGET (self), FALSE); gtk_widget_set_can_focus (GTK_WIDGET (self), TRUE); diff --git a/gtk/gtktextbuffer.c b/gtk/gtktextbuffer.c index f3f17ffdbe..c1266724a7 100644 --- a/gtk/gtktextbuffer.c +++ b/gtk/gtktextbuffer.c @@ -173,7 +173,7 @@ static void gtk_text_buffer_get_property (GObject *object, static void gtk_text_buffer_notify (GObject *object, GParamSpec *pspec); -G_DEFINE_TYPE (GtkTextBuffer, gtk_text_buffer, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE (GtkTextBuffer, gtk_text_buffer, G_TYPE_OBJECT) static void gtk_text_buffer_class_init (GtkTextBufferClass *klass) @@ -626,17 +626,12 @@ gtk_text_buffer_class_init (GtkTextBufferClass *klass) G_TYPE_NONE, 1, GTK_TYPE_CLIPBOARD); - - g_type_class_add_private (object_class, sizeof (GtkTextBufferPrivate)); } static void gtk_text_buffer_init (GtkTextBuffer *buffer) { - buffer->priv = G_TYPE_INSTANCE_GET_PRIVATE (buffer, - GTK_TYPE_TEXT_BUFFER, - GtkTextBufferPrivate); - + buffer->priv = gtk_text_buffer_get_instance_private (buffer); buffer->priv->clipboard_contents_buffers = NULL; buffer->priv->tag_table = NULL; diff --git a/gtk/gtktexthandle.c b/gtk/gtktexthandle.c index bb0f851535..ead6ecd961 100644 --- a/gtk/gtktexthandle.c +++ b/gtk/gtktexthandle.c @@ -66,7 +66,7 @@ struct _GtkTextHandlePrivate guint mode : 2; }; -G_DEFINE_TYPE (GtkTextHandle, _gtk_text_handle, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE (GtkTextHandle, _gtk_text_handle, G_TYPE_OBJECT) static guint signals[LAST_SIGNAL] = { 0 }; @@ -535,8 +535,6 @@ _gtk_text_handle_class_init (GtkTextHandleClass *klass) P_("Window the coordinates are based upon"), GDK_TYPE_WINDOW, GTK_PARAM_READWRITE)); - - g_type_class_add_private (object_class, sizeof (GtkTextHandlePrivate)); } static void @@ -545,9 +543,7 @@ _gtk_text_handle_init (GtkTextHandle *handle) GtkTextHandlePrivate *priv; GtkWidgetPath *path; - handle->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (handle, - GTK_TYPE_TEXT_HANDLE, - GtkTextHandlePrivate); + handle->priv = priv = _gtk_text_handle_get_instance_private (handle); path = gtk_widget_path_new (); gtk_widget_path_append_type (path, GTK_TYPE_TEXT_HANDLE); diff --git a/gtk/gtktextlayout.c b/gtk/gtktextlayout.c index f72f384973..0e18e82875 100644 --- a/gtk/gtktextlayout.c +++ b/gtk/gtktextlayout.c @@ -87,7 +87,7 @@ #include <stdlib.h> #include <string.h> -#define GTK_TEXT_LAYOUT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_TEXT_LAYOUT, GtkTextLayoutPrivate)) +#define GTK_TEXT_LAYOUT_GET_PRIVATE(o) ((GtkTextLayoutPrivate *) gtk_text_layout_get_instance_private ((o))) typedef struct _GtkTextLayoutPrivate GtkTextLayoutPrivate; @@ -173,7 +173,7 @@ static guint signals[LAST_SIGNAL] = { 0 }; PangoAttrType gtk_text_attr_appearance_type = 0; -G_DEFINE_TYPE (GtkTextLayout, gtk_text_layout, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE (GtkTextLayout, gtk_text_layout, G_TYPE_OBJECT) static void gtk_text_layout_dispose (GObject *object) @@ -271,8 +271,6 @@ gtk_text_layout_class_init (GtkTextLayoutClass *klass) G_TYPE_OBJECT, G_TYPE_INT, G_TYPE_INT); - - g_type_class_add_private (object_class, sizeof (GtkTextLayoutPrivate)); } static void diff --git a/gtk/gtktexttag.c b/gtk/gtktexttag.c index 8674e92c9f..b7e3c89835 100644 --- a/gtk/gtktexttag.c +++ b/gtk/gtktexttag.c @@ -174,7 +174,7 @@ static void gtk_text_tag_get_property (GObject *object, static guint signals[LAST_SIGNAL] = { 0 }; -G_DEFINE_TYPE (GtkTextTag, gtk_text_tag, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE (GtkTextTag, gtk_text_tag, G_TYPE_OBJECT) static void gtk_text_tag_class_init (GtkTextTagClass *klass) @@ -750,21 +750,13 @@ gtk_text_tag_class_init (GtkTextTagClass *klass) G_TYPE_OBJECT, GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE, GTK_TYPE_TEXT_ITER); - - g_type_class_add_private (klass, sizeof (GtkTextTagPrivate)); } static void gtk_text_tag_init (GtkTextTag *text_tag) { - GtkTextTagPrivate *priv; - - text_tag->priv = G_TYPE_INSTANCE_GET_PRIVATE (text_tag, - GTK_TYPE_TEXT_TAG, - GtkTextTagPrivate); - priv = text_tag->priv; - - priv->values = gtk_text_attributes_new (); + text_tag->priv = gtk_text_tag_get_instance_private (text_tag); + text_tag->priv->values = gtk_text_attributes_new (); } /** diff --git a/gtk/gtktexttagtable.c b/gtk/gtktexttagtable.c index 73b9124d4b..6c9e500c5d 100644 --- a/gtk/gtktexttagtable.c +++ b/gtk/gtktexttagtable.c @@ -92,6 +92,7 @@ static void gtk_text_tag_table_buildable_add_child (GtkBuildable *bu static guint signals[LAST_SIGNAL] = { 0 }; G_DEFINE_TYPE_WITH_CODE (GtkTextTagTable, gtk_text_tag_table, G_TYPE_OBJECT, + G_ADD_PRIVATE (GtkTextTagTable) G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_text_tag_table_buildable_interface_init)) @@ -151,21 +152,13 @@ gtk_text_tag_table_class_init (GtkTextTagTableClass *klass) G_TYPE_NONE, 1, GTK_TYPE_TEXT_TAG); - - g_type_class_add_private (klass, sizeof (GtkTextTagTablePrivate)); } static void gtk_text_tag_table_init (GtkTextTagTable *table) { - GtkTextTagTablePrivate *priv; - - table->priv = G_TYPE_INSTANCE_GET_PRIVATE (table, - GTK_TYPE_TEXT_TAG_TABLE, - GtkTextTagTablePrivate); - priv = table->priv; - - priv->hash = g_hash_table_new (g_str_hash, g_str_equal); + table->priv = gtk_text_tag_table_get_instance_private (table); + table->priv->hash = g_hash_table_new (g_str_hash, g_str_equal); } /** diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index 08c1ab0427..32e7e403ab 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -122,8 +122,6 @@ #define CURSOR_BLINK_TIME 1200 #define CURSOR_BLINK_TIMEOUT_SEC 10 -#define GTK_TEXT_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_TEXT_VIEW, GtkTextViewPrivate)) - typedef struct _GtkTextWindow GtkTextWindow; typedef struct _GtkTextPendingScroll GtkTextPendingScroll; @@ -594,6 +592,7 @@ static guint signals[LAST_SIGNAL] = { 0 }; static gboolean test_touchscreen = FALSE; G_DEFINE_TYPE_WITH_CODE (GtkTextView, gtk_text_view, GTK_TYPE_CONTAINER, + G_ADD_PRIVATE (GtkTextView) G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE, NULL)) static void @@ -1446,8 +1445,6 @@ gtk_text_view_class_init (GtkTextViewClass *klass) "move-focus", 1, GTK_TYPE_DIRECTION_TYPE, GTK_DIR_TAB_BACKWARD); - g_type_class_add_private (gobject_class, sizeof (GtkTextViewPrivate)); - gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_TEXT_VIEW_ACCESSIBLE); test_touchscreen = g_getenv ("GTK_TEST_TOUCHSCREEN") != NULL; } @@ -1459,7 +1456,7 @@ gtk_text_view_init (GtkTextView *text_view) GtkTargetList *target_list; GtkTextViewPrivate *priv; - text_view->priv = GTK_TEXT_VIEW_GET_PRIVATE (text_view); + text_view->priv = gtk_text_view_get_instance_private (text_view); priv = text_view->priv; gtk_widget_set_can_focus (widget, TRUE); diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 006afe72c6..edb493ba61 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -74,8 +74,6 @@ struct GtkThemingEnginePrivate gchar *name; }; -#define GTK_THEMING_ENGINE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_THEMING_ENGINE, GtkThemingEnginePrivate)) - static void gtk_theming_engine_finalize (GObject *object); static void gtk_theming_engine_impl_set_property (GObject *object, guint prop_id, @@ -188,8 +186,7 @@ static void gtk_theming_engine_render_icon_surface (GtkThemingEngine *engine, gdouble x, gdouble y); -G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT) - +G_DEFINE_TYPE_WITH_PRIVATE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT) typedef struct GtkThemingModule GtkThemingModule; typedef struct GtkThemingModuleClass GtkThemingModuleClass; @@ -266,14 +263,12 @@ gtk_theming_engine_class_init (GtkThemingEngineClass *klass) P_("Theming engine name"), NULL, G_PARAM_CONSTRUCT_ONLY | GTK_PARAM_READWRITE)); - - g_type_class_add_private (object_class, sizeof (GtkThemingEnginePrivate)); } static void gtk_theming_engine_init (GtkThemingEngine *engine) { - engine->priv = GTK_THEMING_ENGINE_GET_PRIVATE (engine); + engine->priv = gtk_theming_engine_get_instance_private (engine); } static void diff --git a/gtk/gtktoggleaction.c b/gtk/gtktoggleaction.c index 68b92fd4f7..a39e4d57c0 100644 --- a/gtk/gtktoggleaction.c +++ b/gtk/gtktoggleaction.c @@ -65,7 +65,7 @@ enum { PROP_ACTIVE }; -G_DEFINE_TYPE (GtkToggleAction, gtk_toggle_action, GTK_TYPE_ACTION) +G_DEFINE_TYPE_WITH_PRIVATE (GtkToggleAction, gtk_toggle_action, GTK_TYPE_ACTION) static void gtk_toggle_action_activate (GtkAction *action); static void set_property (GObject *object, @@ -155,16 +155,12 @@ gtk_toggle_action_class_init (GtkToggleActionClass *klass) NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - - g_type_class_add_private (gobject_class, sizeof (GtkToggleActionPrivate)); } static void gtk_toggle_action_init (GtkToggleAction *action) { - action->private_data = G_TYPE_INSTANCE_GET_PRIVATE (action, - GTK_TYPE_TOGGLE_ACTION, - GtkToggleActionPrivate); + action->private_data = gtk_toggle_action_get_instance_private (action); action->private_data->active = FALSE; action->private_data->draw_as_radio = FALSE; } diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c index 3b9af755ee..4697ae9ee4 100644 --- a/gtk/gtktogglebutton.c +++ b/gtk/gtktogglebutton.c @@ -141,6 +141,7 @@ static guint toggle_button_signals[LAST_SIGNAL] = { 0 }; G_GNUC_BEGIN_IGNORE_DEPRECATIONS; G_DEFINE_TYPE_WITH_CODE (GtkToggleButton, gtk_toggle_button, GTK_TYPE_BUTTON, + G_ADD_PRIVATE (GtkToggleButton) G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE, gtk_toggle_button_activatable_interface_init)) G_GNUC_END_IGNORE_DEPRECATIONS; @@ -209,23 +210,16 @@ gtk_toggle_button_class_init (GtkToggleButtonClass *class) _gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); - g_type_class_add_private (class, sizeof (GtkToggleButtonPrivate)); - gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_TOGGLE_BUTTON_ACCESSIBLE); } static void gtk_toggle_button_init (GtkToggleButton *toggle_button) { - GtkToggleButtonPrivate *priv; - - toggle_button->priv = G_TYPE_INSTANCE_GET_PRIVATE (toggle_button, - GTK_TYPE_TOGGLE_BUTTON, - GtkToggleButtonPrivate); - priv = toggle_button->priv; + toggle_button->priv = gtk_toggle_button_get_instance_private (toggle_button); + toggle_button->priv->active = FALSE; + toggle_button->priv->draw_indicator = FALSE; - priv->active = FALSE; - priv->draw_indicator = FALSE; GTK_BUTTON (toggle_button)->priv->depress_on_activate = TRUE; } diff --git a/gtk/gtktoggletoolbutton.c b/gtk/gtktoggletoolbutton.c index 7c8d22569a..4db54aa629 100644 --- a/gtk/gtktoggletoolbutton.c +++ b/gtk/gtktoggletoolbutton.c @@ -92,6 +92,7 @@ static guint toggle_signals[LAST_SIGNAL] = { 0 }; G_GNUC_BEGIN_IGNORE_DEPRECATIONS; G_DEFINE_TYPE_WITH_CODE (GtkToggleToolButton, gtk_toggle_tool_button, GTK_TYPE_TOOL_BUTTON, + G_ADD_PRIVATE (GtkToggleToolButton) G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE, gtk_toggle_tool_button_activatable_interface_init)) G_GNUC_END_IGNORE_DEPRECATIONS; @@ -142,8 +143,6 @@ gtk_toggle_tool_button_class_init (GtkToggleToolButtonClass *klass) NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - - g_type_class_add_private (object_class, sizeof (GtkToggleToolButtonPrivate)); } static void @@ -152,9 +151,7 @@ gtk_toggle_tool_button_init (GtkToggleToolButton *button) GtkToolButton *tool_button = GTK_TOOL_BUTTON (button); GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (_gtk_tool_button_get_button (tool_button)); - button->priv = G_TYPE_INSTANCE_GET_PRIVATE (button, - GTK_TYPE_TOGGLE_TOOL_BUTTON, - GtkToggleToolButtonPrivate); + button->priv = gtk_toggle_tool_button_get_instance_private (button); /* If the real button is a radio button, it may have been * active at the time it was created. diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c index dcdcf2e32b..b9c5fa8f61 100644 --- a/gtk/gtktoolbar.c +++ b/gtk/gtktoolbar.c @@ -317,6 +317,7 @@ static void toolbar_rebuild_menu (GtkToolShell G_DEFINE_TYPE_WITH_CODE (GtkToolbar, gtk_toolbar, GTK_TYPE_CONTAINER, + G_ADD_PRIVATE (GtkToolbar) G_IMPLEMENT_INTERFACE (GTK_TYPE_TOOL_SHELL, toolbar_tool_shell_iface_init) G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, @@ -656,8 +657,6 @@ gtk_toolbar_class_init (GtkToolbarClass *klass) add_ctrl_tab_bindings (binding_set, 0, GTK_DIR_TAB_FORWARD); add_ctrl_tab_bindings (binding_set, GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD); - - g_type_class_add_private (gobject_class, sizeof (GtkToolbarPrivate)); } static void @@ -676,9 +675,7 @@ gtk_toolbar_init (GtkToolbar *toolbar) GtkToolbarPrivate *priv; GtkStyleContext *context; - toolbar->priv = G_TYPE_INSTANCE_GET_PRIVATE (toolbar, - GTK_TYPE_TOOLBAR, - GtkToolbarPrivate); + toolbar->priv = gtk_toolbar_get_instance_private (toolbar); priv = toolbar->priv; gtk_widget_set_can_focus (GTK_WIDGET (toolbar), FALSE); diff --git a/gtk/gtktoolbutton.c b/gtk/gtktoolbutton.c index 10af3cbcb2..078fbdb006 100644 --- a/gtk/gtktoolbutton.c +++ b/gtk/gtktoolbutton.c @@ -83,9 +83,6 @@ enum { PROP_ACTION_TARGET }; -static void gtk_tool_button_init (GtkToolButton *button, - GtkToolButtonClass *klass); -static void gtk_tool_button_class_init (GtkToolButtonClass *klass); static void gtk_tool_button_set_property (GObject *object, guint prop_id, const GValue *value, @@ -131,46 +128,20 @@ struct _GtkToolButtonPrivate guint contents_invalid : 1; }; -static GObjectClass *parent_class = NULL; static GtkActivatableIface *parent_activatable_iface; static guint toolbutton_signals[LAST_SIGNAL] = { 0 }; -GType -gtk_tool_button_get_type (void) -{ - static GType type = 0; - - if (!type) - { - const GInterfaceInfo actionable_info = - { - (GInterfaceInitFunc) gtk_tool_button_actionable_iface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - const GInterfaceInfo activatable_info = - { - (GInterfaceInitFunc) gtk_tool_button_activatable_interface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - - type = g_type_register_static_simple (GTK_TYPE_TOOL_ITEM, - I_("GtkToolButton"), - sizeof (GtkToolButtonClass), - (GClassInitFunc) gtk_tool_button_class_init, - sizeof (GtkToolButton), - (GInstanceInitFunc) gtk_tool_button_init, - 0); +/* for GTK_TYPE_ACTIVATABLE */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS - G_GNUC_BEGIN_IGNORE_DEPRECATIONS; - g_type_add_interface_static (type, GTK_TYPE_ACTIONABLE, &actionable_info); - g_type_add_interface_static (type, GTK_TYPE_ACTIVATABLE, - &activatable_info); - G_GNUC_END_IGNORE_DEPRECATIONS; - } - return type; -} +G_DEFINE_TYPE_WITH_CODE (GtkToolButton, gtk_tool_button, GTK_TYPE_TOOL_ITEM, + G_ADD_PRIVATE (GtkToolButton) + G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIONABLE, + gtk_tool_button_actionable_iface_init) + G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE, + gtk_tool_button_activatable_interface_init)) + +G_GNUC_END_IGNORE_DEPRECATIONS static void gtk_tool_button_class_init (GtkToolButtonClass *klass) @@ -179,8 +150,6 @@ gtk_tool_button_class_init (GtkToolButtonClass *klass) GtkWidgetClass *widget_class; GtkToolItemClass *tool_item_class; - parent_class = g_type_class_peek_parent (klass); - object_class = (GObjectClass *)klass; widget_class = (GtkWidgetClass *)klass; tool_item_class = (GtkToolItemClass *)klass; @@ -325,26 +294,21 @@ gtk_tool_button_class_init (GtkToolButtonClass *klass) NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - - g_type_class_add_private (object_class, sizeof (GtkToolButtonPrivate)); } static void -gtk_tool_button_init (GtkToolButton *button, - GtkToolButtonClass *klass) +gtk_tool_button_init (GtkToolButton *button) { GtkToolItem *toolitem = GTK_TOOL_ITEM (button); - button->priv = G_TYPE_INSTANCE_GET_PRIVATE (button, - GTK_TYPE_TOOL_BUTTON, - GtkToolButtonPrivate); + button->priv = gtk_tool_button_get_instance_private (button); button->priv->contents_invalid = TRUE; gtk_tool_item_set_homogeneous (toolitem, TRUE); /* create button */ - button->priv->button = g_object_new (klass->button_type, NULL); + button->priv->button = g_object_new (GTK_TOOL_BUTTON_GET_CLASS (button)->button_type, NULL); gtk_button_set_focus_on_click (GTK_BUTTON (button->priv->button), FALSE); g_signal_connect_object (button->priv->button, "clicked", G_CALLBACK (button_clicked), button, 0); @@ -666,8 +630,8 @@ gtk_tool_button_property_notify (GObject *object, strcmp ("is-important", pspec->name) == 0) gtk_tool_button_construct_contents (GTK_TOOL_ITEM (object)); - if (parent_class->notify) - parent_class->notify (object, pspec); + if (G_OBJECT_CLASS (gtk_tool_button_parent_class)->notify != NULL) + G_OBJECT_CLASS (gtk_tool_button_parent_class)->notify (object, pspec); } static void @@ -768,7 +732,7 @@ gtk_tool_button_finalize (GObject *object) if (button->priv->icon_widget) g_object_unref (button->priv->icon_widget); - parent_class->finalize (object); + G_OBJECT_CLASS (gtk_tool_button_parent_class)->finalize (object); } static GtkWidget * @@ -938,7 +902,7 @@ gtk_tool_button_update_icon_spacing (GtkToolButton *button) static void gtk_tool_button_style_updated (GtkWidget *widget) { - GTK_WIDGET_CLASS (parent_class)->style_updated (widget); + GTK_WIDGET_CLASS (gtk_tool_button_parent_class)->style_updated (widget); gtk_tool_button_update_icon_spacing (GTK_TOOL_BUTTON (widget)); } diff --git a/gtk/gtktoolitem.c b/gtk/gtktoolitem.c index 81484526d8..b29a295442 100644 --- a/gtk/gtktoolitem.c +++ b/gtk/gtktoolitem.c @@ -155,6 +155,7 @@ static guint toolitem_signals[LAST_SIGNAL] = { 0 }; G_GNUC_BEGIN_IGNORE_DEPRECATIONS; G_DEFINE_TYPE_WITH_CODE (GtkToolItem, gtk_tool_item, GTK_TYPE_BIN, + G_ADD_PRIVATE (GtkToolItem) G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE, gtk_tool_item_activatable_interface_init)) G_GNUC_END_IGNORE_DEPRECATIONS; @@ -275,8 +276,6 @@ gtk_tool_item_class_init (GtkToolItemClass *klass) NULL, NULL, _gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); - - g_type_class_add_private (object_class, sizeof (GtkToolItemPrivate)); } static void @@ -284,15 +283,11 @@ gtk_tool_item_init (GtkToolItem *toolitem) { gtk_widget_set_can_focus (GTK_WIDGET (toolitem), FALSE); - toolitem->priv = G_TYPE_INSTANCE_GET_PRIVATE (toolitem, - GTK_TYPE_TOOL_ITEM, - GtkToolItemPrivate); - + toolitem->priv = gtk_tool_item_get_instance_private (toolitem); toolitem->priv->visible_horizontal = TRUE; toolitem->priv->visible_vertical = TRUE; toolitem->priv->homogeneous = FALSE; toolitem->priv->expand = FALSE; - toolitem->priv->use_action_appearance = TRUE; } diff --git a/gtk/gtktoolitemgroup.c b/gtk/gtktoolitemgroup.c index dbbe000392..3485fa12d2 100644 --- a/gtk/gtktoolitemgroup.c +++ b/gtk/gtktoolitemgroup.c @@ -110,7 +110,9 @@ struct _GtkToolItemGroupChild static void gtk_tool_item_group_tool_shell_init (GtkToolShellIface *iface); G_DEFINE_TYPE_WITH_CODE (GtkToolItemGroup, gtk_tool_item_group, GTK_TYPE_CONTAINER, -G_IMPLEMENT_INTERFACE (GTK_TYPE_TOOL_SHELL, gtk_tool_item_group_tool_shell_init)); + G_ADD_PRIVATE (GtkToolItemGroup) + G_IMPLEMENT_INTERFACE (GTK_TYPE_TOOL_SHELL, + gtk_tool_item_group_tool_shell_init)); static GtkWidget* gtk_tool_item_group_get_alignment (GtkToolItemGroup *group) @@ -381,9 +383,7 @@ gtk_tool_item_group_init (GtkToolItemGroup *group) gtk_widget_set_redraw_on_allocate (GTK_WIDGET (group), FALSE); - group->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (group, - GTK_TYPE_TOOL_ITEM_GROUP, - GtkToolItemGroupPrivate); + group->priv = priv = gtk_tool_item_group_get_instance_private (group); priv->children = NULL; priv->header_spacing = DEFAULT_HEADER_SPACING; @@ -1677,8 +1677,6 @@ gtk_tool_item_group_class_init (GtkToolItemGroupClass *cls) G_MAXINT, 0, GTK_PARAM_READWRITE)); - - g_type_class_add_private (cls, sizeof (GtkToolItemGroupPrivate)); } /** diff --git a/gtk/gtktoolpalette.c b/gtk/gtktoolpalette.c index 98456fa550..f928cff9a7 100644 --- a/gtk/gtktoolpalette.c +++ b/gtk/gtktoolpalette.c @@ -192,18 +192,16 @@ static void gtk_tool_palette_set_vadjustment (GtkToolPalette *palette, G_DEFINE_TYPE_WITH_CODE (GtkToolPalette, - gtk_tool_palette, - GTK_TYPE_CONTAINER, - G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL) - G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE, NULL)) + gtk_tool_palette, + GTK_TYPE_CONTAINER, + G_ADD_PRIVATE (GtkToolPalette) + G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL) + G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE, NULL)) static void gtk_tool_palette_init (GtkToolPalette *palette) { - palette->priv = G_TYPE_INSTANCE_GET_PRIVATE (palette, - GTK_TYPE_TOOL_PALETTE, - GtkToolPalettePrivate); - + palette->priv = gtk_tool_palette_get_instance_private (palette); palette->priv->groups = g_ptr_array_sized_new (4); g_ptr_array_set_free_func (palette->priv->groups, g_free); @@ -1007,8 +1005,6 @@ gtk_tool_palette_class_init (GtkToolPaletteClass *cls) P_("Whether the item group should receive extra space when the palette grows"), DEFAULT_CHILD_EXPAND, GTK_PARAM_READWRITE)); - - g_type_class_add_private (cls, sizeof (GtkToolPalettePrivate)); } /** diff --git a/gtk/gtktrayicon-x11.c b/gtk/gtktrayicon-x11.c index 8295161d77..43204c6f25 100644 --- a/gtk/gtktrayicon-x11.c +++ b/gtk/gtktrayicon-x11.c @@ -103,7 +103,7 @@ static GdkFilterReturn gtk_tray_icon_manager_filter (GdkXEvent *xevent, gpointer user_data); -G_DEFINE_TYPE (GtkTrayIcon, gtk_tray_icon, GTK_TYPE_PLUG) +G_DEFINE_TYPE_WITH_PRIVATE (GtkTrayIcon, gtk_tray_icon, GTK_TYPE_PLUG) static void gtk_tray_icon_class_init (GtkTrayIconClass *class) @@ -180,16 +180,12 @@ gtk_tray_icon_class_init (GtkTrayIconClass *class) G_MAXINT, 0, GTK_PARAM_READABLE)); - - g_type_class_add_private (class, sizeof (GtkTrayIconPrivate)); } static void gtk_tray_icon_init (GtkTrayIcon *icon) { - icon->priv = G_TYPE_INSTANCE_GET_PRIVATE (icon, GTK_TYPE_TRAY_ICON, - GtkTrayIconPrivate); - + icon->priv = gtk_tray_icon_get_instance_private (icon); icon->priv->stamp = 1; icon->priv->orientation = GTK_ORIENTATION_HORIZONTAL; icon->priv->fg_color.red = 0.0; diff --git a/gtk/gtktreemenu.c b/gtk/gtktreemenu.c index 8fef02e6f9..5bdf729159 100644 --- a/gtk/gtktreemenu.c +++ b/gtk/gtktreemenu.c @@ -197,44 +197,16 @@ static guint tree_menu_signals[N_SIGNALS] = { 0 }; static GQuark tree_menu_path_quark = 0; G_DEFINE_TYPE_WITH_CODE (GtkTreeMenu, _gtk_tree_menu, GTK_TYPE_MENU, + G_ADD_PRIVATE (GtkTreeMenu) G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_LAYOUT, gtk_tree_menu_cell_layout_init)); static void _gtk_tree_menu_init (GtkTreeMenu *menu) { - GtkTreeMenuPrivate *priv; - - menu->priv = G_TYPE_INSTANCE_GET_PRIVATE (menu, - GTK_TYPE_TREE_MENU, - GtkTreeMenuPrivate); - priv = menu->priv; - - priv->model = NULL; - priv->root = NULL; - priv->area = NULL; - priv->context = NULL; - - priv->size_changed_id = 0; - priv->row_inserted_id = 0; - priv->row_deleted_id = 0; - priv->row_reordered_id = 0; - priv->row_changed_id = 0; - - priv->wrap_width = 0; - priv->row_span_col = -1; - priv->col_span_col = -1; - - priv->menu_with_header = FALSE; - priv->tearoff = FALSE; - - priv->row_separator_func = NULL; - priv->row_separator_data = NULL; - priv->row_separator_destroy = NULL; - - priv->header_func = NULL; - priv->header_data = NULL; - priv->header_destroy = NULL; + menu->priv = _gtk_tree_menu_get_instance_private (menu); + menu->priv->row_span_col = -1; + menu->priv->col_span_col = -1; gtk_menu_set_reserve_toggle_size (GTK_MENU (menu), FALSE); } @@ -410,8 +382,6 @@ _gtk_tree_menu_class_init (GtkTreeMenuClass *class) G_MAXINT, -1, GTK_PARAM_READWRITE)); - - g_type_class_add_private (object_class, sizeof (GtkTreeMenuPrivate)); } /**************************************************************** diff --git a/gtk/gtktreemodelfilter.c b/gtk/gtktreemodelfilter.c index 45281c298a..e8fd57c3d0 100644 --- a/gtk/gtktreemodelfilter.c +++ b/gtk/gtktreemodelfilter.c @@ -497,6 +497,7 @@ static void gtk_tree_model_filter_emit_row_inserted_for_path (GtkTr G_DEFINE_TYPE_WITH_CODE (GtkTreeModelFilter, gtk_tree_model_filter, G_TYPE_OBJECT, + G_ADD_PRIVATE (GtkTreeModelFilter) G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, gtk_tree_model_filter_tree_model_init) G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_DRAG_SOURCE, @@ -505,10 +506,7 @@ G_DEFINE_TYPE_WITH_CODE (GtkTreeModelFilter, gtk_tree_model_filter, G_TYPE_OBJEC static void gtk_tree_model_filter_init (GtkTreeModelFilter *filter) { - filter->priv = G_TYPE_INSTANCE_GET_PRIVATE (filter, - GTK_TYPE_TREE_MODEL_FILTER, - GtkTreeModelFilterPrivate); - + filter->priv = gtk_tree_model_filter_get_instance_private (filter); filter->priv->visible_column = -1; filter->priv->zero_ref_count = 0; filter->priv->visible_method_set = FALSE; @@ -550,8 +548,6 @@ gtk_tree_model_filter_class_init (GtkTreeModelFilterClass *filter_class) ("The virtual root (relative to the child model) for this filtermodel"), GTK_TYPE_TREE_PATH, GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_type_class_add_private (object_class, sizeof (GtkTreeModelFilterPrivate)); } static void diff --git a/gtk/gtktreemodelsort.c b/gtk/gtktreemodelsort.c index a3545e99b9..4033dbbc5e 100644 --- a/gtk/gtktreemodelsort.c +++ b/gtk/gtktreemodelsort.c @@ -447,6 +447,7 @@ static void gtk_tree_model_sort_clear_cache_helper (GtkTreeModelSort *t G_DEFINE_TYPE_WITH_CODE (GtkTreeModelSort, gtk_tree_model_sort, G_TYPE_OBJECT, + G_ADD_PRIVATE (GtkTreeModelSort) G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, gtk_tree_model_sort_tree_model_init) G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_SORTABLE, @@ -459,10 +460,8 @@ gtk_tree_model_sort_init (GtkTreeModelSort *tree_model_sort) { GtkTreeModelSortPrivate *priv; - priv = G_TYPE_INSTANCE_GET_PRIVATE (tree_model_sort, - GTK_TYPE_TREE_MODEL_SORT, - GtkTreeModelSortPrivate); - tree_model_sort->priv = priv; + tree_model_sort->priv = priv = + gtk_tree_model_sort_get_instance_private (tree_model_sort); priv->sort_column_id = GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID; priv->stamp = 0; priv->zero_ref_count = 0; @@ -490,8 +489,6 @@ gtk_tree_model_sort_class_init (GtkTreeModelSortClass *class) P_("The model for the TreeModelSort to sort"), GTK_TYPE_TREE_MODEL, GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_type_class_add_private (class, sizeof (GtkTreeModelSortPrivate)); } static void diff --git a/gtk/gtktreeselection.c b/gtk/gtktreeselection.c index 10c9cd717a..65c09900c8 100644 --- a/gtk/gtktreeselection.c +++ b/gtk/gtktreeselection.c @@ -101,7 +101,7 @@ enum static GParamSpec *properties[N_PROPERTIES]; static guint tree_selection_signals [LAST_SIGNAL] = { 0 }; -G_DEFINE_TYPE (GtkTreeSelection, gtk_tree_selection, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE (GtkTreeSelection, gtk_tree_selection, G_TYPE_OBJECT) static void gtk_tree_selection_class_init (GtkTreeSelectionClass *class) @@ -155,21 +155,13 @@ gtk_tree_selection_class_init (GtkTreeSelectionClass *class) NULL, NULL, _gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); - - g_type_class_add_private (class, sizeof (GtkTreeSelectionPrivate)); } static void gtk_tree_selection_init (GtkTreeSelection *selection) { - GtkTreeSelectionPrivate *priv; - - selection->priv = G_TYPE_INSTANCE_GET_PRIVATE (selection, - GTK_TYPE_TREE_SELECTION, - GtkTreeSelectionPrivate); - priv = selection->priv; - - priv->type = GTK_SELECTION_SINGLE; + selection->priv = gtk_tree_selection_get_instance_private (selection); + selection->priv->type = GTK_SELECTION_SINGLE; } static void diff --git a/gtk/gtktreestore.c b/gtk/gtktreestore.c index ccf240911f..de76a8f045 100644 --- a/gtk/gtktreestore.c +++ b/gtk/gtktreestore.c @@ -205,6 +205,7 @@ validate_tree (GtkTreeStore *tree_store) } G_DEFINE_TYPE_WITH_CODE (GtkTreeStore, gtk_tree_store, G_TYPE_OBJECT, + G_ADD_PRIVATE (GtkTreeStore) G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, gtk_tree_store_tree_model_init) G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_DRAG_SOURCE, @@ -224,8 +225,6 @@ gtk_tree_store_class_init (GtkTreeStoreClass *class) object_class = (GObjectClass *) class; object_class->finalize = gtk_tree_store_finalize; - - g_type_class_add_private (class, sizeof (GtkTreeStorePrivate)); } static void @@ -283,9 +282,7 @@ gtk_tree_store_init (GtkTreeStore *tree_store) { GtkTreeStorePrivate *priv; - priv = G_TYPE_INSTANCE_GET_PRIVATE (tree_store, - GTK_TYPE_TREE_STORE, - GtkTreeStorePrivate); + priv = gtk_tree_store_get_instance_private (tree_store); tree_store->priv = priv; priv->root = g_node_new (NULL); /* While the odds are against us getting 0... */ diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index 8a87f519f3..e857094e00 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -907,6 +907,7 @@ static guint tree_view_signals [LAST_SIGNAL] = { 0 }; */ G_DEFINE_TYPE_WITH_CODE (GtkTreeView, gtk_tree_view, GTK_TYPE_CONTAINER, + G_ADD_PRIVATE (GtkTreeView) G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_tree_view_buildable_init) G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE, NULL)) @@ -1715,15 +1716,13 @@ gtk_tree_view_class_init (GtkTreeViewClass *class) gtk_binding_entry_add_signal (binding_set, GDK_KEY_F, GDK_CONTROL_MASK, "start-interactive-search", 0); - g_type_class_add_private (o_class, sizeof (GtkTreeViewPrivate)); - gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_TREE_VIEW_ACCESSIBLE); } static void gtk_tree_view_init (GtkTreeView *tree_view) { - tree_view->priv = G_TYPE_INSTANCE_GET_PRIVATE (tree_view, GTK_TYPE_TREE_VIEW, GtkTreeViewPrivate); + tree_view->priv = gtk_tree_view_get_instance_private (tree_view); gtk_widget_set_can_focus (GTK_WIDGET (tree_view), TRUE); gtk_widget_set_redraw_on_allocate (GTK_WIDGET (tree_view), FALSE); diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c index d1f02aead4..ff3b46c903 100644 --- a/gtk/gtktreeviewcolumn.c +++ b/gtk/gtktreeviewcolumn.c @@ -209,6 +209,7 @@ enum static guint tree_column_signals[LAST_SIGNAL] = { 0 }; G_DEFINE_TYPE_WITH_CODE (GtkTreeViewColumn, gtk_tree_view_column, G_TYPE_INITIALLY_UNOWNED, + G_ADD_PRIVATE (GtkTreeViewColumn) G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_LAYOUT, gtk_tree_view_column_cell_layout_init) G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, @@ -425,8 +426,6 @@ gtk_tree_view_column_class_init (GtkTreeViewColumnClass *class) P_("The GtkCellArea used to layout cells"), GTK_TYPE_CELL_AREA, GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_type_class_add_private (class, sizeof (GtkTreeViewColumnPrivate)); } static void @@ -459,9 +458,7 @@ gtk_tree_view_column_init (GtkTreeViewColumn *tree_column) { GtkTreeViewColumnPrivate *priv; - tree_column->priv = G_TYPE_INSTANCE_GET_PRIVATE (tree_column, - GTK_TYPE_TREE_VIEW_COLUMN, - GtkTreeViewColumnPrivate); + tree_column->priv = gtk_tree_view_column_get_instance_private (tree_column); priv = tree_column->priv; priv->button = NULL; diff --git a/gtk/gtkuimanager.c b/gtk/gtkuimanager.c index 4d85340929..37e4ef7a89 100644 --- a/gtk/gtkuimanager.c +++ b/gtk/gtkuimanager.c @@ -448,6 +448,7 @@ enum static guint ui_manager_signals[LAST_SIGNAL] = { 0 }; G_DEFINE_TYPE_WITH_CODE (GtkUIManager, gtk_ui_manager, G_TYPE_OBJECT, + G_ADD_PRIVATE (GtkUIManager) G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_ui_manager_buildable_init)) @@ -646,20 +647,15 @@ gtk_ui_manager_class_init (GtkUIManagerClass *klass) klass->disconnect_proxy = NULL; klass->pre_activate = NULL; klass->post_activate = NULL; - - g_type_class_add_private (gobject_class, sizeof (GtkUIManagerPrivate)); } - static void gtk_ui_manager_init (GtkUIManager *manager) { guint merge_id; GNode *node; - manager->private_data = G_TYPE_INSTANCE_GET_PRIVATE (manager, - GTK_TYPE_UI_MANAGER, - GtkUIManagerPrivate); + manager->private_data = gtk_ui_manager_get_instance_private (manager); manager->private_data->accel_group = gtk_accel_group_new (); diff --git a/gtk/gtkviewport.c b/gtk/gtkviewport.c index 20120f6b2d..1176cf75a3 100644 --- a/gtk/gtkviewport.c +++ b/gtk/gtkviewport.c @@ -120,6 +120,7 @@ static void gtk_viewport_queue_draw_region (GtkWidget *widget, const cairo_region_t *region); G_DEFINE_TYPE_WITH_CODE (GtkViewport, gtk_viewport, GTK_TYPE_BIN, + G_ADD_PRIVATE (GtkViewport) G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE, NULL)) static void @@ -164,8 +165,6 @@ gtk_viewport_class_init (GtkViewportClass *class) GTK_TYPE_SHADOW_TYPE, GTK_SHADOW_IN, GTK_PARAM_READWRITE)); - - g_type_class_add_private (class, sizeof (GtkViewportPrivate)); } static void @@ -240,9 +239,7 @@ gtk_viewport_init (GtkViewport *viewport) { GtkViewportPrivate *priv; - viewport->priv = G_TYPE_INSTANCE_GET_PRIVATE (viewport, - GTK_TYPE_VIEWPORT, - GtkViewportPrivate); + viewport->priv = gtk_viewport_get_instance_private (viewport); priv = viewport->priv; gtk_widget_set_has_window (GTK_WIDGET (viewport), TRUE); diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index f2a7005575..9997e578e0 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -856,6 +856,7 @@ static void gtk_cairo_set_event (cairo_t *cr, GdkEventExpose *event); /* --- variables --- */ +static gint GtkWidget_private_offset = 0; static gpointer gtk_widget_parent_class = NULL; static guint widget_signals[LAST_SIGNAL] = { 0 }; static guint composite_child_stack = 0; @@ -926,6 +927,9 @@ gtk_widget_get_type (void) g_type_add_class_private (widget_type, sizeof (GtkWidgetClassPrivate)); + GtkWidget_private_offset = + g_type_add_instance_private (widget_type, sizeof (GtkWidgetPrivate)); + g_type_add_interface_static (widget_type, ATK_TYPE_IMPLEMENTOR, &accessibility_info) ; g_type_add_interface_static (widget_type, GTK_TYPE_BUILDABLE, @@ -935,6 +939,12 @@ gtk_widget_get_type (void) return widget_type; } +static inline gpointer +gtk_widget_get_instance_private (GtkWidget *self) +{ + return (G_STRUCT_MEMBER_P (self, GtkWidget_private_offset)); +} + static void gtk_widget_base_class_init (gpointer g_class) { @@ -1017,6 +1027,7 @@ gtk_widget_class_init (GtkWidgetClass *klass) GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GtkBindingSet *binding_set; + g_type_class_adjust_private_offset (klass, &GtkWidget_private_offset); gtk_widget_parent_class = g_type_class_peek_parent (klass); quark_property_parser = g_quark_from_static_string ("gtk-rc-property-parser"); @@ -3552,8 +3563,6 @@ G_GNUC_END_IGNORE_DEPRECATIONS 1, G_MAXINT, 20, GTK_PARAM_READABLE)); - g_type_class_add_private (klass, sizeof (GtkWidgetPrivate)); - gtk_widget_class_set_accessible_type (klass, GTK_TYPE_WIDGET_ACCESSIBLE); } @@ -3915,9 +3924,7 @@ gtk_widget_init (GtkWidget *widget) { GtkWidgetPrivate *priv; - widget->priv = G_TYPE_INSTANCE_GET_PRIVATE (widget, - GTK_TYPE_WIDGET, - GtkWidgetPrivate); + widget->priv = gtk_widget_get_instance_private (widget); priv = widget->priv; priv->child_visible = TRUE; diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 497dde838c..3d0847c030 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -547,6 +547,7 @@ static void ensure_state_flag_backdrop (GtkWidget *widget); static void unset_titlebar (GtkWindow *window); G_DEFINE_TYPE_WITH_CODE (GtkWindow, gtk_window, GTK_TYPE_BIN, + G_ADD_PRIVATE (GtkWindow) G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_window_buildable_interface_init)) @@ -673,8 +674,6 @@ gtk_window_class_init (GtkWindowClass *klass) klass->activate_focus = gtk_window_real_activate_focus; klass->keys_changed = gtk_window_keys_changed; - g_type_class_add_private (gobject_class, sizeof (GtkWindowPrivate)); - /* Construct */ g_object_class_install_property (gobject_class, PROP_TYPE, @@ -1280,9 +1279,7 @@ gtk_window_init (GtkWindow *window) widget = GTK_WIDGET (window); - window->priv = G_TYPE_INSTANCE_GET_PRIVATE (window, - GTK_TYPE_WINDOW, - GtkWindowPrivate); + window->priv = gtk_window_get_instance_private (window); priv = window->priv; gtk_widget_set_has_window (widget, TRUE); @@ -9877,20 +9874,17 @@ gtk_window_has_toplevel_focus (GtkWindow *window) * freed. */ -G_DEFINE_TYPE (GtkWindowGroup, gtk_window_group, G_TYPE_OBJECT) +G_DEFINE_TYPE_WITH_PRIVATE (GtkWindowGroup, gtk_window_group, G_TYPE_OBJECT) static void gtk_window_group_init (GtkWindowGroup *group) { - group->priv = G_TYPE_INSTANCE_GET_PRIVATE (group, - GTK_TYPE_WINDOW_GROUP, - GtkWindowGroupPrivate); + group->priv = gtk_window_group_get_instance_private (group); } static void gtk_window_group_class_init (GtkWindowGroupClass *klass) { - g_type_class_add_private (klass, sizeof (GtkWindowGroupPrivate)); } /** |