diff options
Diffstat (limited to 'gtk')
143 files changed, 616 insertions, 5071 deletions
diff --git a/gtk/gtkaccelgroup.c b/gtk/gtkaccelgroup.c index 55d9cafe36..c92218711a 100644 --- a/gtk/gtkaccelgroup.c +++ b/gtk/gtkaccelgroup.c @@ -39,13 +39,10 @@ /* --- prototypes --- */ -static void gtk_accel_group_class_init (GtkAccelGroupClass *class); -static void gtk_accel_group_init (GtkAccelGroup *accel_group); static void gtk_accel_group_finalize (GObject *object); /* --- variables --- */ -static GObjectClass *parent_class = NULL; static guint signal_accel_activate = 0; static guint signal_accel_changed = 0; static guint quark_acceleratable_groups = 0; @@ -57,44 +54,14 @@ static guint default_accel_mod_mask = (GDK_SHIFT_MASK | GDK_META_MASK); -/* --- functions --- */ -/** - * gtk_accel_group_get_type: - * @returns: the type ID for accelerator groups. - */ -GType -gtk_accel_group_get_type (void) -{ - static GType object_type = 0; - - if (!object_type) - { - static const GTypeInfo object_info = { - sizeof (GtkAccelGroupClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gtk_accel_group_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkAccelGroup), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_accel_group_init, - }; - - object_type = g_type_register_static (G_TYPE_OBJECT, I_("GtkAccelGroup"), - &object_info, 0); - } - - return object_type; -} +G_DEFINE_TYPE (GtkAccelGroup, gtk_accel_group, G_TYPE_OBJECT); +/* --- functions --- */ static void gtk_accel_group_class_init (GtkAccelGroupClass *class) { GObjectClass *object_class = G_OBJECT_CLASS (class); - parent_class = g_type_class_peek_parent (class); - quark_acceleratable_groups = g_quark_from_static_string ("gtk-acceleratable-accel-groups"); object_class->finalize = gtk_accel_group_finalize; @@ -171,7 +138,7 @@ gtk_accel_group_finalize (GObject *object) g_free (accel_group->priv_accels); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_accel_group_parent_class)->finalize (object); } static void diff --git a/gtk/gtkaccellabel.c b/gtk/gtkaccellabel.c index 92a7c9aaa9..528dda5f31 100644 --- a/gtk/gtkaccellabel.c +++ b/gtk/gtkaccellabel.c @@ -43,8 +43,6 @@ enum { PROP_ACCEL_WIDGET }; -static void gtk_accel_label_class_init (GtkAccelLabelClass *klass); -static void gtk_accel_label_init (GtkAccelLabel *accel_label); static void gtk_accel_label_set_property (GObject *object, guint prop_id, const GValue *value, @@ -62,35 +60,7 @@ static gboolean gtk_accel_label_expose_event (GtkWidget *widget, static const gchar *gtk_accel_label_get_string (GtkAccelLabel *accel_label); -static GtkLabelClass *parent_class = NULL; - -GType -gtk_accel_label_get_type (void) -{ - static GType accel_label_type = 0; - - if (!accel_label_type) - { - static const GTypeInfo accel_label_info = - { - sizeof (GtkAccelLabelClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_accel_label_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkAccelLabel), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_accel_label_init, - }; - - accel_label_type = - g_type_register_static (GTK_TYPE_LABEL, I_("GtkAccelLabel"), - &accel_label_info, 0); - } - - return accel_label_type; -} +G_DEFINE_TYPE (GtkAccelLabel, gtk_accel_label, GTK_TYPE_LABEL); static void gtk_accel_label_class_init (GtkAccelLabelClass *class) @@ -99,8 +69,6 @@ gtk_accel_label_class_init (GtkAccelLabelClass *class) GtkObjectClass *object_class = GTK_OBJECT_CLASS (class); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class); - parent_class = g_type_class_peek_parent (class); - gobject_class->finalize = gtk_accel_label_finalize; gobject_class->set_property = gtk_accel_label_set_property; gobject_class->get_property = gtk_accel_label_get_property; @@ -233,7 +201,7 @@ gtk_accel_label_destroy (GtkObject *object) gtk_accel_label_set_accel_widget (accel_label, NULL); gtk_accel_label_set_accel_closure (accel_label, NULL); - GTK_OBJECT_CLASS (parent_class)->destroy (object); + GTK_OBJECT_CLASS (gtk_accel_label_parent_class)->destroy (object); } static void @@ -243,7 +211,7 @@ gtk_accel_label_finalize (GObject *object) g_free (accel_label->accel_string); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_accel_label_parent_class)->finalize (object); } /** @@ -281,8 +249,8 @@ gtk_accel_label_size_request (GtkWidget *widget, PangoLayout *layout; gint width; - if (GTK_WIDGET_CLASS (parent_class)->size_request) - GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition); + if (GTK_WIDGET_CLASS (gtk_accel_label_parent_class)->size_request) + GTK_WIDGET_CLASS (gtk_accel_label_parent_class)->size_request (widget, requisition); layout = gtk_widget_create_pango_layout (widget, gtk_accel_label_get_string (accel_label)); pango_layout_get_pixel_size (layout, &width, NULL); @@ -339,8 +307,8 @@ gtk_accel_label_expose_event (GtkWidget *widget, pango_layout_get_width (label_layout) - ac_width * PANGO_SCALE); - if (GTK_WIDGET_CLASS (parent_class)->expose_event) - GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); + if (GTK_WIDGET_CLASS (gtk_accel_label_parent_class)->expose_event) + GTK_WIDGET_CLASS (gtk_accel_label_parent_class)->expose_event (widget, event); if (direction == GTK_TEXT_DIR_RTL) widget->allocation.x -= ac_width; widget->allocation.width += ac_width; @@ -374,8 +342,8 @@ gtk_accel_label_expose_event (GtkWidget *widget, } else { - if (GTK_WIDGET_CLASS (parent_class)->expose_event) - GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); + if (GTK_WIDGET_CLASS (gtk_accel_label_parent_class)->expose_event) + GTK_WIDGET_CLASS (gtk_accel_label_parent_class)->expose_event (widget, event); } } diff --git a/gtk/gtkaccessible.c b/gtk/gtkaccessible.c index d6cb43cbdb..95b022b4d0 100644 --- a/gtk/gtkaccessible.c +++ b/gtk/gtkaccessible.c @@ -26,7 +26,6 @@ #include "gtkalias.h" static void gtk_accessible_class_init (GtkAccessibleClass *klass); - static void gtk_accessible_real_connect_widget_destroyed (GtkAccessible *accessible); GType @@ -35,24 +34,12 @@ gtk_accessible_get_type (void) static GType accessible_type = 0; if (!accessible_type) - { - static const GTypeInfo accessible_info = - { - sizeof (GtkAccessibleClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_accessible_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkAccessible), - 16, /* n_preallocs */ - (GInstanceInitFunc) NULL, - }; - - accessible_type = - g_type_register_static (ATK_TYPE_OBJECT, I_("GtkAccessible"), - &accessible_info, 0); - } + accessible_type = + g_type_register_static_simple (ATK_TYPE_OBJECT, I_("GtkAccessible"), + sizeof (GtkAccessibleClass), + (GClassInitFunc)gtk_accessible_class_init, + sizeof (GtkAccessible), + NULL, 0); return accessible_type; } diff --git a/gtk/gtkaction.c b/gtk/gtkaction.c index a7d70cc2ae..cc71e15e5f 100644 --- a/gtk/gtkaction.c +++ b/gtk/gtkaction.c @@ -106,41 +106,13 @@ enum PROP_ACTION_GROUP }; -static void gtk_action_init (GtkAction *action); -static void gtk_action_class_init (GtkActionClass *class); static GQuark accel_path_id = 0; static GQuark quark_gtk_action_proxy = 0; static const gchar accel_path_key[] = "GtkAction::accel_path"; static const gchar gtk_action_proxy_key[] = "gtk-action"; -GType -gtk_action_get_type (void) -{ - static GtkType type = 0; - - if (!type) - { - static const GTypeInfo type_info = - { - sizeof (GtkActionClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gtk_action_class_init, - (GClassFinalizeFunc) NULL, - NULL, - - sizeof (GtkAction), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_action_init, - }; - - type = g_type_register_static (G_TYPE_OBJECT, - I_("GtkAction"), - &type_info, 0); - } - return type; -} +G_DEFINE_TYPE (GtkAction, gtk_action, G_TYPE_OBJECT); static void gtk_action_finalize (GObject *object); static void gtk_action_set_property (GObject *object, @@ -185,7 +157,6 @@ static void closure_accel_activate (GClosure *closure, gpointer invocation_hint, gpointer marshal_data); -static GObjectClass *parent_class = NULL; static guint action_signals[LAST_SIGNAL] = { 0 }; @@ -197,7 +168,6 @@ gtk_action_class_init (GtkActionClass *klass) accel_path_id = g_quark_from_static_string (accel_path_key); quark_gtk_action_proxy = g_quark_from_static_string (gtk_action_proxy_key); - parent_class = g_type_class_peek_parent (klass); gobject_class = G_OBJECT_CLASS (klass); gobject_class->finalize = gtk_action_finalize; @@ -449,7 +419,7 @@ gtk_action_finalize (GObject *object) if (action->private_data->accel_group) g_object_unref (action->private_data->accel_group); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_action_parent_class)->finalize (object); } static void diff --git a/gtk/gtkadjustment.c b/gtk/gtkadjustment.c index 6f31797bae..d7ac231fd1 100644 --- a/gtk/gtkadjustment.c +++ b/gtk/gtkadjustment.c @@ -49,9 +49,6 @@ enum { }; -static void gtk_adjustment_class_init (GtkAdjustmentClass *klass); -static void gtk_adjustment_init (GtkAdjustment *adjustment); - static void gtk_adjustment_get_property (GObject *object, guint prop_id, GValue *value, @@ -63,34 +60,7 @@ static void gtk_adjustment_set_property (GObject *object, static guint adjustment_signals[LAST_SIGNAL] = { 0 }; - -GType -gtk_adjustment_get_type (void) -{ - static GType adjustment_type = 0; - - if (!adjustment_type) - { - static const GTypeInfo adjustment_info = - { - sizeof (GtkAdjustmentClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_adjustment_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkAdjustment), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_adjustment_init, - }; - - adjustment_type = - g_type_register_static (GTK_TYPE_OBJECT, I_("GtkAdjustment"), - &adjustment_info, 0); - } - - return adjustment_type; -} +G_DEFINE_TYPE (GtkAdjustment, gtk_adjustment, GTK_TYPE_OBJECT); static void gtk_adjustment_class_init (GtkAdjustmentClass *class) diff --git a/gtk/gtkalignment.c b/gtk/gtkalignment.c index 544e388ee7..42ea39a11f 100644 --- a/gtk/gtkalignment.c +++ b/gtk/gtkalignment.c @@ -56,8 +56,6 @@ struct _GtkAlignmentPrivate guint padding_right; }; -static void gtk_alignment_class_init (GtkAlignmentClass *klass); -static void gtk_alignment_init (GtkAlignment *alignment); static void gtk_alignment_size_request (GtkWidget *widget, GtkRequisition *requisition); static void gtk_alignment_size_allocate (GtkWidget *widget, @@ -71,32 +69,7 @@ static void gtk_alignment_get_property (GObject *object, GValue *value, GParamSpec *pspec); -GType -gtk_alignment_get_type (void) -{ - static GType alignment_type = 0; - - if (!alignment_type) - { - static const GTypeInfo alignment_info = - { - sizeof (GtkAlignmentClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_alignment_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkAlignment), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_alignment_init, - }; - - alignment_type = g_type_register_static (GTK_TYPE_BIN, I_("GtkAlignment"), - &alignment_info, 0); - } - - return alignment_type; -} +G_DEFINE_TYPE (GtkAlignment, gtk_alignment, GTK_TYPE_BIN); static void gtk_alignment_class_init (GtkAlignmentClass *class) diff --git a/gtk/gtkarrow.c b/gtk/gtkarrow.c index 6635816df2..f72f85d393 100644 --- a/gtk/gtkarrow.c +++ b/gtk/gtkarrow.c @@ -43,8 +43,6 @@ enum { }; -static void gtk_arrow_class_init (GtkArrowClass *klass); -static void gtk_arrow_init (GtkArrow *arrow); static gint gtk_arrow_expose (GtkWidget *widget, GdkEventExpose *event); static void gtk_arrow_set_property (GObject *object, @@ -56,32 +54,9 @@ static void gtk_arrow_get_property (GObject *object, GValue *value, GParamSpec *pspec); -GType -gtk_arrow_get_type (void) -{ - static GType arrow_type = 0; - if (!arrow_type) - { - static const GTypeInfo arrow_info = - { - sizeof (GtkArrowClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_arrow_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkArrow), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_arrow_init, - }; - - arrow_type = g_type_register_static (GTK_TYPE_MISC, I_("GtkArrow"), - &arrow_info, 0); - } +G_DEFINE_TYPE (GtkArrow, gtk_arrow, GTK_TYPE_MISC); - return arrow_type; -} static void gtk_arrow_class_init (GtkArrowClass *class) diff --git a/gtk/gtkaspectframe.c b/gtk/gtkaspectframe.c index f15ccec17c..5606752f0b 100644 --- a/gtk/gtkaspectframe.c +++ b/gtk/gtkaspectframe.c @@ -43,8 +43,6 @@ enum { PROP_OBEY_CHILD }; -static void gtk_aspect_frame_class_init (GtkAspectFrameClass *klass); -static void gtk_aspect_frame_init (GtkAspectFrame *aspect_frame); static void gtk_aspect_frame_set_property (GObject *object, guint prop_id, const GValue *value, @@ -59,35 +57,7 @@ static void gtk_aspect_frame_compute_child_allocation (GtkFrame *fram #define MAX_RATIO 10000.0 #define MIN_RATIO 0.0001 -static GtkFrameClass *parent_class = NULL; - -GType -gtk_aspect_frame_get_type (void) -{ - static GType aspect_frame_type = 0; - - if (!aspect_frame_type) - { - static const GTypeInfo aspect_frame_info = - { - sizeof (GtkAspectFrameClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_aspect_frame_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkAspectFrame), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_aspect_frame_init, - }; - - aspect_frame_type = - g_type_register_static (GTK_TYPE_FRAME, I_("GtkAspectFrame"), - &aspect_frame_info, 0); - } - - return aspect_frame_type; -} +G_DEFINE_TYPE (GtkAspectFrame, gtk_aspect_frame, GTK_TYPE_FRAME); static void gtk_aspect_frame_class_init (GtkAspectFrameClass *class) @@ -95,8 +65,6 @@ gtk_aspect_frame_class_init (GtkAspectFrameClass *class) GObjectClass *gobject_class; GtkFrameClass *frame_class; - parent_class = g_type_class_peek_parent (class); - gobject_class = (GObjectClass*) class; frame_class = (GtkFrameClass*) class; @@ -317,7 +285,7 @@ gtk_aspect_frame_compute_child_allocation (GtkFrame *frame, else ratio = aspect_frame->ratio; - parent_class->compute_child_allocation (frame, &full_allocation); + GTK_FRAME_CLASS (gtk_aspect_frame_parent_class)->compute_child_allocation (frame, &full_allocation); if (ratio * full_allocation.height > full_allocation.width) { @@ -334,7 +302,7 @@ gtk_aspect_frame_compute_child_allocation (GtkFrame *frame, child_allocation->y = full_allocation.y + aspect_frame->yalign * (full_allocation.height - child_allocation->height); } else - parent_class->compute_child_allocation (frame, child_allocation); + GTK_FRAME_CLASS (gtk_aspect_frame_parent_class)->compute_child_allocation (frame, child_allocation); } #define __GTK_ASPECT_FRAME_C__ diff --git a/gtk/gtkbbox.c b/gtk/gtkbbox.c index f30656a773..38a57dbb97 100644 --- a/gtk/gtkbbox.c +++ b/gtk/gtkbbox.c @@ -41,8 +41,6 @@ enum { CHILD_PROP_SECONDARY }; -static void gtk_button_box_class_init (GtkButtonBoxClass *klass); -static void gtk_button_box_init (GtkButtonBox *box); static void gtk_button_box_set_property (GObject *object, guint prop_id, const GValue *value, @@ -67,34 +65,7 @@ static void gtk_button_box_get_child_property (GtkContainer *container, #define DEFAULT_CHILD_IPAD_X 4 #define DEFAULT_CHILD_IPAD_Y 0 -GType -gtk_button_box_get_type (void) -{ - static GType button_box_type = 0; - - if (!button_box_type) - { - static const GTypeInfo button_box_info = - { - sizeof (GtkButtonBoxClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_button_box_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkButtonBox), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_button_box_init, - NULL, /* value_table */ - }; - - button_box_type = - g_type_register_static (GTK_TYPE_BOX, I_("GtkButtonBox"), - &button_box_info, G_TYPE_FLAG_ABSTRACT); - } - - return button_box_type; -} +G_DEFINE_ABSTRACT_TYPE (GtkButtonBox, gtk_button_box, GTK_TYPE_BOX); static void gtk_button_box_class_init (GtkButtonBoxClass *class) diff --git a/gtk/gtkbin.c b/gtk/gtkbin.c index a1a8bf1311..f3fb5ef959 100644 --- a/gtk/gtkbin.c +++ b/gtk/gtkbin.c @@ -29,9 +29,6 @@ #include "gtkintl.h" #include "gtkalias.h" - -static void gtk_bin_class_init (GtkBinClass *klass); -static void gtk_bin_init (GtkBin *bin); static void gtk_bin_add (GtkContainer *container, GtkWidget *widget); static void gtk_bin_remove (GtkContainer *container, @@ -43,36 +40,7 @@ static void gtk_bin_forall (GtkContainer *container, static GType gtk_bin_child_type (GtkContainer *container); -static GtkContainerClass *parent_class = NULL; - - -GType -gtk_bin_get_type (void) -{ - static GType bin_type = 0; - - if (!bin_type) - { - static const GTypeInfo bin_info = - { - sizeof (GtkBinClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_bin_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkBin), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_bin_init, - NULL, /* value_table */ - }; - - bin_type = g_type_register_static (GTK_TYPE_CONTAINER, I_("GtkBin"), - &bin_info, G_TYPE_FLAG_ABSTRACT); - } - - return bin_type; -} +G_DEFINE_ABSTRACT_TYPE (GtkBin, gtk_bin, GTK_TYPE_CONTAINER); static void gtk_bin_class_init (GtkBinClass *class) @@ -81,8 +49,6 @@ gtk_bin_class_init (GtkBinClass *class) container_class = (GtkContainerClass*) class; - parent_class = g_type_class_peek_parent (class); - container_class->add = gtk_bin_add; container_class->remove = gtk_bin_remove; container_class->forall = gtk_bin_forall; diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c index 1ddabd2160..470b295e20 100644 --- a/gtk/gtkbox.c +++ b/gtk/gtkbox.c @@ -45,8 +45,6 @@ enum { CHILD_PROP_POSITION }; -static void gtk_box_class_init (GtkBoxClass *klass); -static void gtk_box_init (GtkBox *box); static void gtk_box_set_property (GObject *object, guint prop_id, const GValue *value, @@ -76,36 +74,7 @@ static void gtk_box_get_child_property (GtkContainer *container, static GType gtk_box_child_type (GtkContainer *container); -static GtkContainerClass *parent_class = NULL; - - -GType -gtk_box_get_type (void) -{ - static GType box_type = 0; - - if (!box_type) - { - static const GTypeInfo box_info = - { - sizeof (GtkBoxClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_box_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkBox), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_box_init, - NULL, /* value_table */ - }; - - box_type = g_type_register_static (GTK_TYPE_CONTAINER, I_("GtkBox"), - &box_info, G_TYPE_FLAG_ABSTRACT); - } - - return box_type; -} +G_DEFINE_ABSTRACT_TYPE (GtkBox, gtk_box, GTK_TYPE_CONTAINER); static void gtk_box_class_init (GtkBoxClass *class) @@ -113,8 +82,6 @@ gtk_box_class_init (GtkBoxClass *class) GObjectClass *gobject_class = G_OBJECT_CLASS (class); GtkContainerClass *container_class = GTK_CONTAINER_CLASS (class); - parent_class = g_type_class_peek_parent (class); - gobject_class->set_property = gtk_box_set_property; gobject_class->get_property = gtk_box_get_property; diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c index 0d70bfa893..6e4a50b5be 100644 --- a/gtk/gtkbutton.c +++ b/gtk/gtkbutton.c @@ -84,8 +84,6 @@ struct _GtkButtonPrivate guint32 grab_time; }; -static void gtk_button_class_init (GtkButtonClass *klass); -static void gtk_button_init (GtkButton *button); static void gtk_button_destroy (GtkObject *object); static void gtk_button_set_property (GObject *object, guint prop_id, @@ -139,37 +137,9 @@ static void gtk_button_grab_notify (GtkWidget *widget, gboolean was_grabbed); - -static GtkBinClass *parent_class = NULL; static guint button_signals[LAST_SIGNAL] = { 0 }; - -GType -gtk_button_get_type (void) -{ - static GType button_type = 0; - - if (!button_type) - { - static const GTypeInfo button_info = - { - sizeof (GtkButtonClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_button_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkButton), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_button_init, - }; - - button_type = g_type_register_static (GTK_TYPE_BIN, I_("GtkButton"), - &button_info, 0); - } - - return button_type; -} +G_DEFINE_TYPE (GtkButton, gtk_button, GTK_TYPE_BIN); static void gtk_button_class_init (GtkButtonClass *klass) @@ -184,8 +154,6 @@ gtk_button_class_init (GtkButtonClass *klass) widget_class = (GtkWidgetClass*) klass; container_class = (GtkContainerClass*) klass; - parent_class = g_type_class_peek_parent (klass); - gobject_class->constructor = gtk_button_constructor; gobject_class->set_property = gtk_button_set_property; gobject_class->get_property = gtk_button_get_property; @@ -520,7 +488,7 @@ gtk_button_destroy (GtkObject *object) button->label_text = NULL; } - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); + (* GTK_OBJECT_CLASS (gtk_button_parent_class)->destroy) (object); } static GObject* @@ -531,9 +499,9 @@ gtk_button_constructor (GType type, GObject *object; GtkButton *button; - object = (* G_OBJECT_CLASS (parent_class)->constructor) (type, - n_construct_properties, - construct_params); + object = (* G_OBJECT_CLASS (gtk_button_parent_class)->constructor) (type, + n_construct_properties, + construct_params); button = GTK_BUTTON (object); button->constructed = TRUE; @@ -583,7 +551,7 @@ gtk_button_add (GtkContainer *container, { maybe_set_alignment (GTK_BUTTON (container), widget); - GTK_CONTAINER_CLASS (parent_class)->add (container, widget); + GTK_CONTAINER_CLASS (gtk_button_parent_class)->add (container, widget); } static void @@ -948,7 +916,7 @@ gtk_button_unrealize (GtkWidget *widget) button->event_window = NULL; } - GTK_WIDGET_CLASS (parent_class)->unrealize (widget); + GTK_WIDGET_CLASS (gtk_button_parent_class)->unrealize (widget); } static void @@ -956,7 +924,7 @@ gtk_button_map (GtkWidget *widget) { GtkButton *button = GTK_BUTTON (widget); - GTK_WIDGET_CLASS (parent_class)->map (widget); + GTK_WIDGET_CLASS (gtk_button_parent_class)->map (widget); if (button->event_window) gdk_window_show (button->event_window); @@ -970,7 +938,7 @@ gtk_button_unmap (GtkWidget *widget) if (button->event_window) gdk_window_hide (button->event_window); - GTK_WIDGET_CLASS (parent_class)->unmap (widget); + GTK_WIDGET_CLASS (gtk_button_parent_class)->unmap (widget); } static void @@ -1272,7 +1240,7 @@ gtk_button_expose (GtkWidget *widget, button->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT, "button", "buttondefault"); - (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event); + (* GTK_WIDGET_CLASS (gtk_button_parent_class)->expose_event) (widget, event); } return FALSE; @@ -1347,8 +1315,8 @@ gtk_button_key_release (GtkWidget *widget, gtk_button_finish_activate (button, TRUE); return TRUE; } - else if (GTK_WIDGET_CLASS (parent_class)->key_release_event) - return GTK_WIDGET_CLASS (parent_class)->key_release_event (widget, event); + else if (GTK_WIDGET_CLASS (gtk_button_parent_class)->key_release_event) + return GTK_WIDGET_CLASS (gtk_button_parent_class)->key_release_event (widget, event); else return FALSE; } diff --git a/gtk/gtkcellrenderer.c b/gtk/gtkcellrenderer.c index 762bef1df0..e73ec2d41d 100644 --- a/gtk/gtkcellrenderer.c +++ b/gtk/gtkcellrenderer.c @@ -25,8 +25,6 @@ #include "gtktreeprivate.h" #include "gtkalias.h" -static void gtk_cell_renderer_init (GtkCellRenderer *cell); -static void gtk_cell_renderer_class_init (GtkCellRendererClass *class); static void gtk_cell_renderer_get_property (GObject *object, guint param_id, GValue *value, @@ -75,34 +73,7 @@ enum { static guint cell_renderer_signals[LAST_SIGNAL] = { 0 }; - -GType -gtk_cell_renderer_get_type (void) -{ - static GType cell_type = 0; - - if (!cell_type) - { - static const GTypeInfo cell_info = - { - sizeof (GtkCellRendererClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_cell_renderer_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkCellRenderer), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_cell_renderer_init, - NULL, /* value_table */ - }; - - cell_type = g_type_register_static (GTK_TYPE_OBJECT, I_("GtkCellRenderer"), - &cell_info, G_TYPE_FLAG_ABSTRACT); - } - - return cell_type; -} +G_DEFINE_ABSTRACT_TYPE (GtkCellRenderer, gtk_cell_renderer, GTK_TYPE_OBJECT); static void gtk_cell_renderer_init (GtkCellRenderer *cell) diff --git a/gtk/gtkcellrendererpixbuf.c b/gtk/gtkcellrendererpixbuf.c index 054130012d..6bdfbcaa24 100644 --- a/gtk/gtkcellrendererpixbuf.c +++ b/gtk/gtkcellrendererpixbuf.c @@ -34,8 +34,6 @@ static void gtk_cell_renderer_pixbuf_set_property (GObject * guint param_id, const GValue *value, GParamSpec *pspec); -static void gtk_cell_renderer_pixbuf_init (GtkCellRendererPixbuf *celltext); -static void gtk_cell_renderer_pixbuf_class_init (GtkCellRendererPixbufClass *class); static void gtk_cell_renderer_pixbuf_finalize (GObject *object); static void gtk_cell_renderer_pixbuf_create_stock_pixbuf (GtkCellRendererPixbuf *cellpixbuf, GtkWidget *widget); @@ -69,8 +67,6 @@ enum { PROP_ICON_NAME }; -static gpointer parent_class; - #define GTK_CELL_RENDERER_PIXBUF_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_CELL_RENDERER_PIXBUF, GtkCellRendererPixbufPrivate)) @@ -85,34 +81,7 @@ struct _GtkCellRendererPixbufPrivate gchar *icon_name; }; - -GType -gtk_cell_renderer_pixbuf_get_type (void) -{ - static GType cell_pixbuf_type = 0; - - if (!cell_pixbuf_type) - { - static const GTypeInfo cell_pixbuf_info = - { - sizeof (GtkCellRendererPixbufClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_cell_renderer_pixbuf_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkCellRendererPixbuf), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_cell_renderer_pixbuf_init, - }; - - cell_pixbuf_type = - g_type_register_static (GTK_TYPE_CELL_RENDERER, I_("GtkCellRendererPixbuf"), - &cell_pixbuf_info, 0); - } - - return cell_pixbuf_type; -} +G_DEFINE_TYPE (GtkCellRendererPixbuf, gtk_cell_renderer_pixbuf, GTK_TYPE_CELL_RENDERER); static void gtk_cell_renderer_pixbuf_init (GtkCellRendererPixbuf *cellpixbuf) @@ -129,8 +98,6 @@ gtk_cell_renderer_pixbuf_class_init (GtkCellRendererPixbufClass *class) GObjectClass *object_class = G_OBJECT_CLASS (class); GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (class); - parent_class = g_type_class_peek_parent (class); - object_class->finalize = gtk_cell_renderer_pixbuf_finalize; object_class->get_property = gtk_cell_renderer_pixbuf_get_property; @@ -247,7 +214,7 @@ gtk_cell_renderer_pixbuf_finalize (GObject *object) g_free (priv->stock_detail); g_free (priv->icon_name); - (* G_OBJECT_CLASS (parent_class)->finalize) (object); + (* G_OBJECT_CLASS (gtk_cell_renderer_pixbuf_parent_class)->finalize) (object); } static void diff --git a/gtk/gtkcellrendererspin.c b/gtk/gtkcellrendererspin.c index 23232a63b7..ba65efe659 100644 --- a/gtk/gtkcellrendererspin.c +++ b/gtk/gtkcellrendererspin.c @@ -37,8 +37,6 @@ struct _GtkCellRendererSpinPrivate guint digits; }; -static void gtk_cell_renderer_spin_class_init (GtkCellRendererSpinClass *klass); -static void gtk_cell_renderer_spin_init (GtkCellRendererSpin *self); static void gtk_cell_renderer_spin_finalize (GObject *object); static void gtk_cell_renderer_spin_get_property (GObject *object, diff --git a/gtk/gtkcellrenderertext.c b/gtk/gtkcellrenderertext.c index a821e1d847..426d8c803b 100644 --- a/gtk/gtkcellrenderertext.c +++ b/gtk/gtkcellrenderertext.c @@ -28,8 +28,6 @@ #include "gtktreeprivate.h" #include "gtkalias.h" -static void gtk_cell_renderer_text_init (GtkCellRendererText *celltext); -static void gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class); static void gtk_cell_renderer_text_finalize (GObject *object); static void gtk_cell_renderer_text_get_property (GObject *object, @@ -120,7 +118,6 @@ enum { PROP_ELLIPSIZE_SET }; -static gpointer parent_class; static guint text_cell_renderer_signals [LAST_SIGNAL]; #define GTK_CELL_RENDERER_TEXT_PATH "gtk-cell-renderer-text-path" @@ -151,34 +148,7 @@ struct _GtkCellRendererTextPrivate GtkWidget *entry; }; - -GType -gtk_cell_renderer_text_get_type (void) -{ - static GType cell_text_type = 0; - - if (!cell_text_type) - { - static const GTypeInfo cell_text_info = - { - sizeof (GtkCellRendererTextClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_cell_renderer_text_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkCellRendererText), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_cell_renderer_text_init, - }; - - cell_text_type = - g_type_register_static (GTK_TYPE_CELL_RENDERER, I_("GtkCellRendererText"), - &cell_text_info, 0); - } - - return cell_text_type; -} +G_DEFINE_TYPE (GtkCellRendererText, gtk_cell_renderer_text, GTK_TYPE_CELL_RENDERER); static void gtk_cell_renderer_text_init (GtkCellRendererText *celltext) @@ -205,8 +175,6 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class) GObjectClass *object_class = G_OBJECT_CLASS (class); GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (class); - parent_class = g_type_class_peek_parent (class); - object_class->finalize = gtk_cell_renderer_text_finalize; object_class->get_property = gtk_cell_renderer_text_get_property; @@ -614,7 +582,7 @@ gtk_cell_renderer_text_finalize (GObject *object) if (priv->language) g_object_unref (priv->language); - (* G_OBJECT_CLASS (parent_class)->finalize) (object); + (* G_OBJECT_CLASS (gtk_cell_renderer_text_parent_class)->finalize) (object); } static PangoFontMask diff --git a/gtk/gtkcellrenderertoggle.c b/gtk/gtkcellrenderertoggle.c index 4f62f35c51..e802177c34 100644 --- a/gtk/gtkcellrenderertoggle.c +++ b/gtk/gtkcellrenderertoggle.c @@ -34,8 +34,6 @@ static void gtk_cell_renderer_toggle_set_property (GObject * guint param_id, const GValue *value, GParamSpec *pspec); -static void gtk_cell_renderer_toggle_init (GtkCellRendererToggle *celltext); -static void gtk_cell_renderer_toggle_class_init (GtkCellRendererToggleClass *class); static void gtk_cell_renderer_toggle_get_size (GtkCellRenderer *cell, GtkWidget *widget, GdkRectangle *cell_area, @@ -88,33 +86,7 @@ struct _GtkCellRendererTogglePrivate }; -GType -gtk_cell_renderer_toggle_get_type (void) -{ - static GType cell_toggle_type = 0; - - if (!cell_toggle_type) - { - static const GTypeInfo cell_toggle_info = - { - sizeof (GtkCellRendererToggleClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_cell_renderer_toggle_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkCellRendererToggle), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_cell_renderer_toggle_init, - }; - - cell_toggle_type = - g_type_register_static (GTK_TYPE_CELL_RENDERER, I_("GtkCellRendererToggle"), - &cell_toggle_info, 0); - } - - return cell_toggle_type; -} +G_DEFINE_TYPE (GtkCellRendererToggle, gtk_cell_renderer_toggle, GTK_TYPE_CELL_RENDERER); static void gtk_cell_renderer_toggle_init (GtkCellRendererToggle *celltoggle) diff --git a/gtk/gtkcellview.c b/gtk/gtkcellview.c index 36d985b052..c4c221a041 100644 --- a/gtk/gtkcellview.c +++ b/gtk/gtkcellview.c @@ -57,7 +57,6 @@ struct _GtkCellViewPrivate }; -static void gtk_cell_view_class_init (GtkCellViewClass *klass); static void gtk_cell_view_cell_layout_init (GtkCellLayoutIface *iface); static void gtk_cell_view_get_property (GObject *object, guint param_id, @@ -67,7 +66,6 @@ static void gtk_cell_view_set_property (GObject *obj guint param_id, const GValue *value, GParamSpec *pspec); -static void gtk_cell_view_init (GtkCellView *cellview); static void gtk_cell_view_finalize (GObject *object); static void gtk_cell_view_style_set (GtkWidget *widget, GtkStyle *previous_style); @@ -119,45 +117,9 @@ enum PROP_BACKGROUND_SET }; -static GtkObjectClass *parent_class = NULL; - - -GType -gtk_cell_view_get_type (void) -{ - static GType cell_view_type = 0; - - if (!cell_view_type) - { - static const GTypeInfo cell_view_info = - { - sizeof (GtkCellViewClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_cell_view_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkCellView), - 0, - (GInstanceInitFunc) gtk_cell_view_init - }; - - static const GInterfaceInfo cell_layout_info = - { - (GInterfaceInitFunc) gtk_cell_view_cell_layout_init, - NULL, - NULL - }; - - cell_view_type = g_type_register_static (GTK_TYPE_WIDGET, I_("GtkCellView"), - &cell_view_info, 0); - - g_type_add_interface_static (cell_view_type, GTK_TYPE_CELL_LAYOUT, - &cell_layout_info); - } - - return cell_view_type; -} +G_DEFINE_TYPE_WITH_CODE (GtkCellView, gtk_cell_view, GTK_TYPE_WIDGET, + G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_LAYOUT, + gtk_cell_view_cell_layout_init)); static void gtk_cell_view_class_init (GtkCellViewClass *klass) @@ -165,8 +127,6 @@ gtk_cell_view_class_init (GtkCellViewClass *klass) GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); - gobject_class->get_property = gtk_cell_view_get_property; gobject_class->set_property = gtk_cell_view_set_property; gobject_class->finalize = gtk_cell_view_finalize; @@ -307,7 +267,7 @@ gtk_cell_view_finalize (GObject *object) if (cellview->priv->displayed_row) gtk_tree_row_reference_free (cellview->priv->displayed_row); - (* G_OBJECT_CLASS (parent_class)->finalize) (object); + (* G_OBJECT_CLASS (gtk_cell_view_parent_class)->finalize) (object); } static void diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c index 31442fc33b..71c21e0162 100644 --- a/gtk/gtkcheckbutton.c +++ b/gtk/gtkcheckbutton.c @@ -36,8 +36,6 @@ #define INDICATOR_SPACING 2 -static void gtk_check_button_class_init (GtkCheckButtonClass *klass); -static void gtk_check_button_init (GtkCheckButton *check_button); static void gtk_check_button_size_request (GtkWidget *widget, GtkRequisition *requisition); static void gtk_check_button_size_allocate (GtkWidget *widget, @@ -51,36 +49,7 @@ static void gtk_check_button_draw_indicator (GtkCheckButton *check_but static void gtk_real_check_button_draw_indicator (GtkCheckButton *check_button, GdkRectangle *area); -static GtkToggleButtonClass *parent_class = NULL; - - -GType -gtk_check_button_get_type (void) -{ - static GType check_button_type = 0; - - if (!check_button_type) - { - static const GTypeInfo check_button_info = - { - sizeof (GtkCheckButtonClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_check_button_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkCheckButton), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_check_button_init, - }; - - check_button_type = - g_type_register_static (GTK_TYPE_TOGGLE_BUTTON, I_("GtkCheckButton"), - &check_button_info, 0); - } - - return check_button_type; -} +G_DEFINE_TYPE (GtkCheckButton, gtk_check_button, GTK_TYPE_TOGGLE_BUTTON); static void gtk_check_button_class_init (GtkCheckButtonClass *class) @@ -88,7 +57,6 @@ gtk_check_button_class_init (GtkCheckButtonClass *class) GtkWidgetClass *widget_class; widget_class = (GtkWidgetClass*) class; - parent_class = g_type_class_peek_parent (class); widget_class->size_request = gtk_check_button_size_request; widget_class->size_allocate = gtk_check_button_size_allocate; @@ -258,7 +226,7 @@ gtk_check_button_size_request (GtkWidget *widget, requisition->height = MAX (requisition->height, temp) + 2 * (focus_width + focus_pad); } else - (* GTK_WIDGET_CLASS (parent_class)->size_request) (widget, requisition); + (* GTK_WIDGET_CLASS (gtk_check_button_parent_class)->size_request) (widget, requisition); } static void @@ -323,7 +291,7 @@ gtk_check_button_size_allocate (GtkWidget *widget, } } else - (* GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation); + (* GTK_WIDGET_CLASS (gtk_check_button_parent_class)->size_allocate) (widget, allocation); } static gint @@ -347,8 +315,8 @@ gtk_check_button_expose (GtkWidget *widget, bin->child, event); } - else if (GTK_WIDGET_CLASS (parent_class)->expose_event) - (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event); + else if (GTK_WIDGET_CLASS (gtk_check_button_parent_class)->expose_event) + (* GTK_WIDGET_CLASS (gtk_check_button_parent_class)->expose_event) (widget, event); } return FALSE; diff --git a/gtk/gtkcheckmenuitem.c b/gtk/gtkcheckmenuitem.c index 9c8ef0f275..429dadaaa2 100644 --- a/gtk/gtkcheckmenuitem.c +++ b/gtk/gtkcheckmenuitem.c @@ -44,8 +44,6 @@ enum { PROP_DRAW_AS_RADIO }; -static void gtk_check_menu_item_class_init (GtkCheckMenuItemClass *klass); -static void gtk_check_menu_item_init (GtkCheckMenuItem *check_menu_item); static gint gtk_check_menu_item_expose (GtkWidget *widget, GdkEventExpose *event); static void gtk_check_menu_item_activate (GtkMenuItem *menu_item); @@ -65,37 +63,9 @@ static void gtk_check_menu_item_get_property (GObject *object, GParamSpec *pspec); -static GtkMenuItemClass *parent_class = NULL; static guint check_menu_item_signals[LAST_SIGNAL] = { 0 }; - -GType -gtk_check_menu_item_get_type (void) -{ - static GType check_menu_item_type = 0; - - if (!check_menu_item_type) - { - static const GTypeInfo check_menu_item_info = - { - sizeof (GtkCheckMenuItemClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_check_menu_item_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkCheckMenuItem), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_check_menu_item_init, - }; - - check_menu_item_type = - g_type_register_static (GTK_TYPE_MENU_ITEM, I_("GtkCheckMenuItem"), - &check_menu_item_info, 0); - } - - return check_menu_item_type; -} +G_DEFINE_TYPE (GtkCheckMenuItem, gtk_check_menu_item, GTK_TYPE_MENU_ITEM); static void gtk_check_menu_item_class_init (GtkCheckMenuItemClass *klass) @@ -108,8 +78,6 @@ gtk_check_menu_item_class_init (GtkCheckMenuItemClass *klass) widget_class = (GtkWidgetClass*) klass; menu_item_class = (GtkMenuItemClass*) klass; - parent_class = g_type_class_peek_parent (klass); - gobject_class->set_property = gtk_check_menu_item_set_property; gobject_class->get_property = gtk_check_menu_item_get_property; @@ -384,8 +352,8 @@ static gint gtk_check_menu_item_expose (GtkWidget *widget, GdkEventExpose *event) { - if (GTK_WIDGET_CLASS (parent_class)->expose_event) - (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event); + if (GTK_WIDGET_CLASS (gtk_check_menu_item_parent_class)->expose_event) + (* GTK_WIDGET_CLASS (gtk_check_menu_item_parent_class)->expose_event) (widget, event); gtk_check_menu_item_draw_indicator (GTK_CHECK_MENU_ITEM (widget), &event->area); diff --git a/gtk/gtkclipboard.c b/gtk/gtkclipboard.c index 8eceb1dd8b..3e501294e7 100644 --- a/gtk/gtkclipboard.c +++ b/gtk/gtkclipboard.c @@ -158,23 +158,12 @@ gtk_clipboard_get_type (void) static GType clipboard_type = 0; if (!clipboard_type) - { - static const GTypeInfo clipboard_info = - { - sizeof (GtkClipboardClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_clipboard_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkClipboard), - 0, /* n_preallocs */ - (GInstanceInitFunc) NULL, - }; - - clipboard_type = g_type_register_static (G_TYPE_OBJECT, I_("GtkClipboard"), - &clipboard_info, 0); - } + clipboard_type = g_type_register_static_simple (G_TYPE_OBJECT, + I_("GtkClipboard"), + sizeof (GtkClipboardClass), + (GClassInitFunc)gtk_clipboard_class_init, + sizeof (GtkClipboard), + NULL, 0); return clipboard_type; } diff --git a/gtk/gtkcolorbutton.c b/gtk/gtkcolorbutton.c index 6e844cb4a9..94f79187b4 100644 --- a/gtk/gtkcolorbutton.c +++ b/gtk/gtkcolorbutton.c @@ -87,9 +87,6 @@ enum LAST_SIGNAL }; -static void gtk_color_button_class_init (GtkColorButtonClass *klass); -static void gtk_color_button_init (GtkColorButton *color_button); - /* gobject signals */ static void gtk_color_button_finalize (GObject *object); static void gtk_color_button_set_property (GObject *object, @@ -134,38 +131,11 @@ static void gtk_color_button_drag_data_received (GtkWidget *widget, GtkColorButton *color_button); -static gpointer parent_class = NULL; static guint color_button_signals[LAST_SIGNAL] = { 0 }; static const GtkTargetEntry drop_types[] = { { "application/x-color", 0, 0 } }; -GType -gtk_color_button_get_type (void) -{ - static GType color_button_type = 0; - - if (!color_button_type) - { - static const GTypeInfo color_button_info = - { - sizeof (GtkColorButtonClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_color_button_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkColorButton), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_color_button_init, - }; - - color_button_type = - g_type_register_static (GTK_TYPE_BUTTON, I_("GtkColorButton"), - &color_button_info, 0); - } - - return color_button_type; -} +G_DEFINE_TYPE (GtkColorButton, gtk_color_button, GTK_TYPE_BUTTON); static void gtk_color_button_class_init (GtkColorButtonClass *klass) @@ -178,8 +148,6 @@ gtk_color_button_class_init (GtkColorButtonClass *klass) widget_class = GTK_WIDGET_CLASS (klass); button_class = GTK_BUTTON_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); - gobject_class->get_property = gtk_color_button_get_property; gobject_class->set_property = gtk_color_button_set_property; gobject_class->finalize = gtk_color_button_finalize; @@ -406,7 +374,7 @@ gtk_color_button_realize (GtkWidget *widget) { GtkColorButton *color_button = GTK_COLOR_BUTTON (widget); - GTK_WIDGET_CLASS (parent_class)->realize (widget); + GTK_WIDGET_CLASS (gtk_color_button_parent_class)->realize (widget); color_button->priv->gc = gdk_gc_new (widget->window); @@ -421,7 +389,7 @@ gtk_color_button_unrealize (GtkWidget *widget) g_object_unref (color_button->priv->gc); color_button->priv->gc = NULL; - GTK_WIDGET_CLASS (parent_class)->unrealize (widget); + GTK_WIDGET_CLASS (gtk_color_button_parent_class)->unrealize (widget); } static void @@ -430,7 +398,7 @@ gtk_color_button_style_set (GtkWidget *widget, { GtkColorButton *color_button = GTK_COLOR_BUTTON (widget); - GTK_WIDGET_CLASS (parent_class)->style_set (widget, previous_style); + GTK_WIDGET_CLASS (gtk_color_button_parent_class)->style_set (widget, previous_style); if (GTK_WIDGET_REALIZED (widget)) { @@ -637,7 +605,7 @@ gtk_color_button_finalize (GObject *object) g_free (color_button->priv->title); color_button->priv->title = NULL; - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_color_button_parent_class)->finalize (object); } diff --git a/gtk/gtkcolorsel.c b/gtk/gtkcolorsel.c index 7d3d608de4..2d60240446 100644 --- a/gtk/gtkcolorsel.c +++ b/gtk/gtkcolorsel.c @@ -147,8 +147,6 @@ struct _ColorSelectionPrivate }; -static void gtk_color_selection_init (GtkColorSelection *colorsel); -static void gtk_color_selection_class_init (GtkColorSelectionClass *klass); static void gtk_color_selection_destroy (GtkObject *object); static void gtk_color_selection_finalize (GObject *object); static void update_color (GtkColorSelection *colorsel); @@ -183,7 +181,6 @@ static void make_control_relations (AtkObject *atk_ static void make_all_relations (AtkObject *atk_obj, ColorSelectionPrivate *priv); -static gpointer parent_class = NULL; static guint color_selection_signals[LAST_SIGNAL] = { 0 }; static const gchar default_colors[] = "black:white:gray50:red:purple:blue:light blue:green:yellow:orange:lavender:brown:goldenrod4:dodger blue:pink:light green:gray10:gray30:gray75:gray90"; @@ -1812,33 +1809,7 @@ default_change_palette_func (GdkScreen *screen, g_free (str); } -GType -gtk_color_selection_get_type (void) -{ - static GType color_selection_type = 0; - - if (!color_selection_type) - { - static const GTypeInfo color_selection_info = - { - sizeof (GtkColorSelectionClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_color_selection_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkColorSelection), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_color_selection_init, - }; - - color_selection_type = - g_type_register_static (GTK_TYPE_VBOX, I_("GtkColorSelection"), - &color_selection_info, 0); - } - - return color_selection_type; -} +G_DEFINE_TYPE (GtkColorSelection, gtk_color_selection, GTK_TYPE_VBOX); static void gtk_color_selection_class_init (GtkColorSelectionClass *klass) @@ -1851,8 +1822,6 @@ gtk_color_selection_class_init (GtkColorSelectionClass *klass) object_class = GTK_OBJECT_CLASS (klass); widget_class = GTK_WIDGET_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); - object_class->destroy = gtk_color_selection_destroy; gobject_class->finalize = gtk_color_selection_finalize; @@ -2122,13 +2091,13 @@ gtk_color_selection_destroy (GtkObject *object) priv->tooltips = NULL; } - GTK_OBJECT_CLASS (parent_class)->destroy (object); + GTK_OBJECT_CLASS (gtk_color_selection_parent_class)->destroy (object); } static void gtk_color_selection_finalize (GObject *object) { - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_color_selection_parent_class)->finalize (object); } static void @@ -2144,7 +2113,7 @@ gtk_color_selection_realize (GtkWidget *widget) widget); update_palette (colorsel); - GTK_WIDGET_CLASS (parent_class)->realize (widget); + GTK_WIDGET_CLASS (gtk_color_selection_parent_class)->realize (widget); } static void @@ -2156,7 +2125,7 @@ gtk_color_selection_unrealize (GtkWidget *widget) g_signal_handler_disconnect (settings, priv->settings_connection); - GTK_WIDGET_CLASS (parent_class)->unrealize (widget); + GTK_WIDGET_CLASS (gtk_color_selection_parent_class)->unrealize (widget); } /* We override show-all since we have internal widgets that diff --git a/gtk/gtkcolorseldialog.c b/gtk/gtkcolorseldialog.c index a14a89fe01..e00f34304c 100644 --- a/gtk/gtkcolorseldialog.c +++ b/gtk/gtkcolorseldialog.c @@ -34,48 +34,15 @@ #include "gtkalias.h" -static void gtk_color_selection_dialog_class_init (GtkColorSelectionDialogClass *klass); -static void gtk_color_selection_dialog_init (GtkColorSelectionDialog *colorseldiag); - -static GtkWindowClass *color_selection_dialog_parent_class = NULL; - - /***************************/ /* GtkColorSelectionDialog */ /***************************/ -GType -gtk_color_selection_dialog_get_type (void) -{ - static GType color_selection_dialog_type = 0; - - if (!color_selection_dialog_type) - { - static const GTypeInfo colorsel_diag_info = - { - sizeof (GtkColorSelectionDialogClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_color_selection_dialog_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkColorSelectionDialog), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_color_selection_dialog_init, - }; - - color_selection_dialog_type = - g_type_register_static (GTK_TYPE_DIALOG, I_("GtkColorSelectionDialog"), - &colorsel_diag_info, 0); - } - - return color_selection_dialog_type; -} +G_DEFINE_TYPE (GtkColorSelectionDialog, gtk_color_selection_dialog, GTK_TYPE_DIALOG); static void gtk_color_selection_dialog_class_init (GtkColorSelectionDialogClass *klass) { - color_selection_dialog_parent_class = g_type_class_peek_parent (klass); } static void diff --git a/gtk/gtkcombo.c b/gtk/gtkcombo.c index 345780f39a..65cdbbf31a 100644 --- a/gtk/gtkcombo.c +++ b/gtk/gtkcombo.c @@ -64,8 +64,6 @@ enum { PROP_VALUE_IN_LIST }; -static void gtk_combo_class_init (GtkComboClass *klass); -static void gtk_combo_init (GtkCombo *combo); static void gtk_combo_realize (GtkWidget *widget); static void gtk_combo_unrealize (GtkWidget *widget); static void gtk_combo_destroy (GtkObject *combo); @@ -122,7 +120,8 @@ static void gtk_combo_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static GtkHBoxClass *parent_class = NULL; + +G_DEFINE_TYPE (GtkCombo, gtk_combo, GTK_TYPE_HBOX); static void gtk_combo_class_init (GtkComboClass * klass) @@ -135,8 +134,6 @@ gtk_combo_class_init (GtkComboClass * klass) oclass = (GtkObjectClass *) klass; widget_class = (GtkWidgetClass *) klass; - parent_class = g_type_class_peek_parent (klass); - gobject_class->set_property = gtk_combo_set_property; gobject_class->get_property = gtk_combo_get_property; @@ -198,7 +195,7 @@ gtk_combo_destroy (GtkObject *object) combo->popwin = NULL; } - GTK_OBJECT_CLASS (parent_class)->destroy (object); + GTK_OBJECT_CLASS (gtk_combo_parent_class)->destroy (object); } static int @@ -1010,7 +1007,7 @@ gtk_combo_realize (GtkWidget *widget) gtk_window_set_screen (GTK_WINDOW (combo->popwin), gtk_widget_get_screen (widget)); - GTK_WIDGET_CLASS( parent_class )->realize (widget); + GTK_WIDGET_CLASS (gtk_combo_parent_class)->realize (widget); } static void @@ -1021,34 +1018,7 @@ gtk_combo_unrealize (GtkWidget *widget) gtk_combo_popdown_list (combo); gtk_widget_unrealize (combo->popwin); - GTK_WIDGET_CLASS (parent_class)->unrealize (widget); -} - -GType -gtk_combo_get_type (void) -{ - static GType combo_type = 0; - - if (!combo_type) - { - static const GTypeInfo combo_info = - { - sizeof (GtkComboClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_combo_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkCombo), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_combo_init, - }; - - combo_type = g_type_register_static (GTK_TYPE_HBOX, I_("GtkCombo"), - &combo_info, 0); - } - - return combo_type; + GTK_WIDGET_CLASS (gtk_combo_parent_class)->unrealize (widget); } GtkWidget* @@ -1166,7 +1136,7 @@ gtk_combo_size_allocate (GtkWidget *widget, g_return_if_fail (GTK_IS_COMBO (widget)); g_return_if_fail (allocation != NULL); - GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation); + GTK_WIDGET_CLASS (gtk_combo_parent_class)->size_allocate (widget, allocation); combo = GTK_COMBO (widget); diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c index 640661aa90..6228aeccff 100644 --- a/gtk/gtkcombobox.c +++ b/gtk/gtkcombobox.c @@ -202,7 +202,6 @@ enum { PROP_POPUP_SHOWN }; -static GtkBinClass *parent_class = NULL; static guint combo_box_signals[LAST_SIGNAL] = {0,}; #define BONUS_PADDING 4 @@ -210,10 +209,8 @@ static guint combo_box_signals[LAST_SIGNAL] = {0,}; /* common */ -static void gtk_combo_box_class_init (GtkComboBoxClass *klass); static void gtk_combo_box_cell_layout_init (GtkCellLayoutIface *iface); static void gtk_combo_box_cell_editable_init (GtkCellEditableIface *iface); -static void gtk_combo_box_init (GtkComboBox *combo_box); static void gtk_combo_box_finalize (GObject *object); static void gtk_combo_box_destroy (GtkObject *object); @@ -438,59 +435,11 @@ static void gtk_combo_box_start_editing (GtkCellEditable *cell_editable, GdkEvent *event); -GType -gtk_combo_box_get_type (void) -{ - static GType combo_box_type = 0; - - if (!combo_box_type) - { - static const GTypeInfo combo_box_info = - { - sizeof (GtkComboBoxClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_combo_box_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkComboBox), - 0, - (GInstanceInitFunc) gtk_combo_box_init - }; - - static const GInterfaceInfo cell_layout_info = - { - (GInterfaceInitFunc) gtk_combo_box_cell_layout_init, - NULL, - NULL - }; - - static const GInterfaceInfo cell_editable_info = - { - (GInterfaceInitFunc) gtk_combo_box_cell_editable_init, - NULL, - NULL - }; - - combo_box_type = g_type_register_static (GTK_TYPE_BIN, - I_("GtkComboBox"), - &combo_box_info, - 0); - - g_type_add_interface_static (combo_box_type, - GTK_TYPE_CELL_LAYOUT, - &cell_layout_info); - - - g_type_add_interface_static (combo_box_type, - GTK_TYPE_CELL_EDITABLE, - &cell_editable_info); - - - } - - return combo_box_type; -} +G_DEFINE_TYPE_WITH_CODE (GtkComboBox, gtk_combo_box, GTK_TYPE_BIN, + G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_LAYOUT, + gtk_combo_box_cell_layout_init) + G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_EDITABLE, + gtk_combo_box_cell_editable_init)); /* common */ static void @@ -526,8 +475,6 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass) object_class->set_property = gtk_combo_box_set_property; object_class->get_property = gtk_combo_box_get_property; - parent_class = g_type_class_peek_parent (klass); - /* signals */ /** * GtkComboBox::changed: @@ -4962,7 +4909,7 @@ gtk_combo_box_destroy (GtkObject *object) combo_box->priv->row_separator_data = NULL; combo_box->priv->row_separator_destroy = NULL; - GTK_OBJECT_CLASS (parent_class)->destroy (object); + GTK_OBJECT_CLASS (gtk_combo_box_parent_class)->destroy (object); combo_box->priv->cell_view = NULL; } @@ -5009,7 +4956,7 @@ gtk_combo_box_finalize (GObject *object) g_free (combo_box->priv->tearoff_title); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_combo_box_parent_class)->finalize (object); } static gboolean diff --git a/gtk/gtkcomboboxentry.c b/gtk/gtkcomboboxentry.c index 5ce651e032..8153aa43d5 100644 --- a/gtk/gtkcomboboxentry.c +++ b/gtk/gtkcomboboxentry.c @@ -38,9 +38,6 @@ struct _GtkComboBoxEntryPrivate gint text_column; }; -static void gtk_combo_box_entry_class_init (GtkComboBoxEntryClass *klass); -static void gtk_combo_box_entry_init (GtkComboBoxEntry *entry_box); - static void gtk_combo_box_entry_set_property (GObject *object, guint prop_id, const GValue *value, @@ -68,35 +65,7 @@ enum PROP_TEXT_COLUMN }; - -GType -gtk_combo_box_entry_get_type (void) -{ - static GType combo_box_entry_type = 0; - - if (!combo_box_entry_type) - { - static const GTypeInfo combo_box_entry_info = - { - sizeof (GtkComboBoxEntryClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_combo_box_entry_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkComboBoxEntry), - 0, - (GInstanceInitFunc) gtk_combo_box_entry_init - }; - - combo_box_entry_type = g_type_register_static (GTK_TYPE_COMBO_BOX, - I_("GtkComboBoxEntry"), - &combo_box_entry_info, - 0); - } - - return combo_box_entry_type; -} +G_DEFINE_TYPE (GtkComboBoxEntry, gtk_combo_box_entry, GTK_TYPE_COMBO_BOX); static void gtk_combo_box_entry_class_init (GtkComboBoxEntryClass *klass) diff --git a/gtk/gtkdialog.c b/gtk/gtkdialog.c index 5a96fc73c6..26c1a6e064 100644 --- a/gtk/gtkdialog.c +++ b/gtk/gtkdialog.c @@ -52,9 +52,6 @@ struct _ResponseData gint response_id; }; -static void gtk_dialog_class_init (GtkDialogClass *klass); -static void gtk_dialog_init (GtkDialog *dialog); - static void gtk_dialog_add_buttons_valist (GtkDialog *dialog, const gchar *first_button_text, va_list args); @@ -91,35 +88,9 @@ enum { LAST_SIGNAL }; -static gpointer parent_class; static guint dialog_signals[LAST_SIGNAL]; -GType -gtk_dialog_get_type (void) -{ - static GType dialog_type = 0; - - if (!dialog_type) - { - static const GTypeInfo dialog_info = - { - sizeof (GtkDialogClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_dialog_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkDialog), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_dialog_init, - }; - - dialog_type = g_type_register_static (GTK_TYPE_WINDOW, I_("GtkDialog"), - &dialog_info, 0); - } - - return dialog_type; -} +G_DEFINE_TYPE (GtkDialog, gtk_dialog, GTK_TYPE_WINDOW); static void gtk_dialog_class_init (GtkDialogClass *class) @@ -131,8 +102,6 @@ gtk_dialog_class_init (GtkDialogClass *class) gobject_class = G_OBJECT_CLASS (class); widget_class = GTK_WIDGET_CLASS (class); - parent_class = g_type_class_peek_parent (class); - gobject_class->set_property = gtk_dialog_set_property; gobject_class->get_property = gtk_dialog_get_property; @@ -338,7 +307,7 @@ gtk_dialog_map (GtkWidget *widget) GtkWindow *window = GTK_WINDOW (widget); GtkDialog *dialog = GTK_DIALOG (widget); - GTK_WIDGET_CLASS (parent_class)->map (widget); + GTK_WIDGET_CLASS (gtk_dialog_parent_class)->map (widget); if (!window->focus_widget) { diff --git a/gtk/gtkdrawingarea.c b/gtk/gtkdrawingarea.c index 992ebcf550..9a5d6091e3 100644 --- a/gtk/gtkdrawingarea.c +++ b/gtk/gtkdrawingarea.c @@ -30,41 +30,12 @@ #include "gtkalias.h" -static void gtk_drawing_area_class_init (GtkDrawingAreaClass *klass); -static void gtk_drawing_area_init (GtkDrawingArea *darea); static void gtk_drawing_area_realize (GtkWidget *widget); static void gtk_drawing_area_size_allocate (GtkWidget *widget, GtkAllocation *allocation); static void gtk_drawing_area_send_configure (GtkDrawingArea *darea); - -GType -gtk_drawing_area_get_type (void) -{ - static GType drawing_area_type = 0; - - if (!drawing_area_type) - { - static const GTypeInfo drawing_area_info = - { - sizeof (GtkDrawingAreaClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_drawing_area_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkDrawingArea), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_drawing_area_init, - }; - - drawing_area_type = - g_type_register_static (GTK_TYPE_WIDGET, I_("GtkDrawingArea"), - &drawing_area_info, 0); - } - - return drawing_area_type; -} +G_DEFINE_TYPE (GtkDrawingArea, gtk_drawing_area, GTK_TYPE_WIDGET); static void gtk_drawing_area_class_init (GtkDrawingAreaClass *class) diff --git a/gtk/gtkeditable.c b/gtk/gtkeditable.c index 6a2f6c77ea..117dfcdadb 100644 --- a/gtk/gtkeditable.c +++ b/gtk/gtkeditable.c @@ -33,7 +33,7 @@ #include "gtkalias.h" -static void gtk_editable_base_init (gpointer g_class); +static void gtk_editable_base_init (gpointer g_class); GType diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 2cf8f01609..8dc73de0de 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -135,10 +135,8 @@ typedef enum { /* GObject, GtkObject methods */ -static void gtk_entry_class_init (GtkEntryClass *klass); static void gtk_entry_editable_init (GtkEditableClass *iface); static void gtk_entry_cell_editable_init (GtkCellEditableIface *iface); -static void gtk_entry_init (GtkEntry *entry); static void gtk_entry_set_property (GObject *object, guint prop_id, const GValue *value, @@ -373,55 +371,11 @@ static void connect_completion_signals (GtkEntry *entr GtkEntryCompletion *completion); -static GtkWidgetClass *parent_class = NULL; - -GType -gtk_entry_get_type (void) -{ - static GType entry_type = 0; - - if (!entry_type) - { - static const GTypeInfo entry_info = - { - sizeof (GtkEntryClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_entry_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkEntry), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_entry_init, - }; - - static const GInterfaceInfo editable_info = - { - (GInterfaceInitFunc) gtk_entry_editable_init, /* interface_init */ - NULL, /* interface_finalize */ - NULL /* interface_data */ - }; - - static const GInterfaceInfo cell_editable_info = - { - (GInterfaceInitFunc) gtk_entry_cell_editable_init, /* interface_init */ - NULL, /* interface_finalize */ - NULL /* interface_data */ - }; - - entry_type = g_type_register_static (GTK_TYPE_WIDGET, I_("GtkEntry"), - &entry_info, 0); - - g_type_add_interface_static (entry_type, - GTK_TYPE_EDITABLE, - &editable_info); - g_type_add_interface_static (entry_type, - GTK_TYPE_CELL_EDITABLE, - &cell_editable_info); - } - - return entry_type; -} +G_DEFINE_TYPE_WITH_CODE (GtkEntry, gtk_entry, GTK_TYPE_WIDGET, + G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE, + gtk_entry_editable_init) + G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_EDITABLE, + gtk_entry_cell_editable_init)); static void add_move_binding (GtkBindingSet *binding_set, @@ -456,7 +410,6 @@ gtk_entry_class_init (GtkEntryClass *class) widget_class = (GtkWidgetClass*) class; gtk_object_class = (GtkObjectClass *)class; - parent_class = g_type_class_peek_parent (class); gobject_class->finalize = gtk_entry_finalize; gobject_class->set_property = gtk_entry_set_property; @@ -1178,7 +1131,7 @@ gtk_entry_destroy (GtkObject *object) trash_area (entry->text, strlen (entry->text)); } - GTK_OBJECT_CLASS (parent_class)->destroy (object); + GTK_OBJECT_CLASS (gtk_entry_parent_class)->destroy (object); } static void @@ -1209,7 +1162,7 @@ gtk_entry_finalize (GObject *object) entry->text = NULL; } - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_entry_parent_class)->finalize (object); } static void @@ -1294,8 +1247,8 @@ gtk_entry_unrealize (GtkWidget *widget) entry->popup_menu = NULL; } - if (GTK_WIDGET_CLASS (parent_class)->unrealize) - (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); + if (GTK_WIDGET_CLASS (gtk_entry_parent_class)->unrealize) + (* GTK_WIDGET_CLASS (gtk_entry_parent_class)->unrealize) (widget); } void @@ -2016,7 +1969,7 @@ gtk_entry_key_press (GtkWidget *widget, gtk_entry_reset_im_context (entry); } - if (GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, event)) + if (GTK_WIDGET_CLASS (gtk_entry_parent_class)->key_press_event (widget, event)) /* Activate key bindings */ return TRUE; @@ -2039,7 +1992,7 @@ gtk_entry_key_release (GtkWidget *widget, } } - return GTK_WIDGET_CLASS (parent_class)->key_release_event (widget, event); + return GTK_WIDGET_CLASS (gtk_entry_parent_class)->key_release_event (widget, event); } static gint @@ -2099,7 +2052,7 @@ gtk_entry_grab_focus (GtkWidget *widget) GtkEntry *entry = GTK_ENTRY (widget); gboolean select_on_focus; - GTK_WIDGET_CLASS (parent_class)->grab_focus (widget); + GTK_WIDGET_CLASS (gtk_entry_parent_class)->grab_focus (widget); g_object_get (gtk_widget_get_settings (widget), "gtk-entry-select-on-focus", @@ -2118,7 +2071,7 @@ gtk_entry_direction_changed (GtkWidget *widget, gtk_entry_recompute (entry); - GTK_WIDGET_CLASS (parent_class)->direction_changed (widget, previous_dir); + GTK_WIDGET_CLASS (gtk_entry_parent_class)->direction_changed (widget, previous_dir); } static void diff --git a/gtk/gtkentrycompletion.c b/gtk/gtkentrycompletion.c index e9e923869b..285a7ab4f5 100644 --- a/gtk/gtkentrycompletion.c +++ b/gtk/gtkentrycompletion.c @@ -65,9 +65,7 @@ enum #define GTK_ENTRY_COMPLETION_GET_PRIVATE(obj)(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_ENTRY_COMPLETION, GtkEntryCompletionPrivate)) -static void gtk_entry_completion_class_init (GtkEntryCompletionClass *klass); static void gtk_entry_completion_cell_layout_init (GtkCellLayoutIface *iface); -static void gtk_entry_completion_init (GtkEntryCompletion *completion); static void gtk_entry_completion_set_property (GObject *object, guint prop_id, const GValue *value, @@ -139,55 +137,17 @@ static gboolean gtk_entry_completion_match_selected (GtkEntryCompletion *co static gboolean gtk_entry_completion_real_insert_prefix (GtkEntryCompletion *completion, const gchar *prefix); -static GObjectClass *parent_class = NULL; static guint entry_completion_signals[LAST_SIGNAL] = { 0 }; - -GType -gtk_entry_completion_get_type (void) -{ - static GType entry_completion_type = 0; - - if (!entry_completion_type) - { - static const GTypeInfo entry_completion_info = - { - sizeof (GtkEntryCompletionClass), - NULL, - NULL, - (GClassInitFunc) gtk_entry_completion_class_init, - NULL, - NULL, - sizeof (GtkEntryCompletion), - 0, - (GInstanceInitFunc) gtk_entry_completion_init - }; - - static const GInterfaceInfo cell_layout_info = - { - (GInterfaceInitFunc) gtk_entry_completion_cell_layout_init, - NULL, - NULL - }; - - entry_completion_type = - g_type_register_static (G_TYPE_OBJECT, I_("GtkEntryCompletion"), - &entry_completion_info, 0); - - g_type_add_interface_static (entry_completion_type, - GTK_TYPE_CELL_LAYOUT, - &cell_layout_info); - } - - return entry_completion_type; -} +G_DEFINE_TYPE_WITH_CODE (GtkEntryCompletion, gtk_entry_completion, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_LAYOUT, + gtk_entry_completion_cell_layout_init)); static void gtk_entry_completion_class_init (GtkEntryCompletionClass *klass) { GObjectClass *object_class; - parent_class = g_type_class_peek_parent (klass); object_class = (GObjectClass *)klass; object_class->set_property = gtk_entry_completion_set_property; @@ -612,7 +572,7 @@ gtk_entry_completion_finalize (GObject *object) if (completion->priv->popup_window) gtk_widget_destroy (completion->priv->popup_window); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_entry_completion_parent_class)->finalize (object); } /* implement cell layout interface */ diff --git a/gtk/gtkeventbox.c b/gtk/gtkeventbox.c index 01a05681d6..fd1c2ae7bd 100644 --- a/gtk/gtkeventbox.c +++ b/gtk/gtkeventbox.c @@ -45,8 +45,6 @@ enum { #define GTK_EVENT_BOX_GET_PRIVATE(obj) G_TYPE_INSTANCE_GET_PRIVATE((obj), GTK_TYPE_EVENT_BOX, GtkEventBoxPrivate) -static void gtk_event_box_class_init (GtkEventBoxClass *klass); -static void gtk_event_box_init (GtkEventBox *event_box); static void gtk_event_box_realize (GtkWidget *widget); static void gtk_event_box_unrealize (GtkWidget *widget); static void gtk_event_box_map (GtkWidget *widget); @@ -68,34 +66,7 @@ static void gtk_event_box_get_property (GObject *object, GValue *value, GParamSpec *pspec); -static GtkBinClass *parent_class = NULL; - -GType -gtk_event_box_get_type (void) -{ - static GType event_box_type = 0; - - if (!event_box_type) - { - static const GTypeInfo event_box_info = - { - sizeof (GtkEventBoxClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_event_box_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkEventBox), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_event_box_init, - }; - - event_box_type = g_type_register_static (GTK_TYPE_BIN, I_("GtkEventBox"), - &event_box_info, 0); - } - - return event_box_type; -} +G_DEFINE_TYPE (GtkEventBox, gtk_event_box, GTK_TYPE_BIN); static void gtk_event_box_class_init (GtkEventBoxClass *class) @@ -103,8 +74,6 @@ gtk_event_box_class_init (GtkEventBoxClass *class) GObjectClass *gobject_class = G_OBJECT_CLASS (class); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class); - parent_class = g_type_class_peek_parent (class); - gobject_class->set_property = gtk_event_box_set_property; gobject_class->get_property = gtk_event_box_get_property; @@ -479,8 +448,8 @@ gtk_event_box_unrealize (GtkWidget *widget) priv->event_window = NULL; } - if (GTK_WIDGET_CLASS (parent_class)->unrealize) - (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); + if (GTK_WIDGET_CLASS (gtk_event_box_parent_class)->unrealize) + (* GTK_WIDGET_CLASS (gtk_event_box_parent_class)->unrealize) (widget); } static void @@ -493,7 +462,7 @@ gtk_event_box_map (GtkWidget *widget) if (priv->event_window != NULL && !priv->above_child) gdk_window_show (priv->event_window); - (* GTK_WIDGET_CLASS (parent_class)->map) (widget); + (* GTK_WIDGET_CLASS (gtk_event_box_parent_class)->map) (widget); if (priv->event_window != NULL && priv->above_child) gdk_window_show (priv->event_window); @@ -509,7 +478,7 @@ gtk_event_box_unmap (GtkWidget *widget) if (priv->event_window != NULL) gdk_window_hide (priv->event_window); - (* GTK_WIDGET_CLASS (parent_class)->unmap) (widget); + (* GTK_WIDGET_CLASS (gtk_event_box_parent_class)->unmap) (widget); } @@ -601,7 +570,7 @@ gtk_event_box_expose (GtkWidget *widget, if (!GTK_WIDGET_NO_WINDOW (widget)) gtk_event_box_paint (widget, &event->area); - (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event); + (* GTK_WIDGET_CLASS (gtk_event_box_parent_class)->expose_event) (widget, event); } return FALSE; diff --git a/gtk/gtkexpander.c b/gtk/gtkexpander.c index c658340b79..d90e16561b 100644 --- a/gtk/gtkexpander.c +++ b/gtk/gtkexpander.c @@ -68,9 +68,6 @@ struct _GtkExpanderPrivate guint prelight : 1; }; -static void gtk_expander_class_init (GtkExpanderClass *klass); -static void gtk_expander_init (GtkExpander *expander); - static void gtk_expander_set_property (GObject *object, guint prop_id, const GValue *value, @@ -129,35 +126,7 @@ static void gtk_expander_activate (GtkExpander *expander); static void get_expander_bounds (GtkExpander *expander, GdkRectangle *rect); -static GtkBinClass *parent_class = NULL; - -GType -gtk_expander_get_type (void) -{ - static GType expander_type = 0; - - if (!expander_type) - { - static const GTypeInfo expander_info = - { - sizeof (GtkExpanderClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_expander_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkExpander), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_expander_init, - }; - - expander_type = g_type_register_static (GTK_TYPE_BIN, - I_("GtkExpander"), - &expander_info, 0); - } - - return expander_type; -} +G_DEFINE_TYPE (GtkExpander, gtk_expander, GTK_TYPE_BIN); static void gtk_expander_class_init (GtkExpanderClass *klass) @@ -167,8 +136,6 @@ gtk_expander_class_init (GtkExpanderClass *klass) GtkWidgetClass *widget_class; GtkContainerClass *container_class; - parent_class = g_type_class_peek_parent (klass); - gobject_class = (GObjectClass *) klass; object_class = (GtkObjectClass *) klass; widget_class = (GtkWidgetClass *) klass; @@ -392,7 +359,7 @@ gtk_expander_destroy (GtkObject *object) priv->animation_timeout = 0; } - GTK_OBJECT_CLASS (parent_class)->destroy (object); + GTK_OBJECT_CLASS (gtk_expander_parent_class)->destroy (object); } static void @@ -448,7 +415,7 @@ gtk_expander_unrealize (GtkWidget *widget) priv->event_window = NULL; } - GTK_WIDGET_CLASS (parent_class)->unrealize (widget); + GTK_WIDGET_CLASS (gtk_expander_parent_class)->unrealize (widget); } static void @@ -707,7 +674,7 @@ gtk_expander_map (GtkWidget *widget) if (priv->label_widget) gtk_widget_map (priv->label_widget); - GTK_WIDGET_CLASS (parent_class)->map (widget); + GTK_WIDGET_CLASS (gtk_expander_parent_class)->map (widget); if (priv->event_window) gdk_window_show (priv->event_window); @@ -721,7 +688,7 @@ gtk_expander_unmap (GtkWidget *widget) if (priv->event_window) gdk_window_hide (priv->event_window); - GTK_WIDGET_CLASS (parent_class)->unmap (widget); + GTK_WIDGET_CLASS (gtk_expander_parent_class)->unmap (widget); if (priv->label_widget) gtk_widget_unmap (priv->label_widget); @@ -884,7 +851,7 @@ gtk_expander_expose (GtkWidget *widget, if (GTK_WIDGET_HAS_FOCUS (expander)) gtk_expander_paint_focus (expander, &event->area); - GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); + GTK_WIDGET_CLASS (gtk_expander_parent_class)->expose_event (widget, event); } return FALSE; @@ -1208,7 +1175,7 @@ static void gtk_expander_add (GtkContainer *container, GtkWidget *widget) { - GTK_CONTAINER_CLASS (parent_class)->add (container, widget); + GTK_CONTAINER_CLASS (gtk_expander_parent_class)->add (container, widget); gtk_widget_set_child_visible (widget, GTK_EXPANDER (container)->priv->expanded); gtk_widget_queue_resize (GTK_WIDGET (container)); @@ -1223,7 +1190,7 @@ gtk_expander_remove (GtkContainer *container, if (GTK_EXPANDER (expander)->priv->label_widget == widget) gtk_expander_set_label_widget (expander, NULL); else - GTK_CONTAINER_CLASS (parent_class)->remove (container, widget); + GTK_CONTAINER_CLASS (gtk_expander_parent_class)->remove (container, widget); } static void diff --git a/gtk/gtkfilechooser.c b/gtk/gtkfilechooser.c index 55689952b3..4ed46e9a85 100644 --- a/gtk/gtkfilechooser.c +++ b/gtk/gtkfilechooser.c @@ -39,18 +39,12 @@ gtk_file_chooser_get_type (void) if (!file_chooser_type) { - static const GTypeInfo file_chooser_info = - { - sizeof (GtkFileChooserIface), /* class_size */ - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc)gtk_file_chooser_class_init, /* class_init */ - }; - - file_chooser_type = g_type_register_static (G_TYPE_INTERFACE, - I_("GtkFileChooser"), - &file_chooser_info, 0); - + file_chooser_type = g_type_register_static_simple (G_TYPE_INTERFACE, + I_("GtkFileChooser"), + sizeof (GtkFileChooserIface), + gtk_file_chooser_class_init, + 0, NULL, 0); + g_type_interface_add_prerequisite (file_chooser_type, GTK_TYPE_WIDGET); } diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c index 27a7df701b..3d46c1cc10 100644 --- a/gtk/gtkfilechooserdefault.c +++ b/gtk/gtkfilechooserdefault.c @@ -241,10 +241,8 @@ typedef enum { #define NUM_LINES 40 #define NUM_CHARS 60 -static void gtk_file_chooser_default_class_init (GtkFileChooserDefaultClass *class); static void gtk_file_chooser_default_iface_init (GtkFileChooserIface *iface); static void gtk_file_chooser_embed_default_iface_init (GtkFileChooserEmbedIface *iface); -static void gtk_file_chooser_default_init (GtkFileChooserDefault *impl); static GObject* gtk_file_chooser_default_constructor (GType type, guint n_construct_properties, @@ -412,7 +410,6 @@ static const GtkFileInfo *get_list_file_info (GtkFileChooserDefault *impl, static void load_remove_timer (GtkFileChooserDefault *impl); static void browse_files_center_selected_row (GtkFileChooserDefault *impl); -static GObjectClass *parent_class; @@ -445,56 +442,14 @@ static GtkTreeModel *shortcuts_model_filter_new (GtkFileChooserDefault *impl, -GType -_gtk_file_chooser_default_get_type (void) -{ - static GType file_chooser_default_type = 0; - - if (!file_chooser_default_type) - { - static const GTypeInfo file_chooser_default_info = - { - sizeof (GtkFileChooserDefaultClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_file_chooser_default_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkFileChooserDefault), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_file_chooser_default_init, - }; - - static const GInterfaceInfo file_chooser_info = - { - (GInterfaceInitFunc) gtk_file_chooser_default_iface_init, /* interface_init */ - NULL, /* interface_finalize */ - NULL /* interface_data */ - }; - - static const GInterfaceInfo file_chooser_embed_info = - { - (GInterfaceInitFunc) gtk_file_chooser_embed_default_iface_init, /* interface_init */ - NULL, /* interface_finalize */ - NULL /* interface_data */ - }; - - file_chooser_default_type = g_type_register_static (GTK_TYPE_VBOX, I_("GtkFileChooserDefault"), - &file_chooser_default_info, 0); - - g_type_add_interface_static (file_chooser_default_type, - GTK_TYPE_FILE_CHOOSER, - &file_chooser_info); - g_type_add_interface_static (file_chooser_default_type, - GTK_TYPE_FILE_CHOOSER_EMBED, - &file_chooser_embed_info); - } - - return file_chooser_default_type; -} +G_DEFINE_TYPE_WITH_CODE (GtkFileChooserDefault, _gtk_file_chooser_default, GTK_TYPE_VBOX, + G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_CHOOSER, + gtk_file_chooser_default_iface_init) + G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_CHOOSER_EMBED, + gtk_file_chooser_embed_default_iface_init)); static void -gtk_file_chooser_default_class_init (GtkFileChooserDefaultClass *class) +_gtk_file_chooser_default_class_init (GtkFileChooserDefaultClass *class) { static const guint quick_bookmark_keyvals[10] = { GDK_1, GDK_2, GDK_3, GDK_4, GDK_5, GDK_6, GDK_7, GDK_8, GDK_9, GDK_0 @@ -504,8 +459,6 @@ gtk_file_chooser_default_class_init (GtkFileChooserDefaultClass *class) GtkBindingSet *binding_set; int i; - parent_class = g_type_class_peek_parent (class); - gobject_class->finalize = gtk_file_chooser_default_finalize; gobject_class->constructor = gtk_file_chooser_default_constructor; gobject_class->set_property = gtk_file_chooser_default_set_property; @@ -670,8 +623,9 @@ gtk_file_chooser_embed_default_iface_init (GtkFileChooserEmbedIface *iface) iface->should_respond = gtk_file_chooser_default_should_respond; iface->initial_focus = gtk_file_chooser_default_initial_focus; } + static void -gtk_file_chooser_default_init (GtkFileChooserDefault *impl) +_gtk_file_chooser_default_init (GtkFileChooserDefault *impl) { profile_start ("start", NULL); #ifdef PROFILE_FILE_CHOOSER @@ -856,7 +810,7 @@ gtk_file_chooser_default_finalize (GObject *object) g_object_unref (impl->tooltips); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (_gtk_file_chooser_default_parent_class)->finalize (object); } /* Shows an error dialog set as transient for the specified window */ @@ -3746,7 +3700,6 @@ file_list_drag_data_received_cb (GtkWidget *widget, char *uri; GtkFilePath *path; GError *error = NULL; - gint i; impl = GTK_FILE_CHOOSER_DEFAULT (data); chooser = GTK_FILE_CHOOSER (data); @@ -4383,9 +4336,9 @@ gtk_file_chooser_default_constructor (GType type, profile_start ("start", NULL); - object = parent_class->constructor (type, - n_construct_properties, - construct_params); + object = G_OBJECT_CLASS (_gtk_file_chooser_default_parent_class)->constructor (type, + n_construct_properties, + construct_params); impl = GTK_FILE_CHOOSER_DEFAULT (object); g_assert (impl->file_system); @@ -4914,7 +4867,7 @@ gtk_file_chooser_default_dispose (GObject *object) remove_settings_signal (impl, gtk_widget_get_screen (GTK_WIDGET (impl))); - G_OBJECT_CLASS (parent_class)->dispose (object); + G_OBJECT_CLASS (_gtk_file_chooser_default_parent_class)->dispose (object); } /* We override show-all since we have internal widgets that @@ -5054,8 +5007,8 @@ gtk_file_chooser_default_style_set (GtkWidget *widget, impl = GTK_FILE_CHOOSER_DEFAULT (widget); profile_msg (" parent class style_set start", NULL); - if (GTK_WIDGET_CLASS (parent_class)->style_set) - GTK_WIDGET_CLASS (parent_class)->style_set (widget, previous_style); + if (GTK_WIDGET_CLASS (_gtk_file_chooser_default_parent_class)->style_set) + GTK_WIDGET_CLASS (_gtk_file_chooser_default_parent_class)->style_set (widget, previous_style); profile_msg (" parent class style_set end", NULL); if (gtk_widget_has_screen (GTK_WIDGET (impl))) @@ -5078,8 +5031,8 @@ gtk_file_chooser_default_screen_changed (GtkWidget *widget, impl = GTK_FILE_CHOOSER_DEFAULT (widget); - if (GTK_WIDGET_CLASS (parent_class)->screen_changed) - GTK_WIDGET_CLASS (parent_class)->screen_changed (widget, previous_screen); + if (GTK_WIDGET_CLASS (_gtk_file_chooser_default_parent_class)->screen_changed) + GTK_WIDGET_CLASS (_gtk_file_chooser_default_parent_class)->screen_changed (widget, previous_screen); remove_settings_signal (impl, previous_screen); check_icon_theme (impl); @@ -5147,7 +5100,7 @@ gtk_file_chooser_default_map (GtkWidget *widget) impl = GTK_FILE_CHOOSER_DEFAULT (widget); - GTK_WIDGET_CLASS (parent_class)->map (widget); + GTK_WIDGET_CLASS (_gtk_file_chooser_default_parent_class)->map (widget); switch (impl->reload_state) { @@ -5188,7 +5141,7 @@ gtk_file_chooser_default_unmap (GtkWidget *widget) impl = GTK_FILE_CHOOSER_DEFAULT (widget); - GTK_WIDGET_CLASS (parent_class)->unmap (widget); + GTK_WIDGET_CLASS (_gtk_file_chooser_default_parent_class)->unmap (widget); impl->reload_state = RELOAD_WAS_UNMAPPED; } diff --git a/gtk/gtkfilechooserdialog.c b/gtk/gtkfilechooserdialog.c index 9db98970a2..e36c42c58c 100644 --- a/gtk/gtkfilechooserdialog.c +++ b/gtk/gtkfilechooserdialog.c @@ -33,8 +33,6 @@ #define GTK_FILE_CHOOSER_DIALOG_GET_PRIVATE(o) (GTK_FILE_CHOOSER_DIALOG (o)->priv) -static void gtk_file_chooser_dialog_class_init (GtkFileChooserDialogClass *class); -static void gtk_file_chooser_dialog_init (GtkFileChooserDialog *dialog); static void gtk_file_chooser_dialog_finalize (GObject *object); static GObject* gtk_file_chooser_dialog_constructor (GType type, @@ -57,44 +55,9 @@ static void gtk_file_chooser_dialog_style_set (GtkWidget *wid static void response_cb (GtkDialog *dialog, gint response_id); -static GObjectClass *parent_class; - -GType -gtk_file_chooser_dialog_get_type (void) -{ - static GType file_chooser_dialog_type = 0; - - if (!file_chooser_dialog_type) - { - static const GTypeInfo file_chooser_dialog_info = - { - sizeof (GtkFileChooserDialogClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_file_chooser_dialog_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkFileChooserDialog), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_file_chooser_dialog_init, - }; - - static const GInterfaceInfo file_chooser_info = - { - (GInterfaceInitFunc) _gtk_file_chooser_delegate_iface_init, /* interface_init */ - NULL, /* interface_finalize */ - NULL /* interface_data */ - }; - - file_chooser_dialog_type = g_type_register_static (GTK_TYPE_DIALOG, I_("GtkFileChooserDialog"), - &file_chooser_dialog_info, 0); - g_type_add_interface_static (file_chooser_dialog_type, - GTK_TYPE_FILE_CHOOSER, - &file_chooser_info); - } - - return file_chooser_dialog_type; -} +G_DEFINE_TYPE_WITH_CODE (GtkFileChooserDialog, gtk_file_chooser_dialog, GTK_TYPE_DIALOG, + G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_CHOOSER, + _gtk_file_chooser_delegate_iface_init)); static void gtk_file_chooser_dialog_class_init (GtkFileChooserDialogClass *class) @@ -102,8 +65,6 @@ gtk_file_chooser_dialog_class_init (GtkFileChooserDialogClass *class) GObjectClass *gobject_class = G_OBJECT_CLASS (class); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class); - parent_class = g_type_class_peek_parent (class); - gobject_class->constructor = gtk_file_chooser_dialog_constructor; gobject_class->set_property = gtk_file_chooser_dialog_set_property; gobject_class->get_property = gtk_file_chooser_dialog_get_property; @@ -149,7 +110,7 @@ gtk_file_chooser_dialog_finalize (GObject *object) g_free (dialog->priv->file_system); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_file_chooser_dialog_parent_class)->finalize (object); } /* Callback used when the user activates a file in the file chooser widget */ @@ -398,9 +359,9 @@ gtk_file_chooser_dialog_constructor (GType type, GtkFileChooserDialogPrivate *priv; GObject *object; - object = parent_class->constructor (type, - n_construct_properties, - construct_params); + object = G_OBJECT_CLASS (gtk_file_chooser_dialog_parent_class)->constructor (type, + n_construct_properties, + construct_params); priv = GTK_FILE_CHOOSER_DIALOG_GET_PRIVATE (object); gtk_widget_push_composite_child (); @@ -526,7 +487,7 @@ gtk_file_chooser_dialog_map (GtkWidget *widget) _gtk_file_chooser_embed_initial_focus (GTK_FILE_CHOOSER_EMBED (priv->widget)); - GTK_WIDGET_CLASS (parent_class)->map (widget); + GTK_WIDGET_CLASS (gtk_file_chooser_dialog_parent_class)->map (widget); } /* GtkWidget::unmap handler */ @@ -536,7 +497,7 @@ gtk_file_chooser_dialog_unmap (GtkWidget *widget) GtkFileChooserDialog *dialog = GTK_FILE_CHOOSER_DIALOG (widget); GtkFileChooserDialogPrivate *priv = GTK_FILE_CHOOSER_DIALOG_GET_PRIVATE (dialog); - GTK_WIDGET_CLASS (parent_class)->unmap (widget); + GTK_WIDGET_CLASS (gtk_file_chooser_dialog_parent_class)->unmap (widget); /* See bug #145470. We unmap the GtkFileChooserWidget so that if the dialog * is remapped, the widget will be remapped as well. Implementations should @@ -553,8 +514,8 @@ gtk_file_chooser_dialog_style_set (GtkWidget *widget, { GtkDialog *dialog; - if (GTK_WIDGET_CLASS (parent_class)->style_set) - GTK_WIDGET_CLASS (parent_class)->style_set (widget, previous_style); + if (GTK_WIDGET_CLASS (gtk_file_chooser_dialog_parent_class)->style_set) + GTK_WIDGET_CLASS (gtk_file_chooser_dialog_parent_class)->style_set (widget, previous_style); dialog = GTK_DIALOG (widget); diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c index cbae54c121..311d9d3e99 100644 --- a/gtk/gtkfilechooserentry.c +++ b/gtk/gtkfilechooserentry.c @@ -71,9 +71,7 @@ enum N_COLUMNS }; -static void gtk_file_chooser_entry_class_init (GtkFileChooserEntryClass *class); -static void gtk_file_chooser_entry_iface_init (GtkEditableClass *iface); -static void gtk_file_chooser_entry_init (GtkFileChooserEntry *chooser_entry); +static void gtk_file_chooser_entry_iface_init (GtkEditableClass *iface); static void gtk_file_chooser_entry_finalize (GObject *object); static void gtk_file_chooser_entry_dispose (GObject *object); @@ -106,57 +104,19 @@ static char *maybe_append_separator_to_path (GtkFileChooserEntry *chooser_ent GtkFilePath *path, gchar *display_name); -static GObjectClass *parent_class; static GtkEditableClass *parent_editable_iface; -GType -_gtk_file_chooser_entry_get_type (void) -{ - static GType file_chooser_entry_type = 0; - - if (!file_chooser_entry_type) - { - static const GTypeInfo file_chooser_entry_info = - { - sizeof (GtkFileChooserEntryClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_file_chooser_entry_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkFileChooserEntry), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_file_chooser_entry_init, - }; - - static const GInterfaceInfo editable_info = - { - (GInterfaceInitFunc) gtk_file_chooser_entry_iface_init, /* interface_init */ - NULL, /* interface_finalize */ - NULL /* interface_data */ - }; - - - file_chooser_entry_type = g_type_register_static (GTK_TYPE_ENTRY, I_("GtkFileChooserEntry"), - &file_chooser_entry_info, 0); - g_type_add_interface_static (file_chooser_entry_type, - GTK_TYPE_EDITABLE, - &editable_info); - } - - - return file_chooser_entry_type; -} +G_DEFINE_TYPE_WITH_CODE (GtkFileChooserEntry, _gtk_file_chooser_entry, GTK_TYPE_ENTRY, + G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE, + gtk_file_chooser_entry_iface_init)); static void -gtk_file_chooser_entry_class_init (GtkFileChooserEntryClass *class) +_gtk_file_chooser_entry_class_init (GtkFileChooserEntryClass *class) { GObjectClass *gobject_class = G_OBJECT_CLASS (class); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class); GtkEntryClass *entry_class = GTK_ENTRY_CLASS (class); - parent_class = g_type_class_peek_parent (class); - gobject_class->finalize = gtk_file_chooser_entry_finalize; gobject_class->dispose = gtk_file_chooser_entry_dispose; @@ -175,7 +135,7 @@ gtk_file_chooser_entry_iface_init (GtkEditableClass *iface) } static void -gtk_file_chooser_entry_init (GtkFileChooserEntry *chooser_entry) +_gtk_file_chooser_entry_init (GtkFileChooserEntry *chooser_entry) { GtkEntryCompletion *comp; GtkCellRenderer *cell; @@ -218,7 +178,7 @@ gtk_file_chooser_entry_finalize (GObject *object) gtk_file_path_free (chooser_entry->current_folder_path); g_free (chooser_entry->file_part); - parent_class->finalize (object); + G_OBJECT_CLASS (_gtk_file_chooser_entry_parent_class)->finalize (object); } static void @@ -254,7 +214,7 @@ gtk_file_chooser_entry_dispose (GObject *object) chooser_entry->file_system = NULL; } - parent_class->dispose (object); + G_OBJECT_CLASS (_gtk_file_chooser_entry_parent_class)->dispose (object); } /* Match functions for the GtkEntryCompletion */ @@ -728,7 +688,7 @@ gtk_file_chooser_entry_focus (GtkWidget *widget, entry = GTK_ENTRY (widget); if (!chooser_entry->eat_tabs) - return GTK_WIDGET_CLASS (parent_class)->focus (widget, direction); + return GTK_WIDGET_CLASS (_gtk_file_chooser_entry_parent_class)->focus (widget, direction); control_pressed = FALSE; @@ -760,7 +720,7 @@ gtk_file_chooser_entry_focus (GtkWidget *widget, return TRUE; } else - return GTK_WIDGET_CLASS (parent_class)->focus (widget, direction); + return GTK_WIDGET_CLASS (_gtk_file_chooser_entry_parent_class)->focus (widget, direction); } static void @@ -774,7 +734,7 @@ gtk_file_chooser_entry_activate (GtkEntry *entry) entry->text_length); } - GTK_ENTRY_CLASS (parent_class)->activate (entry); + GTK_ENTRY_CLASS (_gtk_file_chooser_entry_parent_class)->activate (entry); } /* This will see if a path typed by the user is new, and installs the loading diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c index fa4e3f2d71..dceb774f27 100644 --- a/gtk/gtkfilechooserwidget.c +++ b/gtk/gtkfilechooserwidget.c @@ -20,6 +20,7 @@ #include <config.h> #include "gtkfilechooserprivate.h" + #include "gtkfilechooserwidget.h" #include "gtkfilechooserdefault.h" #include "gtkfilechooserutils.h" @@ -30,8 +31,6 @@ #define GTK_FILE_CHOOSER_WIDGET_GET_PRIVATE(o) (GTK_FILE_CHOOSER_WIDGET (o)->priv) -static void gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class); -static void gtk_file_chooser_widget_init (GtkFileChooserWidget *chooser_widget); static void gtk_file_chooser_widget_finalize (GObject *object); static GObject* gtk_file_chooser_widget_constructor (GType type, @@ -46,63 +45,17 @@ static void gtk_file_chooser_widget_get_property (GObject *obj GValue *value, GParamSpec *pspec); -static GObjectClass *parent_class; - -GType -gtk_file_chooser_widget_get_type (void) -{ - static GType file_chooser_widget_type = 0; - - if (!file_chooser_widget_type) - { - static const GTypeInfo file_chooser_widget_info = - { - sizeof (GtkFileChooserWidgetClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_file_chooser_widget_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkFileChooserWidget), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_file_chooser_widget_init, - }; - - static const GInterfaceInfo file_chooser_info = - { - (GInterfaceInitFunc) _gtk_file_chooser_delegate_iface_init, /* interface_init */ - NULL, /* interface_finalize */ - NULL /* interface_data */ - }; - - static const GInterfaceInfo file_chooser_embed_info = - { - (GInterfaceInitFunc) _gtk_file_chooser_embed_delegate_iface_init, /* interface_init */ - NULL, /* interface_finalize */ - NULL /* interface_data */ - }; - - file_chooser_widget_type = g_type_register_static (GTK_TYPE_VBOX, I_("GtkFileChooserWidget"), - &file_chooser_widget_info, 0); - - g_type_add_interface_static (file_chooser_widget_type, - GTK_TYPE_FILE_CHOOSER, - &file_chooser_info); - g_type_add_interface_static (file_chooser_widget_type, - GTK_TYPE_FILE_CHOOSER_EMBED, - &file_chooser_embed_info); - } - - return file_chooser_widget_type; -} +G_DEFINE_TYPE_WITH_CODE (GtkFileChooserWidget, gtk_file_chooser_widget, GTK_TYPE_VBOX, + G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_CHOOSER, + _gtk_file_chooser_delegate_iface_init) + G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_CHOOSER_EMBED, + _gtk_file_chooser_embed_delegate_iface_init)); static void gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class) { GObjectClass *gobject_class = G_OBJECT_CLASS (class); - parent_class = g_type_class_peek_parent (class); - gobject_class->constructor = gtk_file_chooser_widget_constructor; gobject_class->set_property = gtk_file_chooser_widget_set_property; gobject_class->get_property = gtk_file_chooser_widget_get_property; @@ -129,7 +82,7 @@ gtk_file_chooser_widget_finalize (GObject *object) g_free (chooser->priv->file_system); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_file_chooser_widget_parent_class)->finalize (object); } static GObject* @@ -140,9 +93,9 @@ gtk_file_chooser_widget_constructor (GType type, GtkFileChooserWidgetPrivate *priv; GObject *object; - object = parent_class->constructor (type, - n_construct_properties, - construct_params); + 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); gtk_widget_push_composite_child (); diff --git a/gtk/gtkfilefilter.c b/gtk/gtkfilefilter.c index b5b285e2e1..4567da98a4 100644 --- a/gtk/gtkfilefilter.c +++ b/gtk/gtkfilefilter.c @@ -90,23 +90,11 @@ gtk_file_filter_get_type (void) static GType file_filter_type = 0; if (!file_filter_type) - { - static const GTypeInfo file_filter_info = - { - sizeof (GtkFileFilterClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_file_filter_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkFileFilter), - 0, /* n_preallocs */ - NULL /* init */ - }; - - file_filter_type = g_type_register_static (GTK_TYPE_OBJECT, I_("GtkFileFilter"), - &file_filter_info, 0); - } + file_filter_type = g_type_register_static_simple (GTK_TYPE_OBJECT, I_("GtkFileFilter"), + sizeof (GtkFileFilterClass), + (GClassInitFunc)gtk_file_filter_class_init, + sizeof (GtkFileFilter), + NULL, 0); return file_filter_type; } diff --git a/gtk/gtkfilesel.c b/gtk/gtkfilesel.c index 22f606adc5..4cf800a449 100644 --- a/gtk/gtkfilesel.c +++ b/gtk/gtkfilesel.c @@ -372,7 +372,6 @@ static gint compare_cmpl_dir(const void* a, const void* b); static void update_cmpl(PossibleCompletion* poss, CompletionState* cmpl_state); -static void gtk_file_selection_class_init (GtkFileSelectionClass *klass); static void gtk_file_selection_set_property (GObject *object, guint prop_id, const GValue *value, @@ -381,7 +380,6 @@ static void gtk_file_selection_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static void gtk_file_selection_init (GtkFileSelection *filesel); static void gtk_file_selection_finalize (GObject *object); static void gtk_file_selection_destroy (GtkObject *object); static void gtk_file_selection_map (GtkWidget *widget); @@ -466,8 +464,6 @@ compare_sys_filenames (const gchar *a, #endif -static GtkWindowClass *parent_class = NULL; - /* Saves errno when something cmpl does fails. */ static gint cmpl_errno; @@ -507,33 +503,7 @@ translate_win32_path (GtkFileSelection *filesel) } #endif -GType -gtk_file_selection_get_type (void) -{ - static GType file_selection_type = 0; - - if (!file_selection_type) - { - static const GTypeInfo filesel_info = - { - sizeof (GtkFileSelectionClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_file_selection_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkFileSelection), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_file_selection_init, - }; - - file_selection_type = - g_type_register_static (GTK_TYPE_DIALOG, I_("GtkFileSelection"), - &filesel_info, 0); - } - - return file_selection_type; -} +G_DEFINE_TYPE (GtkFileSelection, gtk_file_selection, GTK_TYPE_DIALOG); static void gtk_file_selection_class_init (GtkFileSelectionClass *class) @@ -546,8 +516,6 @@ gtk_file_selection_class_init (GtkFileSelectionClass *class) object_class = (GtkObjectClass*) class; widget_class = (GtkWidgetClass*) class; - parent_class = g_type_class_peek_parent (class); - gobject_class->finalize = gtk_file_selection_finalize; gobject_class->set_property = gtk_file_selection_set_property; gobject_class->get_property = gtk_file_selection_get_property; @@ -1333,7 +1301,7 @@ gtk_file_selection_destroy (GtkObject *object) filesel->last_selected = NULL; } - GTK_OBJECT_CLASS (parent_class)->destroy (object); + GTK_OBJECT_CLASS (gtk_file_selection_parent_class)->destroy (object); } static void @@ -1344,7 +1312,7 @@ gtk_file_selection_map (GtkWidget *widget) /* Refresh the contents */ gtk_file_selection_populate (filesel, "", FALSE, FALSE); - GTK_WIDGET_CLASS (parent_class)->map (widget); + GTK_WIDGET_CLASS (gtk_file_selection_parent_class)->map (widget); } static void @@ -1354,7 +1322,7 @@ gtk_file_selection_finalize (GObject *object) g_free (filesel->fileop_file); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_file_selection_parent_class)->finalize (object); } /* Begin file operations callbacks */ diff --git a/gtk/gtkfilesystem.c b/gtk/gtkfilesystem.c index d1af8fe932..6246f7945e 100644 --- a/gtk/gtkfilesystem.c +++ b/gtk/gtkfilesystem.c @@ -325,42 +325,13 @@ gtk_file_info_render_icon (const GtkFileInfo *info, * GtkFileSystemHandle * *****************************************/ -static void gtk_file_system_handle_init (GtkFileSystemHandle *handle); -static void gtk_file_system_handle_class_init (GtkFileSystemHandleClass *klass); - enum { PROP_0, PROP_CANCELLED }; -GType -gtk_file_system_handle_get_type (void) -{ - static GType file_system_handle_type = 0; - - if (!file_system_handle_type) - { - static const GTypeInfo file_system_handle_info = - { - sizeof (GtkFileSystemHandleClass), - NULL, - NULL, - (GClassInitFunc) gtk_file_system_handle_class_init, - NULL, - NULL, - sizeof (GtkFileSystemHandle), - 0, - (GInstanceInitFunc) gtk_file_system_handle_init, - }; - - file_system_handle_type = g_type_register_static (G_TYPE_OBJECT, - I_("GtkFileSystemHandle"), - &file_system_handle_info, 0); - } - - return file_system_handle_type; -} +G_DEFINE_TYPE (GtkFileSystemHandle, gtk_file_system_handle, G_TYPE_OBJECT); #if 0 GtkFileSystemHandle * diff --git a/gtk/gtkfilesystemmodel.c b/gtk/gtkfilesystemmodel.c index d365351add..32aebbcdc2 100644 --- a/gtk/gtkfilesystemmodel.c +++ b/gtk/gtkfilesystemmodel.c @@ -46,9 +46,7 @@ struct _GtkFileSystemModelClass }; -static void gtk_file_system_model_class_init (GtkFileSystemModelClass *class); static void gtk_file_system_model_iface_init (GtkTreeModelIface *iface); -static void gtk_file_system_model_init (GtkFileSystemModel *model); static void gtk_file_system_model_finalize (GObject *object); static void gtk_file_system_model_dispose (GObject *object); @@ -138,8 +136,6 @@ static void root_files_removed_callback (GtkFileFolder *folder, GSList *paths, GtkFileSystemModel *model); -static GObjectClass *parent_class = NULL; - /* Signal IDs */ enum { FINISHED_LOADING, @@ -150,61 +146,17 @@ static guint file_system_model_signals[LAST_SIGNAL] = { 0 }; -GType -_gtk_file_system_model_get_type (void) -{ - static GType file_system_model_type = 0; - - if (!file_system_model_type) - { - static const GTypeInfo file_system_model_info = - { - sizeof (GtkFileSystemModelClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_file_system_model_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkFileSystemModel), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_file_system_model_init, - }; - - static const GInterfaceInfo file_system_info = - { - (GInterfaceInitFunc) gtk_file_system_model_iface_init, /* interface_init */ - NULL, /* interface_finalize */ - NULL /* interface_data */ - }; - - static const GInterfaceInfo drag_source_info = - { - (GInterfaceInitFunc) drag_source_iface_init, /* interface_init */ - NULL, /* interface_finalize */ - NULL /* interface_data */ - }; - - file_system_model_type = g_type_register_static (G_TYPE_OBJECT, - I_("GtkFileSystemModel"), - &file_system_model_info, 0); - g_type_add_interface_static (file_system_model_type, - GTK_TYPE_TREE_MODEL, - &file_system_info); - g_type_add_interface_static (file_system_model_type, - GTK_TYPE_TREE_DRAG_SOURCE, - &drag_source_info); - } - - return file_system_model_type; -} +G_DEFINE_TYPE_WITH_CODE (GtkFileSystemModel, _gtk_file_system_model, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, + gtk_file_system_model_iface_init) + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_DRAG_SOURCE, + drag_source_iface_init)); static void -gtk_file_system_model_class_init (GtkFileSystemModelClass *class) +_gtk_file_system_model_class_init (GtkFileSystemModelClass *class) { GObjectClass *gobject_class = G_OBJECT_CLASS (class); - parent_class = g_type_class_peek_parent (class); - gobject_class->finalize = gtk_file_system_model_finalize; gobject_class->dispose = gtk_file_system_model_dispose; @@ -238,7 +190,7 @@ gtk_file_system_model_iface_init (GtkTreeModelIface *iface) } static void -gtk_file_system_model_init (GtkFileSystemModel *model) +_gtk_file_system_model_init (GtkFileSystemModel *model) { model->show_files = TRUE; model->show_folders = TRUE; @@ -268,7 +220,7 @@ gtk_file_system_model_finalize (GObject *object) children = next; } - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (_gtk_file_system_model_parent_class)->finalize (object); } @@ -287,7 +239,7 @@ gtk_file_system_model_dispose (GObject *object) model->pending_handles = NULL; } - G_OBJECT_CLASS (parent_class)->dispose (object); + G_OBJECT_CLASS (_gtk_file_system_model_parent_class)->dispose (object); } static void diff --git a/gtk/gtkfilesystemunix.c b/gtk/gtkfilesystemunix.c index 39f98a1aba..c98e9658ab 100644 --- a/gtk/gtkfilesystemunix.c +++ b/gtk/gtkfilesystemunix.c @@ -132,12 +132,7 @@ static const GtkFileInfoType STAT_NEEDED_MASK = (GTK_FILE_INFO_IS_FOLDER | GTK_FILE_INFO_SIZE | GTK_FILE_INFO_ICON); -static GObjectClass *system_parent_class; -static GObjectClass *folder_parent_class; - -static void gtk_file_system_unix_class_init (GtkFileSystemUnixClass *class); static void gtk_file_system_unix_iface_init (GtkFileSystemIface *iface); -static void gtk_file_system_unix_init (GtkFileSystemUnix *impl); static void gtk_file_system_unix_finalize (GObject *object); static GSList * gtk_file_system_unix_list_volumes (GtkFileSystem *file_system); @@ -215,10 +210,7 @@ static void gtk_file_system_unix_set_bookmark_label (GtkFileSystem *file const GtkFilePath *path, const gchar *label); -static GType gtk_file_folder_unix_get_type (void); -static void gtk_file_folder_unix_class_init (GtkFileFolderUnixClass *class); static void gtk_file_folder_unix_iface_init (GtkFileFolderIface *iface); -static void gtk_file_folder_unix_init (GtkFileFolderUnix *impl); static void gtk_file_folder_unix_finalize (GObject *object); static GtkFileInfo *gtk_file_folder_unix_get_info (GtkFileFolder *folder, @@ -269,43 +261,17 @@ static char * get_parent_dir (const char *filename); /* * GtkFileSystemUnix */ -GType -gtk_file_system_unix_get_type (void) -{ - static GType file_system_unix_type = 0; +G_DEFINE_TYPE_WITH_CODE (GtkFileSystemUnix, gtk_file_system_unix, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_SYSTEM, + gtk_file_system_unix_iface_init)); - if (!file_system_unix_type) - { - static const GTypeInfo file_system_unix_info = - { - sizeof (GtkFileSystemUnixClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_file_system_unix_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkFileSystemUnix), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_file_system_unix_init, - }; - - static const GInterfaceInfo file_system_info = - { - (GInterfaceInitFunc) gtk_file_system_unix_iface_init, /* interface_init */ - NULL, /* interface_finalize */ - NULL /* interface_data */ - }; - - file_system_unix_type = g_type_register_static (G_TYPE_OBJECT, - I_("GtkFileSystemUnix"), - &file_system_unix_info, 0); - g_type_add_interface_static (file_system_unix_type, - GTK_TYPE_FILE_SYSTEM, - &file_system_info); - } +/* + * GtkFileFolderUnix + */ +G_DEFINE_TYPE_WITH_CODE (GtkFileFolderUnix, gtk_file_folder_unix, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_FOLDER, + gtk_file_folder_unix_iface_init)); - return file_system_unix_type; -} /** * gtk_file_system_unix_new: @@ -327,8 +293,6 @@ gtk_file_system_unix_class_init (GtkFileSystemUnixClass *class) { GObjectClass *gobject_class = G_OBJECT_CLASS (class); - system_parent_class = g_type_class_peek_parent (class); - gobject_class->finalize = gtk_file_system_unix_finalize; } @@ -387,7 +351,7 @@ gtk_file_system_unix_finalize (GObject *object) /* FIXME: assert that the hash is empty? */ g_hash_table_destroy (system_unix->folder_hash); - system_parent_class->finalize (object); + G_OBJECT_CLASS (gtk_file_system_unix_parent_class)->finalize (object); } /* Returns our single root volume */ @@ -2047,54 +2011,11 @@ gtk_file_system_unix_set_bookmark_label (GtkFileSystem *file_system, g_free (uri); } -/* - * GtkFileFolderUnix - */ -static GType -gtk_file_folder_unix_get_type (void) -{ - static GType file_folder_unix_type = 0; - - if (!file_folder_unix_type) - { - static const GTypeInfo file_folder_unix_info = - { - sizeof (GtkFileFolderUnixClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_file_folder_unix_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkFileFolderUnix), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_file_folder_unix_init, - }; - - static const GInterfaceInfo file_folder_info = - { - (GInterfaceInitFunc) gtk_file_folder_unix_iface_init, /* interface_init */ - NULL, /* interface_finalize */ - NULL /* interface_data */ - }; - - file_folder_unix_type = g_type_register_static (G_TYPE_OBJECT, - I_("GtkFileFolderUnix"), - &file_folder_unix_info, 0); - g_type_add_interface_static (file_folder_unix_type, - GTK_TYPE_FILE_FOLDER, - &file_folder_info); - } - - return file_folder_unix_type; -} - static void gtk_file_folder_unix_class_init (GtkFileFolderUnixClass *class) { GObjectClass *gobject_class = G_OBJECT_CLASS (class); - folder_parent_class = g_type_class_peek_parent (class); - gobject_class->finalize = gtk_file_folder_unix_finalize; } @@ -2134,7 +2055,7 @@ gtk_file_folder_unix_finalize (GObject *object) g_free (folder_unix->filename); - folder_parent_class->finalize (object); + G_OBJECT_CLASS (gtk_file_folder_unix_parent_class)->finalize (object); } /* Creates a GtkFileInfo for "/" by stat()ing it */ diff --git a/gtk/gtkfixed.c b/gtk/gtkfixed.c index d98cb04a60..d2465e9adc 100644 --- a/gtk/gtkfixed.c +++ b/gtk/gtkfixed.c @@ -29,15 +29,12 @@ #include "gtkprivate.h" #include "gtkintl.h" #include "gtkalias.h" - enum { CHILD_PROP_0, CHILD_PROP_X, CHILD_PROP_Y }; -static void gtk_fixed_class_init (GtkFixedClass *klass); -static void gtk_fixed_init (GtkFixed *fixed); static void gtk_fixed_realize (GtkWidget *widget); static void gtk_fixed_size_request (GtkWidget *widget, GtkRequisition *requisition); @@ -64,35 +61,7 @@ static void gtk_fixed_get_child_property (GtkContainer *container, GValue *value, GParamSpec *pspec); -static GtkContainerClass *parent_class = NULL; - - -GType -gtk_fixed_get_type (void) -{ - static GType fixed_type = 0; - - if (!fixed_type) - { - static const GTypeInfo fixed_info = - { - sizeof (GtkFixedClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_fixed_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkFixed), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_fixed_init, - }; - - fixed_type = g_type_register_static (GTK_TYPE_CONTAINER, I_("GtkFixed"), - &fixed_info, 0); - } - - return fixed_type; -} +G_DEFINE_TYPE (GtkFixed, gtk_fixed, GTK_TYPE_CONTAINER); static void gtk_fixed_class_init (GtkFixedClass *class) @@ -103,8 +72,6 @@ gtk_fixed_class_init (GtkFixedClass *class) widget_class = (GtkWidgetClass*) class; container_class = (GtkContainerClass*) class; - parent_class = g_type_class_peek_parent (class); - widget_class->realize = gtk_fixed_realize; widget_class->size_request = gtk_fixed_size_request; widget_class->size_allocate = gtk_fixed_size_allocate; @@ -306,7 +273,7 @@ gtk_fixed_realize (GtkWidget *widget) gint attributes_mask; if (GTK_WIDGET_NO_WINDOW (widget)) - GTK_WIDGET_CLASS (parent_class)->realize (widget); + GTK_WIDGET_CLASS (gtk_fixed_parent_class)->realize (widget); else { GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); diff --git a/gtk/gtkfontbutton.c b/gtk/gtkfontbutton.c index 91f05d23f1..4c2e5756e6 100644 --- a/gtk/gtkfontbutton.c +++ b/gtk/gtkfontbutton.c @@ -84,8 +84,6 @@ enum }; /* Prototypes */ -static void gtk_font_button_init (GtkFontButton *font_button); -static void gtk_font_button_class_init (GtkFontButtonClass *klass); static void gtk_font_button_finalize (GObject *object); static void gtk_font_button_get_property (GObject *object, guint param_id, @@ -111,37 +109,9 @@ static GtkWidget *gtk_font_button_create_inside (GtkFontButton *gfs); static void gtk_font_button_label_use_font (GtkFontButton *gfs); static void gtk_font_button_update_font_info (GtkFontButton *gfs); -static gpointer parent_class = NULL; static guint font_button_signals[LAST_SIGNAL] = { 0 }; -GType -gtk_font_button_get_type (void) -{ - static GType font_button_type = 0; - - if (!font_button_type) - { - static const GTypeInfo font_button_info = - { - sizeof (GtkFontButtonClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_font_button_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkFontButton), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_font_button_init, - }; - - font_button_type = - g_type_register_static (GTK_TYPE_BUTTON, I_("GtkFontButton"), - &font_button_info, 0); - } - - return font_button_type; -} - +G_DEFINE_TYPE (GtkFontButton, gtk_font_button, GTK_TYPE_BUTTON); static void gtk_font_button_class_init (GtkFontButtonClass *klass) @@ -152,8 +122,6 @@ gtk_font_button_class_init (GtkFontButtonClass *klass) gobject_class = (GObjectClass *) klass; button_class = (GtkButtonClass *) klass; - parent_class = g_type_class_peek_parent (klass); - gobject_class->finalize = gtk_font_button_finalize; gobject_class->set_property = gtk_font_button_set_property; gobject_class->get_property = gtk_font_button_get_property; @@ -316,7 +284,7 @@ gtk_font_button_finalize (GObject *object) g_free (font_button->priv->title); font_button->priv->title = NULL; - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_font_button_parent_class)->finalize (object); } static void diff --git a/gtk/gtkfontsel.c b/gtk/gtkfontsel.c index 7d4ba76bdd..e4e2cd54cf 100644 --- a/gtk/gtkfontsel.c +++ b/gtk/gtkfontsel.c @@ -113,7 +113,6 @@ enum { SIZE_COLUMN }; -static void gtk_font_selection_class_init (GtkFontSelectionClass *klass); static void gtk_font_selection_set_property (GObject *object, guint prop_id, const GValue *value, @@ -122,7 +121,6 @@ static void gtk_font_selection_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static void gtk_font_selection_init (GtkFontSelection *fontsel); static void gtk_font_selection_finalize (GObject *object); static void gtk_font_selection_screen_changed (GtkWidget *widget, GdkScreen *previous_screen); @@ -161,41 +159,7 @@ static void gtk_font_selection_update_preview (GtkFontSelection *fs); static GdkFont* gtk_font_selection_get_font_internal (GtkFontSelection *fontsel); -/* FontSelectionDialog */ -static void gtk_font_selection_dialog_class_init (GtkFontSelectionDialogClass *klass); -static void gtk_font_selection_dialog_init (GtkFontSelectionDialog *fontseldiag); - -static GtkVBoxClass *font_selection_parent_class = NULL; -static GtkWindowClass *font_selection_dialog_parent_class = NULL; - - -GType -gtk_font_selection_get_type (void) -{ - static GType font_selection_type = 0; - - if (!font_selection_type) - { - static const GTypeInfo fontsel_type_info = - { - sizeof (GtkFontSelectionClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_font_selection_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkFontSelection), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_font_selection_init, - }; - - font_selection_type = - g_type_register_static (GTK_TYPE_VBOX, I_("GtkFontSelection"), - &fontsel_type_info, 0); - } - - return font_selection_type; -} +G_DEFINE_TYPE (GtkFontSelection, gtk_font_selection, GTK_TYPE_VBOX); static void gtk_font_selection_class_init (GtkFontSelectionClass *klass) @@ -203,8 +167,6 @@ gtk_font_selection_class_init (GtkFontSelectionClass *klass) GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - font_selection_parent_class = g_type_class_peek_parent (klass); - gobject_class->set_property = gtk_font_selection_set_property; gobject_class->get_property = gtk_font_selection_get_property; @@ -311,7 +273,6 @@ static void gtk_font_selection_init (GtkFontSelection *fontsel) { GtkWidget *scrolled_win; - GtkWidget *text_frame; GtkWidget *text_box; GtkWidget *table, *label; GtkWidget *font_label, *style_label; @@ -598,7 +559,7 @@ gtk_font_selection_finalize (GObject *object) if (fontsel->font) gdk_font_unref (fontsel->font); - (* G_OBJECT_CLASS (font_selection_parent_class)->finalize) (object); + (* G_OBJECT_CLASS (gtk_font_selection_parent_class)->finalize) (object); } static void @@ -1333,38 +1294,11 @@ gtk_font_selection_set_preview_text (GtkFontSelection *fontsel, * GtkFontSelectionDialog *****************************************************************************/ -GType -gtk_font_selection_dialog_get_type (void) -{ - static GType font_selection_dialog_type = 0; - - if (!font_selection_dialog_type) - { - static const GTypeInfo fontsel_diag_info = - { - sizeof (GtkFontSelectionDialogClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_font_selection_dialog_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkFontSelectionDialog), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_font_selection_dialog_init, - }; - - font_selection_dialog_type = - g_type_register_static (GTK_TYPE_DIALOG, I_("GtkFontSelectionDialog"), - &fontsel_diag_info, 0); - } - - return font_selection_dialog_type; -} +G_DEFINE_TYPE (GtkFontSelectionDialog, gtk_font_selection_dialog, GTK_TYPE_DIALOG); static void gtk_font_selection_dialog_class_init (GtkFontSelectionDialogClass *klass) { - font_selection_dialog_parent_class = g_type_class_peek_parent (klass); } static void diff --git a/gtk/gtkframe.c b/gtk/gtkframe.c index 460a53db74..febefaf4a6 100644 --- a/gtk/gtkframe.c +++ b/gtk/gtkframe.c @@ -45,9 +45,6 @@ enum { PROP_LABEL_WIDGET }; - -static void gtk_frame_class_init (GtkFrameClass *klass); -static void gtk_frame_init (GtkFrame *frame); static void gtk_frame_set_property (GObject *object, guint param_id, const GValue *value, @@ -76,35 +73,7 @@ static void gtk_frame_compute_child_allocation (GtkFrame *frame, static void gtk_frame_real_compute_child_allocation (GtkFrame *frame, GtkAllocation *child_allocation); -static GtkBinClass *parent_class = NULL; - - -GType -gtk_frame_get_type (void) -{ - static GType frame_type = 0; - - if (!frame_type) - { - static const GTypeInfo frame_info = - { - sizeof (GtkFrameClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_frame_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkFrame), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_frame_init, - }; - - frame_type = g_type_register_static (GTK_TYPE_BIN, I_("GtkFrame"), - &frame_info, 0); - } - - return frame_type; -} +G_DEFINE_TYPE (GtkFrame, gtk_frame, GTK_TYPE_BIN); static void gtk_frame_class_init (GtkFrameClass *class) @@ -117,8 +86,6 @@ gtk_frame_class_init (GtkFrameClass *class) widget_class = GTK_WIDGET_CLASS (class); container_class = GTK_CONTAINER_CLASS (class); - parent_class = g_type_class_peek_parent (class); - gobject_class->set_property = gtk_frame_set_property; gobject_class->get_property = gtk_frame_get_property; @@ -287,7 +254,7 @@ gtk_frame_remove (GtkContainer *container, if (frame->label_widget == child) gtk_frame_set_label_widget (frame, NULL); else - GTK_CONTAINER_CLASS (parent_class)->remove (container, child); + GTK_CONTAINER_CLASS (gtk_frame_parent_class)->remove (container, child); } static void @@ -587,7 +554,7 @@ gtk_frame_expose (GtkWidget *widget, { gtk_frame_paint (widget, &event->area); - (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event); + (* GTK_WIDGET_CLASS (gtk_frame_parent_class)->expose_event) (widget, event); } return FALSE; diff --git a/gtk/gtkgamma.c b/gtk/gtkgamma.c index 0cb5f2a6b4..b07fea552b 100644 --- a/gtk/gtkgamma.c +++ b/gtk/gtkgamma.c @@ -46,12 +46,7 @@ #include "gtkintl.h" #include "gtkalias.h" -static GtkVBoxClass *parent_class = NULL; - - /* forward declarations: */ -static void gtk_gamma_curve_class_init (GtkGammaCurveClass *class); -static void gtk_gamma_curve_init (GtkGammaCurve *curve); static void gtk_gamma_curve_destroy (GtkObject *object); static void curve_type_changed_callback (GtkWidget *w, gpointer data); @@ -213,39 +208,13 @@ static const char *const xpm[][27] = } }; -GType -gtk_gamma_curve_get_type (void) -{ - static GType gamma_curve_type = 0; - - if (!gamma_curve_type) - { - static const GTypeInfo gamma_curve_info = - { - sizeof (GtkGammaCurveClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_gamma_curve_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkGammaCurve), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_gamma_curve_init, - }; - - gamma_curve_type = g_type_register_static (GTK_TYPE_VBOX, I_("GtkGammaCurve"), - &gamma_curve_info, 0); - } - return gamma_curve_type; -} +G_DEFINE_TYPE (GtkGammaCurve, gtk_gamma_curve, GTK_TYPE_VBOX); static void gtk_gamma_curve_class_init (GtkGammaCurveClass *class) { GtkObjectClass *object_class; - parent_class = g_type_class_peek_parent (class); - object_class = (GtkObjectClass *) class; object_class->destroy = gtk_gamma_curve_destroy; } @@ -482,8 +451,8 @@ gtk_gamma_curve_destroy (GtkObject *object) if (c->gamma_dialog) gtk_widget_destroy (c->gamma_dialog); - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); + if (GTK_OBJECT_CLASS (gtk_gamma_curve_parent_class)->destroy) + (* GTK_OBJECT_CLASS (gtk_gamma_curve_parent_class)->destroy) (object); } #define __GTK_GAMMA_CURVE_C__ diff --git a/gtk/gtkhandlebox.c b/gtk/gtkhandlebox.c index 42005ffebd..96348d71d1 100644 --- a/gtk/gtkhandlebox.c +++ b/gtk/gtkhandlebox.c @@ -104,8 +104,6 @@ enum { * <--------bin_window--------------------> */ -static void gtk_handle_box_class_init (GtkHandleBoxClass *klass); -static void gtk_handle_box_init (GtkHandleBox *handle_box); static void gtk_handle_box_set_property (GObject *object, guint param_id, const GValue *value, @@ -145,37 +143,9 @@ static void gtk_handle_box_reattach (GtkHandleBox *hb); static void gtk_handle_box_end_drag (GtkHandleBox *hb, guint32 time); - -static GtkBinClass *parent_class; static guint handle_box_signals[SIGNAL_LAST] = { 0 }; - -GType -gtk_handle_box_get_type (void) -{ - static GType handle_box_type = 0; - - if (!handle_box_type) - { - static const GTypeInfo handle_box_info = - { - sizeof (GtkHandleBoxClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_handle_box_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkHandleBox), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_handle_box_init, - }; - - handle_box_type = g_type_register_static (GTK_TYPE_BIN, I_("GtkHandleBox"), - &handle_box_info, 0); - } - - return handle_box_type; -} +G_DEFINE_TYPE (GtkHandleBox, gtk_handle_box, GTK_TYPE_BIN); static void gtk_handle_box_class_init (GtkHandleBoxClass *class) @@ -190,8 +160,6 @@ gtk_handle_box_class_init (GtkHandleBoxClass *class) widget_class = (GtkWidgetClass *) class; container_class = (GtkContainerClass *) class; - parent_class = g_type_class_peek_parent (class); - gobject_class->set_property = gtk_handle_box_set_property; gobject_class->get_property = gtk_handle_box_get_property; @@ -370,8 +338,8 @@ gtk_handle_box_new (void) static void gtk_handle_box_destroy (GtkObject *object) { - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); + if (GTK_OBJECT_CLASS (gtk_handle_box_parent_class)->destroy) + (* GTK_OBJECT_CLASS (gtk_handle_box_parent_class)->destroy) (object); } static void @@ -499,8 +467,8 @@ gtk_handle_box_unrealize (GtkWidget *widget) gdk_window_destroy (hb->float_window); hb->float_window = NULL; - if (GTK_WIDGET_CLASS (parent_class)->unrealize) - (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); + if (GTK_WIDGET_CLASS (gtk_handle_box_parent_class)->unrealize) + (* GTK_WIDGET_CLASS (gtk_handle_box_parent_class)->unrealize) (widget); } static void @@ -958,7 +926,7 @@ gtk_handle_box_paint (GtkWidget *widget, event ? &event->area : area); if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) - (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event); + (* GTK_WIDGET_CLASS (gtk_handle_box_parent_class)->expose_event) (widget, event); } static gint @@ -1362,14 +1330,14 @@ gtk_handle_box_add (GtkContainer *container, GtkWidget *widget) { gtk_widget_set_parent_window (widget, GTK_HANDLE_BOX (container)->bin_window); - GTK_CONTAINER_CLASS (parent_class)->add (container, widget); + GTK_CONTAINER_CLASS (gtk_handle_box_parent_class)->add (container, widget); } static void gtk_handle_box_remove (GtkContainer *container, GtkWidget *widget) { - GTK_CONTAINER_CLASS (parent_class)->remove (container, widget); + GTK_CONTAINER_CLASS (gtk_handle_box_parent_class)->remove (container, widget); gtk_handle_box_reattach (GTK_HANDLE_BOX (container)); } diff --git a/gtk/gtkhbbox.c b/gtk/gtkhbbox.c index 9fdf66516b..8f90ea3d2e 100644 --- a/gtk/gtkhbbox.c +++ b/gtk/gtkhbbox.c @@ -30,8 +30,6 @@ #include "gtkalias.h" -static void gtk_hbutton_box_class_init (GtkHButtonBoxClass *klass); -static void gtk_hbutton_box_init (GtkHButtonBox *box); static void gtk_hbutton_box_size_request (GtkWidget *widget, GtkRequisition *requisition); static void gtk_hbutton_box_size_allocate (GtkWidget *widget, @@ -40,33 +38,7 @@ static void gtk_hbutton_box_size_allocate (GtkWidget *widget, static gint default_spacing = 30; static gint default_layout_style = GTK_BUTTONBOX_EDGE; -GType -gtk_hbutton_box_get_type (void) -{ - static GType hbutton_box_type = 0; - - if (!hbutton_box_type) - { - static const GTypeInfo hbutton_box_info = - { - sizeof (GtkHButtonBoxClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_hbutton_box_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkHButtonBox), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_hbutton_box_init, - }; - - hbutton_box_type = - g_type_register_static (GTK_TYPE_BUTTON_BOX, I_("GtkHButtonBox"), - &hbutton_box_info, 0); - } - - return hbutton_box_type; -} +G_DEFINE_TYPE (GtkHButtonBox, gtk_hbutton_box, GTK_TYPE_BUTTON_BOX); static void gtk_hbutton_box_class_init (GtkHButtonBoxClass *class) @@ -82,7 +54,7 @@ gtk_hbutton_box_class_init (GtkHButtonBoxClass *class) static void gtk_hbutton_box_init (GtkHButtonBox *hbutton_box) { - /* button_box_init has done everything allready */ + /* button_box_init has done everything already */ } GtkWidget* diff --git a/gtk/gtkhbox.c b/gtk/gtkhbox.c index 4c610bee2a..9b0a5e88fe 100644 --- a/gtk/gtkhbox.c +++ b/gtk/gtkhbox.c @@ -30,40 +30,13 @@ #include "gtkalias.h" -static void gtk_hbox_class_init (GtkHBoxClass *klass); -static void gtk_hbox_init (GtkHBox *box); static void gtk_hbox_size_request (GtkWidget *widget, GtkRequisition *requisition); static void gtk_hbox_size_allocate (GtkWidget *widget, GtkAllocation *allocation); -GType -gtk_hbox_get_type (void) -{ - static GType hbox_type = 0; - - if (!hbox_type) - { - static const GTypeInfo hbox_info = - { - sizeof (GtkHBoxClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_hbox_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkHBox), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_hbox_init, - }; - - hbox_type = g_type_register_static (GTK_TYPE_BOX, I_("GtkHBox"), - &hbox_info, 0); - } - - return hbox_type; -} +G_DEFINE_TYPE (GtkHBox, gtk_hbox, GTK_TYPE_BOX); static void gtk_hbox_class_init (GtkHBoxClass *class) diff --git a/gtk/gtkhpaned.c b/gtk/gtkhpaned.c index 34eb3c0711..103a70aadd 100644 --- a/gtk/gtkhpaned.c +++ b/gtk/gtkhpaned.c @@ -29,49 +29,18 @@ #include "gtkintl.h" #include "gtkalias.h" -static void gtk_hpaned_class_init (GtkHPanedClass *klass); -static void gtk_hpaned_init (GtkHPaned *hpaned); static void gtk_hpaned_size_request (GtkWidget *widget, GtkRequisition *requisition); static void gtk_hpaned_size_allocate (GtkWidget *widget, GtkAllocation *allocation); -static gpointer parent_class; - -GType -gtk_hpaned_get_type (void) -{ - static GType hpaned_type = 0; - - if (!hpaned_type) - { - static const GTypeInfo hpaned_info = - { - sizeof (GtkHPanedClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_hpaned_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkHPaned), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_hpaned_init, - }; - - hpaned_type = g_type_register_static (GTK_TYPE_PANED, I_("GtkHPaned"), - &hpaned_info, 0); - } - - return hpaned_type; -} +G_DEFINE_TYPE (GtkHPaned, gtk_hpaned, GTK_TYPE_PANED); static void gtk_hpaned_class_init (GtkHPanedClass *class) { GtkWidgetClass *widget_class; - parent_class = g_type_class_peek_parent (class); - widget_class = (GtkWidgetClass *) class; widget_class->size_request = gtk_hpaned_size_request; diff --git a/gtk/gtkhruler.c b/gtk/gtkhruler.c index 2dc5aba9d1..3a1a206b7f 100644 --- a/gtk/gtkhruler.c +++ b/gtk/gtkhruler.c @@ -41,40 +41,12 @@ #define ROUND(x) ((int) ((x) + 0.5)) -static void gtk_hruler_class_init (GtkHRulerClass *klass); -static void gtk_hruler_init (GtkHRuler *hruler); static gint gtk_hruler_motion_notify (GtkWidget *widget, GdkEventMotion *event); static void gtk_hruler_draw_ticks (GtkRuler *ruler); static void gtk_hruler_draw_pos (GtkRuler *ruler); - -GType -gtk_hruler_get_type (void) -{ - static GType hruler_type = 0; - - if (!hruler_type) - { - static const GTypeInfo hruler_info = - { - sizeof (GtkHRulerClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_hruler_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkHRuler), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_hruler_init, - }; - - hruler_type = g_type_register_static (GTK_TYPE_RULER, I_("GtkHRuler"), - &hruler_info, 0); - } - - return hruler_type; -} +G_DEFINE_TYPE (GtkHRuler, gtk_hruler, GTK_TYPE_RULER); static void gtk_hruler_class_init (GtkHRulerClass *klass) diff --git a/gtk/gtkhscale.c b/gtk/gtkhscale.c index 597ed8ef10..d066112cc0 100644 --- a/gtk/gtkhscale.c +++ b/gtk/gtkhscale.c @@ -32,10 +32,6 @@ #include "gtkintl.h" #include "gtkalias.h" -static gpointer parent_class; - -static void gtk_hscale_class_init (GtkHScaleClass *klass); -static void gtk_hscale_init (GtkHScale *hscale); static gboolean gtk_hscale_expose (GtkWidget *widget, GdkEventExpose *event); @@ -43,32 +39,7 @@ static void gtk_hscale_get_layout_offsets (GtkScale *scale, gint *x, gint *y); -GType -gtk_hscale_get_type (void) -{ - static GType hscale_type = 0; - - if (!hscale_type) - { - static const GTypeInfo hscale_info = - { - sizeof (GtkHScaleClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_hscale_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkHScale), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_hscale_init, - }; - - hscale_type = g_type_register_static (GTK_TYPE_SCALE, I_("GtkHScale"), - &hscale_info, 0); - } - - return hscale_type; -} +G_DEFINE_TYPE (GtkHScale, gtk_hscale, GTK_TYPE_SCALE); static void gtk_hscale_class_init (GtkHScaleClass *class) @@ -81,8 +52,6 @@ gtk_hscale_class_init (GtkHScaleClass *class) range_class = GTK_RANGE_CLASS (class); scale_class = GTK_SCALE_CLASS (class); - parent_class = g_type_class_peek_parent (class); - range_class->slider_detail = "hscale"; scale_class->get_layout_offsets = gtk_hscale_get_layout_offsets; @@ -166,8 +135,8 @@ gtk_hscale_expose (GtkWidget *widget, /* We need to chain up _first_ so the various geometry members of * GtkRange struct are updated. */ - if (GTK_WIDGET_CLASS (parent_class)->expose_event) - GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); + if (GTK_WIDGET_CLASS (gtk_hscale_parent_class)->expose_event) + GTK_WIDGET_CLASS (gtk_hscale_parent_class)->expose_event (widget, event); if (scale->draw_value) { diff --git a/gtk/gtkhscrollbar.c b/gtk/gtkhscrollbar.c index d67f8ad3c6..60c273f86c 100644 --- a/gtk/gtkhscrollbar.c +++ b/gtk/gtkhscrollbar.c @@ -31,36 +31,7 @@ #include "gtkintl.h" #include "gtkalias.h" -static void gtk_hscrollbar_class_init (GtkHScrollbarClass *klass); -static void gtk_hscrollbar_init (GtkHScrollbar *hscrollbar); - -GType -gtk_hscrollbar_get_type (void) -{ - static GType hscrollbar_type = 0; - - if (!hscrollbar_type) - { - static const GTypeInfo hscrollbar_info = - { - sizeof (GtkHScrollbarClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_hscrollbar_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkHScrollbar), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_hscrollbar_init, - }; - - hscrollbar_type = - g_type_register_static (GTK_TYPE_SCROLLBAR, I_("GtkHScrollbar"), - &hscrollbar_info, 0); - } - - return hscrollbar_type; -} +G_DEFINE_TYPE (GtkHScrollbar, gtk_hscrollbar, GTK_TYPE_SCROLLBAR); static void gtk_hscrollbar_class_init (GtkHScrollbarClass *class) diff --git a/gtk/gtkhseparator.c b/gtk/gtkhseparator.c index cc6c4f8a1b..2b0f216d01 100644 --- a/gtk/gtkhseparator.c +++ b/gtk/gtkhseparator.c @@ -30,41 +30,12 @@ #include "gtkalias.h" -static void gtk_hseparator_class_init (GtkHSeparatorClass *klass); -static void gtk_hseparator_init (GtkHSeparator *hseparator); static void gtk_hseparator_size_request (GtkWidget *widget, GtkRequisition *requisition); static gint gtk_hseparator_expose (GtkWidget *widget, GdkEventExpose *event); - -GType -gtk_hseparator_get_type (void) -{ - static GType hseparator_type = 0; - - if (!hseparator_type) - { - static const GTypeInfo hseparator_info = - { - sizeof (GtkHSeparatorClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_hseparator_class_init, - NULL, /* class_finalize */ - NULL, /* class_init */ - sizeof (GtkHSeparator), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_hseparator_init, - }; - - hseparator_type = - g_type_register_static (GTK_TYPE_SEPARATOR, I_("GtkHSeparator"), - &hseparator_info, 0); - } - - return hseparator_type; -} +G_DEFINE_TYPE (GtkHSeparator, gtk_hseparator, GTK_TYPE_SEPARATOR); static void gtk_hseparator_class_init (GtkHSeparatorClass *class) diff --git a/gtk/gtkhsv.c b/gtk/gtkhsv.c index cc7a87aad7..3a256e6c82 100644 --- a/gtk/gtkhsv.c +++ b/gtk/gtkhsv.c @@ -88,8 +88,6 @@ enum { LAST_SIGNAL }; -static void gtk_hsv_class_init (GtkHSVClass *class); -static void gtk_hsv_init (GtkHSV *hsv); static void gtk_hsv_destroy (GtkObject *object); static void gtk_hsv_map (GtkWidget *widget); static void gtk_hsv_unmap (GtkWidget *widget); @@ -115,42 +113,8 @@ static void gtk_hsv_move (GtkHSV *hsv, GtkDirectionType dir); static guint hsv_signals[LAST_SIGNAL]; -static GtkWidgetClass *parent_class; - -/** - * gtk_hsv_get_type: - * @void: - * - * Registers the &GtkHSV class if necessary, and returns the type ID associated - * to it. - * - * Return value: The type ID of the &GtkHSV class. - **/ -GType -gtk_hsv_get_type (void) -{ - static GType hsv_type = 0; - - if (!hsv_type) { - static const GTypeInfo hsv_info = { - sizeof (GtkHSVClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_hsv_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkHSV), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_hsv_init, - }; - - hsv_type = g_type_register_static (GTK_TYPE_WIDGET, I_("GtkHSV"), - &hsv_info, 0); - } - - return hsv_type; -} +G_DEFINE_TYPE (GtkHSV, gtk_hsv, GTK_TYPE_WIDGET); /* Class initialization function for the HSV color selector */ static void @@ -167,8 +131,6 @@ gtk_hsv_class_init (GtkHSVClass *class) widget_class = (GtkWidgetClass *) class; hsv_class = GTK_HSV_CLASS (class); - parent_class = g_type_class_peek_parent (class); - object_class->destroy = gtk_hsv_destroy; widget_class->map = gtk_hsv_map; @@ -264,7 +226,7 @@ gtk_hsv_init (GtkHSV *hsv) static void gtk_hsv_destroy (GtkObject *object) { - GTK_OBJECT_CLASS (parent_class)->destroy (object); + GTK_OBJECT_CLASS (gtk_hsv_parent_class)->destroy (object); } /* Default signal handlers */ @@ -281,7 +243,7 @@ gtk_hsv_map (GtkWidget *widget) hsv = GTK_HSV (widget); priv = hsv->priv; - GTK_WIDGET_CLASS (parent_class)->map (widget); + GTK_WIDGET_CLASS (gtk_hsv_parent_class)->map (widget); gdk_window_show (priv->window); } @@ -299,7 +261,7 @@ gtk_hsv_unmap (GtkWidget *widget) gdk_window_hide (priv->window); - GTK_WIDGET_CLASS (parent_class)->unmap (widget); + GTK_WIDGET_CLASS (gtk_hsv_parent_class)->unmap (widget); } /* Realize handler for the HSV color selector */ @@ -367,8 +329,8 @@ gtk_hsv_unrealize (GtkWidget *widget) g_object_unref (priv->gc); priv->gc = NULL; - if (GTK_WIDGET_CLASS (parent_class)->unrealize) - GTK_WIDGET_CLASS (parent_class)->unrealize (widget); + if (GTK_WIDGET_CLASS (gtk_hsv_parent_class)->unrealize) + GTK_WIDGET_CLASS (gtk_hsv_parent_class)->unrealize (widget); } /* Size_request handler for the HSV color selector */ diff --git a/gtk/gtkiconfactory.c b/gtk/gtkiconfactory.c index c64d3c0e46..51e048ec19 100644 --- a/gtk/gtkiconfactory.c +++ b/gtk/gtkiconfactory.c @@ -82,10 +82,7 @@ struct _GtkIconSource #endif }; -static gpointer parent_class = NULL; -static void gtk_icon_factory_init (GtkIconFactory *icon_factory); -static void gtk_icon_factory_class_init (GtkIconFactoryClass *klass); static void gtk_icon_factory_finalize (GObject *object); static void get_default_icons (GtkIconFactory *icon_factory); static void icon_source_clear (GtkIconSource *source); @@ -99,33 +96,7 @@ static GtkIconSize icon_size_register_intern (const gchar *name, 0, 0, 0, \ any_direction, any_state, any_size } -GType -gtk_icon_factory_get_type (void) -{ - static GType icon_factory_type = 0; - - if (!icon_factory_type) - { - static const GTypeInfo icon_factory_info = - { - sizeof (GtkIconFactoryClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_icon_factory_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkIconFactory), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_icon_factory_init, - }; - - icon_factory_type = - g_type_register_static (G_TYPE_OBJECT, I_("GtkIconFactory"), - &icon_factory_info, 0); - } - - return icon_factory_type; -} +G_DEFINE_TYPE (GtkIconFactory, gtk_icon_factory, G_TYPE_OBJECT); static void gtk_icon_factory_init (GtkIconFactory *factory) @@ -139,8 +110,6 @@ gtk_icon_factory_class_init (GtkIconFactoryClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); - object_class->finalize = gtk_icon_factory_finalize; } @@ -162,7 +131,7 @@ gtk_icon_factory_finalize (GObject *object) g_hash_table_destroy (factory->icons); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_icon_factory_parent_class)->finalize (object); } /** diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c index 0fad206840..1af2fd1bd5 100644 --- a/gtk/gtkicontheme.c +++ b/gtk/gtkicontheme.c @@ -186,8 +186,6 @@ typedef struct GtkIconCache *cache; } IconThemeDirMtime; -static void gtk_icon_theme_class_init (GtkIconThemeClass *klass); -static void gtk_icon_theme_init (GtkIconTheme *icon_theme); static void gtk_icon_theme_finalize (GObject *object); static void theme_dir_destroy (IconThemeDir *dir); @@ -228,8 +226,6 @@ static BuiltinIcon *find_builtin_icon (const gchar *icon_name, gint *min_difference_p, gboolean *has_larger_p); -static GObjectClass *parent_class = NULL; - static guint signal_changed = 0; static GHashTable *icon_theme_builtin_icons; @@ -238,32 +234,7 @@ static GHashTable *icon_theme_builtin_icons; GtkIconCache *_builtin_cache = NULL; static GList *builtin_dirs = NULL; - -GType -gtk_icon_theme_get_type (void) -{ - static GType type = 0; - - if (type == 0) - { - static const GTypeInfo info = - { - sizeof (GtkIconThemeClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_icon_theme_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkIconTheme), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_icon_theme_init, - }; - - type = g_type_register_static (G_TYPE_OBJECT, I_("GtkIconTheme"), &info, 0); - } - - return type; -} +G_DEFINE_TYPE (GtkIconTheme, gtk_icon_theme, G_TYPE_OBJECT); /** * gtk_icon_theme_new: @@ -353,8 +324,6 @@ gtk_icon_theme_class_init (GtkIconThemeClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); - gobject_class->finalize = gtk_icon_theme_finalize; /** @@ -702,7 +671,7 @@ gtk_icon_theme_finalize (GObject *object) blow_themes (icon_theme); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_icon_theme_parent_class)->finalize (object); } /** diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c index 88c40ae305..8abe168c63 100644 --- a/gtk/gtkiconview.c +++ b/gtk/gtkiconview.c @@ -222,7 +222,6 @@ enum }; /* GObject vfuncs */ -static void gtk_icon_view_class_init (GtkIconViewClass *klass); static void gtk_icon_view_cell_layout_init (GtkCellLayoutIface *iface); static void gtk_icon_view_finalize (GObject *object); static void gtk_icon_view_set_property (GObject *object, diff --git a/gtk/gtkimage.c b/gtk/gtkimage.c index cbd62a292b..43bf569098 100644 --- a/gtk/gtkimage.c +++ b/gtk/gtkimage.c @@ -51,9 +51,6 @@ struct _GtkImagePrivate #define DEFAULT_ICON_SIZE GTK_ICON_SIZE_BUTTON - -static void gtk_image_class_init (GtkImageClass *klass); -static void gtk_image_init (GtkImage *image); static gint gtk_image_expose (GtkWidget *widget, GdkEventExpose *event); static void gtk_image_unmap (GtkWidget *widget); @@ -83,8 +80,6 @@ static void gtk_image_get_property (GObject *object, static void icon_theme_changed (GtkImage *image); -static gpointer parent_class; - enum { PROP_0, @@ -102,32 +97,7 @@ enum PROP_STORAGE_TYPE }; -GType -gtk_image_get_type (void) -{ - static GType image_type = 0; - - if (!image_type) - { - static const GTypeInfo image_info = - { - sizeof (GtkImageClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_image_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkImage), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_image_init, - }; - - image_type = g_type_register_static (GTK_TYPE_MISC, I_("GtkImage"), - &image_info, 0); - } - - return image_type; -} +G_DEFINE_TYPE (GtkImage, gtk_image, GTK_TYPE_MISC); static void gtk_image_class_init (GtkImageClass *class) @@ -136,8 +106,6 @@ gtk_image_class_init (GtkImageClass *class) GtkObjectClass *object_class; GtkWidgetClass *widget_class; - parent_class = g_type_class_peek_parent (class); - gobject_class = G_OBJECT_CLASS (class); gobject_class->set_property = gtk_image_set_property; @@ -298,7 +266,7 @@ gtk_image_destroy (GtkObject *object) gtk_image_reset (image); - GTK_OBJECT_CLASS (parent_class)->destroy (object); + GTK_OBJECT_CLASS (gtk_image_parent_class)->destroy (object); } static void @@ -1370,8 +1338,8 @@ gtk_image_unmap (GtkWidget *widget) { gtk_image_reset_anim_iter (GTK_IMAGE (widget)); - if (GTK_WIDGET_CLASS (parent_class)->unmap) - GTK_WIDGET_CLASS (parent_class)->unmap (widget); + if (GTK_WIDGET_CLASS (gtk_image_parent_class)->unmap) + GTK_WIDGET_CLASS (gtk_image_parent_class)->unmap (widget); } static void @@ -1379,8 +1347,8 @@ gtk_image_unrealize (GtkWidget *widget) { gtk_image_reset_anim_iter (GTK_IMAGE (widget)); - if (GTK_WIDGET_CLASS (parent_class)->unrealize) - GTK_WIDGET_CLASS (parent_class)->unrealize (widget); + if (GTK_WIDGET_CLASS (gtk_image_parent_class)->unrealize) + GTK_WIDGET_CLASS (gtk_image_parent_class)->unrealize (widget); } static gint @@ -2032,7 +2000,7 @@ gtk_image_size_request (GtkWidget *widget, gtk_image_calc_size (image); /* Chain up to default that simply reads current requisition */ - GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition); + GTK_WIDGET_CLASS (gtk_image_parent_class)->size_request (widget, requisition); } static void @@ -2043,8 +2011,8 @@ gtk_image_style_set (GtkWidget *widget, image = GTK_IMAGE (widget); - if (GTK_WIDGET_CLASS (parent_class)->style_set) - GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style); + if (GTK_WIDGET_CLASS (gtk_image_parent_class)->style_set) + GTK_WIDGET_CLASS (gtk_image_parent_class)->style_set (widget, prev_style); icon_theme_changed (image); } @@ -2057,8 +2025,8 @@ gtk_image_screen_changed (GtkWidget *widget, image = GTK_IMAGE (widget); - if (GTK_WIDGET_CLASS (parent_class)->screen_changed) - GTK_WIDGET_CLASS (parent_class)->screen_changed (widget, prev_screen); + if (GTK_WIDGET_CLASS (gtk_image_parent_class)->screen_changed) + GTK_WIDGET_CLASS (gtk_image_parent_class)->screen_changed (widget, prev_screen); icon_theme_changed (image); } diff --git a/gtk/gtkimagemenuitem.c b/gtk/gtkimagemenuitem.c index 7e62c6f4a2..954cb85e8c 100644 --- a/gtk/gtkimagemenuitem.c +++ b/gtk/gtkimagemenuitem.c @@ -37,8 +37,6 @@ #include "gtkprivate.h" #include "gtkalias.h" -static void gtk_image_menu_item_class_init (GtkImageMenuItemClass *klass); -static void gtk_image_menu_item_init (GtkImageMenuItem *image_menu_item); static void gtk_image_menu_item_size_request (GtkWidget *widget, GtkRequisition *requisition); static void gtk_image_menu_item_size_allocate (GtkWidget *widget, @@ -70,35 +68,7 @@ enum { PROP_IMAGE }; -static GtkMenuItemClass *parent_class = NULL; - -GType -gtk_image_menu_item_get_type (void) -{ - static GType image_menu_item_type = 0; - - if (!image_menu_item_type) - { - static const GTypeInfo image_menu_item_info = - { - sizeof (GtkImageMenuItemClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_image_menu_item_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkImageMenuItem), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_image_menu_item_init, - }; - - image_menu_item_type = - g_type_register_static (GTK_TYPE_MENU_ITEM, I_("GtkImageMenuItem"), - &image_menu_item_info, 0); - } - - return image_menu_item_type; -} +G_DEFINE_TYPE (GtkImageMenuItem, gtk_image_menu_item, GTK_TYPE_MENU_ITEM); static void gtk_image_menu_item_class_init (GtkImageMenuItemClass *klass) @@ -113,8 +83,6 @@ gtk_image_menu_item_class_init (GtkImageMenuItemClass *klass) menu_item_class = (GtkMenuItemClass*) klass; container_class = (GtkContainerClass*) klass; - parent_class = g_type_class_peek_parent (klass); - widget_class->screen_changed = gtk_image_menu_item_screen_changed; widget_class->size_request = gtk_image_menu_item_size_request; widget_class->size_allocate = gtk_image_menu_item_size_allocate; @@ -272,7 +240,7 @@ gtk_image_menu_item_size_request (GtkWidget *widget, child_height = child_requisition.height; } - (* GTK_WIDGET_CLASS (parent_class)->size_request) (widget, requisition); + (* GTK_WIDGET_CLASS (gtk_image_menu_item_parent_class)->size_request) (widget, requisition); /* not done with height since that happens via the * toggle_size_request @@ -303,7 +271,7 @@ gtk_image_menu_item_size_allocate (GtkWidget *widget, image_menu_item = GTK_IMAGE_MENU_ITEM (widget); - (* GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation); + (* GTK_WIDGET_CLASS (gtk_image_menu_item_parent_class)->size_allocate) (widget, allocation); if (image_menu_item->image && show_image (image_menu_item)) { @@ -379,10 +347,10 @@ gtk_image_menu_item_forall (GtkContainer *container, { GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (container); - (* GTK_CONTAINER_CLASS (parent_class)->forall) (container, - include_internals, - callback, - callback_data); + (* GTK_CONTAINER_CLASS (gtk_image_menu_item_parent_class)->forall) (container, + include_internals, + callback, + callback_data); if (image_menu_item->image) (* callback) (image_menu_item->image, callback_data); @@ -587,7 +555,7 @@ gtk_image_menu_item_remove (GtkContainer *container, } else { - (* GTK_CONTAINER_CLASS (parent_class)->remove) (container, child); + (* GTK_CONTAINER_CLASS (gtk_image_menu_item_parent_class)->remove) (container, child); } } diff --git a/gtk/gtkimcontext.c b/gtk/gtkimcontext.c index 877fd19fed..f2d88497cc 100644 --- a/gtk/gtkimcontext.c +++ b/gtk/gtkimcontext.c @@ -37,9 +37,6 @@ enum { static guint im_context_signals[LAST_SIGNAL] = { 0 }; -static void gtk_im_context_class_init (GtkIMContextClass *class); -static void gtk_im_context_init (GtkIMContext *im_context); - static void gtk_im_context_real_get_preedit_string (GtkIMContext *context, gchar **str, PangoAttrList **attrs, @@ -54,34 +51,7 @@ static void gtk_im_context_real_set_surrounding (GtkIMContext *context, gint len, gint cursor_index); -GType -gtk_im_context_get_type (void) -{ - static GType im_context_type = 0; - - if (!im_context_type) - { - static const GTypeInfo im_context_info = - { - sizeof (GtkIMContextClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gtk_im_context_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkIMContext), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_im_context_init, - NULL, /* value_table */ - }; - - im_context_type = - g_type_register_static (G_TYPE_OBJECT, I_("GtkIMContext"), - &im_context_info, G_TYPE_FLAG_ABSTRACT); - } - - return im_context_type; -} +G_DEFINE_TYPE (GtkIMContext, gtk_im_context, G_TYPE_OBJECT); static void gtk_im_context_class_init (GtkIMContextClass *klass) diff --git a/gtk/gtkimcontextsimple.c b/gtk/gtkimcontextsimple.c index 08f74b4bb7..7676fe3305 100644 --- a/gtk/gtkimcontextsimple.c +++ b/gtk/gtkimcontextsimple.c @@ -929,8 +929,6 @@ static const guint16 gtk_compose_ignore[] = { GDK_ISO_Level3_Shift }; -static void gtk_im_context_simple_class_init (GtkIMContextSimpleClass *class); -static void gtk_im_context_simple_init (GtkIMContextSimple *im_context_simple); static void gtk_im_context_simple_finalize (GObject *obj); static gboolean gtk_im_context_simple_filter_keypress (GtkIMContext *context, GdkEventKey *key); @@ -940,35 +938,7 @@ static void gtk_im_context_simple_get_preedit_string (GtkIMContext PangoAttrList **attrs, gint *cursor_pos); -static GObjectClass *parent_class; - -GType -gtk_im_context_simple_get_type (void) -{ - static GType im_context_simple_type = 0; - - if (!im_context_simple_type) - { - static const GTypeInfo im_context_simple_info = - { - sizeof (GtkIMContextSimpleClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gtk_im_context_simple_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkIMContextSimple), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_im_context_simple_init, - }; - - im_context_simple_type = - g_type_register_static (GTK_TYPE_IM_CONTEXT, I_("GtkIMContextSimple"), - &im_context_simple_info, 0); - } - - return im_context_simple_type; -} +G_DEFINE_TYPE (GtkIMContextSimple, gtk_im_context_simple, GTK_TYPE_IM_CONTEXT); static void gtk_im_context_simple_class_init (GtkIMContextSimpleClass *class) @@ -976,8 +946,6 @@ gtk_im_context_simple_class_init (GtkIMContextSimpleClass *class) GtkIMContextClass *im_context_class = GTK_IM_CONTEXT_CLASS (class); GObjectClass *gobject_class = G_OBJECT_CLASS (class); - parent_class = g_type_class_peek_parent (class); - im_context_class->filter_keypress = gtk_im_context_simple_filter_keypress; im_context_class->reset = gtk_im_context_simple_reset; im_context_class->get_preedit_string = gtk_im_context_simple_get_preedit_string; @@ -1002,7 +970,7 @@ gtk_im_context_simple_finalize (GObject *obj) context_simple->tables = NULL; } - parent_class->finalize (obj); + G_OBJECT_CLASS (gtk_im_context_simple_parent_class)->finalize (obj); } /** diff --git a/gtk/gtkimmodule.c b/gtk/gtkimmodule.c index a6d6531f1f..618e2f9496 100644 --- a/gtk/gtkimmodule.c +++ b/gtk/gtkimmodule.c @@ -174,23 +174,12 @@ gtk_im_module_get_type (void) static GType im_module_type = 0; if (!im_module_type) - { - static const GTypeInfo im_module_info = { - sizeof (GtkIMModuleClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_im_module_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkIMModule), - 0, /* n_preallocs */ - NULL, /* instance_init */ - }; - - im_module_type = - g_type_register_static (G_TYPE_TYPE_MODULE, I_("GtkIMModule"), - &im_module_info, 0); - } + im_module_type = + g_type_register_static_simple (G_TYPE_TYPE_MODULE, I_("GtkIMModule"), + sizeof (GtkIMModuleClass), + (GClassInitFunc)gtk_im_module_class_init, + sizeof (GtkIMModule), + NULL, 0); return im_module_type; } diff --git a/gtk/gtkimmulticontext.c b/gtk/gtkimmulticontext.c index bd8ee63bfd..417ea9a127 100644 --- a/gtk/gtkimmulticontext.c +++ b/gtk/gtkimmulticontext.c @@ -40,8 +40,6 @@ struct _GtkIMMulticontextPrivate guint focus_in : 1; }; -static void gtk_im_multicontext_class_init (GtkIMMulticontextClass *class); -static void gtk_im_multicontext_init (GtkIMMulticontext *im_multicontext); static void gtk_im_multicontext_finalize (GObject *object); static void gtk_im_multicontext_set_slave (GtkIMMulticontext *multicontext, @@ -86,37 +84,10 @@ static gboolean gtk_im_multicontext_delete_surrounding_cb (GtkIMContext * gint offset, gint n_chars, GtkIMMulticontext *multicontext); -static GtkIMContextClass *parent_class; static const gchar *global_context_id = NULL; -GType -gtk_im_multicontext_get_type (void) -{ - static GType im_multicontext_type = 0; - - if (!im_multicontext_type) - { - static const GTypeInfo im_multicontext_info = - { - sizeof (GtkIMMulticontextClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gtk_im_multicontext_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkIMMulticontext), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_im_multicontext_init, - }; - - im_multicontext_type = - g_type_register_static (GTK_TYPE_IM_CONTEXT, I_("GtkIMMulticontext"), - &im_multicontext_info, 0); - } - - return im_multicontext_type; -} +G_DEFINE_TYPE (GtkIMMulticontext, gtk_im_multicontext, GTK_TYPE_IM_CONTEXT); static void gtk_im_multicontext_class_init (GtkIMMulticontextClass *class) @@ -124,8 +95,6 @@ gtk_im_multicontext_class_init (GtkIMMulticontextClass *class) GObjectClass *gobject_class = G_OBJECT_CLASS (class); GtkIMContextClass *im_context_class = GTK_IM_CONTEXT_CLASS (class); - parent_class = g_type_class_peek_parent (class); - im_context_class->set_client_window = gtk_im_multicontext_set_client_window; im_context_class->get_preedit_string = gtk_im_multicontext_get_preedit_string; im_context_class->filter_keypress = gtk_im_multicontext_filter_keypress; @@ -173,7 +142,7 @@ gtk_im_multicontext_finalize (GObject *object) gtk_im_multicontext_set_slave (multicontext, NULL, TRUE); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_im_multicontext_parent_class)->finalize (object); } static void diff --git a/gtk/gtkinputdialog.c b/gtk/gtkinputdialog.c index 9f7b03f5bb..ac1ef7f13f 100644 --- a/gtk/gtkinputdialog.c +++ b/gtk/gtkinputdialog.c @@ -94,8 +94,6 @@ enum /* Forward declarations */ -static void gtk_input_dialog_class_init (GtkInputDialogClass *klass); -static void gtk_input_dialog_init (GtkInputDialog *inputd); static void gtk_input_dialog_screen_changed (GtkWidget *widget, GdkScreen *previous_screen); static void gtk_input_dialog_set_device (GtkWidget *widget, @@ -119,36 +117,9 @@ static void gtk_input_dialog_destroy_key (GtkWidget *widget, static void gtk_input_dialog_fill_keys (GtkInputDialog *inputd, GdkDevice *info); -static GtkObjectClass *parent_class = NULL; static guint input_dialog_signals[LAST_SIGNAL] = { 0 }; -GType -gtk_input_dialog_get_type (void) -{ - static GType input_dialog_type = 0; - - if (!input_dialog_type) - { - static const GTypeInfo input_dialog_info = - { - sizeof (GtkInputDialogClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_input_dialog_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkInputDialog), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_input_dialog_init, - }; - - input_dialog_type = - g_type_register_static (GTK_TYPE_DIALOG, I_("GtkInputDialog"), - &input_dialog_info, 0); - } - - return input_dialog_type; -} +G_DEFINE_TYPE (GtkInputDialog, gtk_input_dialog, GTK_TYPE_DIALOG); static GtkInputDialogPrivate * gtk_input_dialog_get_private (GtkInputDialog *input_dialog) @@ -179,8 +150,6 @@ gtk_input_dialog_class_init (GtkInputDialogClass *klass) GObjectClass *object_class = (GObjectClass *) klass; GtkWidgetClass *widget_class = (GtkWidgetClass *)klass; - parent_class = g_type_class_peek_parent (klass); - widget_class->screen_changed = gtk_input_dialog_screen_changed; klass->enable_device = NULL; diff --git a/gtk/gtkinvisible.c b/gtk/gtkinvisible.c index afdb51ead8..5128aa8842 100644 --- a/gtk/gtkinvisible.c +++ b/gtk/gtkinvisible.c @@ -37,8 +37,6 @@ enum { LAST_ARG }; -static void gtk_invisible_class_init (GtkInvisibleClass *klass); -static void gtk_invisible_init (GtkInvisible *invisible); static void gtk_invisible_destroy (GtkObject *object); static void gtk_invisible_realize (GtkWidget *widget); static void gtk_invisible_style_set (GtkWidget *widget, @@ -59,34 +57,7 @@ static GObject *gtk_invisible_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_params); -static GObjectClass *parent_class; - -GType -gtk_invisible_get_type (void) -{ - static GType invisible_type = 0; - - if (!invisible_type) - { - static const GTypeInfo invisible_info = - { - sizeof (GtkInvisibleClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_invisible_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkInvisible), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_invisible_init, - }; - - invisible_type = g_type_register_static (GTK_TYPE_WIDGET, I_("GtkInvisible"), - &invisible_info, 0); - } - - return invisible_type; -} +G_DEFINE_TYPE (GtkInvisible, gtk_invisible, GTK_TYPE_WIDGET); static void gtk_invisible_class_init (GtkInvisibleClass *class) @@ -99,8 +70,6 @@ gtk_invisible_class_init (GtkInvisibleClass *class) object_class = (GtkObjectClass*) class; gobject_class = (GObjectClass*) class; - parent_class = g_type_class_peek_parent (class); - widget_class->realize = gtk_invisible_realize; widget_class->style_set = gtk_invisible_style_set; widget_class->show = gtk_invisible_show; @@ -149,7 +118,7 @@ gtk_invisible_destroy (GtkObject *object) g_object_unref (invisible); } - GTK_OBJECT_CLASS (parent_class)->destroy (object); + GTK_OBJECT_CLASS (gtk_invisible_parent_class)->destroy (object); } /** @@ -339,9 +308,9 @@ gtk_invisible_constructor (GType type, { GObject *object; - object = (* G_OBJECT_CLASS (parent_class)->constructor) (type, - n_construct_properties, - construct_params); + object = (* G_OBJECT_CLASS (gtk_invisible_parent_class)->constructor) (type, + n_construct_properties, + construct_params); gtk_widget_realize (GTK_WIDGET (object)); diff --git a/gtk/gtkitem.c b/gtk/gtkitem.c index 38a47580f6..d15b42d15b 100644 --- a/gtk/gtkitem.c +++ b/gtk/gtkitem.c @@ -39,8 +39,6 @@ enum { }; -static void gtk_item_class_init (GtkItemClass *klass); -static void gtk_item_init (GtkItem *item); static void gtk_item_realize (GtkWidget *widget); static gint gtk_item_enter (GtkWidget *widget, GdkEventCrossing *event); @@ -50,34 +48,7 @@ static gint gtk_item_leave (GtkWidget *widget, static guint item_signals[LAST_SIGNAL] = { 0 }; - -GType -gtk_item_get_type (void) -{ - static GType item_type = 0; - - if (!item_type) - { - static const GTypeInfo item_info = - { - sizeof (GtkItemClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_item_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkItem), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_item_init, - NULL, /* value_table */ - }; - - item_type = g_type_register_static (GTK_TYPE_BIN, I_("GtkItem"), - &item_info, G_TYPE_FLAG_ABSTRACT); - } - - return item_type; -} +G_DEFINE_TYPE (GtkItem, gtk_item, GTK_TYPE_BIN); static void gtk_item_class_init (GtkItemClass *class) diff --git a/gtk/gtkitemfactory.c b/gtk/gtkitemfactory.c index 9dbde99866..2148f6db3d 100644 --- a/gtk/gtkitemfactory.c +++ b/gtk/gtkitemfactory.c @@ -74,15 +74,11 @@ struct _GtkIFCBData /* --- prototypes --- */ -static void gtk_item_factory_class_init (GtkItemFactoryClass *klass); -static void gtk_item_factory_init (GtkItemFactory *ifactory); static void gtk_item_factory_destroy (GtkObject *object); static void gtk_item_factory_finalize (GObject *object); /* --- static variables --- */ -static GtkItemFactoryClass *gtk_item_factory_class = NULL; -static gpointer parent_class = NULL; static const gchar item_factory_string[] = "Gtk-<ItemFactory>"; static GQuark quark_popup_data = 0; static GQuark quark_if_menu_pos = 0; @@ -102,45 +98,15 @@ static GQuark quark_type_separator_item = 0; static GQuark quark_type_branch = 0; static GQuark quark_type_last_branch = 0; +G_DEFINE_TYPE (GtkItemFactory, gtk_item_factory, GTK_TYPE_OBJECT); /* --- functions --- */ -GType -gtk_item_factory_get_type (void) -{ - static GType item_factory_type = 0; - - if (!item_factory_type) - { - static const GTypeInfo item_factory_info = - { - sizeof (GtkItemFactoryClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_item_factory_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkItemFactory), - 0, - (GInstanceInitFunc) gtk_item_factory_init, - }; - - item_factory_type = - g_type_register_static (GTK_TYPE_OBJECT, I_("GtkItemFactory"), - &item_factory_info, 0); - } - - return item_factory_type; -} - static void gtk_item_factory_class_init (GtkItemFactoryClass *class) { GObjectClass *gobject_class = G_OBJECT_CLASS (class); GtkObjectClass *object_class = GTK_OBJECT_CLASS (class); - gtk_item_factory_class = class; - parent_class = g_type_class_peek_parent (class); - gobject_class->finalize = gtk_item_factory_finalize; object_class->destroy = gtk_item_factory_destroy; @@ -537,7 +503,7 @@ gtk_item_factory_destroy (GtkObject *object) g_slist_free (ifactory->items); ifactory->items = NULL; - GTK_OBJECT_CLASS (parent_class)->destroy (object); + GTK_OBJECT_CLASS (gtk_item_factory_parent_class)->destroy (object); } static void @@ -556,7 +522,7 @@ gtk_item_factory_finalize (GObject *object) if (ifactory->translate_notify) ifactory->translate_notify (ifactory->translate_data); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_item_factory_parent_class)->finalize (object); } /** diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index de02fee511..30b3226aa5 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -97,8 +97,6 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; -static void gtk_label_class_init (GtkLabelClass *klass); -static void gtk_label_init (GtkLabel *label); static void gtk_label_set_property (GObject *object, guint prop_id, const GValue *value, @@ -193,35 +191,9 @@ static gint gtk_label_move_forward_word (GtkLabel *label, static gint gtk_label_move_backward_word (GtkLabel *label, gint start); -static GtkMiscClass *parent_class = NULL; static GQuark quark_angle = 0; -GType -gtk_label_get_type (void) -{ - static GType label_type = 0; - - if (!label_type) - { - static const GTypeInfo label_info = - { - sizeof (GtkLabelClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_label_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkLabel), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_label_init, - }; - - label_type = g_type_register_static (GTK_TYPE_MISC, I_("GtkLabel"), - &label_info, 0); - } - - return label_type; -} +G_DEFINE_TYPE (GtkLabel, gtk_label, GTK_TYPE_MISC); static void add_move_binding (GtkBindingSet *binding_set, @@ -254,8 +226,6 @@ gtk_label_class_init (GtkLabelClass *class) GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class); GtkBindingSet *binding_set; - parent_class = g_type_class_peek_parent (class); - quark_angle = g_quark_from_static_string ("angle"); gobject_class->set_property = gtk_label_set_property; @@ -1740,7 +1710,7 @@ gtk_label_destroy (GtkObject *object) gtk_label_set_mnemonic_widget (label, NULL); - GTK_OBJECT_CLASS (parent_class)->destroy (object); + GTK_OBJECT_CLASS (gtk_label_parent_class)->destroy (object); } static void @@ -1766,7 +1736,7 @@ gtk_label_finalize (GObject *object) g_free (label->select_info); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_label_parent_class)->finalize (object); } static void @@ -2145,7 +2115,7 @@ gtk_label_size_allocate (GtkWidget *widget, label = GTK_LABEL (widget); - (* GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation); + (* GTK_WIDGET_CLASS (gtk_label_parent_class)->size_allocate) (widget, allocation); if (label->ellipsize) { @@ -2174,8 +2144,8 @@ gtk_label_state_changed (GtkWidget *widget, if (label->select_info) gtk_label_select_region (label, 0, 0); - if (GTK_WIDGET_CLASS (parent_class)->state_changed) - GTK_WIDGET_CLASS (parent_class)->state_changed (widget, prev_state); + if (GTK_WIDGET_CLASS (gtk_label_parent_class)->state_changed) + GTK_WIDGET_CLASS (gtk_label_parent_class)->state_changed (widget, prev_state); } static void @@ -2201,7 +2171,7 @@ gtk_label_direction_changed (GtkWidget *widget, if (label->layout) pango_layout_context_changed (label->layout); - GTK_WIDGET_CLASS (parent_class)->direction_changed (widget, previous_dir); + GTK_WIDGET_CLASS (gtk_label_parent_class)->direction_changed (widget, previous_dir); } static void @@ -2622,7 +2592,7 @@ gtk_label_realize (GtkWidget *widget) label = GTK_LABEL (widget); - (* GTK_WIDGET_CLASS (parent_class)->realize) (widget); + (* GTK_WIDGET_CLASS (gtk_label_parent_class)->realize) (widget); if (label->select_info) gtk_label_create_window (label); @@ -2638,7 +2608,7 @@ gtk_label_unrealize (GtkWidget *widget) if (label->select_info) gtk_label_destroy_window (label); - (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); + (* GTK_WIDGET_CLASS (gtk_label_parent_class)->unrealize) (widget); } static void @@ -2648,7 +2618,7 @@ gtk_label_map (GtkWidget *widget) label = GTK_LABEL (widget); - (* GTK_WIDGET_CLASS (parent_class)->map) (widget); + (* GTK_WIDGET_CLASS (gtk_label_parent_class)->map) (widget); if (label->select_info) gdk_window_show (label->select_info->window); @@ -2664,7 +2634,7 @@ gtk_label_unmap (GtkWidget *widget) if (label->select_info) gdk_window_hide (label->select_info->window); - (* GTK_WIDGET_CLASS (parent_class)->unmap) (widget); + (* GTK_WIDGET_CLASS (gtk_label_parent_class)->unmap) (widget); } static void @@ -2786,7 +2756,7 @@ gtk_label_grab_focus (GtkWidget *widget) if (label->select_info == NULL) return; - GTK_WIDGET_CLASS (parent_class)->grab_focus (widget); + GTK_WIDGET_CLASS (gtk_label_parent_class)->grab_focus (widget); g_object_get (gtk_widget_get_settings (widget), "gtk-label-select-on-focus", diff --git a/gtk/gtklayout.c b/gtk/gtklayout.c index 9adb36364a..b7e178e610 100644 --- a/gtk/gtklayout.c +++ b/gtk/gtklayout.c @@ -59,7 +59,6 @@ enum { CHILD_PROP_Y }; -static void gtk_layout_class_init (GtkLayoutClass *class); static void gtk_layout_get_property (GObject *object, guint prop_id, GValue *value, @@ -71,7 +70,6 @@ static void gtk_layout_set_property (GObject *object, static GObject *gtk_layout_constructor (GType type, guint n_properties, GObjectConstructParam *properties); -static void gtk_layout_init (GtkLayout *layout); static void gtk_layout_finalize (GObject *object); static void gtk_layout_realize (GtkWidget *widget); static void gtk_layout_unrealize (GtkWidget *widget); @@ -114,7 +112,7 @@ static void gtk_layout_set_adjustment_upper (GtkAdjustment *adj, gdouble upper, gboolean always_emit_changed); -static GtkWidgetClass *parent_class = NULL; +G_DEFINE_TYPE (GtkLayout, gtk_layout, GTK_TYPE_CONTAINER); /* Public interface */ @@ -263,7 +261,7 @@ gtk_layout_finalize (GObject *object) g_object_unref (layout->hadjustment); g_object_unref (layout->vadjustment); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_layout_parent_class)->finalize (object); } /** @@ -559,33 +557,6 @@ gtk_layout_thaw (GtkLayout *layout) /* Basic Object handling procedures */ -GType -gtk_layout_get_type (void) -{ - static GType layout_type = 0; - - if (!layout_type) - { - static const GTypeInfo layout_info = - { - sizeof (GtkLayoutClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_layout_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkLayout), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_layout_init, - }; - - layout_type = g_type_register_static (GTK_TYPE_CONTAINER, I_("GtkLayout"), - &layout_info, 0); - } - - return layout_type; -} - static void gtk_layout_class_init (GtkLayoutClass *class) { @@ -597,8 +568,6 @@ gtk_layout_class_init (GtkLayoutClass *class) widget_class = (GtkWidgetClass*) class; container_class = (GtkContainerClass*) class; - parent_class = g_type_class_peek_parent (class); - gobject_class->set_property = gtk_layout_set_property; gobject_class->get_property = gtk_layout_get_property; gobject_class->finalize = gtk_layout_finalize; @@ -828,9 +797,9 @@ gtk_layout_constructor (GType type, GObject *object; GtkAdjustment *hadj, *vadj; - object = G_OBJECT_CLASS (parent_class)->constructor (type, - n_properties, - properties); + object = G_OBJECT_CLASS (gtk_layout_parent_class)->constructor (type, + n_properties, + properties); layout = GTK_LAYOUT (object); @@ -903,8 +872,8 @@ gtk_layout_realize (GtkWidget *widget) static void gtk_layout_style_set (GtkWidget *widget, GtkStyle *old_style) { - if (GTK_WIDGET_CLASS (parent_class)->style_set) - (* GTK_WIDGET_CLASS (parent_class)->style_set) (widget, old_style); + if (GTK_WIDGET_CLASS (gtk_layout_parent_class)->style_set) + (* GTK_WIDGET_CLASS (gtk_layout_parent_class)->style_set) (widget, old_style); if (GTK_WIDGET_REALIZED (widget)) { @@ -954,8 +923,8 @@ gtk_layout_unrealize (GtkWidget *widget) gdk_window_destroy (layout->bin_window); layout->bin_window = NULL; - if (GTK_WIDGET_CLASS (parent_class)->unrealize) - (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); + if (GTK_WIDGET_CLASS (gtk_layout_parent_class)->unrealize) + (* GTK_WIDGET_CLASS (gtk_layout_parent_class)->unrealize) (widget); } static void @@ -1044,7 +1013,7 @@ gtk_layout_expose (GtkWidget *widget, GdkEventExpose *event) if (event->window != layout->bin_window) return FALSE; - (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event); + (* GTK_WIDGET_CLASS (gtk_layout_parent_class)->expose_event) (widget, event); return FALSE; } diff --git a/gtk/gtkliststore.c b/gtk/gtkliststore.c index 8e082b343f..801f40fc27 100644 --- a/gtk/gtkliststore.c +++ b/gtk/gtkliststore.c @@ -31,8 +31,6 @@ #define GTK_LIST_STORE_IS_SORTED(list) (((GtkListStore*)(list))->sort_column_id != GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID) #define VALID_ITER(iter, list_store) ((iter)!= NULL && (iter)->user_data != NULL && list_store->stamp == (iter)->stamp && !_gtk_sequence_ptr_is_end ((iter)->user_data) && _gtk_sequence_ptr_get_sequence ((iter)->user_data) == list_store->seq) -static void gtk_list_store_init (GtkListStore *list_store); -static void gtk_list_store_class_init (GtkListStoreClass *class); static void gtk_list_store_tree_model_init (GtkTreeModelIface *iface); static void gtk_list_store_drag_source_init(GtkTreeDragSourceIface *iface); static void gtk_list_store_drag_dest_init (GtkTreeDragDestIface *iface); @@ -117,82 +115,21 @@ static void gtk_list_store_set_default_sort_func (GtkTreeSortable *so static gboolean gtk_list_store_has_default_sort_func (GtkTreeSortable *sortable); -static GObjectClass *parent_class = NULL; - -GType -gtk_list_store_get_type (void) -{ - static GType list_store_type = 0; - - if (!list_store_type) - { - static const GTypeInfo list_store_info = - { - sizeof (GtkListStoreClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_list_store_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkListStore), - 0, - (GInstanceInitFunc) gtk_list_store_init, - }; - - static const GInterfaceInfo tree_model_info = - { - (GInterfaceInitFunc) gtk_list_store_tree_model_init, - NULL, - NULL - }; - - static const GInterfaceInfo drag_source_info = - { - (GInterfaceInitFunc) gtk_list_store_drag_source_init, - NULL, - NULL - }; - - static const GInterfaceInfo drag_dest_info = - { - (GInterfaceInitFunc) gtk_list_store_drag_dest_init, - NULL, - NULL - }; - - static const GInterfaceInfo sortable_info = - { - (GInterfaceInitFunc) gtk_list_store_sortable_init, - NULL, - NULL - }; - - list_store_type = g_type_register_static (G_TYPE_OBJECT, I_("GtkListStore"), - &list_store_info, 0); - - g_type_add_interface_static (list_store_type, - GTK_TYPE_TREE_MODEL, - &tree_model_info); - g_type_add_interface_static (list_store_type, - GTK_TYPE_TREE_DRAG_SOURCE, - &drag_source_info); - g_type_add_interface_static (list_store_type, - GTK_TYPE_TREE_DRAG_DEST, - &drag_dest_info); - g_type_add_interface_static (list_store_type, - GTK_TYPE_TREE_SORTABLE, - &sortable_info); - } - - return list_store_type; -} +G_DEFINE_TYPE_WITH_CODE (GtkListStore, gtk_list_store, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, + gtk_list_store_tree_model_init) + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_DRAG_SOURCE, + gtk_list_store_drag_source_init) + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_DRAG_DEST, + gtk_list_store_drag_dest_init) + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_SORTABLE, + gtk_list_store_sortable_init)); static void gtk_list_store_class_init (GtkListStoreClass *class) { GObjectClass *object_class; - parent_class = g_type_class_peek_parent (class); object_class = (GObjectClass*) class; object_class->finalize = gtk_list_store_finalize; @@ -438,7 +375,7 @@ gtk_list_store_finalize (GObject *object) } /* must chain up */ - (* parent_class->finalize) (object); + (* G_OBJECT_CLASS (gtk_list_store_parent_class)->finalize) (object); } /* Fulfill the GtkTreeModel requirements */ diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c index 68d1e71a52..44e647fc81 100644 --- a/gtk/gtkmenu.c +++ b/gtk/gtkmenu.c @@ -25,7 +25,6 @@ */ #define GTK_MENU_INTERNALS - #include <config.h> #include <string.h> /* memset */ #include "gdk/gdkkeysyms.h" @@ -135,8 +134,6 @@ enum { CHILD_PROP_BOTTOM_ATTACH }; -static void gtk_menu_class_init (GtkMenuClass *klass); -static void gtk_menu_init (GtkMenu *menu); static void gtk_menu_set_property (GObject *object, guint prop_id, const GValue *value, @@ -248,7 +245,6 @@ static gboolean gtk_menu_real_can_activate_accel (GtkWidget *widget, static void _gtk_menu_refresh_accel_paths (GtkMenu *menu, gboolean group_changed); -static GtkMenuShellClass *parent_class = NULL; static const gchar attach_data_key[] = "gtk-menu-attach-data"; static guint menu_signals[LAST_SIGNAL] = { 0 }; @@ -259,32 +255,7 @@ gtk_menu_get_private (GtkMenu *menu) return G_TYPE_INSTANCE_GET_PRIVATE (menu, GTK_TYPE_MENU, GtkMenuPrivate); } -GType -gtk_menu_get_type (void) -{ - static GType menu_type = 0; - - if (!menu_type) - { - static const GTypeInfo menu_info = - { - sizeof (GtkMenuClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_menu_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkMenu), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_menu_init, - }; - - menu_type = g_type_register_static (GTK_TYPE_MENU_SHELL, I_("GtkMenu"), - &menu_info, 0); - } - - return menu_type; -} +G_DEFINE_TYPE (GtkMenu, gtk_menu, GTK_TYPE_MENU_SHELL); static void menu_queue_resize (GtkMenu *menu) @@ -461,8 +432,6 @@ gtk_menu_class_init (GtkMenuClass *class) GtkMenuShellClass *menu_shell_class = GTK_MENU_SHELL_CLASS (class); GtkBindingSet *binding_set; - parent_class = g_type_class_peek_parent (class); - gobject_class->finalize = gtk_menu_finalize; gobject_class->set_property = gtk_menu_set_property; gobject_class->get_property = gtk_menu_get_property; @@ -989,7 +958,7 @@ gtk_menu_destroy (GtkObject *object) priv->title = NULL; } - GTK_OBJECT_CLASS (parent_class)->destroy (object); + GTK_OBJECT_CLASS (gtk_menu_parent_class)->destroy (object); } static void @@ -999,7 +968,7 @@ gtk_menu_finalize (GObject *object) g_free (menu->accel_path); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_menu_parent_class)->finalize (object); } static void @@ -1196,7 +1165,7 @@ gtk_menu_remove (GtkContainer *container, menu->old_active_menu_item = NULL; } - GTK_CONTAINER_CLASS (parent_class)->remove (container, widget); + GTK_CONTAINER_CLASS (gtk_menu_parent_class)->remove (container, widget); g_object_set_data (G_OBJECT (widget), I_(ATTACH_INFO_KEY), NULL); menu_queue_resize (menu); @@ -1224,7 +1193,7 @@ gtk_menu_real_insert (GtkMenuShell *menu_shell, if (GTK_WIDGET_REALIZED (menu_shell)) gtk_widget_set_parent_window (child, menu->bin_window); - GTK_MENU_SHELL_CLASS (parent_class)->insert (menu_shell, child, position); + GTK_MENU_SHELL_CLASS (gtk_menu_parent_class)->insert (menu_shell, child, position); menu_queue_resize (menu); } @@ -2218,7 +2187,7 @@ gtk_menu_unrealize (GtkWidget *widget) gdk_window_destroy (menu->bin_window); menu->bin_window = NULL; - (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); + (* GTK_WIDGET_CLASS (gtk_menu_parent_class)->unrealize) (widget); } static void @@ -2587,7 +2556,7 @@ gtk_menu_expose (GtkWidget *widget, { gtk_menu_paint (widget, event); - (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event); + (* GTK_WIDGET_CLASS (gtk_menu_parent_class)->expose_event) (widget, event); } return FALSE; @@ -2600,7 +2569,7 @@ gtk_menu_show (GtkWidget *widget) _gtk_menu_refresh_accel_paths (menu, FALSE); - GTK_WIDGET_CLASS (parent_class)->show (widget); + GTK_WIDGET_CLASS (gtk_menu_parent_class)->show (widget); } static gboolean @@ -2645,7 +2614,7 @@ gtk_menu_button_press (GtkWidget *widget, if (gtk_menu_button_scroll (widget, event)) return TRUE; - return GTK_WIDGET_CLASS (parent_class)->button_press_event (widget, event); + return GTK_WIDGET_CLASS (gtk_menu_parent_class)->button_press_event (widget, event); } static gboolean @@ -2671,7 +2640,7 @@ gtk_menu_button_release (GtkWidget *widget, if (gtk_menu_button_scroll (widget, event)) return TRUE; - return GTK_WIDGET_CLASS (parent_class)->button_release_event (widget, event); + return GTK_WIDGET_CLASS (gtk_menu_parent_class)->button_release_event (widget, event); } static const gchar * @@ -2733,7 +2702,7 @@ gtk_menu_key_press (GtkWidget *widget, gtk_menu_stop_navigating_submenu (menu); - if (GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, event)) + if (GTK_WIDGET_CLASS (gtk_menu_parent_class)->key_press_event (widget, event)) return TRUE; display = gtk_widget_get_display (widget); @@ -3455,7 +3424,7 @@ gtk_menu_enter_notify (GtkWidget *widget, event->x_root, event->y_root)) return TRUE; - return GTK_WIDGET_CLASS (parent_class)->enter_notify_event (widget, event); + return GTK_WIDGET_CLASS (gtk_menu_parent_class)->enter_notify_event (widget, event); } static gboolean @@ -3505,7 +3474,7 @@ gtk_menu_leave_notify (GtkWidget *widget, } } - return GTK_WIDGET_CLASS (parent_class)->leave_notify_event (widget, event); + return GTK_WIDGET_CLASS (gtk_menu_parent_class)->leave_notify_event (widget, event); } static void @@ -3515,8 +3484,7 @@ gtk_menu_stop_navigating_submenu (GtkMenu *menu) { gdk_region_destroy (menu->navigation_region); menu->navigation_region = NULL; - } - + } if (menu->navigation_timeout) { g_source_remove (menu->navigation_timeout); @@ -3549,7 +3517,7 @@ gtk_menu_stop_navigating_submenu_cb (gpointer user_data) send_event->crossing.time = GDK_CURRENT_TIME; /* Bogus */ send_event->crossing.send_event = TRUE; - GTK_WIDGET_CLASS (parent_class)->enter_notify_event (GTK_WIDGET (menu), (GdkEventCrossing *)send_event); + GTK_WIDGET_CLASS (gtk_menu_parent_class)->enter_notify_event (GTK_WIDGET (menu), (GdkEventCrossing *)send_event); gdk_event_free (send_event); } @@ -4306,7 +4274,7 @@ gtk_menu_select_item (GtkMenuShell *menu_shell, if (GTK_WIDGET_REALIZED (GTK_WIDGET (menu))) gtk_menu_scroll_item_visible (menu_shell, menu_item); - GTK_MENU_SHELL_CLASS (parent_class)->select_item (menu_shell, menu_item); + GTK_MENU_SHELL_CLASS (gtk_menu_parent_class)->select_item (menu_shell, menu_item); } @@ -4628,7 +4596,7 @@ gtk_menu_move_current (GtkMenuShell *menu_shell, } } - GTK_MENU_SHELL_CLASS (parent_class)->move_current (menu_shell, direction); + GTK_MENU_SHELL_CLASS (gtk_menu_parent_class)->move_current (menu_shell, direction); } static gint diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c index 402d7a5856..5df2c725e4 100644 --- a/gtk/gtkmenubar.c +++ b/gtk/gtkmenubar.c @@ -95,23 +95,12 @@ gtk_menu_bar_get_type (void) static GType menu_bar_type = 0; if (!menu_bar_type) - { - static const GTypeInfo menu_bar_info = - { - sizeof (GtkMenuBarClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_menu_bar_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkMenuBar), - 0, /* n_preallocs */ - NULL, /* instance_init */ - }; - - menu_bar_type = g_type_register_static (GTK_TYPE_MENU_SHELL, I_("GtkMenuBar"), - &menu_bar_info, 0); - } + menu_bar_type = g_type_register_static_simple (GTK_TYPE_MENU_SHELL, + I_("GtkMenuBar"), + sizeof (GtkMenuBarClass), + gtk_menu_bar_class_init, + sizeof (GtkMenuBar), + NULL, 0); return menu_bar_type; } diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c index 3b3d346c59..0a4543b98d 100644 --- a/gtk/gtkmenuitem.c +++ b/gtk/gtkmenuitem.c @@ -51,8 +51,6 @@ enum { }; -static void gtk_menu_item_class_init (GtkMenuItemClass *klass); -static void gtk_menu_item_init (GtkMenuItem *menu_item); static void gtk_menu_item_destroy (GtkObject *object); static void gtk_menu_item_finalize (GObject *object); static void gtk_menu_item_size_request (GtkWidget *widget, @@ -97,35 +95,9 @@ static gboolean gtk_menu_item_can_activate_accel (GtkWidget *widget, guint signal_id); -static GtkItemClass *parent_class; static guint menu_item_signals[LAST_SIGNAL] = { 0 }; -GType -gtk_menu_item_get_type (void) -{ - static GType menu_item_type = 0; - - if (!menu_item_type) - { - static const GTypeInfo menu_item_info = - { - sizeof (GtkMenuItemClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_menu_item_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkMenuItem), - 16, /* n_preallocs */ - (GInstanceInitFunc) gtk_menu_item_init, - }; - - menu_item_type = g_type_register_static (GTK_TYPE_ITEM, I_("GtkMenuItem"), - &menu_item_info, 0); - } - - return menu_item_type; -} +G_DEFINE_TYPE (GtkMenuItem, gtk_menu_item, GTK_TYPE_ITEM); static void gtk_menu_item_class_init (GtkMenuItemClass *klass) @@ -136,8 +108,6 @@ gtk_menu_item_class_init (GtkMenuItemClass *klass) GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass); GtkItemClass *item_class = GTK_ITEM_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); - gobject_class->finalize = gtk_menu_item_finalize; object_class->destroy = gtk_menu_item_destroy; @@ -326,7 +296,7 @@ gtk_menu_item_destroy (GtkObject *object) if (menu_item->submenu) gtk_widget_destroy (menu_item->submenu); - GTK_OBJECT_CLASS (parent_class)->destroy (object); + GTK_OBJECT_CLASS (gtk_menu_item_parent_class)->destroy (object); } static void @@ -336,7 +306,7 @@ gtk_menu_item_finalize (GObject *object) g_free (menu_item->accel_path); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_menu_item_parent_class)->finalize (object); } static void @@ -717,8 +687,8 @@ gtk_menu_item_unrealize (GtkWidget *widget) gdk_window_destroy (menu_item->event_window); menu_item->event_window = NULL; - if (GTK_WIDGET_CLASS (parent_class)->unrealize) - (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); + if (GTK_WIDGET_CLASS (gtk_menu_item_parent_class)->unrealize) + (* GTK_WIDGET_CLASS (gtk_menu_item_parent_class)->unrealize) (widget); } static void @@ -726,7 +696,7 @@ gtk_menu_item_map (GtkWidget *widget) { GtkMenuItem *menu_item = GTK_MENU_ITEM (widget); - GTK_WIDGET_CLASS (parent_class)->map (widget); + GTK_WIDGET_CLASS (gtk_menu_item_parent_class)->map (widget); gdk_window_show (menu_item->event_window); } @@ -738,7 +708,7 @@ gtk_menu_item_unmap (GtkWidget *widget) gdk_window_hide (menu_item->event_window); - GTK_WIDGET_CLASS (parent_class)->unmap (widget); + GTK_WIDGET_CLASS (gtk_menu_item_parent_class)->unmap (widget); } static void @@ -877,7 +847,7 @@ gtk_menu_item_expose (GtkWidget *widget, { gtk_menu_item_paint (widget, &event->area); - (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event); + (* GTK_WIDGET_CLASS (gtk_menu_item_parent_class)->expose_event) (widget, event); } return FALSE; @@ -1389,8 +1359,8 @@ gtk_menu_item_parent_set (GtkWidget *widget, menu->accel_group, TRUE); - if (GTK_WIDGET_CLASS (parent_class)->parent_set) - GTK_WIDGET_CLASS (parent_class)->parent_set (widget, previous_parent); + if (GTK_WIDGET_CLASS (gtk_menu_item_parent_class)->parent_set) + GTK_WIDGET_CLASS (gtk_menu_item_parent_class)->parent_set (widget, previous_parent); } void diff --git a/gtk/gtkmenushell.c b/gtk/gtkmenushell.c index bce558672a..4d5d837aa5 100644 --- a/gtk/gtkmenushell.c +++ b/gtk/gtkmenushell.c @@ -142,8 +142,6 @@ struct _GtkMenuShellPrivate gboolean take_focus; }; -static void gtk_menu_shell_class_init (GtkMenuShellClass *klass); -static void gtk_menu_shell_init (GtkMenuShell *menu_shell); static void gtk_menu_shell_set_property (GObject *object, guint prop_id, const GValue *value, @@ -201,38 +199,9 @@ static void gtk_menu_shell_reset_key_hash (GtkMenuShell *menu_shell); static gboolean gtk_menu_shell_activate_mnemonic (GtkMenuShell *menu_shell, GdkEventKey *event); -static GtkContainerClass *parent_class = NULL; static guint menu_shell_signals[LAST_SIGNAL] = { 0 }; - -GType -gtk_menu_shell_get_type (void) -{ - static GType menu_shell_type = 0; - - if (!menu_shell_type) - { - static const GTypeInfo menu_shell_info = - { - sizeof (GtkMenuShellClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_menu_shell_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkMenuShell), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_menu_shell_init, - NULL, /* value_table */ - }; - - menu_shell_type = - g_type_register_static (GTK_TYPE_CONTAINER, I_("GtkMenuShell"), - &menu_shell_info, G_TYPE_FLAG_ABSTRACT); - } - - return menu_shell_type; -} +G_DEFINE_TYPE (GtkMenuShell, gtk_menu_shell, GTK_TYPE_CONTAINER); static void gtk_menu_shell_class_init (GtkMenuShellClass *klass) @@ -247,8 +216,6 @@ gtk_menu_shell_class_init (GtkMenuShellClass *klass) widget_class = (GtkWidgetClass*) klass; container_class = (GtkContainerClass*) klass; - parent_class = g_type_class_peek_parent (klass); - object_class->set_property = gtk_menu_shell_set_property; object_class->get_property = gtk_menu_shell_get_property; object_class->finalize = gtk_menu_shell_finalize; @@ -456,7 +423,7 @@ gtk_menu_shell_finalize (GObject *object) if (priv->key_hash) _gtk_key_hash_free (priv->key_hash); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_menu_shell_parent_class)->finalize (object); } diff --git a/gtk/gtkmenutoolbutton.c b/gtk/gtkmenutoolbutton.c index e0d845d8a2..db7b3eb4c4 100644 --- a/gtk/gtkmenutoolbutton.c +++ b/gtk/gtkmenutoolbutton.c @@ -43,8 +43,6 @@ struct _GtkMenuToolButtonPrivate GtkMenu *menu; }; -static void gtk_menu_tool_button_init (GtkMenuToolButton *button); -static void gtk_menu_tool_button_class_init (GtkMenuToolButtonClass *klass); static void gtk_menu_tool_button_destroy (GtkObject *object); static int menu_deactivate_cb (GtkMenuShell *menu_shell, @@ -65,35 +63,7 @@ enum static gint signals[LAST_SIGNAL]; -static GObjectClass *parent_class = NULL; - -GType -gtk_menu_tool_button_get_type (void) -{ - static GType type = 0; - - if (type == 0) - { - static const GTypeInfo info = - { - sizeof (GtkMenuToolButtonClass), - (GBaseInitFunc) 0, - (GBaseFinalizeFunc) 0, - (GClassInitFunc) gtk_menu_tool_button_class_init, - (GClassFinalizeFunc) 0, - NULL, - sizeof (GtkMenuToolButton), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_menu_tool_button_init - }; - - type = g_type_register_static (GTK_TYPE_TOOL_BUTTON, - I_("GtkMenuToolButton"), - &info, 0); - } - - return type; -} +G_DEFINE_TYPE (GtkMenuToolButton, gtk_menu_tool_button, GTK_TYPE_TOOL_BUTTON); static gboolean gtk_menu_tool_button_set_tooltip (GtkToolItem *tool_item, @@ -175,7 +145,7 @@ gtk_menu_tool_button_toolbar_reconfigured (GtkToolItem *toolitem) gtk_menu_tool_button_construct_contents (GTK_MENU_TOOL_BUTTON (toolitem)); /* chain up */ - GTK_TOOL_ITEM_CLASS (parent_class)->toolbar_reconfigured (toolitem); + GTK_TOOL_ITEM_CLASS (gtk_menu_tool_button_parent_class)->toolbar_reconfigured (toolitem); } static void @@ -239,8 +209,6 @@ gtk_menu_tool_button_class_init (GtkMenuToolButtonClass *klass) GtkWidgetClass *widget_class; GtkToolItemClass *toolitem_class; - parent_class = g_type_class_peek_parent (klass); - object_class = (GObjectClass *)klass; gtk_object_class = (GtkObjectClass *)klass; widget_class = (GtkWidgetClass *)klass; @@ -460,8 +428,8 @@ gtk_menu_tool_button_destroy (GtkObject *object) button); } - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (*GTK_OBJECT_CLASS (parent_class)->destroy) (object); + if (GTK_OBJECT_CLASS (gtk_menu_tool_button_parent_class)->destroy) + (*GTK_OBJECT_CLASS (gtk_menu_tool_button_parent_class)->destroy) (object); } /** diff --git a/gtk/gtkmessagedialog.c b/gtk/gtkmessagedialog.c index 2f839b726d..19c21da8f7 100644 --- a/gtk/gtkmessagedialog.c +++ b/gtk/gtkmessagedialog.c @@ -50,8 +50,6 @@ struct _GtkMessageDialogPrivate gboolean has_secondary_text; }; -static void gtk_message_dialog_class_init (GtkMessageDialogClass *klass); -static void gtk_message_dialog_init (GtkMessageDialog *dialog); static void gtk_message_dialog_style_set (GtkWidget *widget, GtkStyle *prev_style); @@ -76,34 +74,7 @@ enum { PROP_SECONDARY_USE_MARKUP }; -static gpointer parent_class; - -GType -gtk_message_dialog_get_type (void) -{ - static GType dialog_type = 0; - - if (!dialog_type) - { - static const GTypeInfo dialog_info = - { - sizeof (GtkMessageDialogClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_message_dialog_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkMessageDialog), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_message_dialog_init, - }; - - dialog_type = g_type_register_static (GTK_TYPE_DIALOG, I_("GtkMessageDialog"), - &dialog_info, 0); - } - - return dialog_type; -} +G_DEFINE_TYPE (GtkMessageDialog, gtk_message_dialog, GTK_TYPE_DIALOG); static void gtk_message_dialog_class_init (GtkMessageDialogClass *class) @@ -113,8 +84,6 @@ gtk_message_dialog_class_init (GtkMessageDialogClass *class) widget_class = GTK_WIDGET_CLASS (class); gobject_class = G_OBJECT_CLASS (class); - - parent_class = g_type_class_peek_parent (class); widget_class->style_set = gtk_message_dialog_style_set; @@ -858,8 +827,8 @@ gtk_message_dialog_style_set (GtkWidget *widget, setup_primary_label_font (dialog); - if (GTK_WIDGET_CLASS (parent_class)->style_set) - (GTK_WIDGET_CLASS (parent_class)->style_set) (widget, prev_style); + if (GTK_WIDGET_CLASS (gtk_message_dialog_parent_class)->style_set) + (GTK_WIDGET_CLASS (gtk_message_dialog_parent_class)->style_set) (widget, prev_style); } #define __GTK_MESSAGE_DIALOG_C__ diff --git a/gtk/gtkmisc.c b/gtk/gtkmisc.c index 1a0225d9c3..5089193cd9 100644 --- a/gtk/gtkmisc.c +++ b/gtk/gtkmisc.c @@ -40,8 +40,6 @@ enum { PROP_YPAD }; -static void gtk_misc_class_init (GtkMiscClass *klass); -static void gtk_misc_init (GtkMisc *misc); static void gtk_misc_realize (GtkWidget *widget); static void gtk_misc_set_property (GObject *object, guint prop_id, @@ -53,33 +51,7 @@ static void gtk_misc_get_property (GObject *object, GParamSpec *pspec); -GType -gtk_misc_get_type (void) -{ - static GType misc_type = 0; - - if (!misc_type) - { - static const GTypeInfo misc_info = - { - sizeof (GtkMiscClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_misc_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkMisc), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_misc_init, - NULL, /* value_table */ - }; - - misc_type = g_type_register_static (GTK_TYPE_WIDGET, I_("GtkMisc"), - &misc_info, G_TYPE_FLAG_ABSTRACT); - } - - return misc_type; -} +G_DEFINE_TYPE (GtkMisc, gtk_misc, GTK_TYPE_WIDGET); static void gtk_misc_class_init (GtkMiscClass *class) diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 2800cd68ec..f8ab9a0531 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -184,9 +184,6 @@ static const GtkTargetEntry notebook_dest_targets[] = { #endif /*** GtkNotebook Methods ***/ -static void gtk_notebook_class_init (GtkNotebookClass *klass); -static void gtk_notebook_init (GtkNotebook *notebook); - static gboolean gtk_notebook_select_page (GtkNotebook *notebook, gboolean move_focus); static gboolean gtk_notebook_focus_tab (GtkNotebook *notebook, @@ -395,35 +392,9 @@ static void stop_scrolling (GtkNotebook *notebook); static GtkNotebookWindowCreationFunc window_creation_hook = NULL; static gpointer window_creation_hook_data; -static GtkContainerClass *parent_class = NULL; static guint notebook_signals[LAST_SIGNAL] = { 0 }; -GType -gtk_notebook_get_type (void) -{ - static GType notebook_type = 0; - - if (!notebook_type) - { - static const GTypeInfo notebook_info = - { - sizeof (GtkNotebookClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_notebook_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkNotebook), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_notebook_init, - }; - - notebook_type = g_type_register_static (GTK_TYPE_CONTAINER, I_("GtkNotebook"), - ¬ebook_info, 0); - } - - return notebook_type; -} +G_DEFINE_TYPE (GtkNotebook, gtk_notebook, GTK_TYPE_CONTAINER); static void add_tab_bindings (GtkBindingSet *binding_set, @@ -480,8 +451,6 @@ gtk_notebook_class_init (GtkNotebookClass *class) GtkContainerClass *container_class = GTK_CONTAINER_CLASS (class); GtkBindingSet *binding_set; - parent_class = g_type_class_peek_parent (class); - gobject_class->set_property = gtk_notebook_set_property; gobject_class->get_property = gtk_notebook_get_property; object_class->destroy = gtk_notebook_destroy; @@ -1284,7 +1253,7 @@ gtk_notebook_destroy (GtkObject *object) priv->switch_tab_timer = 0; } - GTK_OBJECT_CLASS (parent_class)->destroy (object); + GTK_OBJECT_CLASS (gtk_notebook_parent_class)->destroy (object); } static void @@ -1526,7 +1495,7 @@ gtk_notebook_unmap (GtkWidget *widget) gdk_window_hide (GTK_NOTEBOOK (widget)->event_window); - GTK_WIDGET_CLASS (parent_class)->unmap (widget); + GTK_WIDGET_CLASS (gtk_notebook_parent_class)->unmap (widget); } static void @@ -1580,8 +1549,8 @@ gtk_notebook_unrealize (GtkWidget *widget) gdk_window_destroy (notebook->event_window); notebook->event_window = NULL; - if (GTK_WIDGET_CLASS (parent_class)->unrealize) - (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); + if (GTK_WIDGET_CLASS (gtk_notebook_parent_class)->unrealize) + (* GTK_WIDGET_CLASS (gtk_notebook_parent_class)->unrealize) (widget); } static void @@ -2780,7 +2749,7 @@ gtk_notebook_style_set (GtkWidget *widget, notebook->has_after_previous = has_after_previous; notebook->has_after_next = has_after_next; - (* GTK_WIDGET_CLASS (parent_class)->style_set) (widget, previous); + (* GTK_WIDGET_CLASS (gtk_notebook_parent_class)->style_set) (widget, previous); } static void @@ -3517,7 +3486,7 @@ gtk_notebook_set_focus_child (GtkContainer *container, } } - parent_class->set_focus_child (container, child); + GTK_CONTAINER_CLASS (gtk_notebook_parent_class)->set_focus_child (container, child); } static void diff --git a/gtk/gtkoldeditable.c b/gtk/gtkoldeditable.c index b9ae01d370..81dd33a499 100644 --- a/gtk/gtkoldeditable.c +++ b/gtk/gtkoldeditable.c @@ -75,9 +75,7 @@ enum { TARGET_COMPOUND_TEXT }; -static void gtk_old_editable_class_init (GtkOldEditableClass *klass); static void gtk_old_editable_editable_init (GtkEditableClass *iface); -static void gtk_old_editable_init (GtkOldEditable *editable); static void gtk_old_editable_set_arg (GtkObject *object, GtkArg *arg, guint arg_id); @@ -128,46 +126,11 @@ static void gtk_old_editable_set_position (GtkEditable *editable, gint position); static gint gtk_old_editable_get_position (GtkEditable *editable); -static GtkWidgetClass *parent_class = NULL; static guint editable_signals[LAST_SIGNAL] = { 0 }; -GtkType -gtk_old_editable_get_type (void) -{ - static GtkType old_editable_type = 0; - - if (!old_editable_type) - { - static const GTypeInfo old_editable_info = - { - sizeof (GtkOldEditableClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_old_editable_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkOldEditable), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_old_editable_init, - NULL, /* value_table */ - }; - - static const GInterfaceInfo editable_info = - { - (GInterfaceInitFunc) gtk_old_editable_editable_init, /* interface_init */ - NULL, /* interface_finalize */ - NULL /* interface_data */ - }; - - old_editable_type = g_type_register_static (GTK_TYPE_WIDGET, I_("GtkOldEditable"), - &old_editable_info, G_TYPE_FLAG_ABSTRACT); - g_type_add_interface_static (old_editable_type, - GTK_TYPE_EDITABLE, - &editable_info); - } - - return old_editable_type; -} +G_DEFINE_TYPE_WITH_CODE (GtkOldEditable, gtk_old_editable, GTK_TYPE_WIDGET, + G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE, + gtk_old_editable_editable_init)); static void gtk_old_editable_class_init (GtkOldEditableClass *class) @@ -178,8 +141,6 @@ gtk_old_editable_class_init (GtkOldEditableClass *class) object_class = (GtkObjectClass*) class; widget_class = (GtkWidgetClass*) class; - parent_class = gtk_type_class (GTK_TYPE_WIDGET); - object_class->set_arg = gtk_old_editable_set_arg; object_class->get_arg = gtk_old_editable_get_arg; @@ -558,7 +519,7 @@ gtk_old_editable_selection_clear (GtkWidget *widget, /* Let the selection handling code know that the selection * has been changed, since we've overriden the default handler */ - if (!parent_class->selection_clear_event (widget, event)) + if (!GTK_WIDGET_CLASS (gtk_old_editable_parent_class)->selection_clear_event (widget, event)) return FALSE; if (old_editable->has_selection) diff --git a/gtk/gtkoptionmenu.c b/gtk/gtkoptionmenu.c index 2cfce2e3e1..e9cf677d7c 100644 --- a/gtk/gtkoptionmenu.c +++ b/gtk/gtkoptionmenu.c @@ -62,8 +62,6 @@ static const GtkOptionMenuProps default_props = { 0 }; -static void gtk_option_menu_class_init (GtkOptionMenuClass *klass); -static void gtk_option_menu_init (GtkOptionMenu *option_menu); static void gtk_option_menu_destroy (GtkObject *object); static void gtk_option_menu_set_property (GObject *object, guint prop_id, @@ -116,37 +114,9 @@ enum LAST_PROP }; -static GtkButtonClass *parent_class = NULL; static guint signals[LAST_SIGNAL] = { 0 }; - -GType -gtk_option_menu_get_type (void) -{ - static GType option_menu_type = 0; - - if (!option_menu_type) - { - static const GTypeInfo option_menu_info = - { - sizeof (GtkOptionMenuClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_option_menu_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkOptionMenu), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_option_menu_init, - }; - - option_menu_type = - g_type_register_static (GTK_TYPE_BUTTON, I_("GtkOptionMenu"), - &option_menu_info, 0); - } - - return option_menu_type; -} +G_DEFINE_TYPE (GtkOptionMenu, gtk_option_menu, GTK_TYPE_BUTTON); static void gtk_option_menu_class_init (GtkOptionMenuClass *class) @@ -161,8 +131,6 @@ gtk_option_menu_class_init (GtkOptionMenuClass *class) widget_class = (GtkWidgetClass*) class; container_class = (GtkContainerClass*) class; - parent_class = g_type_class_peek_parent (class); - signals[CHANGED] = g_signal_new (I_("changed"), G_OBJECT_CLASS_TYPE (class), @@ -414,8 +382,8 @@ gtk_option_menu_destroy (GtkObject *object) if (option_menu->menu) gtk_widget_destroy (option_menu->menu); - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); + if (GTK_OBJECT_CLASS (gtk_option_menu_parent_class)->destroy) + (* GTK_OBJECT_CLASS (gtk_option_menu_parent_class)->destroy) (object); } static void diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c index a7f87f17a2..4690977b3c 100644 --- a/gtk/gtkpaned.c +++ b/gtk/gtkpaned.c @@ -60,8 +60,6 @@ enum { LAST_SIGNAL }; -static void gtk_paned_class_init (GtkPanedClass *klass); -static void gtk_paned_init (GtkPaned *paned); static void gtk_paned_set_property (GObject *object, guint prop_id, const GValue *value, @@ -133,8 +131,6 @@ static GType gtk_paned_child_type (GtkContainer *container); static void gtk_paned_grab_notify (GtkWidget *widget, gboolean was_grabbed); -static GtkContainerClass *parent_class = NULL; - struct _GtkPanedPrivate { GtkWidget *saved_focus; @@ -142,33 +138,7 @@ struct _GtkPanedPrivate guint32 grab_time; }; -GType -gtk_paned_get_type (void) -{ - static GType paned_type = 0; - - if (!paned_type) - { - static const GTypeInfo paned_info = - { - sizeof (GtkPanedClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_paned_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkPaned), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_paned_init, - NULL, /* value_table */ - }; - - paned_type = g_type_register_static (GTK_TYPE_CONTAINER, I_("GtkPaned"), - &paned_info, G_TYPE_FLAG_ABSTRACT); - } - - return paned_type; -} +G_DEFINE_TYPE (GtkPaned, gtk_paned, GTK_TYPE_CONTAINER); static guint signals[LAST_SIGNAL] = { 0 }; @@ -207,8 +177,6 @@ gtk_paned_class_init (GtkPanedClass *class) container_class = (GtkContainerClass *) class; paned_class = (GtkPanedClass *) class; - parent_class = g_type_class_peek_parent (class); - object_class->set_property = gtk_paned_set_property; object_class->get_property = gtk_paned_get_property; object_class->finalize = gtk_paned_finalize; @@ -648,7 +616,7 @@ gtk_paned_finalize (GObject *object) gtk_paned_set_saved_focus (paned, NULL); gtk_paned_set_first_paned (paned, NULL); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_paned_parent_class)->finalize (object); } static void @@ -716,8 +684,8 @@ gtk_paned_unrealize (GtkWidget *widget) gtk_paned_set_saved_focus (paned, NULL); gtk_paned_set_first_paned (paned, NULL); - if (GTK_WIDGET_CLASS (parent_class)->unrealize) - (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); + if (GTK_WIDGET_CLASS (gtk_paned_parent_class)->unrealize) + (* GTK_WIDGET_CLASS (gtk_paned_parent_class)->unrealize) (widget); } static void @@ -727,7 +695,7 @@ gtk_paned_map (GtkWidget *widget) gdk_window_show (paned->handle); - GTK_WIDGET_CLASS (parent_class)->map (widget); + GTK_WIDGET_CLASS (gtk_paned_parent_class)->map (widget); } static void @@ -737,7 +705,7 @@ gtk_paned_unmap (GtkWidget *widget) gdk_window_hide (paned->handle); - GTK_WIDGET_CLASS (parent_class)->unmap (widget); + GTK_WIDGET_CLASS (gtk_paned_parent_class)->unmap (widget); } static gboolean @@ -768,7 +736,7 @@ gtk_paned_expose (GtkWidget *widget, } /* Chain up to draw children */ - GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); + GTK_WIDGET_CLASS (gtk_paned_parent_class)->expose_event (widget, event); return FALSE; } @@ -874,7 +842,7 @@ gtk_paned_focus (GtkWidget *widget, */ GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS); - retval = (* GTK_WIDGET_CLASS (parent_class)->focus) (widget, direction); + retval = (* GTK_WIDGET_CLASS (gtk_paned_parent_class)->focus) (widget, direction); GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS); return retval; @@ -1361,8 +1329,8 @@ gtk_paned_set_focus_child (GtkContainer *container, } } - if (parent_class->set_focus_child) - (* parent_class->set_focus_child) (container, focus_child); + if (GTK_CONTAINER_CLASS (gtk_paned_parent_class)->set_focus_child) + (* GTK_CONTAINER_CLASS (gtk_paned_parent_class)->set_focus_child) (container, focus_child); } static void diff --git a/gtk/gtkpixmap.c b/gtk/gtkpixmap.c index 0b1d48261e..3f211d08a1 100644 --- a/gtk/gtkpixmap.c +++ b/gtk/gtkpixmap.c @@ -38,40 +38,12 @@ #include "gtkalias.h" -static void gtk_pixmap_class_init (GtkPixmapClass *klass); -static void gtk_pixmap_init (GtkPixmap *pixmap); static gint gtk_pixmap_expose (GtkWidget *widget, GdkEventExpose *event); static void gtk_pixmap_finalize (GObject *object); static void build_insensitive_pixmap (GtkPixmap *gtkpixmap); -static GtkWidgetClass *parent_class; - -GtkType -gtk_pixmap_get_type (void) -{ - static GtkType pixmap_type = 0; - - if (!pixmap_type) - { - static const GtkTypeInfo pixmap_info = - { - "GtkPixmap", - sizeof (GtkPixmap), - sizeof (GtkPixmapClass), - (GtkClassInitFunc) gtk_pixmap_class_init, - (GtkObjectInitFunc) gtk_pixmap_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - I_("GtkPixmap"); - pixmap_type = gtk_type_unique (GTK_TYPE_MISC, &pixmap_info); - } - - return pixmap_type; -} +G_DEFINE_TYPE (GtkPixmap, gtk_pixmap, GTK_TYPE_MISC); static void gtk_pixmap_class_init (GtkPixmapClass *class) @@ -80,7 +52,6 @@ gtk_pixmap_class_init (GtkPixmapClass *class) GtkWidgetClass *widget_class; widget_class = (GtkWidgetClass*) class; - parent_class = gtk_type_class (gtk_misc_get_type ()); gobject_class->finalize = gtk_pixmap_finalize; @@ -117,7 +88,7 @@ gtk_pixmap_finalize (GObject *object) { gtk_pixmap_set (GTK_PIXMAP (object), NULL, NULL); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_pixmap_parent_class)->finalize (object); } void diff --git a/gtk/gtkplug.c b/gtk/gtkplug.c index 962ded6d66..a77cf07ed7 100644 --- a/gtk/gtkplug.c +++ b/gtk/gtkplug.c @@ -36,8 +36,6 @@ #include "gtkalias.h" -static void gtk_plug_class_init (GtkPlugClass *klass); -static void gtk_plug_init (GtkPlug *plug); static void gtk_plug_finalize (GObject *object); static void gtk_plug_realize (GtkWidget *widget); static void gtk_plug_unrealize (GtkWidget *widget); @@ -58,7 +56,6 @@ static gboolean gtk_plug_focus (GtkWidget *widget, static void gtk_plug_check_resize (GtkContainer *container); static void gtk_plug_keys_changed (GtkWindow *window); -static GtkWindowClass *parent_class = NULL; static GtkBinClass *bin_class = NULL; typedef struct @@ -74,32 +71,7 @@ enum { static guint plug_signals[LAST_SIGNAL] = { 0 }; -GType -gtk_plug_get_type (void) -{ - static GType plug_type = 0; - - if (!plug_type) - { - static const GTypeInfo plug_info = - { - sizeof (GtkPlugClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_plug_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkPlug), - 16, /* n_preallocs */ - (GInstanceInitFunc) gtk_plug_init, - }; - - plug_type = g_type_register_static (GTK_TYPE_WINDOW, I_("GtkPlug"), - &plug_info, 0); - } - - return plug_type; -} +G_DEFINE_TYPE (GtkPlug, gtk_plug, GTK_TYPE_WINDOW); static void gtk_plug_class_init (GtkPlugClass *class) @@ -109,7 +81,6 @@ gtk_plug_class_init (GtkPlugClass *class) GtkWindowClass *window_class = (GtkWindowClass *)class; GtkContainerClass *container_class = (GtkContainerClass *)class; - parent_class = g_type_class_peek_parent (class); bin_class = g_type_class_peek (GTK_TYPE_BIN); gobject_class->finalize = gtk_plug_finalize; @@ -461,7 +432,7 @@ gtk_plug_finalize (GObject *object) plug->grabbed_keys = NULL; } - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_plug_parent_class)->finalize (object); } static void @@ -489,8 +460,8 @@ gtk_plug_unrealize (GtkWidget *widget) g_object_unref (plug->modality_group); } - if (GTK_WIDGET_CLASS (parent_class)->unrealize) - (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); + if (GTK_WIDGET_CLASS (gtk_plug_parent_class)->unrealize) + (* GTK_WIDGET_CLASS (gtk_plug_parent_class)->unrealize) (widget); } static void @@ -579,7 +550,7 @@ static void gtk_plug_show (GtkWidget *widget) { if (GTK_WIDGET_TOPLEVEL (widget)) - GTK_WIDGET_CLASS (parent_class)->show (widget); + GTK_WIDGET_CLASS (gtk_plug_parent_class)->show (widget); else GTK_WIDGET_CLASS (bin_class)->show (widget); } @@ -588,7 +559,7 @@ static void gtk_plug_hide (GtkWidget *widget) { if (GTK_WIDGET_TOPLEVEL (widget)) - GTK_WIDGET_CLASS (parent_class)->hide (widget); + GTK_WIDGET_CLASS (gtk_plug_parent_class)->hide (widget); else GTK_WIDGET_CLASS (bin_class)->hide (widget); } @@ -649,7 +620,7 @@ gtk_plug_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { if (GTK_WIDGET_TOPLEVEL (widget)) - GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation); + GTK_WIDGET_CLASS (gtk_plug_parent_class)->size_allocate (widget, allocation); else { GtkBin *bin = GTK_BIN (widget); @@ -682,7 +653,7 @@ gtk_plug_key_press_event (GtkWidget *widget, GdkEventKey *event) { if (GTK_WIDGET_TOPLEVEL (widget)) - return GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, event); + return GTK_WIDGET_CLASS (gtk_plug_parent_class)->key_press_event (widget, event); else return FALSE; } @@ -704,7 +675,7 @@ gtk_plug_set_focus (GtkWindow *window, { GtkPlug *plug = GTK_PLUG (window); - GTK_WINDOW_CLASS (parent_class)->set_focus (window, focus); + GTK_WINDOW_CLASS (gtk_plug_parent_class)->set_focus (window, focus); /* Ask for focus from embedder */ @@ -887,7 +858,7 @@ static void gtk_plug_check_resize (GtkContainer *container) { if (GTK_WIDGET_TOPLEVEL (container)) - GTK_CONTAINER_CLASS (parent_class)->check_resize (container); + GTK_CONTAINER_CLASS (gtk_plug_parent_class)->check_resize (container); else GTK_CONTAINER_CLASS (bin_class)->check_resize (container); } diff --git a/gtk/gtkpreview.c b/gtk/gtkpreview.c index 36090e53a8..d7ddcca56d 100644 --- a/gtk/gtkpreview.c +++ b/gtk/gtkpreview.c @@ -51,8 +51,6 @@ enum { }; -static void gtk_preview_class_init (GtkPreviewClass *klass); -static void gtk_preview_init (GtkPreview *preview); static void gtk_preview_set_property (GObject *object, guint prop_id, const GValue *value, @@ -70,36 +68,11 @@ static gint gtk_preview_expose (GtkWidget *widget, static void gtk_preview_make_buffer (GtkPreview *preview); static void gtk_fill_lookup_array (guchar *array); -static GtkWidgetClass *parent_class = NULL; static GtkPreviewClass *preview_class = NULL; static gint install_cmap = FALSE; -GtkType -gtk_preview_get_type (void) -{ - static GtkType preview_type = 0; - - if (!preview_type) - { - static const GtkTypeInfo preview_info = - { - "GtkPreview", - sizeof (GtkPreview), - sizeof (GtkPreviewClass), - (GtkClassInitFunc) gtk_preview_class_init, - (GtkObjectInitFunc) gtk_preview_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - I_("GtkPreview"); - preview_type = gtk_type_unique (GTK_TYPE_WIDGET, &preview_info); - } - - return preview_type; -} +G_DEFINE_TYPE (GtkPreview, gtk_preview, GTK_TYPE_WIDGET); static void gtk_preview_class_init (GtkPreviewClass *klass) @@ -109,7 +82,6 @@ gtk_preview_class_init (GtkPreviewClass *klass) widget_class = (GtkWidgetClass*) klass; - parent_class = gtk_type_class (GTK_TYPE_WIDGET); preview_class = klass; gobject_class->finalize = gtk_preview_finalize; @@ -448,7 +420,7 @@ gtk_preview_finalize (GObject *object) g_free (preview->buffer); preview->type = (GtkPreviewType) -1; - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_preview_parent_class)->finalize (object); } static void diff --git a/gtk/gtkprogress.c b/gtk/gtkprogress.c index 3aae0fa69b..2cc166acae 100644 --- a/gtk/gtkprogress.c +++ b/gtk/gtkprogress.c @@ -45,8 +45,6 @@ enum { }; -static void gtk_progress_class_init (GtkProgressClass *klass); -static void gtk_progress_init (GtkProgress *progress); static void gtk_progress_set_property (GObject *object, guint prop_id, const GValue *value, @@ -68,36 +66,7 @@ static void gtk_progress_value_changed (GtkAdjustment *adjustment, static void gtk_progress_changed (GtkAdjustment *adjustment, GtkProgress *progress); - -static GtkWidgetClass *parent_class = NULL; - - -GType -gtk_progress_get_type (void) -{ - static GType progress_type = 0; - - if (!progress_type) - { - static const GTypeInfo progress_info = - { - sizeof (GtkProgressClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_progress_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkProgress), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_progress_init, - }; - - progress_type = g_type_register_static (GTK_TYPE_WIDGET, I_("GtkProgress"), - &progress_info, 0); - } - - return progress_type; -} +G_DEFINE_TYPE (GtkProgress, gtk_progress, GTK_TYPE_WIDGET); static void gtk_progress_class_init (GtkProgressClass *class) @@ -109,8 +78,6 @@ gtk_progress_class_init (GtkProgressClass *class) object_class = (GtkObjectClass *) class; widget_class = (GtkWidgetClass *) class; - parent_class = gtk_type_class (GTK_TYPE_WIDGET); - gobject_class->finalize = gtk_progress_finalize; gobject_class->set_property = gtk_progress_set_property; @@ -295,7 +262,7 @@ gtk_progress_destroy (GtkObject *object) progress->adjustment = NULL; } - GTK_OBJECT_CLASS (parent_class)->destroy (object); + GTK_OBJECT_CLASS (gtk_progress_parent_class)->destroy (object); } static void @@ -313,7 +280,7 @@ gtk_progress_finalize (GObject *object) if (progress->format) g_free (progress->format); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_progress_parent_class)->finalize (object); } static gint diff --git a/gtk/gtkprogressbar.c b/gtk/gtkprogressbar.c index 75edf5f810..27e31d3860 100644 --- a/gtk/gtkprogressbar.c +++ b/gtk/gtkprogressbar.c @@ -65,8 +65,6 @@ enum { PROP_DISCRETE_BLOCKS }; -static void gtk_progress_bar_class_init (GtkProgressBarClass *klass); -static void gtk_progress_bar_init (GtkProgressBar *pbar); static void gtk_progress_bar_set_property (GObject *object, guint prop_id, const GValue *value, @@ -91,33 +89,7 @@ static void gtk_progress_bar_set_activity_blocks_internal (GtkProgressBar *pbar, guint blocks); -GType -gtk_progress_bar_get_type (void) -{ - static GType progress_bar_type = 0; - - if (!progress_bar_type) - { - static const GTypeInfo progress_bar_info = - { - sizeof (GtkProgressBarClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_progress_bar_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkProgressBar), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_progress_bar_init, - }; - - progress_bar_type = - g_type_register_static (GTK_TYPE_PROGRESS, I_("GtkProgressBar"), - &progress_bar_info, 0); - } - - return progress_bar_type; -} +G_DEFINE_TYPE (GtkProgressBar, gtk_progress_bar, GTK_TYPE_PROGRESS); static void gtk_progress_bar_class_init (GtkProgressBarClass *class) diff --git a/gtk/gtkradioaction.c b/gtk/gtkradioaction.c index 8d243f163c..ab3cadf7fb 100644 --- a/gtk/gtkradioaction.c +++ b/gtk/gtkradioaction.c @@ -60,8 +60,6 @@ enum PROP_CURRENT_VALUE }; -static void gtk_radio_action_init (GtkRadioAction *action); -static void gtk_radio_action_class_init (GtkRadioActionClass *class); static void gtk_radio_action_finalize (GObject *object); static void gtk_radio_action_set_property (GObject *object, guint prop_id, @@ -75,35 +73,8 @@ static void gtk_radio_action_activate (GtkAction *action); static GtkWidget *create_menu_item (GtkAction *action); -GType -gtk_radio_action_get_type (void) -{ - static GtkType type = 0; - - if (!type) - { - static const GTypeInfo type_info = - { - sizeof (GtkRadioActionClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gtk_radio_action_class_init, - (GClassFinalizeFunc) NULL, - NULL, - - sizeof (GtkRadioAction), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_radio_action_init, - }; - - type = g_type_register_static (GTK_TYPE_TOGGLE_ACTION, - I_("GtkRadioAction"), - &type_info, 0); - } - return type; -} +G_DEFINE_TYPE (GtkRadioAction, gtk_radio_action, GTK_TYPE_TOGGLE_ACTION); -static GObjectClass *parent_class = NULL; static guint radio_action_signals[LAST_SIGNAL] = { 0 }; static void @@ -112,7 +83,6 @@ gtk_radio_action_class_init (GtkRadioActionClass *klass) GObjectClass *gobject_class; GtkActionClass *action_class; - parent_class = g_type_class_peek_parent (klass); gobject_class = G_OBJECT_CLASS (klass); action_class = GTK_ACTION_CLASS (klass); @@ -265,7 +235,7 @@ gtk_radio_action_finalize (GObject *object) tmp_action->private_data->group = action->private_data->group; } - (* parent_class->finalize) (object); + G_OBJECT_CLASS (gtk_radio_action_parent_class)->finalize (object); } static void diff --git a/gtk/gtkradiobutton.c b/gtk/gtkradiobutton.c index d57bda5f10..9a076b5b18 100644 --- a/gtk/gtkradiobutton.c +++ b/gtk/gtkradiobutton.c @@ -39,8 +39,6 @@ enum { }; -static void gtk_radio_button_class_init (GtkRadioButtonClass *klass); -static void gtk_radio_button_init (GtkRadioButton *radio_button); static void gtk_radio_button_destroy (GtkObject *object); static gboolean gtk_radio_button_focus (GtkWidget *widget, GtkDirectionType direction); @@ -56,38 +54,10 @@ static void gtk_radio_button_get_property (GObject *object, GValue *value, GParamSpec *pspec); -static GtkCheckButtonClass *parent_class = NULL; +G_DEFINE_TYPE (GtkRadioButton, gtk_radio_button, GTK_TYPE_CHECK_BUTTON); static guint group_changed_signal = 0; -GType -gtk_radio_button_get_type (void) -{ - static GType radio_button_type = 0; - - if (!radio_button_type) - { - static const GTypeInfo radio_button_info = - { - sizeof (GtkRadioButtonClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_radio_button_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkRadioButton), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_radio_button_init, - }; - - radio_button_type = - g_type_register_static (GTK_TYPE_CHECK_BUTTON, I_("GtkRadioButton"), - &radio_button_info, 0); - } - - return radio_button_type; -} - static void gtk_radio_button_class_init (GtkRadioButtonClass *class) { @@ -103,8 +73,6 @@ gtk_radio_button_class_init (GtkRadioButtonClass *class) button_class = (GtkButtonClass*) class; check_button_class = (GtkCheckButtonClass*) class; - parent_class = g_type_class_peek_parent (class); - gobject_class->set_property = gtk_radio_button_set_property; gobject_class->get_property = gtk_radio_button_get_property; @@ -414,8 +382,8 @@ gtk_radio_button_destroy (GtkObject *object) if (was_in_group) g_signal_emit (radio_button, group_changed_signal, 0); - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); + if (GTK_OBJECT_CLASS (gtk_radio_button_parent_class)->destroy) + (* GTK_OBJECT_CLASS (gtk_radio_button_parent_class)->destroy) (object); } static void @@ -473,7 +441,7 @@ gtk_radio_button_focus (GtkWidget *widget, * they look like buttons to the user. */ if (!GTK_TOGGLE_BUTTON (widget)->draw_indicator) - return GTK_WIDGET_CLASS (parent_class)->focus (widget, direction); + return GTK_WIDGET_CLASS (gtk_radio_button_parent_class)->focus (widget, direction); if (gtk_widget_is_focus (widget)) { diff --git a/gtk/gtkradiomenuitem.c b/gtk/gtkradiomenuitem.c index 5c74509bb6..e050625176 100644 --- a/gtk/gtkradiomenuitem.c +++ b/gtk/gtkradiomenuitem.c @@ -39,8 +39,6 @@ enum { }; -static void gtk_radio_menu_item_class_init (GtkRadioMenuItemClass *klass); -static void gtk_radio_menu_item_init (GtkRadioMenuItem *radio_menu_item); static void gtk_radio_menu_item_destroy (GtkObject *object); static void gtk_radio_menu_item_activate (GtkMenuItem *menu_item); static void gtk_radio_menu_item_set_property (GObject *object, @@ -52,37 +50,9 @@ static void gtk_radio_menu_item_get_property (GObject *object, GValue *value, GParamSpec *pspec); -static GtkCheckMenuItemClass *parent_class = NULL; - static guint group_changed_signal = 0; -GType -gtk_radio_menu_item_get_type (void) -{ - static GType radio_menu_item_type = 0; - - if (!radio_menu_item_type) - { - static const GTypeInfo radio_menu_item_info = - { - sizeof (GtkRadioMenuItemClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_radio_menu_item_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkRadioMenuItem), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_radio_menu_item_init, - }; - - radio_menu_item_type = - g_type_register_static (GTK_TYPE_CHECK_MENU_ITEM, I_("GtkRadioMenuItem"), - &radio_menu_item_info, 0); - } - - return radio_menu_item_type; -} +G_DEFINE_TYPE (GtkRadioMenuItem, gtk_radio_menu_item, GTK_TYPE_CHECK_MENU_ITEM); GtkWidget* gtk_radio_menu_item_new (GSList *group) @@ -356,8 +326,6 @@ gtk_radio_menu_item_class_init (GtkRadioMenuItemClass *klass) object_class = GTK_OBJECT_CLASS (klass); menu_item_class = GTK_MENU_ITEM_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); - gobject_class->set_property = gtk_radio_menu_item_set_property; gobject_class->get_property = gtk_radio_menu_item_get_property; @@ -447,8 +415,8 @@ gtk_radio_menu_item_destroy (GtkObject *object) if (was_in_group) g_signal_emit (radio_menu_item, group_changed_signal, 0); - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); + if (GTK_OBJECT_CLASS (gtk_radio_menu_item_parent_class)->destroy) + (* GTK_OBJECT_CLASS (gtk_radio_menu_item_parent_class)->destroy) (object); } static void diff --git a/gtk/gtkradiotoolbutton.c b/gtk/gtkradiotoolbutton.c index 4bf5f3eb3e..5e8b69e8b7 100644 --- a/gtk/gtkradiotoolbutton.c +++ b/gtk/gtkradiotoolbutton.c @@ -32,40 +32,13 @@ enum { PROP_GROUP }; -static void gtk_radio_tool_button_init (GtkRadioToolButton *button); -static void gtk_radio_tool_button_class_init (GtkRadioToolButtonClass *klass); static void gtk_radio_tool_button_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -GType -gtk_radio_tool_button_get_type (void) -{ - static GType type = 0; - - if (!type) - { - static const GTypeInfo type_info = - { - sizeof (GtkRadioToolButtonClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gtk_radio_tool_button_class_init, - (GClassFinalizeFunc) NULL, - NULL, - sizeof (GtkRadioToolButton), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_radio_tool_button_init - }; - - type = g_type_register_static (GTK_TYPE_TOGGLE_TOOL_BUTTON, - I_("GtkRadioToolButton"), &type_info, 0); - } - return type; -} +G_DEFINE_TYPE (GtkRadioToolButton, gtk_radio_tool_button, GTK_TYPE_TOGGLE_TOOL_BUTTON); - static void gtk_radio_tool_button_class_init (GtkRadioToolButtonClass *klass) { diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c index b1dcc14491..c26240dfb8 100644 --- a/gtk/gtkrange.c +++ b/gtk/gtkrange.c @@ -98,8 +98,6 @@ struct _GtkRangeLayout }; -static void gtk_range_class_init (GtkRangeClass *klass); -static void gtk_range_init (GtkRange *range); static void gtk_range_set_property (GObject *object, guint prop_id, const GValue *value, @@ -191,37 +189,9 @@ static gboolean gtk_range_key_press (GtkWidget *range, GdkEventKey *event); -static GtkWidgetClass *parent_class = NULL; static guint signals[LAST_SIGNAL]; - -GType -gtk_range_get_type (void) -{ - static GType range_type = 0; - - if (!range_type) - { - static const GTypeInfo range_info = - { - sizeof (GtkRangeClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_range_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkRange), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_range_init, - NULL, /* value_table */ - }; - - range_type = g_type_register_static (GTK_TYPE_WIDGET, I_("GtkRange"), - &range_info, G_TYPE_FLAG_ABSTRACT); - } - - return range_type; -} +G_DEFINE_TYPE (GtkRange, gtk_range, GTK_TYPE_WIDGET); static void gtk_range_class_init (GtkRangeClass *class) @@ -234,8 +204,6 @@ gtk_range_class_init (GtkRangeClass *class) object_class = (GtkObjectClass*) class; widget_class = (GtkWidgetClass*) class; - parent_class = g_type_class_peek_parent (class); - gobject_class->set_property = gtk_range_set_property; gobject_class->get_property = gtk_range_get_property; gobject_class->finalize = gtk_range_finalize; @@ -887,7 +855,7 @@ gtk_range_finalize (GObject *object) g_free (range->layout); - (* G_OBJECT_CLASS (parent_class)->finalize) (object); + (* G_OBJECT_CLASS (gtk_range_parent_class)->finalize) (object); } static void @@ -910,7 +878,7 @@ gtk_range_destroy (GtkObject *object) range->adjustment = NULL; } - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); + (* GTK_OBJECT_CLASS (gtk_range_parent_class)->destroy) (object); } static void @@ -1008,8 +976,8 @@ gtk_range_unrealize (GtkWidget *widget) gdk_window_destroy (range->event_window); range->event_window = NULL; - if (GTK_WIDGET_CLASS (parent_class)->unrealize) - (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); + if (GTK_WIDGET_CLASS (gtk_range_parent_class)->unrealize) + (* GTK_WIDGET_CLASS (gtk_range_parent_class)->unrealize) (widget); } static void @@ -1019,7 +987,7 @@ gtk_range_map (GtkWidget *widget) gdk_window_show (range->event_window); - GTK_WIDGET_CLASS (parent_class)->map (widget); + GTK_WIDGET_CLASS (gtk_range_parent_class)->map (widget); } static void @@ -1031,7 +999,7 @@ gtk_range_unmap (GtkWidget *widget) gdk_window_hide (range->event_window); - GTK_WIDGET_CLASS (parent_class)->unmap (widget); + GTK_WIDGET_CLASS (gtk_range_parent_class)->unmap (widget); } static void @@ -1873,7 +1841,7 @@ gtk_range_style_set (GtkWidget *widget, range->need_recalc = TRUE; - (* GTK_WIDGET_CLASS (parent_class)->style_set) (widget, previous_style); + (* GTK_WIDGET_CLASS (gtk_range_parent_class)->style_set) (widget, previous_style); } static void diff --git a/gtk/gtkrc.c b/gtk/gtkrc.c index d03b8473ef..c11632bc39 100644 --- a/gtk/gtkrc.c +++ b/gtk/gtkrc.c @@ -227,8 +227,6 @@ static void gtk_rc_clear_hash_node (gpointer key, static void gtk_rc_clear_styles (GtkRcContext *context); static void gtk_rc_add_initial_default_files (void); -static void gtk_rc_style_init (GtkRcStyle *style); -static void gtk_rc_style_class_init (GtkRcStyleClass *klass); static void gtk_rc_style_finalize (GObject *object); static void gtk_rc_style_real_merge (GtkRcStyle *dest, GtkRcStyle *src); @@ -238,7 +236,6 @@ static gint gtk_rc_properties_cmp (gconstpointer bsearch_node1, gconstpointer bsearch_node2); static void gtk_rc_set_free (GtkRcSet *rc_set); -static gpointer parent_class = NULL; static const GScannerConfig gtk_rc_scanner_config = { @@ -1034,32 +1031,7 @@ gtk_rc_parse (const gchar *filename) /* Handling of RC styles */ -GType -gtk_rc_style_get_type (void) -{ - static GType rc_style_type = 0; - - if (!rc_style_type) - { - static const GTypeInfo rc_style_info = - { - sizeof (GtkRcStyleClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gtk_rc_style_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkRcStyle), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_rc_style_init, - }; - - rc_style_type = g_type_register_static (G_TYPE_OBJECT, I_("GtkRcStyle"), - &rc_style_info, 0); - } - - return rc_style_type; -} +G_DEFINE_TYPE (GtkRcStyle, gtk_rc_style, G_TYPE_OBJECT); static void gtk_rc_style_init (GtkRcStyle *style) @@ -1096,8 +1068,6 @@ gtk_rc_style_class_init (GtkRcStyleClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); - object_class->finalize = gtk_rc_style_finalize; klass->parse = NULL; @@ -1182,7 +1152,7 @@ gtk_rc_style_finalize (GObject *object) g_slist_foreach (rc_priv->color_hashes, (GFunc) g_hash_table_unref, NULL); g_slist_free (rc_priv->color_hashes); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_rc_style_parent_class)->finalize (object); } GtkRcStyle * diff --git a/gtk/gtkrecentchooser.c b/gtk/gtkrecentchooser.c index 721d04d6a9..7435d76689 100644 --- a/gtk/gtkrecentchooser.c +++ b/gtk/gtkrecentchooser.c @@ -50,18 +50,12 @@ gtk_recent_chooser_get_type (void) if (!chooser_type) { - static const GTypeInfo chooser_info = - { - sizeof (GtkRecentChooserIface), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_recent_chooser_class_init, - }; + chooser_type = g_type_register_static_simple (G_TYPE_INTERFACE, + I_("GtkRecentChooser"), + sizeof (GtkRecentChooserIface), + (GClassInitFunc) gtk_recent_chooser_class_init, + 0, NULL, 0); - chooser_type = g_type_register_static (G_TYPE_INTERFACE, - I_("GtkRecentChooser"), - &chooser_info, 0); - g_type_interface_add_prerequisite (chooser_type, GTK_TYPE_OBJECT); } diff --git a/gtk/gtkruler.c b/gtk/gtkruler.c index ccc9b86be8..e6a4a0e357 100644 --- a/gtk/gtkruler.c +++ b/gtk/gtkruler.c @@ -39,8 +39,6 @@ enum { PROP_METRIC }; -static void gtk_ruler_class_init (GtkRulerClass *klass); -static void gtk_ruler_init (GtkRuler *ruler); static void gtk_ruler_realize (GtkWidget *widget); static void gtk_ruler_unrealize (GtkWidget *widget); static void gtk_ruler_size_allocate (GtkWidget *widget, @@ -57,8 +55,6 @@ static void gtk_ruler_get_property (GObject *object, GValue *value, GParamSpec *pspec); -static GtkWidgetClass *parent_class; - static const GtkRulerMetric ruler_metrics[] = { { NULL, NULL, 1.0, { 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000 }, { 1, 5, 10, 50, 100 }}, @@ -66,33 +62,7 @@ static const GtkRulerMetric ruler_metrics[] = { NULL, NULL, 28.35, { 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000 }, { 1, 5, 10, 50, 100 }}, }; - -GType -gtk_ruler_get_type (void) -{ - static GType ruler_type = 0; - - if (!ruler_type) - { - static const GTypeInfo ruler_info = - { - sizeof (GtkRulerClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_ruler_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkRuler), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_ruler_init, - }; - - ruler_type = g_type_register_static (GTK_TYPE_WIDGET, I_("GtkRuler"), - &ruler_info, 0); - } - - return ruler_type; -} +G_DEFINE_TYPE (GtkRuler, gtk_ruler, GTK_TYPE_WIDGET); static void gtk_ruler_class_init (GtkRulerClass *class) @@ -103,8 +73,6 @@ gtk_ruler_class_init (GtkRulerClass *class) gobject_class = G_OBJECT_CLASS (class); widget_class = (GtkWidgetClass*) class; - parent_class = g_type_class_peek_parent (class); - gobject_class->set_property = gtk_ruler_set_property; gobject_class->get_property = gtk_ruler_get_property; @@ -422,8 +390,8 @@ gtk_ruler_unrealize (GtkWidget *widget) ruler->backing_store = NULL; ruler->non_gr_exp_gc = NULL; - if (GTK_WIDGET_CLASS (parent_class)->unrealize) - (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); + if (GTK_WIDGET_CLASS (gtk_ruler_parent_class)->unrealize) + (* GTK_WIDGET_CLASS (gtk_ruler_parent_class)->unrealize) (widget); } static void diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c index 1124dd8e55..89def27d0b 100644 --- a/gtk/gtkscale.c +++ b/gtk/gtkscale.c @@ -64,10 +64,7 @@ enum { }; static guint signals[LAST_SIGNAL]; -static GtkRangeClass *parent_class = NULL; -static void gtk_scale_class_init (GtkScaleClass *klass); -static void gtk_scale_init (GtkScale *scale); static void gtk_scale_set_property (GObject *object, guint prop_id, const GValue *value, @@ -84,33 +81,7 @@ static void gtk_scale_finalize (GObject *object); static void gtk_scale_screen_changed (GtkWidget *widget, GdkScreen *old_screen); -GType -gtk_scale_get_type (void) -{ - static GType scale_type = 0; - - if (!scale_type) - { - static const GTypeInfo scale_info = - { - sizeof (GtkScaleClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_scale_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkScale), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_scale_init, - NULL, /* value_table */ - }; - - scale_type = g_type_register_static (GTK_TYPE_RANGE, I_("GtkScale"), - &scale_info, G_TYPE_FLAG_ABSTRACT); - } - - return scale_type; -} +G_DEFINE_TYPE (GtkScale, gtk_scale, GTK_TYPE_RANGE); static gboolean single_string_accumulator (GSignalInvocationHint *ihint, @@ -146,8 +117,6 @@ gtk_scale_class_init (GtkScaleClass *class) range_class = (GtkRangeClass*) class; widget_class = (GtkWidgetClass*) class; - parent_class = g_type_class_peek_parent (class); - gobject_class->set_property = gtk_scale_set_property; gobject_class->get_property = gtk_scale_get_property; gobject_class->finalize = gtk_scale_finalize; @@ -611,7 +580,7 @@ gtk_scale_style_set (GtkWidget *widget, _gtk_scale_clear_layout (GTK_SCALE (widget)); - (* GTK_WIDGET_CLASS (parent_class)->style_set) (widget, previous); + (* GTK_WIDGET_CLASS (gtk_scale_parent_class)->style_set) (widget, previous); } static void @@ -661,7 +630,7 @@ gtk_scale_finalize (GObject *object) _gtk_scale_clear_layout (scale); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_scale_parent_class)->finalize (object); } /** diff --git a/gtk/gtkscrollbar.c b/gtk/gtkscrollbar.c index fb70fb5779..4165ab5f7d 100644 --- a/gtk/gtkscrollbar.c +++ b/gtk/gtkscrollbar.c @@ -31,41 +31,10 @@ #include "gtkprivate.h" #include "gtkalias.h" -static void gtk_scrollbar_class_init (GtkScrollbarClass *klass); -static void gtk_scrollbar_init (GtkScrollbar *scrollbar); static void gtk_scrollbar_style_set (GtkWidget *widget, GtkStyle *previous); -static gpointer parent_class; - -GType -gtk_scrollbar_get_type (void) -{ - static GType scrollbar_type = 0; - - if (!scrollbar_type) - { - static const GTypeInfo scrollbar_info = - { - sizeof (GtkScrollbarClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_scrollbar_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkScrollbar), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_scrollbar_init, - NULL, /* value_table */ - }; - - scrollbar_type = - g_type_register_static (GTK_TYPE_RANGE, I_("GtkScrollbar"), - &scrollbar_info, G_TYPE_FLAG_ABSTRACT); - } - - return scrollbar_type; -} +G_DEFINE_TYPE (GtkScrollbar, gtk_scrollbar, GTK_TYPE_RANGE); static void gtk_scrollbar_class_init (GtkScrollbarClass *class) @@ -74,8 +43,6 @@ gtk_scrollbar_class_init (GtkScrollbarClass *class) widget_class = GTK_WIDGET_CLASS (class); - parent_class = g_type_class_peek_parent (class); - widget_class->style_set = gtk_scrollbar_style_set; gtk_widget_class_install_style_property (widget_class, @@ -161,7 +128,7 @@ gtk_scrollbar_style_set (GtkWidget *widget, range->has_stepper_c = has_c; range->has_stepper_d = has_d; - (* GTK_WIDGET_CLASS (parent_class)->style_set) (widget, previous); + (* GTK_WIDGET_CLASS (gtk_scrollbar_parent_class)->style_set) (widget, previous); } #define __GTK_SCROLLBAR_C__ diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c index 2baa45621e..87ecb000d9 100644 --- a/gtk/gtkscrolledwindow.c +++ b/gtk/gtkscrolledwindow.c @@ -100,8 +100,6 @@ enum LAST_SIGNAL }; -static void gtk_scrolled_window_class_init (GtkScrolledWindowClass *klass); -static void gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window); static void gtk_scrolled_window_destroy (GtkObject *object); static void gtk_scrolled_window_finalize (GObject *object); static void gtk_scrolled_window_set_property (GObject *object, @@ -146,37 +144,9 @@ static void gtk_scrolled_window_adjustment_changed (GtkAdjustment *adju static void gtk_scrolled_window_update_real_placement (GtkScrolledWindow *scrolled_window); -static GtkContainerClass *parent_class = NULL; - static guint signals[LAST_SIGNAL] = {0}; -GType -gtk_scrolled_window_get_type (void) -{ - static GType scrolled_window_type = 0; - - if (!scrolled_window_type) - { - static const GTypeInfo scrolled_window_info = - { - sizeof (GtkScrolledWindowClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_scrolled_window_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkScrolledWindow), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_scrolled_window_init, - }; - - scrolled_window_type = - g_type_register_static (GTK_TYPE_BIN, I_("GtkScrolledWindow"), - &scrolled_window_info, 0); - } - - return scrolled_window_type; -} +G_DEFINE_TYPE (GtkScrolledWindow, gtk_scrolled_window, GTK_TYPE_BIN); static void add_scroll_binding (GtkBindingSet *binding_set, @@ -223,8 +193,6 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class) widget_class = (GtkWidgetClass*) class; container_class = (GtkContainerClass*) class; - parent_class = g_type_class_peek_parent (class); - gobject_class->finalize = gtk_scrolled_window_finalize; gobject_class->set_property = gtk_scrolled_window_set_property; gobject_class->get_property = gtk_scrolled_window_get_property; @@ -809,7 +777,7 @@ gtk_scrolled_window_destroy (GtkObject *object) gtk_widget_destroy (scrolled_window->hscrollbar); gtk_widget_destroy (scrolled_window->vscrollbar); - GTK_OBJECT_CLASS (parent_class)->destroy (object); + GTK_OBJECT_CLASS (gtk_scrolled_window_parent_class)->destroy (object); } static void @@ -820,7 +788,7 @@ gtk_scrolled_window_finalize (GObject *object) g_object_unref (scrolled_window->hscrollbar); g_object_unref (scrolled_window->vscrollbar); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_scrolled_window_parent_class)->finalize (object); } static void @@ -1000,7 +968,7 @@ gtk_scrolled_window_expose (GtkWidget *widget, { gtk_scrolled_window_paint (widget, &event->area); - (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event); + (* GTK_WIDGET_CLASS (gtk_scrolled_window_parent_class)->expose_event) (widget, event); } return FALSE; @@ -1015,7 +983,7 @@ gtk_scrolled_window_forall (GtkContainer *container, g_return_if_fail (GTK_IS_SCROLLED_WINDOW (container)); g_return_if_fail (callback != NULL); - GTK_CONTAINER_CLASS (parent_class)->forall (container, + GTK_CONTAINER_CLASS (gtk_scrolled_window_parent_class)->forall (container, include_internals, callback, callback_data); @@ -1599,7 +1567,7 @@ gtk_scrolled_window_remove (GtkContainer *container, gtk_widget_set_scroll_adjustments (child, NULL, NULL); /* chain parent class handler to remove child */ - GTK_CONTAINER_CLASS (parent_class)->remove (container, child); + GTK_CONTAINER_CLASS (gtk_scrolled_window_parent_class)->remove (container, child); } void diff --git a/gtk/gtkseparator.c b/gtk/gtkseparator.c index e2ddc59057..5aa9d332fa 100644 --- a/gtk/gtkseparator.c +++ b/gtk/gtkseparator.c @@ -30,38 +30,7 @@ #include "gtkalias.h" -static void gtk_separator_class_init (GtkSeparatorClass *klass); -static void gtk_separator_init (GtkSeparator *separator); - - -GType -gtk_separator_get_type (void) -{ - static GType separator_type = 0; - - if (!separator_type) - { - static const GTypeInfo separator_info = - { - sizeof (GtkSeparatorClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_separator_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkSeparator), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_separator_init, - NULL, /* value_table */ - }; - - separator_type = - g_type_register_static (GTK_TYPE_WIDGET, I_("GtkSeparator"), - &separator_info, G_TYPE_FLAG_ABSTRACT); - } - - return separator_type; -} +G_DEFINE_TYPE (GtkSeparator, gtk_separator, GTK_TYPE_WIDGET); static void gtk_separator_class_init (GtkSeparatorClass *class) diff --git a/gtk/gtkseparatortoolitem.c b/gtk/gtkseparatortoolitem.c index fc3d267e2e..0cb800666e 100644 --- a/gtk/gtkseparatortoolitem.c +++ b/gtk/gtkseparatortoolitem.c @@ -36,9 +36,6 @@ enum { PROP_DRAW }; -static void gtk_separator_tool_item_class_init (GtkSeparatorToolItemClass *class); -static void gtk_separator_tool_item_init (GtkSeparatorToolItem *separator_item, - GtkSeparatorToolItemClass *class); static gboolean gtk_separator_tool_item_create_menu_proxy (GtkToolItem *item); static void gtk_separator_tool_item_set_property (GObject *object, guint prop_id, @@ -58,8 +55,6 @@ static gint get_space_size (GtkToolItem -static GObjectClass *parent_class = NULL; - #define GTK_SEPARATOR_TOOL_ITEM_GET_PRIVATE(obj)(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_SEPARATOR_TOOL_ITEM, GtkSeparatorToolItemPrivate)) struct _GtkSeparatorToolItemPrivate @@ -67,31 +62,7 @@ struct _GtkSeparatorToolItemPrivate guint draw : 1; }; -GType -gtk_separator_tool_item_get_type (void) -{ - static GType type = 0; - - if (!type) - { - static const GTypeInfo type_info = - { - sizeof (GtkSeparatorToolItemClass), - (GBaseInitFunc) 0, - (GBaseFinalizeFunc) 0, - (GClassInitFunc) gtk_separator_tool_item_class_init, - (GClassFinalizeFunc) 0, - NULL, - sizeof (GtkSeparatorToolItem), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_separator_tool_item_init, - }; - - type = g_type_register_static (GTK_TYPE_TOOL_ITEM, - I_("GtkSeparatorToolItem"), &type_info, 0); - } - return type; -} +G_DEFINE_TYPE (GtkSeparatorToolItem, gtk_separator_tool_item, GTK_TYPE_TOOL_ITEM); static gint get_space_size (GtkToolItem *tool_item) @@ -117,7 +88,6 @@ gtk_separator_tool_item_class_init (GtkSeparatorToolItemClass *class) GtkToolItemClass *toolitem_class; GtkWidgetClass *widget_class; - parent_class = g_type_class_peek_parent (class); object_class = (GObjectClass *)class; container_class = (GtkContainerClass *)class; toolitem_class = (GtkToolItemClass *)class; @@ -143,8 +113,7 @@ gtk_separator_tool_item_class_init (GtkSeparatorToolItemClass *class) } static void -gtk_separator_tool_item_init (GtkSeparatorToolItem *separator_item, - GtkSeparatorToolItemClass *class) +gtk_separator_tool_item_init (GtkSeparatorToolItem *separator_item) { separator_item->priv = GTK_SEPARATOR_TOOL_ITEM_GET_PRIVATE (separator_item); separator_item->priv->draw = TRUE; diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c index 05e300e43a..17f96a6dd2 100644 --- a/gtk/gtksettings.c +++ b/gtk/gtksettings.c @@ -97,8 +97,6 @@ enum { /* --- prototypes --- */ -static void gtk_settings_init (GtkSettings *settings); -static void gtk_settings_class_init (GtkSettingsClass *class); static void gtk_settings_finalize (GObject *object); static void gtk_settings_get_property (GObject *object, guint property_id, @@ -131,40 +129,14 @@ static GHashTable *get_color_hash (GtkSettings *setting /* --- variables --- */ -static gpointer parent_class = NULL; static GQuark quark_property_parser = 0; static GSList *object_list = NULL; static guint class_n_properties = 0; -/* --- functions --- */ -GType -gtk_settings_get_type (void) -{ - static GType settings_type = 0; - - if (!settings_type) - { - static const GTypeInfo settings_info = - { - sizeof (GtkSettingsClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_settings_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkSettings), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_settings_init, - }; - - settings_type = g_type_register_static (G_TYPE_OBJECT, I_("GtkSettings"), - &settings_info, 0); - } - - return settings_type; -} +G_DEFINE_TYPE (GtkSettings, gtk_settings, G_TYPE_OBJECT); +/* --- functions --- */ static void gtk_settings_init (GtkSettings *settings) { @@ -207,8 +179,6 @@ gtk_settings_class_init (GtkSettingsClass *class) GObjectClass *gobject_class = G_OBJECT_CLASS (class); guint result; - parent_class = g_type_class_peek_parent (class); - gobject_class->finalize = gtk_settings_finalize; gobject_class->get_property = gtk_settings_get_property; gobject_class->set_property = gtk_settings_set_property; @@ -556,7 +526,7 @@ gtk_settings_finalize (GObject *object) g_datalist_clear (&settings->queued_settings); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_settings_parent_class)->finalize (object); } /** diff --git a/gtk/gtksizegroup.c b/gtk/gtksizegroup.c index d66586c886..8e38934c06 100644 --- a/gtk/gtksizegroup.c +++ b/gtk/gtksizegroup.c @@ -268,8 +268,7 @@ gtk_size_group_class_init (GtkSizeGroupClass *klass) P_("The directions in which the size group affects the requested sizes" " of its component widgets"), GTK_TYPE_SIZE_GROUP_MODE, - GTK_SIZE_GROUP_HORIZONTAL, - GTK_PARAM_READWRITE)); + GTK_SIZE_GROUP_HORIZONTAL, GTK_PARAM_READWRITE)); /** * GtkSizeGroup:ignore-hidden: @@ -302,32 +301,7 @@ gtk_size_group_init (GtkSizeGroup *size_group) size_group->ignore_hidden = 0; } -GType -gtk_size_group_get_type (void) -{ - static GType size_group_type = 0; - - if (!size_group_type) - { - static const GTypeInfo size_group_info = - { - sizeof (GtkSizeGroupClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_size_group_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkSizeGroup), - 16, /* n_preallocs */ - (GInstanceInitFunc) gtk_size_group_init, - }; - - size_group_type = g_type_register_static (G_TYPE_OBJECT, I_("GtkSizeGroup"), - &size_group_info, 0); - } - - return size_group_type; -} +G_DEFINE_TYPE (GtkSizeGroup, gtk_size_group, G_TYPE_OBJECT); static void gtk_size_group_set_property (GObject *object, diff --git a/gtk/gtksocket.c b/gtk/gtksocket.c index d15ad80795..fc65323ff8 100644 --- a/gtk/gtksocket.c +++ b/gtk/gtksocket.c @@ -43,8 +43,6 @@ /* Forward declararations */ -static void gtk_socket_class_init (GtkSocketClass *klass); -static void gtk_socket_init (GtkSocket *socket); static void gtk_socket_finalize (GObject *object); static void gtk_socket_notify (GObject *object, GParamSpec *pspec); @@ -86,8 +84,6 @@ enum { static guint socket_signals[LAST_SIGNAL] = { 0 }; -static GtkWidgetClass *parent_class = NULL; - /** * _gtk_socket_get_private: * @@ -101,33 +97,8 @@ _gtk_socket_get_private (GtkSocket *socket) { return G_TYPE_INSTANCE_GET_PRIVATE (socket, GTK_TYPE_SOCKET, GtkSocketPrivate); } - -GType -gtk_socket_get_type (void) -{ - static GType socket_type = 0; - - if (!socket_type) - { - static const GTypeInfo socket_info = - { - sizeof (GtkSocketClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_socket_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkSocket), - 16, /* n_preallocs */ - (GInstanceInitFunc) gtk_socket_init, - }; - - socket_type = g_type_register_static (GTK_TYPE_CONTAINER, I_("GtkSocket"), - &socket_info, 0); - } - return socket_type; -} +G_DEFINE_TYPE (GtkSocket, gtk_socket, GTK_TYPE_CONTAINER); static void gtk_socket_finalize (GObject *object) @@ -137,7 +108,7 @@ gtk_socket_finalize (GObject *object) g_object_unref (socket->accel_group); socket->accel_group = NULL; - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_socket_parent_class)->finalize (object); } static void @@ -151,8 +122,6 @@ gtk_socket_class_init (GtkSocketClass *class) widget_class = (GtkWidgetClass*) class; container_class = (GtkContainerClass*) class; - parent_class = g_type_class_peek_parent (class); - gobject_class->finalize = gtk_socket_finalize; gobject_class->notify = gtk_socket_notify; @@ -406,8 +375,8 @@ gtk_socket_unrealize (GtkWidget *widget) _gtk_socket_end_embedding (socket); } - if (GTK_WIDGET_CLASS (parent_class)->unrealize) - (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); + if (GTK_WIDGET_CLASS (gtk_socket_parent_class)->unrealize) + (* GTK_WIDGET_CLASS (gtk_socket_parent_class)->unrealize) (widget); } static void diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c index cc2a7eaa8c..fe832aa7ba 100644 --- a/gtk/gtkspinbutton.c +++ b/gtk/gtkspinbutton.c @@ -72,9 +72,7 @@ enum LAST_SIGNAL }; -static void gtk_spin_button_class_init (GtkSpinButtonClass *klass); static void gtk_spin_button_editable_init (GtkEditableClass *iface); -static void gtk_spin_button_init (GtkSpinButton *spin_button); static void gtk_spin_button_finalize (GObject *object); static void gtk_spin_button_destroy (GtkObject *object); static void gtk_spin_button_set_property (GObject *object, @@ -142,48 +140,13 @@ static gint spin_button_get_shadow_type (GtkSpinButton *spin_button); static void spin_button_redraw (GtkSpinButton *spin_button); -static GtkEntryClass *parent_class = NULL; static guint spinbutton_signals[LAST_SIGNAL] = {0}; #define NO_ARROW 2 -GType -gtk_spin_button_get_type (void) -{ - static GType spin_button_type = 0; - - if (!spin_button_type) - { - static const GTypeInfo spin_button_info = - { - sizeof (GtkSpinButtonClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_spin_button_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkSpinButton), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_spin_button_init, - }; - - static const GInterfaceInfo editable_info = - { - (GInterfaceInitFunc) gtk_spin_button_editable_init, /* interface_init */ - NULL, /* interface_finalize */ - NULL /* interface_data */ - }; - - spin_button_type = - g_type_register_static (GTK_TYPE_ENTRY, I_("GtkSpinButton"), - &spin_button_info, 0); - - g_type_add_interface_static (spin_button_type, - GTK_TYPE_EDITABLE, - &editable_info); - } - return spin_button_type; -} +G_DEFINE_TYPE_WITH_CODE (GtkSpinButton, gtk_spin_button, GTK_TYPE_ENTRY, + G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE, + gtk_spin_button_editable_init)); #define add_spin_binding(binding_set, keyval, mask, scroll) \ gtk_binding_entry_add_signal (binding_set, keyval, mask, \ @@ -203,8 +166,6 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class) widget_class = (GtkWidgetClass*) class; entry_class = (GtkEntryClass*) class; - parent_class = g_type_class_peek_parent (class); - gobject_class->finalize = gtk_spin_button_finalize; gobject_class->set_property = gtk_spin_button_set_property; @@ -512,7 +473,7 @@ gtk_spin_button_finalize (GObject *object) { gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON (object), NULL); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_spin_button_parent_class)->finalize (object); } static void @@ -520,7 +481,7 @@ gtk_spin_button_destroy (GtkObject *object) { gtk_spin_button_stop_spinning (GTK_SPIN_BUTTON (object)); - GTK_OBJECT_CLASS (parent_class)->destroy (object); + GTK_OBJECT_CLASS (gtk_spin_button_parent_class)->destroy (object); } static void @@ -528,7 +489,7 @@ gtk_spin_button_map (GtkWidget *widget) { if (GTK_WIDGET_REALIZED (widget) && !GTK_WIDGET_MAPPED (widget)) { - GTK_WIDGET_CLASS (parent_class)->map (widget); + GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->map (widget); gdk_window_show (GTK_SPIN_BUTTON (widget)->panel); } } @@ -541,7 +502,7 @@ gtk_spin_button_unmap (GtkWidget *widget) gtk_spin_button_stop_spinning (GTK_SPIN_BUTTON (widget)); gdk_window_hide (GTK_SPIN_BUTTON (widget)->panel); - GTK_WIDGET_CLASS (parent_class)->unmap (widget); + GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->unmap (widget); } } @@ -562,7 +523,7 @@ gtk_spin_button_realize (GtkWidget *widget) widget->allocation.width -= arrow_size + 2 * widget->style->xthickness; gtk_widget_set_events (widget, gtk_widget_get_events (widget) | GDK_KEY_RELEASE_MASK); - GTK_WIDGET_CLASS (parent_class)->realize (widget); + GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->realize (widget); widget->allocation.width = real_width; @@ -604,7 +565,7 @@ gtk_spin_button_unrealize (GtkWidget *widget) { GtkSpinButton *spin = GTK_SPIN_BUTTON (widget); - GTK_WIDGET_CLASS (parent_class)->unrealize (widget); + GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->unrealize (widget); if (spin->panel) { @@ -649,7 +610,7 @@ gtk_spin_button_size_request (GtkWidget *widget, spin_button = GTK_SPIN_BUTTON (widget); arrow_size = spin_button_get_arrow_size (spin_button); - GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition); + GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->size_request (widget, requisition); if (entry->width_chars < 0) { @@ -743,7 +704,7 @@ gtk_spin_button_size_allocate (GtkWidget *widget, panel_allocation.y = allocation->y + (allocation->height - panel_allocation.height) / 2; - GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, &entry_allocation); + GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->size_allocate (widget, &entry_allocation); if (GTK_WIDGET_REALIZED (widget)) { @@ -774,7 +735,7 @@ gtk_spin_button_expose (GtkWidget *widget, GdkRectangle rect; if (event->window != spin->panel) - GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); + GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->expose_event (widget, event); /* we redraw the panel even if it wasn't exposed. This is * because spin->panel is not a child window of widget->window, @@ -983,7 +944,7 @@ gtk_spin_button_focus_out (GtkWidget *widget, if (GTK_ENTRY (widget)->editable) gtk_spin_button_update (GTK_SPIN_BUTTON (widget)); - return GTK_WIDGET_CLASS (parent_class)->focus_out_event (widget, event); + return GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->focus_out_event (widget, event); } static void @@ -1121,7 +1082,7 @@ gtk_spin_button_button_press (GtkWidget *widget, return TRUE; } else - return GTK_WIDGET_CLASS (parent_class)->button_press_event (widget, event); + return GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->button_press_event (widget, event); } return FALSE; } @@ -1172,7 +1133,7 @@ gtk_spin_button_button_release (GtkWidget *widget, return TRUE; } else - return GTK_WIDGET_CLASS (parent_class)->button_release_event (widget, event); + return GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->button_release_event (widget, event); } static gint @@ -1206,7 +1167,7 @@ gtk_spin_button_motion_notify (GtkWidget *widget, return FALSE; } - return GTK_WIDGET_CLASS (parent_class)->motion_notify_event (widget, event); + return GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->motion_notify_event (widget, event); } static gint @@ -1408,7 +1369,7 @@ gtk_spin_button_activate (GtkEntry *entry) gtk_spin_button_update (GTK_SPIN_BUTTON (entry)); /* Chain up so that entry->activates_default is honored */ - parent_class->activate (entry); + GTK_ENTRY_CLASS (gtk_spin_button_parent_class)->activate (entry); } static void @@ -1419,7 +1380,7 @@ gtk_spin_button_insert_text (GtkEditable *editable, { GtkEntry *entry = GTK_ENTRY (editable); GtkSpinButton *spin = GTK_SPIN_BUTTON (editable); - GtkEditableClass *parent_editable_iface = g_type_interface_peek (parent_class, GTK_TYPE_EDITABLE); + GtkEditableClass *parent_editable_iface = g_type_interface_peek (gtk_spin_button_parent_class, GTK_TYPE_EDITABLE); if (spin->numeric) { diff --git a/gtk/gtkstatusbar.c b/gtk/gtkstatusbar.c index 73c693ac20..22a4481129 100644 --- a/gtk/gtkstatusbar.c +++ b/gtk/gtkstatusbar.c @@ -57,8 +57,6 @@ enum PROP_HAS_RESIZE_GRIP }; -static void gtk_statusbar_class_init (GtkStatusbarClass *class); -static void gtk_statusbar_init (GtkStatusbar *statusbar); static void gtk_statusbar_destroy (GtkObject *object); static void gtk_statusbar_update (GtkStatusbar *statusbar, guint context_id, @@ -94,35 +92,9 @@ static void label_selectable_changed (GtkWidget *label, gpointer data); -static GtkContainerClass *parent_class; static guint statusbar_signals[SIGNAL_LAST] = { 0 }; -GType -gtk_statusbar_get_type (void) -{ - static GType statusbar_type = 0; - - if (!statusbar_type) - { - static const GTypeInfo statusbar_info = - { - sizeof (GtkStatusbarClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_statusbar_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkStatusbar), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_statusbar_init, - }; - - statusbar_type = g_type_register_static (GTK_TYPE_HBOX, I_("GtkStatusbar"), - &statusbar_info, 0); - } - - return statusbar_type; -} +G_DEFINE_TYPE (GtkStatusbar, gtk_statusbar, GTK_TYPE_HBOX); static void gtk_statusbar_class_init (GtkStatusbarClass *class) @@ -135,8 +107,6 @@ gtk_statusbar_class_init (GtkStatusbarClass *class) object_class = (GtkObjectClass *) class; widget_class = (GtkWidgetClass *) class; - parent_class = g_type_class_peek_parent (class); - gobject_class->set_property = gtk_statusbar_set_property; gobject_class->get_property = gtk_statusbar_get_property; @@ -462,7 +432,7 @@ gtk_statusbar_destroy (GtkObject *object) g_slist_free (statusbar->keys); statusbar->keys = NULL; - GTK_OBJECT_CLASS (parent_class)->destroy (object); + GTK_OBJECT_CLASS (gtk_statusbar_parent_class)->destroy (object); } static void @@ -622,7 +592,7 @@ gtk_statusbar_realize (GtkWidget *widget) statusbar = GTK_STATUSBAR (widget); - (* GTK_WIDGET_CLASS (parent_class)->realize) (widget); + (* GTK_WIDGET_CLASS (gtk_statusbar_parent_class)->realize) (widget); if (statusbar->has_resize_grip) gtk_statusbar_create_window (statusbar); @@ -638,7 +608,7 @@ gtk_statusbar_unrealize (GtkWidget *widget) if (statusbar->grip_window) gtk_statusbar_destroy_window (statusbar); - (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); + (* GTK_WIDGET_CLASS (gtk_statusbar_parent_class)->unrealize) (widget); } static void @@ -648,7 +618,7 @@ gtk_statusbar_map (GtkWidget *widget) statusbar = GTK_STATUSBAR (widget); - (* GTK_WIDGET_CLASS (parent_class)->map) (widget); + (* GTK_WIDGET_CLASS (gtk_statusbar_parent_class)->map) (widget); if (statusbar->grip_window) gdk_window_show (statusbar->grip_window); @@ -664,7 +634,7 @@ gtk_statusbar_unmap (GtkWidget *widget) if (statusbar->grip_window) gdk_window_hide (statusbar->grip_window); - (* GTK_WIDGET_CLASS (parent_class)->unmap) (widget); + (* GTK_WIDGET_CLASS (gtk_statusbar_parent_class)->unmap) (widget); } static gboolean @@ -715,7 +685,7 @@ gtk_statusbar_expose_event (GtkWidget *widget, statusbar = GTK_STATUSBAR (widget); - GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); + GTK_WIDGET_CLASS (gtk_statusbar_parent_class)->expose_event (widget, event); if (statusbar->has_resize_grip) { @@ -755,7 +725,7 @@ gtk_statusbar_size_request (GtkWidget *widget, gtk_widget_style_get (GTK_WIDGET (statusbar), "shadow-type", &shadow_type, NULL); gtk_frame_set_shadow_type (GTK_FRAME (statusbar->frame), shadow_type); - GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition); + GTK_WIDGET_CLASS (gtk_statusbar_parent_class)->size_request (widget, requisition); } /* look for extra children between the frame containing @@ -821,7 +791,7 @@ gtk_statusbar_size_allocate (GtkWidget *widget, } /* chain up normally */ - GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation); + GTK_WIDGET_CLASS (gtk_statusbar_parent_class)->size_allocate (widget, allocation); if (statusbar->has_resize_grip) { diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 6b5a42bd5e..092d1c150d 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -59,8 +59,6 @@ struct _GtkStylePrivate { }; /* --- prototypes --- */ -static void gtk_style_init (GtkStyle *style); -static void gtk_style_class_init (GtkStyleClass *klass); static void gtk_style_finalize (GObject *object); static void gtk_style_realize (GtkStyle *style, GdkColormap *colormap); @@ -355,39 +353,13 @@ static const GdkColor gtk_default_insensitive_bg = { 0, GTK_GRAY }; static const GdkColor gtk_default_selected_base = { 0, GTK_BLUE }; static const GdkColor gtk_default_active_base = { 0, GTK_VERY_DARK_GRAY }; -static gpointer parent_class = NULL; - /* --- signals --- */ static guint realize_signal = 0; static guint unrealize_signal = 0; +G_DEFINE_TYPE (GtkStyle, gtk_style, G_TYPE_OBJECT); + /* --- functions --- */ -GType -gtk_style_get_type (void) -{ - static GType style_type = 0; - - if (!style_type) - { - static const GTypeInfo style_info = - { - sizeof (GtkStyleClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gtk_style_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkStyle), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_style_init, - }; - - style_type = g_type_register_static (G_TYPE_OBJECT, I_("GtkStyle"), - &style_info, 0); - } - - return style_type; -} /** * _gtk_style_init_for_settings: @@ -505,8 +477,6 @@ gtk_style_class_init (GtkStyleClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); - object_class->finalize = gtk_style_finalize; klass->clone = gtk_style_real_clone; @@ -649,7 +619,7 @@ gtk_style_finalize (GObject *object) if (style->rc_style) gtk_rc_style_unref (style->rc_style); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_style_parent_class)->finalize (object); } diff --git a/gtk/gtktable.c b/gtk/gtktable.c index 2ab0054df8..05035356e3 100644 --- a/gtk/gtktable.c +++ b/gtk/gtktable.c @@ -54,8 +54,6 @@ enum }; -static void gtk_table_class_init (GtkTableClass *klass); -static void gtk_table_init (GtkTable *table); static void gtk_table_finalize (GObject *object); static void gtk_table_size_request (GtkWidget *widget, GtkRequisition *requisition); @@ -100,35 +98,7 @@ static void gtk_table_size_allocate_pass1 (GtkTable *table); static void gtk_table_size_allocate_pass2 (GtkTable *table); -static GtkContainerClass *parent_class = NULL; - - -GType -gtk_table_get_type (void) -{ - static GType table_type = 0; - - if (!table_type) - { - static const GTypeInfo table_info = - { - sizeof (GtkTableClass), - NULL, - NULL, - (GClassInitFunc) gtk_table_class_init, - NULL, - NULL, - sizeof (GtkTable), - 0, - (GInstanceInitFunc) gtk_table_init, - }; - - table_type = g_type_register_static (GTK_TYPE_CONTAINER, I_("GtkTable"), - &table_info, 0); - } - - return table_type; -} +G_DEFINE_TYPE (GtkTable, gtk_table, GTK_TYPE_CONTAINER); static void gtk_table_class_init (GtkTableClass *class) @@ -137,8 +107,6 @@ gtk_table_class_init (GtkTableClass *class) GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class); GtkContainerClass *container_class = GTK_CONTAINER_CLASS (class); - parent_class = g_type_class_peek_parent (class); - gobject_class->finalize = gtk_table_finalize; gobject_class->get_property = gtk_table_get_property; @@ -839,7 +807,7 @@ gtk_table_finalize (GObject *object) g_free (table->rows); g_free (table->cols); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_table_parent_class)->finalize (object); } static void diff --git a/gtk/gtktearoffmenuitem.c b/gtk/gtktearoffmenuitem.c index c41af0aaaf..6e07fc3703 100644 --- a/gtk/gtktearoffmenuitem.c +++ b/gtk/gtktearoffmenuitem.c @@ -35,8 +35,6 @@ #define TEAR_LENGTH 5 #define BORDER_SPACING 3 -static void gtk_tearoff_menu_item_class_init (GtkTearoffMenuItemClass *klass); -static void gtk_tearoff_menu_item_init (GtkTearoffMenuItem *tearoff_menu_item); static void gtk_tearoff_menu_item_size_request (GtkWidget *widget, GtkRequisition *requisition); static gint gtk_tearoff_menu_item_expose (GtkWidget *widget, @@ -45,33 +43,7 @@ static void gtk_tearoff_menu_item_activate (GtkMenuItem *menu_item); static void gtk_tearoff_menu_item_parent_set (GtkWidget *widget, GtkWidget *previous); -GType -gtk_tearoff_menu_item_get_type (void) -{ - static GType tearoff_menu_item_type = 0; - - if (!tearoff_menu_item_type) - { - static const GTypeInfo tearoff_menu_item_info = - { - sizeof (GtkTearoffMenuItemClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_tearoff_menu_item_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkTearoffMenuItem), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_tearoff_menu_item_init, - }; - - tearoff_menu_item_type = - g_type_register_static (GTK_TYPE_MENU_ITEM, I_("GtkTearoffMenuItem"), - &tearoff_menu_item_info, 0); - } - - return tearoff_menu_item_type; -} +G_DEFINE_TYPE (GtkTearoffMenuItem, gtk_tearoff_menu_item, GTK_TYPE_MENU_ITEM); GtkWidget* gtk_tearoff_menu_item_new (void) diff --git a/gtk/gtktextbuffer.c b/gtk/gtktextbuffer.c index 628686c8b5..b9f2f7acb9 100644 --- a/gtk/gtktextbuffer.c +++ b/gtk/gtktextbuffer.c @@ -99,8 +99,6 @@ enum { PROP_PASTE_TARGET_LIST }; -static void gtk_text_buffer_init (GtkTextBuffer *tkxt_buffer); -static void gtk_text_buffer_class_init (GtkTextBufferClass *klass); static void gtk_text_buffer_finalize (GObject *object); static void gtk_text_buffer_real_insert_text (GtkTextBuffer *buffer, @@ -139,7 +137,6 @@ static GtkTextBuffer *create_clipboard_contents_buffer (GtkTextBuffer *buffer); static void gtk_text_buffer_free_target_lists (GtkTextBuffer *buffer); -static GObjectClass *parent_class = NULL; static guint signals[LAST_SIGNAL] = { 0 }; static void gtk_text_buffer_set_property (GObject *object, @@ -153,41 +150,13 @@ static void gtk_text_buffer_get_property (GObject *object, static void gtk_text_buffer_notify (GObject *object, GParamSpec *pspec); - -GType -gtk_text_buffer_get_type (void) -{ - static GType our_type = 0; - - if (our_type == 0) - { - static const GTypeInfo our_info = - { - sizeof (GtkTextBufferClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gtk_text_buffer_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkTextBuffer), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_text_buffer_init - }; - - our_type = g_type_register_static (G_TYPE_OBJECT, I_("GtkTextBuffer"), - &our_info, 0); - } - - return our_type; -} +G_DEFINE_TYPE (GtkTextBuffer, gtk_text_buffer, G_TYPE_OBJECT); static void gtk_text_buffer_class_init (GtkTextBufferClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); - object_class->finalize = gtk_text_buffer_finalize; object_class->set_property = gtk_text_buffer_set_property; object_class->get_property = gtk_text_buffer_get_property; @@ -598,7 +567,7 @@ gtk_text_buffer_finalize (GObject *object) gtk_text_buffer_free_target_lists (buffer); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_text_buffer_parent_class)->finalize (object); } static GtkTextBTree* diff --git a/gtk/gtktextchild.c b/gtk/gtktextchild.c index 5fd0d72108..a63f98074f 100644 --- a/gtk/gtktextchild.c +++ b/gtk/gtktextchild.c @@ -304,38 +304,9 @@ _gtk_anchored_child_set_layout (GtkWidget *child, layout); } -static void gtk_text_child_anchor_init (GtkTextChildAnchor *child_anchor); -static void gtk_text_child_anchor_class_init (GtkTextChildAnchorClass *klass); -static void gtk_text_child_anchor_finalize (GObject *obj); +static void gtk_text_child_anchor_finalize (GObject *obj); -static gpointer parent_class = NULL; - -GType -gtk_text_child_anchor_get_type (void) -{ - static GType object_type = 0; - - if (!object_type) - { - static const GTypeInfo object_info = - { - sizeof (GtkTextChildAnchorClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gtk_text_child_anchor_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkTextChildAnchor), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_text_child_anchor_init, - }; - - object_type = g_type_register_static (G_TYPE_OBJECT, I_("GtkTextChildAnchor"), - &object_info, 0); - } - - return object_type; -} +G_DEFINE_TYPE (GtkTextChildAnchor, gtk_text_child_anchor, G_TYPE_OBJECT); static void gtk_text_child_anchor_init (GtkTextChildAnchor *child_anchor) @@ -348,8 +319,6 @@ gtk_text_child_anchor_class_init (GtkTextChildAnchorClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); - object_class->finalize = gtk_text_child_anchor_finalize; } @@ -404,7 +373,7 @@ gtk_text_child_anchor_finalize (GObject *obj) anchor->segment = NULL; - G_OBJECT_CLASS (parent_class)->finalize (obj); + G_OBJECT_CLASS (gtk_text_child_anchor_parent_class)->finalize (obj); } /** diff --git a/gtk/gtktextlayout.c b/gtk/gtktextlayout.c index 1077573fce..f96b9c2736 100644 --- a/gtk/gtktextlayout.c +++ b/gtk/gtktextlayout.c @@ -155,50 +155,19 @@ enum { #define PIXEL_BOUND(d) (((d) + PANGO_SCALE - 1) / PANGO_SCALE) -static void gtk_text_layout_init (GtkTextLayout *text_layout); -static void gtk_text_layout_class_init (GtkTextLayoutClass *klass); -static void gtk_text_layout_finalize (GObject *object); +static void gtk_text_layout_finalize (GObject *object); - -static GtkObjectClass *parent_class = NULL; static guint signals[LAST_SIGNAL] = { 0 }; PangoAttrType gtk_text_attr_appearance_type = 0; -GType -gtk_text_layout_get_type (void) -{ - static GType our_type = 0; - - if (our_type == 0) - { - static const GTypeInfo our_info = - { - sizeof (GtkTextLayoutClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gtk_text_layout_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkTextLayout), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_text_layout_init - }; - - our_type = g_type_register_static (G_TYPE_OBJECT, I_("GtkTextLayout"), - &our_info, 0); - } - - return our_type; -} +G_DEFINE_TYPE (GtkTextLayout, gtk_text_layout, G_TYPE_OBJECT); static void gtk_text_layout_class_init (GtkTextLayoutClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); - object_class->finalize = gtk_text_layout_finalize; klass->wrap = gtk_text_layout_real_wrap; @@ -310,7 +279,7 @@ gtk_text_layout_finalize (GObject *object) } - (* G_OBJECT_CLASS (parent_class)->finalize) (object); + (* G_OBJECT_CLASS (gtk_text_layout_parent_class)->finalize) (object); } void diff --git a/gtk/gtktextmark.c b/gtk/gtktextmark.c index 4961b8d50b..dd6b543113 100644 --- a/gtk/gtktextmark.c +++ b/gtk/gtktextmark.c @@ -53,39 +53,9 @@ #include "gtkintl.h" #include "gtkalias.h" -static void gtk_text_mark_init (GtkTextMark *mark); -static void gtk_text_mark_class_init (GtkTextMarkClass *klass); -static void gtk_text_mark_finalize (GObject *obj); +static void gtk_text_mark_finalize (GObject *obj); - -static gpointer parent_class = NULL; - -GType -gtk_text_mark_get_type (void) -{ - static GType object_type = 0; - - if (!object_type) - { - static const GTypeInfo object_info = - { - sizeof (GtkTextMarkClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gtk_text_mark_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkTextMark), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_text_mark_init, - }; - - object_type = g_type_register_static (G_TYPE_OBJECT, I_("GtkTextMark"), - &object_info, 0); - } - - return object_type; -} +G_DEFINE_TYPE (GtkTextMark, gtk_text_mark, G_TYPE_OBJECT); static void gtk_text_mark_init (GtkTextMark *mark) @@ -98,8 +68,6 @@ gtk_text_mark_class_init (GtkTextMarkClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); - object_class->finalize = gtk_text_mark_finalize; } @@ -127,7 +95,7 @@ gtk_text_mark_finalize (GObject *obj) } /* chain parent_class' handler */ - G_OBJECT_CLASS (parent_class)->finalize (obj); + G_OBJECT_CLASS (gtk_text_mark_parent_class)->finalize (obj); } /** diff --git a/gtk/gtktexttag.c b/gtk/gtktexttag.c index d19831e502..26ce902fd9 100644 --- a/gtk/gtktexttag.c +++ b/gtk/gtktexttag.c @@ -140,8 +140,6 @@ enum { LAST_ARG }; -static void gtk_text_tag_init (GtkTextTag *text_tag); -static void gtk_text_tag_class_init (GtkTextTagClass *klass); static void gtk_text_tag_finalize (GObject *object); static void gtk_text_tag_set_property (GObject *object, guint prop_id, @@ -152,43 +150,15 @@ static void gtk_text_tag_get_property (GObject *object, GValue *value, GParamSpec *pspec); -static GObjectClass *parent_class = NULL; static guint signals[LAST_SIGNAL] = { 0 }; -GType -gtk_text_tag_get_type (void) -{ - static GType our_type = 0; - - if (our_type == 0) - { - static const GTypeInfo our_info = - { - sizeof (GtkTextTagClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gtk_text_tag_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkTextTag), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_text_tag_init - }; - - our_type = g_type_register_static (G_TYPE_OBJECT, I_("GtkTextTag"), - &our_info, 0); - } - - return our_type; -} +G_DEFINE_TYPE (GtkTextTag, gtk_text_tag, G_TYPE_OBJECT); static void gtk_text_tag_class_init (GtkTextTagClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); - object_class->set_property = gtk_text_tag_set_property; object_class->get_property = gtk_text_tag_get_property; @@ -740,7 +710,7 @@ gtk_text_tag_finalize (GObject *object) g_free (text_tag->name); text_tag->name = NULL; - (* G_OBJECT_CLASS (parent_class)->finalize) (object); + (* G_OBJECT_CLASS (gtk_text_tag_parent_class)->finalize) (object); } static void diff --git a/gtk/gtktexttagtable.c b/gtk/gtktexttagtable.c index 6b54fecad1..85642f3428 100644 --- a/gtk/gtktexttagtable.c +++ b/gtk/gtktexttagtable.c @@ -44,8 +44,6 @@ enum { LAST_ARG }; -static void gtk_text_tag_table_init (GtkTextTagTable *table); -static void gtk_text_tag_table_class_init (GtkTextTagTableClass *klass); static void gtk_text_tag_table_finalize (GObject *object); static void gtk_text_tag_table_set_property (GObject *object, guint prop_id, @@ -56,43 +54,15 @@ static void gtk_text_tag_table_get_property (GObject *object, GValue *value, GParamSpec *pspec); -static GObjectClass *parent_class = NULL; static guint signals[LAST_SIGNAL] = { 0 }; -GType -gtk_text_tag_table_get_type (void) -{ - static GType our_type = 0; - - if (our_type == 0) - { - static const GTypeInfo our_info = - { - sizeof (GtkTextTagTableClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gtk_text_tag_table_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkTextTagTable), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_text_tag_table_init - }; - - our_type = g_type_register_static (G_TYPE_OBJECT, I_("GtkTextTagTable"), - &our_info, 0); - } - - return our_type; -} +G_DEFINE_TYPE (GtkTextTagTable, gtk_text_tag_table, G_TYPE_OBJECT); static void gtk_text_tag_table_class_init (GtkTextTagTableClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); - object_class->set_property = gtk_text_tag_table_set_property; object_class->get_property = gtk_text_tag_table_get_property; @@ -193,7 +163,7 @@ gtk_text_tag_table_finalize (GObject *object) g_slist_free (table->buffers); - (* G_OBJECT_CLASS (parent_class)->finalize) (object); + (* G_OBJECT_CLASS (gtk_text_tag_table_parent_class)->finalize) (object); } static void gtk_text_tag_table_set_property (GObject *object, diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index c8004f915c..ad5825994a 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -149,8 +149,6 @@ enum LAST_PROP }; -static void gtk_text_view_init (GtkTextView *text_view); -static void gtk_text_view_class_init (GtkTextViewClass *klass); static void gtk_text_view_destroy (GtkObject *object); static void gtk_text_view_finalize (GObject *object); static void gtk_text_view_set_property (GObject *object, @@ -418,35 +416,9 @@ static gint text_window_get_width (GtkTextWindow *win); static gint text_window_get_height (GtkTextWindow *win); -static GtkContainerClass *parent_class = NULL; static guint signals[LAST_SIGNAL] = { 0 }; -GType -gtk_text_view_get_type (void) -{ - static GType our_type = 0; - - if (our_type == 0) - { - static const GTypeInfo our_info = - { - sizeof (GtkTextViewClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_text_view_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkTextView), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_text_view_init, - }; - - our_type = g_type_register_static (GTK_TYPE_CONTAINER, I_("GtkTextView"), - &our_info, 0); - } - - return our_type; -} +G_DEFINE_TYPE (GtkTextView, gtk_text_view, GTK_TYPE_CONTAINER); static void add_move_binding (GtkBindingSet *binding_set, @@ -480,8 +452,6 @@ gtk_text_view_class_init (GtkTextViewClass *klass) GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass); GtkBindingSet *binding_set; - parent_class = g_type_class_peek_parent (klass); - /* Default handlers and virtual methods */ gobject_class->set_property = gtk_text_view_set_property; @@ -2569,7 +2539,7 @@ gtk_text_view_destroy (GtkObject *object) gtk_text_view_set_buffer (text_view, NULL); gtk_text_view_destroy_layout (text_view); - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); + (* GTK_OBJECT_CLASS (gtk_text_view_parent_class)->destroy) (object); } static void @@ -2610,7 +2580,7 @@ gtk_text_view_finalize (GObject *object) g_object_unref (text_view->im_context); - (* G_OBJECT_CLASS (parent_class)->finalize) (object); + (* G_OBJECT_CLASS (gtk_text_view_parent_class)->finalize) (object); } static void @@ -3579,7 +3549,7 @@ gtk_text_view_unrealize (GtkWidget *widget) gtk_text_view_destroy_layout (text_view); - (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); + (* GTK_WIDGET_CLASS (gtk_text_view_parent_class)->unrealize) (widget); } static void @@ -3880,8 +3850,8 @@ gtk_text_view_key_press_event (GtkWidget *widget, GdkEventKey *event) retval = TRUE; } /* Binding set */ - else if (GTK_WIDGET_CLASS (parent_class)->key_press_event && - GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, event)) + else if (GTK_WIDGET_CLASS (gtk_text_view_parent_class)->key_press_event && + GTK_WIDGET_CLASS (gtk_text_view_parent_class)->key_press_event (widget, event)) retval = TRUE; /* use overall editability not can_insert, more predictable for users */ else if (text_view->editable && @@ -3948,7 +3918,7 @@ gtk_text_view_key_release_event (GtkWidget *widget, GdkEventKey *event) return TRUE; } else - return GTK_WIDGET_CLASS (parent_class)->key_release_event (widget, event); + return GTK_WIDGET_CLASS (gtk_text_view_parent_class)->key_release_event (widget, event); } static gint @@ -4355,7 +4325,7 @@ gtk_text_view_focus (GtkWidget *widget, * children to get the focus */ GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS); - result = GTK_WIDGET_CLASS (parent_class)->focus (widget, direction); + result = GTK_WIDGET_CLASS (gtk_text_view_parent_class)->focus (widget, direction); GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS); return result; diff --git a/gtk/gtktoggleaction.c b/gtk/gtktoggleaction.c index 8d032c5469..826ec960ce 100644 --- a/gtk/gtktoggleaction.c +++ b/gtk/gtktoggleaction.c @@ -51,36 +51,7 @@ enum { PROP_ACTIVE }; -static void gtk_toggle_action_init (GtkToggleAction *action); -static void gtk_toggle_action_class_init (GtkToggleActionClass *class); - -GType -gtk_toggle_action_get_type (void) -{ - static GtkType type = 0; - - if (!type) - { - static const GTypeInfo type_info = - { - sizeof (GtkToggleActionClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gtk_toggle_action_class_init, - (GClassFinalizeFunc) NULL, - NULL, - - sizeof (GtkToggleAction), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_toggle_action_init, - }; - - type = g_type_register_static (GTK_TYPE_ACTION, - I_("GtkToggleAction"), - &type_info, 0); - } - return type; -} +G_DEFINE_TYPE (GtkToggleAction, gtk_toggle_action, GTK_TYPE_ACTION); static void gtk_toggle_action_activate (GtkAction *action); static void gtk_toggle_action_real_toggled (GtkToggleAction *action); diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c index 5552ec3a63..088198a7cc 100644 --- a/gtk/gtktogglebutton.c +++ b/gtk/gtktogglebutton.c @@ -50,8 +50,6 @@ enum { }; -static void gtk_toggle_button_class_init (GtkToggleButtonClass *klass); -static void gtk_toggle_button_init (GtkToggleButton *toggle_button); static gint gtk_toggle_button_expose (GtkWidget *widget, GdkEventExpose *event); static gboolean gtk_toggle_button_mnemonic_activate (GtkWidget *widget, @@ -70,35 +68,8 @@ static void gtk_toggle_button_get_property (GObject *object, static void gtk_toggle_button_update_state (GtkButton *button); static guint toggle_button_signals[LAST_SIGNAL] = { 0 }; -static GtkContainerClass *parent_class = NULL; -GType -gtk_toggle_button_get_type (void) -{ - static GType toggle_button_type = 0; - - if (!toggle_button_type) - { - static const GTypeInfo toggle_button_info = - { - sizeof (GtkToggleButtonClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_toggle_button_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkToggleButton), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_toggle_button_init, - }; - - toggle_button_type = - g_type_register_static (GTK_TYPE_BUTTON, I_("GtkToggleButton"), - &toggle_button_info, 0); - } - - return toggle_button_type; -} +G_DEFINE_TYPE (GtkToggleButton, gtk_toggle_button, GTK_TYPE_BUTTON); static void gtk_toggle_button_class_init (GtkToggleButtonClass *class) @@ -113,8 +84,6 @@ gtk_toggle_button_class_init (GtkToggleButtonClass *class) container_class = (GtkContainerClass*) class; button_class = (GtkButtonClass*) class; - parent_class = g_type_class_peek_parent (class); - gobject_class->set_property = gtk_toggle_button_set_property; gobject_class->get_property = gtk_toggle_button_get_property; diff --git a/gtk/gtktoggletoolbutton.c b/gtk/gtktoggletoolbutton.c index 1144ba2430..4d956e3562 100644 --- a/gtk/gtktoggletoolbutton.c +++ b/gtk/gtktoggletoolbutton.c @@ -50,8 +50,6 @@ struct _GtkToggleToolButtonPrivate guint active : 1; }; -static void gtk_toggle_tool_button_init (GtkToggleToolButton *button); -static void gtk_toggle_tool_button_class_init (GtkToggleToolButtonClass *klass); static void gtk_toggle_tool_button_set_property (GObject *object, guint prop_id, @@ -69,35 +67,9 @@ static void button_toggled (GtkWidget *widget, static void menu_item_activated (GtkWidget *widget, GtkToggleToolButton *button); -static GObjectClass *parent_class = NULL; static guint toggle_signals[LAST_SIGNAL] = { 0 }; -GType -gtk_toggle_tool_button_get_type (void) -{ - static GType type = 0; - - if (!type) - { - static const GTypeInfo type_info = - { - sizeof (GtkToggleToolButtonClass), - (GBaseInitFunc) 0, - (GBaseFinalizeFunc) 0, - (GClassInitFunc) gtk_toggle_tool_button_class_init, - (GClassFinalizeFunc) 0, - NULL, - sizeof (GtkToggleToolButton), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_toggle_tool_button_init - }; - - type = g_type_register_static (GTK_TYPE_TOOL_BUTTON, - I_("GtkToggleToolButton"), &type_info, 0); - } - return type; -} - +G_DEFINE_TYPE (GtkToggleToolButton, gtk_toggle_tool_button, GTK_TYPE_TOOL_BUTTON); static void gtk_toggle_tool_button_class_init (GtkToggleToolButtonClass *klass) @@ -106,8 +78,6 @@ gtk_toggle_tool_button_class_init (GtkToggleToolButtonClass *klass) GtkToolItemClass *toolitem_class; GtkToolButtonClass *toolbutton_class; - parent_class = g_type_class_peek_parent (klass); - object_class = (GObjectClass *)klass; toolitem_class = (GtkToolItemClass *)klass; toolbutton_class = (GtkToolButtonClass *)klass; diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c index 09146a445c..98535add88 100644 --- a/gtk/gtktoolbar.c +++ b/gtk/gtktoolbar.c @@ -153,8 +153,6 @@ struct _GtkToolbarPrivate guint animation : 1; }; -static void gtk_toolbar_init (GtkToolbar *toolbar); -static void gtk_toolbar_class_init (GtkToolbarClass *klass); static void gtk_toolbar_set_property (GObject *object, guint prop_id, const GValue *value, @@ -304,36 +302,9 @@ static void toolbar_content_set_expand (ToolbarContent *content, #define GTK_TOOLBAR_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_TOOLBAR, GtkToolbarPrivate)) -static GtkContainerClass * parent_class = NULL; static guint toolbar_signals [LAST_SIGNAL] = { 0 }; -GType -gtk_toolbar_get_type (void) -{ - static GtkType type = 0; - - if (!type) - { - static const GTypeInfo type_info = - { - sizeof (GtkToolbarClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gtk_toolbar_class_init, - (GClassFinalizeFunc) NULL, - NULL, - sizeof (GtkToolbar), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_toolbar_init, - }; - - type = g_type_register_static (GTK_TYPE_CONTAINER, - I_("GtkToolbar"), - &type_info, 0); - } - - return type; -} +G_DEFINE_TYPE (GtkToolbar, gtk_toolbar, GTK_TYPE_CONTAINER); static void add_arrow_bindings (GtkBindingSet *binding_set, @@ -373,8 +344,6 @@ gtk_toolbar_class_init (GtkToolbarClass *klass) GtkContainerClass *container_class; GtkBindingSet *binding_set; - parent_class = g_type_class_peek_parent (klass); - gobject_class = (GObjectClass *)klass; widget_class = (GtkWidgetClass *)klass; container_class = (GtkContainerClass *)klass; @@ -809,7 +778,7 @@ gtk_toolbar_map (GtkWidget *widget) { GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (widget); - GTK_WIDGET_CLASS (parent_class)->map (widget); + GTK_WIDGET_CLASS (gtk_toolbar_parent_class)->map (widget); if (priv->event_window) gdk_window_show_unraised (priv->event_window); @@ -823,7 +792,7 @@ gtk_toolbar_unmap (GtkWidget *widget) if (priv->event_window) gdk_window_hide (priv->event_window); - GTK_WIDGET_CLASS (parent_class)->unmap (widget); + GTK_WIDGET_CLASS (gtk_toolbar_parent_class)->unmap (widget); } static void @@ -875,8 +844,8 @@ gtk_toolbar_unrealize (GtkWidget *widget) priv->event_window = NULL; } - if (GTK_WIDGET_CLASS (parent_class)->unrealize) - (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); + if (GTK_WIDGET_CLASS (gtk_toolbar_parent_class)->unrealize) + (* GTK_WIDGET_CLASS (gtk_toolbar_parent_class)->unrealize) (widget); } static gint @@ -3200,7 +3169,7 @@ gtk_toolbar_finalize (GObject *object) if (priv->idle_id) g_source_remove (priv->idle_id); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_toolbar_parent_class)->finalize (object); } /** diff --git a/gtk/gtktoolbutton.c b/gtk/gtktoolbutton.c index 8ea3904be1..ee1183fdd3 100644 --- a/gtk/gtktoolbutton.c +++ b/gtk/gtktoolbutton.c @@ -101,24 +101,13 @@ gtk_tool_button_get_type (void) static GtkType type = 0; if (!type) - { - static const GTypeInfo type_info = - { - sizeof (GtkToolButtonClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gtk_tool_button_class_init, - (GClassFinalizeFunc) NULL, - NULL, - sizeof (GtkToolButton), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_tool_button_init, - }; - - type = g_type_register_static (GTK_TYPE_TOOL_ITEM, - I_("GtkToolButton"), - &type_info, 0); - } + 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); return type; } diff --git a/gtk/gtktoolitem.c b/gtk/gtktoolitem.c index a20c0a3455..cbd89264f8 100644 --- a/gtk/gtktoolitem.c +++ b/gtk/gtktoolitem.c @@ -66,8 +66,6 @@ struct _GtkToolItemPrivate GtkWidget *menu_item; }; -static void gtk_tool_item_init (GtkToolItem *toolitem); -static void gtk_tool_item_class_init (GtkToolItemClass *class); static void gtk_tool_item_finalize (GObject *object); static void gtk_tool_item_parent_set (GtkWidget *toolitem, GtkWidget *parent); @@ -97,36 +95,9 @@ static gboolean gtk_tool_item_real_set_tooltip (GtkToolItem *tool_item, static gboolean gtk_tool_item_create_menu_proxy (GtkToolItem *item); -static GObjectClass *parent_class = NULL; static guint toolitem_signals[LAST_SIGNAL] = { 0 }; -GType -gtk_tool_item_get_type (void) -{ - static GtkType type = 0; - - if (!type) - { - static const GTypeInfo type_info = - { - sizeof (GtkToolItemClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gtk_tool_item_class_init, - (GClassFinalizeFunc) NULL, - NULL, - - sizeof (GtkToolItem), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_tool_item_init, - }; - - type = g_type_register_static (GTK_TYPE_BIN, - I_("GtkToolItem"), - &type_info, 0); - } - return type; -} +G_DEFINE_TYPE (GtkToolItem, gtk_tool_item, GTK_TYPE_BIN); static void gtk_tool_item_class_init (GtkToolItemClass *klass) @@ -134,7 +105,6 @@ gtk_tool_item_class_init (GtkToolItemClass *klass) GObjectClass *object_class; GtkWidgetClass *widget_class; - parent_class = g_type_class_peek_parent (klass); object_class = (GObjectClass *)klass; widget_class = (GtkWidgetClass *)klass; @@ -290,8 +260,8 @@ gtk_tool_item_finalize (GObject *object) if (item->priv->menu_item) g_object_unref (item->priv->menu_item); - if (G_OBJECT_CLASS (parent_class)->finalize) - G_OBJECT_CLASS (parent_class)->finalize (object); + if (G_OBJECT_CLASS (gtk_tool_item_parent_class)->finalize) + G_OBJECT_CLASS (gtk_tool_item_parent_class)->finalize (object); } static void @@ -425,7 +395,7 @@ gtk_tool_item_unrealize (GtkWidget *widget) destroy_drag_window (toolitem); - GTK_WIDGET_CLASS (parent_class)->unrealize (widget); + GTK_WIDGET_CLASS (gtk_tool_item_parent_class)->unrealize (widget); } static void @@ -434,7 +404,7 @@ gtk_tool_item_map (GtkWidget *widget) GtkToolItem *toolitem; toolitem = GTK_TOOL_ITEM (widget); - GTK_WIDGET_CLASS (parent_class)->map (widget); + GTK_WIDGET_CLASS (gtk_tool_item_parent_class)->map (widget); if (toolitem->priv->drag_window) gdk_window_show (toolitem->priv->drag_window); } @@ -447,7 +417,7 @@ gtk_tool_item_unmap (GtkWidget *widget) toolitem = GTK_TOOL_ITEM (widget); if (toolitem->priv->drag_window) gdk_window_hide (toolitem->priv->drag_window); - GTK_WIDGET_CLASS (parent_class)->unmap (widget); + GTK_WIDGET_CLASS (gtk_tool_item_parent_class)->unmap (widget); } static void diff --git a/gtk/gtktooltips.c b/gtk/gtktooltips.c index be47d73036..1e8146b65b 100644 --- a/gtk/gtktooltips.c +++ b/gtk/gtktooltips.c @@ -49,8 +49,6 @@ * to normal */ -static void gtk_tooltips_class_init (GtkTooltipsClass *klass); -static void gtk_tooltips_init (GtkTooltips *tooltips); static void gtk_tooltips_destroy (GtkObject *object); static void gtk_tooltips_event_handler (GtkWidget *widget, @@ -69,36 +67,10 @@ static void gtk_tooltips_unset_tip_window (GtkTooltips *tooltips); static gboolean get_keyboard_mode (GtkWidget *widget); -static GtkObjectClass *parent_class; static const gchar tooltips_data_key[] = "_GtkTooltipsData"; static const gchar tooltips_info_key[] = "_GtkTooltipsInfo"; -GType -gtk_tooltips_get_type (void) -{ - static GType tooltips_type = 0; - - if (!tooltips_type) - { - static const GTypeInfo tooltips_info = - { - sizeof (GtkTooltipsClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_tooltips_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkTooltips), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_tooltips_init, - }; - - tooltips_type = g_type_register_static (GTK_TYPE_OBJECT, I_("GtkTooltips"), - &tooltips_info, 0); - } - - return tooltips_type; -} +G_DEFINE_TYPE (GtkTooltips, gtk_tooltips, GTK_TYPE_OBJECT); static void gtk_tooltips_class_init (GtkTooltipsClass *class) @@ -107,8 +79,6 @@ gtk_tooltips_class_init (GtkTooltipsClass *class) object_class = (GtkObjectClass*) class; - parent_class = g_type_class_peek_parent (class); - object_class->destroy = gtk_tooltips_destroy; } @@ -210,7 +180,7 @@ gtk_tooltips_destroy (GtkObject *object) gtk_tooltips_unset_tip_window (tooltips); - GTK_OBJECT_CLASS (parent_class)->destroy (object); + GTK_OBJECT_CLASS (gtk_tooltips_parent_class)->destroy (object); } static void diff --git a/gtk/gtktreednd.c b/gtk/gtktreednd.c index 49b0054727..1f5d99d2f4 100644 --- a/gtk/gtktreednd.c +++ b/gtk/gtktreednd.c @@ -43,7 +43,8 @@ gtk_tree_drag_source_get_type (void) NULL }; - our_type = g_type_register_static (G_TYPE_INTERFACE, I_("GtkTreeDragSource"), + our_type = g_type_register_static (G_TYPE_INTERFACE, + I_("GtkTreeDragSource"), &our_info, 0); } diff --git a/gtk/gtktreemodelfilter.c b/gtk/gtktreemodelfilter.c index 38beb9f818..760b14f5ee 100644 --- a/gtk/gtktreemodelfilter.c +++ b/gtk/gtktreemodelfilter.c @@ -129,8 +129,6 @@ enum #define FILTER_LEVEL(filter_level) ((FilterLevel *)filter_level) /* general code (object/interface init, properties, etc) */ -static void gtk_tree_model_filter_init (GtkTreeModelFilter *filter); -static void gtk_tree_model_filter_class_init (GtkTreeModelFilterClass *filter_class); static void gtk_tree_model_filter_tree_model_init (GtkTreeModelIface *iface); static void gtk_tree_model_filter_drag_source_init (GtkTreeDragSourceIface *iface); static void gtk_tree_model_filter_finalize (GObject *object); @@ -276,57 +274,11 @@ static FilterElt *bsearch_elt_with_offset (GArra gint *index); -static GObjectClass *parent_class = NULL; - -GType -gtk_tree_model_filter_get_type (void) -{ - static GType tree_model_filter_type = 0; - - if (!tree_model_filter_type) - { - static const GTypeInfo tree_model_filter_info = - { - sizeof (GtkTreeModelFilterClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_tree_model_filter_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkTreeModelFilter), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_tree_model_filter_init - }; - - static const GInterfaceInfo tree_model_info = - { - (GInterfaceInitFunc) gtk_tree_model_filter_tree_model_init, - NULL, - NULL - }; - - static const GInterfaceInfo drag_source_info = - { - (GInterfaceInitFunc) gtk_tree_model_filter_drag_source_init, - NULL, - NULL - }; - - tree_model_filter_type = g_type_register_static (G_TYPE_OBJECT, - I_("GtkTreeModelFilter"), - &tree_model_filter_info, 0); - - g_type_add_interface_static (tree_model_filter_type, - GTK_TYPE_TREE_MODEL, - &tree_model_info); - - g_type_add_interface_static (tree_model_filter_type, - GTK_TYPE_TREE_DRAG_SOURCE, - &drag_source_info); - } - - return tree_model_filter_type; -} +G_DEFINE_TYPE_WITH_CODE (GtkTreeModelFilter, gtk_tree_model_filter, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, + gtk_tree_model_filter_tree_model_init) + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_DRAG_SOURCE, + gtk_tree_model_filter_drag_source_init)); static void gtk_tree_model_filter_init (GtkTreeModelFilter *filter) @@ -346,7 +298,6 @@ gtk_tree_model_filter_class_init (GtkTreeModelFilterClass *filter_class) GObjectClass *object_class; object_class = (GObjectClass *) filter_class; - parent_class = g_type_class_peek_parent (filter_class); object_class->set_property = gtk_tree_model_filter_set_property; object_class->get_property = gtk_tree_model_filter_get_property; @@ -423,7 +374,7 @@ gtk_tree_model_filter_finalize (GObject *object) g_free (filter->priv->modify_types); /* must chain up */ - parent_class->finalize (object); + G_OBJECT_CLASS (gtk_tree_model_filter_parent_class)->finalize (object); } static void diff --git a/gtk/gtktreemodelsort.c b/gtk/gtktreemodelsort.c index 1b89e460a2..9b6ed0a40f 100644 --- a/gtk/gtktreemodelsort.c +++ b/gtk/gtktreemodelsort.c @@ -108,8 +108,6 @@ enum { #define VALID_ITER(iter, tree_model_sort) ((iter) != NULL && (iter)->user_data != NULL && (iter)->user_data2 != NULL && (tree_model_sort)->stamp == (iter)->stamp) /* general (object/interface init, etc) */ -static void gtk_tree_model_sort_init (GtkTreeModelSort *tree_model_sort); -static void gtk_tree_model_sort_class_init (GtkTreeModelSortClass *tree_model_sort_class); static void gtk_tree_model_sort_tree_model_init (GtkTreeModelIface *iface); static void gtk_tree_model_sort_tree_sortable_init (GtkTreeSortableIface *iface); static void gtk_tree_model_sort_drag_source_init (GtkTreeDragSourceIface*iface); @@ -238,68 +236,14 @@ static GtkTreePath *gtk_real_tree_model_sort_convert_child_path_to_path (GtkTree GtkTreePath *child_path, gboolean build_levels); -static GObjectClass *parent_class = NULL; -GType -gtk_tree_model_sort_get_type (void) -{ - static GType tree_model_sort_type = 0; - - if (!tree_model_sort_type) - { - static const GTypeInfo tree_model_sort_info = - { - sizeof (GtkTreeModelSortClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_tree_model_sort_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkTreeModelSort), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_tree_model_sort_init - }; - - static const GInterfaceInfo tree_model_info = - { - (GInterfaceInitFunc) gtk_tree_model_sort_tree_model_init, - NULL, - NULL - }; - - static const GInterfaceInfo sortable_info = - { - (GInterfaceInitFunc) gtk_tree_model_sort_tree_sortable_init, - NULL, - NULL - }; - - static const GInterfaceInfo drag_source_info = - { - (GInterfaceInitFunc) gtk_tree_model_sort_drag_source_init, - NULL, - NULL - }; - - tree_model_sort_type = - g_type_register_static (G_TYPE_OBJECT, I_("GtkTreeModelSort"), - &tree_model_sort_info, 0); - - g_type_add_interface_static (tree_model_sort_type, - GTK_TYPE_TREE_MODEL, - &tree_model_info); - - g_type_add_interface_static (tree_model_sort_type, - GTK_TYPE_TREE_SORTABLE, - &sortable_info); - - g_type_add_interface_static (tree_model_sort_type, - GTK_TYPE_TREE_DRAG_SOURCE, - &drag_source_info); - } - - return tree_model_sort_type; -} +G_DEFINE_TYPE_WITH_CODE (GtkTreeModelSort, gtk_tree_model_sort, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, + gtk_tree_model_sort_tree_model_init) + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_SORTABLE, + gtk_tree_model_sort_tree_sortable_init) + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_DRAG_SOURCE, + gtk_tree_model_sort_drag_source_init)); static void gtk_tree_model_sort_init (GtkTreeModelSort *tree_model_sort) @@ -317,7 +261,6 @@ gtk_tree_model_sort_class_init (GtkTreeModelSortClass *class) GObjectClass *object_class; object_class = (GObjectClass *) class; - parent_class = g_type_class_peek_parent (class); object_class->set_property = gtk_tree_model_sort_set_property; object_class->get_property = gtk_tree_model_sort_get_property; @@ -411,7 +354,7 @@ gtk_tree_model_sort_finalize (GObject *object) } /* must chain up */ - parent_class->finalize (object); + G_OBJECT_CLASS (gtk_tree_model_sort_parent_class)->finalize (object); } static void diff --git a/gtk/gtktreeselection.c b/gtk/gtktreeselection.c index 1ced62de68..2fa67fa138 100644 --- a/gtk/gtktreeselection.c +++ b/gtk/gtktreeselection.c @@ -26,9 +26,6 @@ #include "gtkintl.h" #include "gtkalias.h" -static void gtk_tree_selection_init (GtkTreeSelection *selection); -static void gtk_tree_selection_class_init (GtkTreeSelectionClass *class); - static void gtk_tree_selection_finalize (GObject *object); static gint gtk_tree_selection_real_select_all (GtkTreeSelection *selection); static gint gtk_tree_selection_real_unselect_all (GtkTreeSelection *selection); @@ -43,36 +40,9 @@ enum LAST_SIGNAL }; -static GObjectClass *parent_class = NULL; static guint tree_selection_signals [LAST_SIGNAL] = { 0 }; -GType -gtk_tree_selection_get_type (void) -{ - static GType selection_type = 0; - - if (!selection_type) - { - static const GTypeInfo selection_info = - { - sizeof (GtkTreeSelectionClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_tree_selection_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkTreeSelection), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_tree_selection_init - }; - - selection_type = - g_type_register_static (G_TYPE_OBJECT, I_("GtkTreeSelection"), - &selection_info, 0); - } - - return selection_type; -} +G_DEFINE_TYPE (GtkTreeSelection, gtk_tree_selection, G_TYPE_OBJECT); static void gtk_tree_selection_class_init (GtkTreeSelectionClass *class) @@ -80,7 +50,6 @@ gtk_tree_selection_class_init (GtkTreeSelectionClass *class) GObjectClass *object_class; object_class = (GObjectClass*) class; - parent_class = g_type_class_peek_parent (class); object_class->finalize = gtk_tree_selection_finalize; class->changed = NULL; @@ -115,7 +84,7 @@ gtk_tree_selection_finalize (GObject *object) } /* chain parent_class' handler */ - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_tree_selection_parent_class)->finalize (object); } /** diff --git a/gtk/gtktreestore.c b/gtk/gtktreestore.c index f4793774da..1534dab795 100644 --- a/gtk/gtktreestore.c +++ b/gtk/gtktreestore.c @@ -31,8 +31,6 @@ #define GTK_TREE_STORE_IS_SORTED(tree) (((GtkTreeStore*)(tree))->sort_column_id != GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID) #define VALID_ITER(iter, tree_store) ((iter)!= NULL && (iter)->user_data != NULL && ((GtkTreeStore*)(tree_store))->stamp == (iter)->stamp) -static void gtk_tree_store_init (GtkTreeStore *tree_store); -static void gtk_tree_store_class_init (GtkTreeStoreClass *tree_store_class); static void gtk_tree_store_tree_model_init (GtkTreeModelIface *iface); static void gtk_tree_store_drag_source_init(GtkTreeDragSourceIface *iface); static void gtk_tree_store_drag_dest_init (GtkTreeDragDestIface *iface); @@ -125,9 +123,6 @@ static void gtk_tree_store_move (GtkTreeStore * gboolean before); -static GObjectClass *parent_class = NULL; - - static inline void validate_tree (GtkTreeStore *tree_store) { @@ -139,81 +134,21 @@ validate_tree (GtkTreeStore *tree_store) } } -GType -gtk_tree_store_get_type (void) -{ - static GType tree_store_type = 0; - - if (!tree_store_type) - { - static const GTypeInfo tree_store_info = - { - sizeof (GtkTreeStoreClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_tree_store_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkTreeStore), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_tree_store_init - }; - - static const GInterfaceInfo tree_model_info = - { - (GInterfaceInitFunc) gtk_tree_store_tree_model_init, - NULL, - NULL - }; - - static const GInterfaceInfo drag_source_info = - { - (GInterfaceInitFunc) gtk_tree_store_drag_source_init, - NULL, - NULL - }; - - static const GInterfaceInfo drag_dest_info = - { - (GInterfaceInitFunc) gtk_tree_store_drag_dest_init, - NULL, - NULL - }; - - static const GInterfaceInfo sortable_info = - { - (GInterfaceInitFunc) gtk_tree_store_sortable_init, - NULL, - NULL - }; - - tree_store_type = g_type_register_static (G_TYPE_OBJECT, I_("GtkTreeStore"), - &tree_store_info, 0); - - g_type_add_interface_static (tree_store_type, - GTK_TYPE_TREE_MODEL, - &tree_model_info); - g_type_add_interface_static (tree_store_type, - GTK_TYPE_TREE_DRAG_SOURCE, - &drag_source_info); - g_type_add_interface_static (tree_store_type, - GTK_TYPE_TREE_DRAG_DEST, - &drag_dest_info); - g_type_add_interface_static (tree_store_type, - GTK_TYPE_TREE_SORTABLE, - &sortable_info); - - } - - return tree_store_type; -} +G_DEFINE_TYPE_WITH_CODE (GtkTreeStore, gtk_tree_store, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, + gtk_tree_store_tree_model_init) + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_DRAG_SOURCE, + gtk_tree_store_drag_source_init) + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_DRAG_DEST, + gtk_tree_store_drag_dest_init) + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_SORTABLE, + gtk_tree_store_sortable_init)); static void gtk_tree_store_class_init (GtkTreeStoreClass *class) { GObjectClass *object_class; - parent_class = g_type_class_peek_parent (class); object_class = (GObjectClass *) class; object_class->finalize = gtk_tree_store_finalize; @@ -480,7 +415,7 @@ gtk_tree_store_finalize (GObject *object) } /* must chain up */ - (* parent_class->finalize) (object); + G_OBJECT_CLASS (gtk_tree_store_parent_class)->finalize (object); } /* fulfill the GtkTreeModel requirements */ diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index 744d34f212..a0c69553e6 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -138,9 +138,6 @@ enum { PROP_LEVEL_INDENTATION }; -static void gtk_tree_view_class_init (GtkTreeViewClass *klass); -static void gtk_tree_view_init (GtkTreeView *tree_view); - /* object signals */ static void gtk_tree_view_finalize (GObject *object); static void gtk_tree_view_set_property (GObject *object, @@ -459,7 +456,6 @@ static void gtk_tree_view_tree_window_to_tree_coords (GtkTreeView *tree_view, gint *ty); -static GtkContainerClass *parent_class = NULL; static guint tree_view_signals [LAST_SIGNAL] = { 0 }; @@ -467,33 +463,7 @@ static guint tree_view_signals [LAST_SIGNAL] = { 0 }; /* GType Methods */ -GType -gtk_tree_view_get_type (void) -{ - static GType tree_view_type = 0; - - if (!tree_view_type) - { - static const GTypeInfo tree_view_info = - { - sizeof (GtkTreeViewClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_tree_view_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkTreeView), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_tree_view_init - }; - - tree_view_type = - g_type_register_static (GTK_TYPE_CONTAINER, I_("GtkTreeView"), - &tree_view_info, 0); - } - - return tree_view_type; -} +G_DEFINE_TYPE (GtkTreeView, gtk_tree_view, GTK_TYPE_CONTAINER); static void gtk_tree_view_class_init (GtkTreeViewClass *class) @@ -504,7 +474,6 @@ gtk_tree_view_class_init (GtkTreeViewClass *class) GtkContainerClass *container_class; GtkBindingSet *binding_set; - parent_class = g_type_class_peek_parent (class); binding_set = gtk_binding_set_by_class (class); o_class = (GObjectClass *) class; @@ -1366,7 +1335,7 @@ gtk_tree_view_get_property (GObject *object, static void gtk_tree_view_finalize (GObject *object) { - (* G_OBJECT_CLASS (parent_class)->finalize) (object); + (* G_OBJECT_CLASS (gtk_tree_view_parent_class)->finalize) (object); } @@ -1517,8 +1486,8 @@ gtk_tree_view_destroy (GtkObject *object) tree_view->priv->vadjustment = NULL; } - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); + if (GTK_OBJECT_CLASS (gtk_tree_view_parent_class)->destroy) + (* GTK_OBJECT_CLASS (gtk_tree_view_parent_class)->destroy) (object); } @@ -1758,8 +1727,8 @@ gtk_tree_view_unrealize (GtkWidget *widget) } /* GtkWidget::unrealize destroys children and widget->window */ - if (GTK_WIDGET_CLASS (parent_class)->unrealize) - (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); + if (GTK_WIDGET_CLASS (gtk_tree_view_parent_class)->unrealize) + (* GTK_WIDGET_CLASS (gtk_tree_view_parent_class)->unrealize) (widget); } /* GtkWidget::size_request helper */ @@ -4583,7 +4552,7 @@ gtk_tree_view_key_press (GtkWidget *widget, } /* Chain up to the parent class. It handles the keybindings. */ - if ((* GTK_WIDGET_CLASS (parent_class)->key_press_event) (widget, event)) + if ((* GTK_WIDGET_CLASS (gtk_tree_view_parent_class)->key_press_event) (widget, event)) return TRUE; /* We pass the event to the search_entry. If its text changes, then we start @@ -4657,7 +4626,7 @@ static gboolean gtk_tree_view_key_release (GtkWidget *widget, GdkEventKey *event) { - return (* GTK_WIDGET_CLASS (parent_class)->key_release_event) (widget, event); + return (* GTK_WIDGET_CLASS (gtk_tree_view_parent_class)->key_release_event) (widget, event); } /* FIXME Is this function necessary? Can I get an enter_notify event @@ -7095,7 +7064,7 @@ gtk_tree_view_focus (GtkWidget *widget, static void gtk_tree_view_grab_focus (GtkWidget *widget) { - (* GTK_WIDGET_CLASS (parent_class)->grab_focus) (widget); + (* GTK_WIDGET_CLASS (gtk_tree_view_parent_class)->grab_focus) (widget); gtk_tree_view_focus_to_cursor (GTK_TREE_VIEW (widget)); } @@ -7152,7 +7121,7 @@ gtk_tree_view_set_focus_child (GtkContainer *container, } } - (* parent_class->set_focus_child) (container, child); + GTK_CONTAINER_CLASS (gtk_tree_view_parent_class)->set_focus_child (container, child); } static void diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c index 8313a264ef..17b0f51e61 100644 --- a/gtk/gtktreeviewcolumn.c +++ b/gtk/gtktreeviewcolumn.c @@ -77,8 +77,6 @@ struct _GtkTreeViewColumnCellInfo }; /* Type methods */ -static void gtk_tree_view_column_init (GtkTreeViewColumn *tree_column); -static void gtk_tree_view_column_class_init (GtkTreeViewColumnClass *klass); static void gtk_tree_view_column_cell_layout_init (GtkCellLayoutIface *iface); /* GObject methods */ @@ -153,48 +151,11 @@ static GList *gtk_tree_view_column_cell_prev (GtkTreeViewColum static void gtk_tree_view_column_clear_attributes_by_info (GtkTreeViewColumn *tree_column, GtkTreeViewColumnCellInfo *info); -static GtkObjectClass *parent_class = NULL; static guint tree_column_signals[LAST_SIGNAL] = { 0 }; - -GType -gtk_tree_view_column_get_type (void) -{ - static GType tree_column_type = 0; - - if (!tree_column_type) - { - static const GTypeInfo tree_column_info = - { - sizeof (GtkTreeViewColumnClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_tree_view_column_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkTreeViewColumn), - 0, - (GInstanceInitFunc) gtk_tree_view_column_init - }; - - static const GInterfaceInfo cell_layout_info = - { - (GInterfaceInitFunc) gtk_tree_view_column_cell_layout_init, - NULL, - NULL - }; - - tree_column_type = - g_type_register_static (GTK_TYPE_OBJECT, I_("GtkTreeViewColumn"), - &tree_column_info, 0); - - g_type_add_interface_static (tree_column_type, - GTK_TYPE_CELL_LAYOUT, - &cell_layout_info); - } - - return tree_column_type; -} +G_DEFINE_TYPE_WITH_CODE (GtkTreeViewColumn, gtk_tree_view_column, GTK_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_LAYOUT, + gtk_tree_view_column_cell_layout_init)); static void gtk_tree_view_column_class_init (GtkTreeViewColumnClass *class) @@ -203,8 +164,6 @@ gtk_tree_view_column_class_init (GtkTreeViewColumnClass *class) object_class = (GObjectClass*) class; - parent_class = g_type_class_peek_parent (class); - class->clicked = NULL; object_class->finalize = gtk_tree_view_column_finalize; @@ -433,7 +392,7 @@ gtk_tree_view_column_finalize (GObject *object) if (tree_column->child) g_object_unref (tree_column->child); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_tree_view_column_parent_class)->finalize (object); } static void diff --git a/gtk/gtkuimanager.c b/gtk/gtkuimanager.c index fad7a116ab..bc96c8e05e 100644 --- a/gtk/gtkuimanager.c +++ b/gtk/gtkuimanager.c @@ -107,8 +107,6 @@ struct _NodeUIReference GQuark action_quark; }; -static void gtk_ui_manager_class_init (GtkUIManagerClass *class); -static void gtk_ui_manager_init (GtkUIManager *self); static void gtk_ui_manager_finalize (GObject *object); static void gtk_ui_manager_set_property (GObject *object, guint prop_id, @@ -163,44 +161,15 @@ enum PROP_UI }; -static GObjectClass *parent_class = NULL; static guint ui_manager_signals[LAST_SIGNAL] = { 0 }; -GType -gtk_ui_manager_get_type (void) -{ - static GtkType type = 0; - - if (!type) - { - static const GTypeInfo type_info = - { - sizeof (GtkUIManagerClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) gtk_ui_manager_class_init, - (GClassFinalizeFunc) NULL, - NULL, - - sizeof (GtkUIManager), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_ui_manager_init, - }; - - type = g_type_register_static (G_TYPE_OBJECT, - I_("GtkUIManager"), - &type_info, 0); - } - return type; -} +G_DEFINE_TYPE (GtkUIManager, gtk_ui_manager, G_TYPE_OBJECT); static void gtk_ui_manager_class_init (GtkUIManagerClass *klass) { GObjectClass *gobject_class; - parent_class = g_type_class_peek_parent (klass); - gobject_class = G_OBJECT_CLASS (klass); gobject_class->finalize = gtk_ui_manager_finalize; @@ -428,7 +397,7 @@ gtk_ui_manager_finalize (GObject *object) g_object_unref (self->private_data->accel_group); self->private_data->accel_group = NULL; - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_ui_manager_parent_class)->finalize (object); } static void diff --git a/gtk/gtkvbbox.c b/gtk/gtkvbbox.c index 65c0b0e96a..648ad3f09e 100644 --- a/gtk/gtkvbbox.c +++ b/gtk/gtkvbbox.c @@ -30,8 +30,6 @@ #include "gtkalias.h" -static void gtk_vbutton_box_class_init (GtkVButtonBoxClass *klass); -static void gtk_vbutton_box_init (GtkVButtonBox *box); static void gtk_vbutton_box_size_request (GtkWidget *widget, GtkRequisition *requisition); static void gtk_vbutton_box_size_allocate (GtkWidget *widget, @@ -40,33 +38,7 @@ static void gtk_vbutton_box_size_allocate (GtkWidget *widget, static gint default_spacing = 10; static GtkButtonBoxStyle default_layout_style = GTK_BUTTONBOX_EDGE; -GType -gtk_vbutton_box_get_type (void) -{ - static GType vbutton_box_type = 0; - - if (!vbutton_box_type) - { - static const GTypeInfo vbutton_box_info = - { - sizeof (GtkVButtonBoxClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_vbutton_box_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkVButtonBox), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_vbutton_box_init, - }; - - vbutton_box_type = - g_type_register_static (GTK_TYPE_BUTTON_BOX, I_("GtkVButtonBox"), - &vbutton_box_info, 0); - } - - return vbutton_box_type; -} +G_DEFINE_TYPE (GtkVButtonBox, gtk_vbutton_box, GTK_TYPE_BUTTON_BOX); static void gtk_vbutton_box_class_init (GtkVButtonBoxClass *class) diff --git a/gtk/gtkvbox.c b/gtk/gtkvbox.c index f10890bdd1..0473d8147e 100644 --- a/gtk/gtkvbox.c +++ b/gtk/gtkvbox.c @@ -30,40 +30,12 @@ #include "gtkalias.h" -static void gtk_vbox_class_init (GtkVBoxClass *klass); -static void gtk_vbox_init (GtkVBox *box); static void gtk_vbox_size_request (GtkWidget *widget, GtkRequisition *requisition); static void gtk_vbox_size_allocate (GtkWidget *widget, GtkAllocation *allocation); - -GType -gtk_vbox_get_type (void) -{ - static GType vbox_type = 0; - - if (!vbox_type) - { - static const GTypeInfo vbox_info = - { - sizeof (GtkVBoxClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_vbox_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkVBox), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_vbox_init, - }; - - vbox_type = g_type_register_static (GTK_TYPE_BOX, I_("GtkVBox"), - &vbox_info, 0); - } - - return vbox_type; -} +G_DEFINE_TYPE (GtkVBox, gtk_vbox, GTK_TYPE_BOX); static void gtk_vbox_class_init (GtkVBoxClass *class) diff --git a/gtk/gtkviewport.c b/gtk/gtkviewport.c index be304a3aff..d2c4495dac 100644 --- a/gtk/gtkviewport.c +++ b/gtk/gtkviewport.c @@ -39,8 +39,6 @@ enum { }; -static void gtk_viewport_class_init (GtkViewportClass *klass); -static void gtk_viewport_init (GtkViewport *viewport); static void gtk_viewport_finalize (GObject *object); static void gtk_viewport_destroy (GtkObject *object); static void gtk_viewport_set_property (GObject *object, @@ -71,34 +69,7 @@ static void gtk_viewport_adjustment_value_changed (GtkAdjustment *adjustment, static void gtk_viewport_style_set (GtkWidget *widget, GtkStyle *previous_style); -static GtkBinClass *parent_class; - -GType -gtk_viewport_get_type (void) -{ - static GType viewport_type = 0; - - if (!viewport_type) - { - static const GTypeInfo viewport_info = - { - sizeof (GtkViewportClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_viewport_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkViewport), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_viewport_init, - }; - - viewport_type = g_type_register_static (GTK_TYPE_BIN, I_("GtkViewport"), - &viewport_info, 0); - } - - return viewport_type; -} +G_DEFINE_TYPE (GtkViewport, gtk_viewport, GTK_TYPE_BIN); static void gtk_viewport_class_init (GtkViewportClass *class) @@ -113,8 +84,6 @@ gtk_viewport_class_init (GtkViewportClass *class) widget_class = (GtkWidgetClass*) class; container_class = (GtkContainerClass*) class; - parent_class = g_type_class_peek_parent (class); - gobject_class->finalize = gtk_viewport_finalize; gobject_class->set_property = gtk_viewport_set_property; gobject_class->get_property = gtk_viewport_get_property; @@ -288,7 +257,7 @@ gtk_viewport_finalize (GObject *object) viewport_disconnect_adjustment (viewport, GTK_ORIENTATION_HORIZONTAL); viewport_disconnect_adjustment (viewport, GTK_ORIENTATION_VERTICAL); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_viewport_parent_class)->finalize (object); } static void @@ -299,7 +268,7 @@ gtk_viewport_destroy (GtkObject *object) viewport_disconnect_adjustment (viewport, GTK_ORIENTATION_HORIZONTAL); viewport_disconnect_adjustment (viewport, GTK_ORIENTATION_VERTICAL); - GTK_OBJECT_CLASS (parent_class)->destroy (object); + GTK_OBJECT_CLASS (gtk_viewport_parent_class)->destroy (object); } /** @@ -668,8 +637,8 @@ gtk_viewport_unrealize (GtkWidget *widget) gdk_window_destroy (viewport->bin_window); viewport->bin_window = NULL; - if (GTK_WIDGET_CLASS (parent_class)->unrealize) - (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); + if (GTK_WIDGET_CLASS (gtk_viewport_parent_class)->unrealize) + (* GTK_WIDGET_CLASS (gtk_viewport_parent_class)->unrealize) (widget); } static void @@ -711,7 +680,7 @@ gtk_viewport_expose (GtkWidget *widget, &event->area, widget, "viewportbin", 0, 0, -1, -1); - (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event); + (* GTK_WIDGET_CLASS (gtk_viewport_parent_class)->expose_event) (widget, event); } } @@ -731,7 +700,7 @@ gtk_viewport_add (GtkContainer *container, gtk_widget_set_parent_window (child, GTK_VIEWPORT (bin)->bin_window); - GTK_CONTAINER_CLASS (parent_class)->add (container, child); + GTK_CONTAINER_CLASS (gtk_viewport_parent_class)->add (container, child); } static void diff --git a/gtk/gtkvpaned.c b/gtk/gtkvpaned.c index e00fc616ac..ba5e4c3deb 100644 --- a/gtk/gtkvpaned.c +++ b/gtk/gtkvpaned.c @@ -29,49 +29,18 @@ #include "gtkintl.h" #include "gtkalias.h" -static void gtk_vpaned_class_init (GtkVPanedClass *klass); -static void gtk_vpaned_init (GtkVPaned *vpaned); static void gtk_vpaned_size_request (GtkWidget *widget, GtkRequisition *requisition); static void gtk_vpaned_size_allocate (GtkWidget *widget, GtkAllocation *allocation); -static gpointer parent_class; - -GType -gtk_vpaned_get_type (void) -{ - static GType vpaned_type = 0; - - if (!vpaned_type) - { - static const GTypeInfo vpaned_info = - { - sizeof (GtkVPanedClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_vpaned_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkVPaned), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_vpaned_init, - }; - - vpaned_type = g_type_register_static (GTK_TYPE_PANED, I_("GtkVPaned"), - &vpaned_info, 0); - } - - return vpaned_type; -} +G_DEFINE_TYPE (GtkVPaned, gtk_vpaned, GTK_TYPE_PANED); static void gtk_vpaned_class_init (GtkVPanedClass *class) { GtkWidgetClass *widget_class; - parent_class = g_type_class_peek_parent (class); - widget_class = (GtkWidgetClass *) class; widget_class->size_request = gtk_vpaned_size_request; diff --git a/gtk/gtkvruler.c b/gtk/gtkvruler.c index eb910ab03e..009004a63c 100644 --- a/gtk/gtkvruler.c +++ b/gtk/gtkvruler.c @@ -42,40 +42,12 @@ #define ROUND(x) ((int) ((x) + 0.5)) -static void gtk_vruler_class_init (GtkVRulerClass *klass); -static void gtk_vruler_init (GtkVRuler *vruler); static gint gtk_vruler_motion_notify (GtkWidget *widget, GdkEventMotion *event); static void gtk_vruler_draw_ticks (GtkRuler *ruler); static void gtk_vruler_draw_pos (GtkRuler *ruler); - -GType -gtk_vruler_get_type (void) -{ - static GType vruler_type = 0; - - if (!vruler_type) - { - static const GTypeInfo vruler_info = - { - sizeof (GtkVRulerClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_vruler_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkVRuler), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_vruler_init, - }; - - vruler_type = g_type_register_static (GTK_TYPE_RULER, I_("GtkVRuler"), - &vruler_info, 0); - } - - return vruler_type; -} +G_DEFINE_TYPE (GtkVRuler, gtk_vruler, GTK_TYPE_RULER); static void gtk_vruler_class_init (GtkVRulerClass *klass) diff --git a/gtk/gtkvscale.c b/gtk/gtkvscale.c index da92e7ef77..e0dc9835c0 100644 --- a/gtk/gtkvscale.c +++ b/gtk/gtkvscale.c @@ -34,10 +34,6 @@ #define VALUE_SPACING 2 -static gpointer parent_class; - -static void gtk_vscale_class_init (GtkVScaleClass *klass); -static void gtk_vscale_init (GtkVScale *vscale); static gboolean gtk_vscale_expose (GtkWidget *widget, GdkEventExpose *event); @@ -45,32 +41,7 @@ static void gtk_vscale_get_layout_offsets (GtkScale *scale, gint *x, gint *y); -GType -gtk_vscale_get_type (void) -{ - static GType vscale_type = 0; - - if (!vscale_type) - { - static const GTypeInfo vscale_info = - { - sizeof (GtkVScaleClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_vscale_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkVScale), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_vscale_init, - }; - - vscale_type = g_type_register_static (GTK_TYPE_SCALE, I_("GtkVScale"), - &vscale_info, 0); - } - - return vscale_type; -} +G_DEFINE_TYPE (GtkVScale, gtk_vscale, GTK_TYPE_SCALE); static void gtk_vscale_class_init (GtkVScaleClass *class) @@ -83,8 +54,6 @@ gtk_vscale_class_init (GtkVScaleClass *class) range_class = GTK_RANGE_CLASS (class); scale_class = GTK_SCALE_CLASS (class); - parent_class = g_type_class_peek_parent (class); - range_class->slider_detail = "vscale"; scale_class->get_layout_offsets = gtk_vscale_get_layout_offsets; @@ -168,8 +137,8 @@ gtk_vscale_expose (GtkWidget *widget, /* We need to chain up _first_ so the various geometry members of * GtkRange struct are updated. */ - if (GTK_WIDGET_CLASS (parent_class)->expose_event) - GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); + if (GTK_WIDGET_CLASS (gtk_vscale_parent_class)->expose_event) + GTK_WIDGET_CLASS (gtk_vscale_parent_class)->expose_event (widget, event); if (scale->draw_value) { diff --git a/gtk/gtkvscrollbar.c b/gtk/gtkvscrollbar.c index 071fc1f3fa..e4c2a0839f 100644 --- a/gtk/gtkvscrollbar.c +++ b/gtk/gtkvscrollbar.c @@ -31,36 +31,7 @@ #include "gtkintl.h" #include "gtkalias.h" -static void gtk_vscrollbar_class_init (GtkVScrollbarClass *klass); -static void gtk_vscrollbar_init (GtkVScrollbar *vscrollbar); - -GType -gtk_vscrollbar_get_type (void) -{ - static GType vscrollbar_type = 0; - - if (!vscrollbar_type) - { - static const GTypeInfo vscrollbar_info = - { - sizeof (GtkVScrollbarClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_vscrollbar_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkVScrollbar), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_vscrollbar_init, - }; - - vscrollbar_type = - g_type_register_static (GTK_TYPE_SCROLLBAR, I_("GtkVScrollbar"), - &vscrollbar_info, 0); - } - - return vscrollbar_type; -} +G_DEFINE_TYPE (GtkVScrollbar, gtk_vscrollbar, GTK_TYPE_SCROLLBAR); static void gtk_vscrollbar_class_init (GtkVScrollbarClass *class) diff --git a/gtk/gtkvseparator.c b/gtk/gtkvseparator.c index eca00ef48b..800321a6d2 100644 --- a/gtk/gtkvseparator.c +++ b/gtk/gtkvseparator.c @@ -30,41 +30,13 @@ #include "gtkalias.h" -static void gtk_vseparator_class_init (GtkVSeparatorClass *klass); -static void gtk_vseparator_init (GtkVSeparator *vseparator); static void gtk_vseparator_size_request (GtkWidget *widget, GtkRequisition *requisition); static gint gtk_vseparator_expose (GtkWidget *widget, GdkEventExpose *event); -GType -gtk_vseparator_get_type (void) -{ - static GType vseparator_type = 0; - - if (!vseparator_type) - { - static const GTypeInfo vseparator_info = - { - sizeof (GtkVSeparatorClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_vseparator_class_init, - NULL, /* class_finalize */ - NULL, /* class_init */ - sizeof (GtkVSeparator), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_vseparator_init, - }; - - vseparator_type = - g_type_register_static (GTK_TYPE_SEPARATOR, I_("GtkVSeparator"), - &vseparator_info, 0); - } - - return vseparator_type; -} +G_DEFINE_TYPE (GtkVSeparator, gtk_vseparator, GTK_TYPE_SEPARATOR); static void gtk_vseparator_class_init (GtkVSeparatorClass *klass) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index aa0dce9bb3..03a208ce27 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -159,8 +159,6 @@ struct _GtkStateData /* --- prototypes --- */ -static void gtk_widget_class_init (GtkWidgetClass *klass); -static void gtk_widget_init (GtkWidget *widget); static void gtk_widget_set_property (GObject *object, guint prop_id, const GValue *value, @@ -235,7 +233,6 @@ static void gtk_widget_get_draw_rectangle (GtkWidget *widget, /* --- variables --- */ -static gpointer parent_class = NULL; static guint widget_signals[LAST_SIGNAL] = { 0 }; static GtkStyle *gtk_default_style = NULL; static GSList *colormap_stack = NULL; @@ -261,44 +258,9 @@ GParamSpecPool *_gtk_widget_child_property_pool = NULL; GObjectNotifyContext *_gtk_widget_child_property_notify_context = NULL; /* --- functions --- */ -GType -gtk_widget_get_type (void) -{ - static GType widget_type = 0; - - if (!widget_type) - { - static const GTypeInfo widget_info = - { - sizeof (GtkWidgetClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_widget_class_init, - NULL, /* class_finalize */ - NULL, /* class_init */ - sizeof (GtkWidget), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_widget_init, - NULL, /* value_table */ - }; - - static const GInterfaceInfo accessibility_info = - { - (GInterfaceInitFunc) gtk_widget_accessible_interface_init, - (GInterfaceFinalizeFunc) NULL, - NULL /* interface data */ - }; - - widget_type = g_type_register_static (GTK_TYPE_OBJECT, I_("GtkWidget"), - &widget_info, G_TYPE_FLAG_ABSTRACT); - - g_type_add_interface_static (widget_type, ATK_TYPE_IMPLEMENTOR, - &accessibility_info) ; - - } - - return widget_type; -} +G_DEFINE_TYPE_WITH_CODE (GtkWidget, gtk_widget, GTK_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (ATK_TYPE_IMPLEMENTOR, + gtk_widget_accessible_interface_init)); static void child_property_notify_dispatcher (GObject *object, @@ -316,8 +278,6 @@ gtk_widget_class_init (GtkWidgetClass *klass) GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); GtkBindingSet *binding_set; - parent_class = g_type_class_peek_parent (klass); - quark_property_parser = g_quark_from_static_string ("gtk-rc-property-parser"); quark_aux_info = g_quark_from_static_string ("gtk-aux-info"); quark_accel_path = g_quark_from_static_string ("gtk-accel-path"); @@ -6776,7 +6736,7 @@ gtk_widget_dispose (GObject *object) if (GTK_WIDGET_REALIZED (widget)) gtk_widget_unrealize (widget); - G_OBJECT_CLASS (parent_class)->dispose (object); + G_OBJECT_CLASS (gtk_widget_parent_class)->dispose (object); } static void @@ -6798,7 +6758,7 @@ gtk_widget_real_destroy (GtkObject *object) widget->style = gtk_widget_get_default_style (); g_object_ref (widget->style); - GTK_OBJECT_CLASS (parent_class)->destroy (object); + GTK_OBJECT_CLASS (gtk_widget_parent_class)->destroy (object); } static void @@ -6834,7 +6794,7 @@ gtk_widget_finalize (GObject *object) if (accessible) g_object_unref (accessible); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_widget_parent_class)->finalize (object); } /***************************************** diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 82cc51dbe0..9b543c7bff 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -177,8 +177,6 @@ struct _GtkWindowPrivate GdkWindowTypeHint type_hint; }; -static void gtk_window_class_init (GtkWindowClass *klass); -static void gtk_window_init (GtkWindow *window); static void gtk_window_dispose (GObject *object); static void gtk_window_destroy (GtkObject *object); static void gtk_window_finalize (GObject *object); @@ -286,7 +284,6 @@ static void gtk_window_on_composited_changed (GdkScreen *screen, GtkWindow *window); static GSList *toplevel_list = NULL; -static GtkBinClass *parent_class = NULL; static guint window_signals[LAST_SIGNAL] = { 0 }; static GList *default_icon_list = NULL; static gchar *default_icon_name = NULL; @@ -309,32 +306,7 @@ static void gtk_window_get_property (GObject *object, GParamSpec *pspec); -GType -gtk_window_get_type (void) -{ - static GType window_type = 0; - - if (!window_type) - { - static const GTypeInfo window_info = - { - sizeof (GtkWindowClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_window_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkWindow), - 0, /* n_preallocs */ - (GInstanceInitFunc) gtk_window_init, - }; - - window_type = g_type_register_static (GTK_TYPE_BIN, I_("GtkWindow"), - &window_info, 0); - } - - return window_type; -} +G_DEFINE_TYPE (GtkWindow, gtk_window, GTK_TYPE_BIN); static void add_tab_bindings (GtkBindingSet *binding_set, @@ -384,8 +356,6 @@ gtk_window_class_init (GtkWindowClass *klass) widget_class = (GtkWidgetClass*) klass; container_class = (GtkContainerClass*) klass; - parent_class = g_type_class_peek_parent (klass); - quark_gtk_embedded = g_quark_from_static_string ("gtk-embedded"); quark_gtk_window_key_hash = g_quark_from_static_string ("gtk-window-key-hash"); quark_gtk_window_default_icon_pixmap = g_quark_from_static_string ("gtk-window-default-icon-pixmap"); @@ -1796,7 +1766,7 @@ gtk_window_dispose (GObject *object) gtk_window_set_focus (window, NULL); gtk_window_set_default (window, NULL); - G_OBJECT_CLASS (parent_class)->dispose (object); + G_OBJECT_CLASS (gtk_window_parent_class)->dispose (object); } static void @@ -3947,7 +3917,7 @@ gtk_window_destroy (GtkObject *object) gtk_window_free_key_hash (window); - GTK_OBJECT_CLASS (parent_class)->destroy (object); + GTK_OBJECT_CLASS (gtk_window_parent_class)->destroy (object); } static void @@ -3986,7 +3956,7 @@ gtk_window_finalize (GObject *object) gtk_window_on_composited_changed, window); } - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (gtk_window_parent_class)->finalize (object); } static void @@ -4418,7 +4388,7 @@ gtk_window_unrealize (GtkWidget *widget) /* Icons */ gtk_window_unrealize_icon (window); - (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); + (* GTK_WIDGET_CLASS (gtk_window_parent_class)->unrealize) (widget); } static void @@ -4698,7 +4668,7 @@ gtk_window_key_press_event (GtkWidget *widget, /* Chain up, invokes binding set */ if (!handled) - handled = GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, event); + handled = GTK_WIDGET_CLASS (gtk_window_parent_class)->key_press_event (widget, event); return handled; } @@ -4716,7 +4686,7 @@ gtk_window_key_release_event (GtkWidget *widget, /* Chain up, invokes binding set */ if (!handled) - handled = GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, event); + handled = GTK_WIDGET_CLASS (gtk_window_parent_class)->key_press_event (widget, event); return handled; } @@ -6062,8 +6032,8 @@ gtk_window_expose (GtkWidget *widget, if (!GTK_WIDGET_APP_PAINTABLE (widget)) gtk_window_paint (widget, &event->area); - if (GTK_WIDGET_CLASS (parent_class)->expose_event) - return GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); + if (GTK_WIDGET_CLASS (gtk_window_parent_class)->expose_event) + return GTK_WIDGET_CLASS (gtk_window_parent_class)->expose_event (widget, event); return FALSE; } |