From ecf3434da05b1f39f793c24b38bfd278e10b5786 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 24 Aug 2010 11:21:41 -0400 Subject: GObject boilerplate cleanup. Prefer thread-safe G_DEFINE_TYPE and G_DEFINE_INTERFACE macros over manual GType registration. This is just a start... lots more to do. --- widgets/misc/e-combo-cell-editable.c | 70 +++++++++++++----------------------- 1 file changed, 24 insertions(+), 46 deletions(-) (limited to 'widgets/misc/e-combo-cell-editable.c') diff --git a/widgets/misc/e-combo-cell-editable.c b/widgets/misc/e-combo-cell-editable.c index 98cd0b17c5..675e499388 100644 --- a/widgets/misc/e-combo-cell-editable.c +++ b/widgets/misc/e-combo-cell-editable.c @@ -35,7 +35,17 @@ struct _EComboCellEditablePriv { #define GRAB_MASK (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK) -static GtkEventBoxClass *parent_class; +/* Forward Declarations */ +static void e_combo_cell_editable_interface_init + (GtkCellEditableIface *interface); + +G_DEFINE_TYPE_WITH_CODE ( + EComboCellEditable, + e_combo_cell_editable, + GTK_TYPE_EVENT_BOX, + G_IMPLEMENT_INTERFACE ( + GTK_TYPE_CELL_EDITABLE, + e_combo_cell_editable_interface_init)) static void kill_popup (EComboCellEditable *ecce) @@ -292,24 +302,23 @@ ecce_start_editing (GtkCellEditable *cell_editable, GdkEvent *event) } static void -ecce_cell_editable_init (GtkCellEditableIface *iface) +e_combo_cell_editable_interface_init (GtkCellEditableIface *interface) { - iface->start_editing = ecce_start_editing; + interface->start_editing = ecce_start_editing; } static void -ecce_finalize (GObject *obj) +ecce_finalize (GObject *object) { - EComboCellEditable *ecce = (EComboCellEditable *) obj; + EComboCellEditable *ecce = (EComboCellEditable *) object; g_free (ecce->priv); - if (G_OBJECT_CLASS (parent_class)->finalize) - G_OBJECT_CLASS (parent_class)->finalize (obj); + G_OBJECT_CLASS (e_combo_cell_editable_parent_class)->finalize (object); } static void -ecce_init (EComboCellEditable *ecce) +e_combo_cell_editable_init (EComboCellEditable *ecce) { GtkWidget *entry, *btn, *box; @@ -344,53 +353,22 @@ ecce_grab_focus (GtkWidget *widget) } static void -ecce_class_init (GObjectClass *klass) +e_combo_cell_editable_class_init (EComboCellEditableClass *class) { - GtkWidgetClass *widget_class = (GtkWidgetClass *)klass; + GObjectClass *object_class; + GtkWidgetClass *widget_class; - klass->finalize = ecce_finalize; + object_class = G_OBJECT_CLASS (class); + object_class->finalize = ecce_finalize; + widget_class = GTK_WIDGET_CLASS (class); widget_class->grab_focus = ecce_grab_focus; - - parent_class = GTK_EVENT_BOX_CLASS (g_type_class_peek_parent (klass)); -} - -GType -e_combo_cell_editable_get_type (void) -{ - static GType ecce_type = 0; - - if (!ecce_type) { - static const GTypeInfo ecce_info = { - sizeof (EComboCellEditableClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) ecce_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EComboCellEditable), - 0, /* n_preallocs */ - (GInstanceInitFunc) ecce_init, - }; - - static const GInterfaceInfo cell_editable_info = { - (GInterfaceInitFunc) ecce_cell_editable_init, - NULL, - NULL - }; - - ecce_type = g_type_register_static (GTK_TYPE_EVENT_BOX, "EComboCellEditable", &ecce_info, 0); - - g_type_add_interface_static (ecce_type, GTK_TYPE_CELL_EDITABLE, &cell_editable_info); - } - - return ecce_type; } GtkCellEditable * e_combo_cell_editable_new (void) { - return GTK_CELL_EDITABLE (g_object_new (E_TYPE_COMBO_CELL_EDITABLE, NULL)); + return g_object_new (E_TYPE_COMBO_CELL_EDITABLE, NULL); } const GList * -- cgit v1.2.3