Commit b0702a91 authored by Christian Persch's avatar Christian Persch

Use G_DEFINE_TYPE[_WITH_CODE] instead of hand-coding the get_type functions. Bug #504661.

svn path=/trunk/; revision=19227
parent dcbaaf2a
2007-12-22 Christian Persch <chpe@gnome.org>
* module/other/gail/*.c: Use G_DEFINE_TYPE[_WITH_CODE] instead of
handwritten get_type functions. Bug #504661.
2007-12-23 Xan Lopez <xan@gnome.org>
* gtk/gtktreeview.c (gtk_tree_view_build_tree): pass correct argument
......
......@@ -23,6 +23,8 @@
static void gail_adjustment_class_init (GailAdjustmentClass *klass);
static void gail_adjustment_init (GailAdjustment *adjustment);
static void gail_adjustment_real_initialize (AtkObject *obj,
gpointer data);
......@@ -40,55 +42,22 @@ static gboolean gail_adjustment_set_current_value (AtkValue *obj,
static void gail_adjustment_destroyed (GtkAdjustment *adjustment,
GailAdjustment *gail_adjustment);
static gpointer parent_class = NULL;
GType
gail_adjustment_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailAdjustmentClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_adjustment_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailAdjustment), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
static const GInterfaceInfo atk_value_info =
{
(GInterfaceInitFunc) atk_value_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
type = g_type_register_static (ATK_TYPE_OBJECT,
"GailAdjustment", &tinfo, 0);
g_type_add_interface_static (type, ATK_TYPE_VALUE,
&atk_value_info);
}
return type;
}
G_DEFINE_TYPE_WITH_CODE (GailAdjustment, gail_adjustment, ATK_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (ATK_TYPE_VALUE, atk_value_interface_init))
static void
gail_adjustment_class_init (GailAdjustmentClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
class->initialize = gail_adjustment_real_initialize;
}
static void
gail_adjustment_init (GailAdjustment *adjustment)
{
}
AtkObject*
gail_adjustment_new (GtkAdjustment *adjustment)
{
......@@ -113,7 +82,7 @@ gail_adjustment_real_initialize (AtkObject *obj,
{
GtkAdjustment *adjustment;
ATK_OBJECT_CLASS (parent_class)->initialize (obj, data);
ATK_OBJECT_CLASS (gail_adjustment_parent_class)->initialize (obj, data);
adjustment = GTK_ADJUSTMENT (data);
......@@ -129,13 +98,10 @@ gail_adjustment_real_initialize (AtkObject *obj,
static void
atk_value_interface_init (AtkValueIface *iface)
{
g_return_if_fail (iface != NULL);
iface->get_current_value = gail_adjustment_get_current_value;
iface->get_maximum_value = gail_adjustment_get_maximum_value;
iface->get_minimum_value = gail_adjustment_get_minimum_value;
iface->set_current_value = gail_adjustment_set_current_value;
}
static void
......
......@@ -20,8 +20,8 @@
#include <gtk/gtk.h>
#include "gailarrow.h"
static void gail_arrow_class_init (GailArrowClass *klass);
static void gail_arrow_object_init (GailArrow *arrow);
static void gail_arrow_class_init (GailArrowClass *klass);
static void gail_arrow_init (GailArrow *arrow);
/* AtkImage */
static void atk_image_interface_init (AtkImageIface *iface);
......@@ -32,44 +32,8 @@ static gboolean gail_arrow_set_image_description
const gchar *description);
static void gail_arrow_finalize (GObject *object);
static GailWidgetClass* parent_class = NULL;
GType
gail_arrow_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailArrowClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_arrow_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailArrow), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) gail_arrow_object_init, /* instance init */
NULL /* value table */
};
static const GInterfaceInfo atk_image_info =
{
(GInterfaceInitFunc) atk_image_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
type = g_type_register_static (GAIL_TYPE_WIDGET,
"GailArrow", &tinfo, 0);
g_type_add_interface_static (type, ATK_TYPE_IMAGE,
&atk_image_info);
}
return type;
}
G_DEFINE_TYPE_WITH_CODE (GailArrow, gail_arrow, GAIL_TYPE_WIDGET,
G_IMPLEMENT_INTERFACE (ATK_TYPE_IMAGE, atk_image_interface_init))
static void
gail_arrow_class_init (GailArrowClass *klass)
......@@ -77,12 +41,10 @@ gail_arrow_class_init (GailArrowClass *klass)
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = gail_arrow_finalize;
parent_class = g_type_class_peek_parent (klass);
}
static void
gail_arrow_object_init (GailArrow *arrow)
gail_arrow_init (GailArrow *arrow)
{
arrow->image_description = NULL;
}
......@@ -107,8 +69,6 @@ gail_arrow_new (GtkWidget *widget)
static void
atk_image_interface_init (AtkImageIface *iface)
{
g_return_if_fail (iface != NULL);
iface->get_image_description = gail_arrow_get_image_description;
iface->set_image_description = gail_arrow_set_image_description;
}
......@@ -123,10 +83,8 @@ gail_arrow_get_image_description (AtkImage *obj)
arrow = GAIL_ARROW (obj);
return arrow->image_description;
}
static gboolean
gail_arrow_set_image_description (AtkImage *obj,
const gchar *description)
......@@ -160,5 +118,5 @@ gail_arrow_finalize (GObject *object)
GailArrow *arrow = GAIL_ARROW (object);
g_free (arrow->image_description);
G_OBJECT_CLASS (parent_class)->finalize (object);
G_OBJECT_CLASS (gail_arrow_parent_class)->finalize (object);
}
......@@ -21,7 +21,7 @@
#include "gailbooleancell.h"
static void gail_boolean_cell_class_init (GailBooleanCellClass *klass);
static void gail_boolean_cell_init (GailBooleanCell *cell);
/* Misc */
static gboolean gail_boolean_cell_update_cache (GailRendererCell *cell,
......@@ -33,33 +33,8 @@ gchar *gail_boolean_cell_property_list[] = {
NULL
};
GType
gail_boolean_cell_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailBooleanCellClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_boolean_cell_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailBooleanCell), /* instance size */
0, /* nb preallocs */
NULL, /* instance init */
NULL /* value table */
};
type = g_type_register_static (GAIL_TYPE_RENDERER_CELL,
"GailBooleanCell", &tinfo, 0);
gail_cell_type_add_action_interface (type);
}
return type;
}
G_DEFINE_TYPE_WITH_CODE (GailBooleanCell, gail_boolean_cell, GAIL_TYPE_RENDERER_CELL,
gail_cell_type_add_action_interface (g_define_type_id))
static void
gail_boolean_cell_class_init (GailBooleanCellClass *klass)
......@@ -70,6 +45,11 @@ gail_boolean_cell_class_init (GailBooleanCellClass *klass)
renderer_cell_class->property_list = gail_boolean_cell_property_list;
}
static void
gail_boolean_cell_init (GailBooleanCell *cell)
{
}
AtkObject*
gail_boolean_cell_new (void)
{
......
......@@ -20,48 +20,25 @@
#include <gtk/gtk.h>
#include "gailbox.h"
static void gail_box_class_init (GailBoxClass *klass);
static void gail_box_class_init (GailBoxClass *klass);
static void gail_box_init (GailBox *box);
static AtkStateSet* gail_box_ref_state_set (AtkObject *accessible);
static GailContainerClass *parent_class = NULL;
GType
gail_box_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailBoxClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_box_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailBox), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
type = g_type_register_static (GAIL_TYPE_CONTAINER,
"GailBox", &tinfo, 0);
}
return type;
}
G_DEFINE_TYPE (GailBox, gail_box, GAIL_TYPE_CONTAINER)
static void
gail_box_class_init (GailBoxClass *klass)
{
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
class->ref_state_set = gail_box_ref_state_set;
}
static void
gail_box_init (GailBox *box)
{
}
AtkObject*
gail_box_new (GtkWidget *widget)
{
......@@ -86,7 +63,7 @@ gail_box_ref_state_set (AtkObject *accessible)
AtkStateSet *state_set;
GtkWidget *widget;
state_set = ATK_OBJECT_CLASS (parent_class)->ref_state_set (accessible);
state_set = ATK_OBJECT_CLASS (gail_box_parent_class)->ref_state_set (accessible);
widget = GTK_ACCESSIBLE (accessible)->widget;
if (widget == NULL)
......
......@@ -26,7 +26,7 @@
#define GAIL_BUTTON_ATTACHED_MENUS "gtk-attached-menus"
static void gail_button_class_init (GailButtonClass *klass);
static void gail_button_object_init (GailButton *button);
static void gail_button_init (GailButton *button);
static G_CONST_RETURN gchar* gail_button_get_name (AtkObject *obj);
static gint gail_button_get_n_children (AtkObject *obj);
......@@ -142,64 +142,10 @@ static gint get_n_attached_menus (GtkWidget *widget)
static GtkWidget* get_nth_attached_menu (GtkWidget *widget,
gint index);
static GailContainer* parent_class = NULL;
GType
gail_button_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailButtonClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_button_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailButton), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) gail_button_object_init, /* instance init */
NULL /* value table */
};
static const GInterfaceInfo atk_action_info =
{
(GInterfaceInitFunc) atk_action_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
static const GInterfaceInfo atk_image_info =
{
(GInterfaceInitFunc) atk_image_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
static const GInterfaceInfo atk_text_info =
{
(GInterfaceInitFunc) atk_text_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
type = g_type_register_static (GAIL_TYPE_CONTAINER,
"GailButton", &tinfo, 0);
g_type_add_interface_static (type, ATK_TYPE_ACTION,
&atk_action_info);
g_type_add_interface_static (type, ATK_TYPE_IMAGE,
&atk_image_info);
g_type_add_interface_static (type, ATK_TYPE_TEXT,
&atk_text_info);
}
return type;
}
G_DEFINE_TYPE_WITH_CODE (GailButton, gail_button, GAIL_TYPE_CONTAINER,
G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, atk_action_interface_init)
G_IMPLEMENT_INTERFACE (ATK_TYPE_IMAGE, atk_image_interface_init)
G_IMPLEMENT_INTERFACE (ATK_TYPE_TEXT, atk_text_interface_init))
static void
gail_button_class_init (GailButtonClass *klass)
......@@ -214,8 +160,6 @@ gail_button_class_init (GailButtonClass *klass)
gobject_class->finalize = gail_button_finalize;
parent_class = g_type_class_peek_parent (klass);
class->get_name = gail_button_get_name;
class->get_n_children = gail_button_get_n_children;
class->ref_child = gail_button_ref_child;
......@@ -227,7 +171,7 @@ gail_button_class_init (GailButtonClass *klass)
}
static void
gail_button_object_init (GailButton *button)
gail_button_init (GailButton *button)
{
button->click_description = NULL;
button->press_description = NULL;
......@@ -261,7 +205,7 @@ gail_button_get_name (AtkObject *obj)
g_return_val_if_fail (GAIL_IS_BUTTON (obj), NULL);
name = ATK_OBJECT_CLASS (parent_class)->get_name (obj);
name = ATK_OBJECT_CLASS (gail_button_parent_class)->get_name (obj);
if (name == NULL)
{
/*
......@@ -335,7 +279,7 @@ gail_button_real_initialize (AtkObject *obj,
GtkWidget *label;
GtkWidget *widget;
ATK_OBJECT_CLASS (parent_class)->initialize (obj, data);
ATK_OBJECT_CLASS (gail_button_parent_class)->initialize (obj, data);
button->state = GTK_STATE_NORMAL;
......@@ -506,8 +450,6 @@ gail_button_real_add_gtk (GtkContainer *container,
static void
atk_action_interface_init (AtkActionIface *iface)
{
g_return_if_fail (iface != NULL);
iface->do_action = gail_button_do_action;
iface->get_n_actions = gail_button_get_n_actions;
iface->get_description = gail_button_get_description;
......@@ -922,7 +864,7 @@ gail_button_ref_state_set (AtkObject *obj)
GtkWidget *widget;
GtkButton *button;
state_set = ATK_OBJECT_CLASS (parent_class)->ref_state_set (obj);
state_set = ATK_OBJECT_CLASS (gail_button_parent_class)->ref_state_set (obj);
widget = GTK_ACCESSIBLE (obj)->widget;
if (widget == NULL)
......@@ -977,8 +919,6 @@ gail_button_released_leave_handler (GtkWidget *widget)
static void
atk_image_interface_init (AtkImageIface *iface)
{
g_return_if_fail (iface != NULL);
iface->get_image_description = gail_button_get_image_description;
iface->get_image_position = gail_button_get_image_position;
iface->get_image_size = gail_button_get_image_size;
......@@ -1142,7 +1082,6 @@ gail_button_set_image_description (AtkImage *image,
static void
atk_text_interface_init (AtkTextIface *iface)
{
g_return_if_fail (iface != NULL);
iface->get_text = gail_button_get_text;
iface->get_character_at_offset = gail_button_get_character_at_offset;
iface->get_text_before_offset = gail_button_get_text_before_offset;
......@@ -1497,7 +1436,7 @@ gail_button_finalize (GObject *object)
{
g_object_unref (button->textutil);
}
G_OBJECT_CLASS (parent_class)->finalize (object);
G_OBJECT_CLASS (gail_button_parent_class)->finalize (object);
}
static GtkWidget*
......
......@@ -21,36 +21,17 @@
#include "gailcalendar.h"
static void gail_calendar_class_init (GailCalendarClass *klass);
static void gail_calendar_init (GailCalendar *calendar);
GType
gail_calendar_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailCalendarClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_calendar_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailCalendar), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};
G_DEFINE_TYPE (GailCalendar, gail_calendar, GAIL_TYPE_WIDGET)
type = g_type_register_static (GAIL_TYPE_WIDGET,
"GailCalendar", &tinfo, 0);
}
return type;
static void
gail_calendar_class_init (GailCalendarClass *klass)
{
}
static void
gail_calendar_class_init (GailCalendarClass *klass)
gail_calendar_init (GailCalendar *calendar)
{
}
......
......@@ -27,7 +27,7 @@ static void gail_cell_class_init (GailCellClass *klass);
static void gail_cell_destroyed (GtkWidget *widget,
GailCell *cell);
static void gail_cell_object_init (GailCell *cell);
static void gail_cell_init (GailCell *cell);
static void gail_cell_object_finalize (GObject *cell);
static AtkStateSet* gail_cell_ref_state_set (AtkObject *obj);
static gint gail_cell_get_index_in_parent (AtkObject *obj);
......@@ -72,45 +72,8 @@ static void gail_cell_get_extents (AtkComponent *componen
AtkCoordType coord_type);
static gboolean gail_cell_grab_focus (AtkComponent *component);
static gpointer parent_class = NULL;
GType
gail_cell_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailCellClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_cell_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailCell), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) gail_cell_object_init, /* instance init */
NULL /* value table */
};
static const GInterfaceInfo atk_component_info =
{
(GInterfaceInitFunc) atk_component_interface_init,
(GInterfaceFinalizeFunc) NULL,
NULL
};
type = g_type_register_static (ATK_TYPE_OBJECT,
"GailCell", &tinfo, 0);
g_type_add_interface_static (type, ATK_TYPE_COMPONENT,
&atk_component_info);
}
return type;
}
G_DEFINE_TYPE_WITH_CODE (GailCell, gail_cell, ATK_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, atk_component_interface_init))
static void
gail_cell_class_init (GailCellClass *klass)
......@@ -118,7 +81,6 @@ gail_cell_class_init (GailCellClass *klass)
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
g_object_class->finalize = gail_cell_object_finalize;
class->get_index_in_parent = gail_cell_get_index_in_parent;
......@@ -126,10 +88,10 @@ gail_cell_class_init (GailCellClass *klass)
}
void
gail_cell_init (GailCell *cell,
GtkWidget *widget,
AtkObject *parent,
gint index)
gail_cell_initialise (GailCell *cell,
GtkWidget *widget,
AtkObject *parent,
gint index)
{
g_return_if_fail (GAIL_IS_CELL (cell));
g_return_if_fail (GTK_IS_WIDGET (widget));
......@@ -156,7 +118,7 @@ gail_cell_destroyed (GtkWidget *widget,
}
static void
gail_cell_object_init (GailCell *cell)
gail_cell_init (GailCell *cell)
{
cell->state_set = atk_state_set_new ();
cell->widget = NULL;
......@@ -206,7 +168,7 @@ gail_cell_object_finalize (GObject *obj)
}
g_object_unref (relation_set);
}
G_OBJECT_CLASS (parent_class)->finalize (obj);
G_OBJECT_CLASS (gail_cell_parent_class)->finalize (obj);
}
static AtkStateSet *
......@@ -318,8 +280,6 @@ gail_cell_get_index_in_parent (AtkObject *obj)
static void
gail_cell_atk_action_interface_init (AtkActionIface *iface)
{
g_assert (iface != NULL);
iface->get_n_actions = gail_cell_action_get_n_actions;
iface->do_action = gail_cell_action_do_action;
iface->get_name = gail_cell_action_get_name;
......@@ -331,7 +291,7 @@ gail_cell_atk_action_interface_init (AtkActionIface *iface)
void
gail_cell_type_add_action_interface (GType type)
{
static const GInterfaceInfo atk_action_info =
const GInterfaceInfo atk_action_info =
{
(GInterfaceInitFunc) gail_cell_atk_action_interface_init,
(GInterfaceFinalizeFunc) NULL,
......@@ -529,8 +489,6 @@ idle_do_action (gpointer data)
static void
atk_component_interface_init (AtkComponentIface *iface)
{
g_assert (iface != NULL);
iface->get_extents = gail_cell_get_extents;
iface->grab_focus = gail_cell_grab_focus;
}
......
......@@ -71,7 +71,7 @@ struct _ActionInfo {
};
void gail_cell_init (GailCell *cell,
void gail_cell_initialise (GailCell *cell,
GtkWidget *widget,
AtkObject *parent,
gint index);
......
......@@ -24,22 +24,23 @@
GType
gail_cell_parent_get_type (void)
{
static GType type = 0;
static volatile gsize g_define_type_id__volatile = 0;
if (!type)
if (g_once_init_enter (&g_define_type_id__volatile))
{
static const GTypeInfo tinfo =
{
sizeof (GailCellParentIface),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
};
type = g_type_register_static (G_TYPE_INTERFACE, "GailCellParent", &tinfo, 0);
GType g_define_type_id =
g_type_register_static_simple (G_TYPE_INTERFACE,
"GailCellParent",
sizeof (GailCellParentIface),
NULL,
0,
NULL,
0);
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
}
return type;
return g_define_type_id__volatile;
}
/**
......
......@@ -24,6 +24,8 @@
static void gail_check_menu_item_class_init (GailCheckMenuItemClass *klass);
static void gail_check_menu_item_init (GailCheckMenuItem *item);
static void gail_check_menu_item_toggled_gtk (GtkWidget *widget);
static void gail_check_menu_item_real_notify_gtk (GObject *obj,
......@@ -34,35 +36,7 @@ static void gail_check_menu_item_real_initialize (AtkObject
static AtkStateSet* gail_check_menu_item_ref_state_set (AtkObject *accessible);
static GailMenuItemClass *parent_class = NULL;
GType
gail_check_menu_item_get_type (void)
{
static GType type = 0;
if (!type)
{
static const GTypeInfo tinfo =
{
sizeof (GailCheckMenuItemClass),
(GBaseInitFunc) NULL, /* base init */
(GBaseFinalizeFunc) NULL, /* base finalize */
(GClassInitFunc) gail_check_menu_item_class_init, /* class init */
(GClassFinalizeFunc) NULL, /* class finalize */
NULL, /* class data */
sizeof (GailCheckMenuItem), /* instance size */
0, /* nb preallocs */
(GInstanceInitFunc) NULL, /* instance init */
NULL /* value table */
};