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-account-combo-box.c | 45 ++++++++++---------------------------- 1 file changed, 12 insertions(+), 33 deletions(-) (limited to 'widgets/misc/e-account-combo-box.c') diff --git a/widgets/misc/e-account-combo-box.c b/widgets/misc/e-account-combo-box.c index e2306baae1..91a843cc8d 100644 --- a/widgets/misc/e-account-combo-box.c +++ b/widgets/misc/e-account-combo-box.c @@ -43,10 +43,14 @@ struct _EAccountComboBoxPrivate { gint num_displayed_accounts; }; -static gpointer parent_class; static CamelSession *camel_session; static guint signal_ids[LAST_SIGNAL]; +G_DEFINE_TYPE ( + EAccountComboBox, + e_account_combo_box, + GTK_TYPE_COMBO_BOX) + static gboolean account_combo_box_has_dupes (GList *list, const gchar *address) @@ -231,10 +235,12 @@ account_combo_box_constructor (GType type, GObjectConstructParam *construct_properties) { GObject *object; + GObjectClass *parent_class; GtkCellRenderer *renderer; /* Chain up to parent's constructor() method. */ - object = G_OBJECT_CLASS (parent_class)->constructor ( + parent_class = G_OBJECT_CLASS (e_account_combo_box_parent_class); + object = parent_class->constructor ( type, n_construct_properties, construct_properties); renderer = gtk_cell_renderer_text_new (); @@ -265,7 +271,7 @@ account_combo_box_dispose (GObject *object) g_hash_table_remove_all (priv->index); /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); + G_OBJECT_CLASS (e_account_combo_box_parent_class)->dispose (object); } static void @@ -278,15 +284,14 @@ account_combo_box_finalize (GObject *object) g_hash_table_destroy (priv->index); /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (e_account_combo_box_parent_class)->finalize (object); } static void -account_combo_box_class_init (EAccountComboBoxClass *class) +e_account_combo_box_class_init (EAccountComboBoxClass *class) { GObjectClass *object_class; - parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EAccountComboBoxPrivate)); object_class = G_OBJECT_CLASS (class); @@ -304,7 +309,7 @@ account_combo_box_class_init (EAccountComboBoxClass *class) } static void -account_combo_box_init (EAccountComboBox *combo_box) +e_account_combo_box_init (EAccountComboBox *combo_box) { GHashTable *index; @@ -318,32 +323,6 @@ account_combo_box_init (EAccountComboBox *combo_box) combo_box->priv->index = index; } -GType -e_account_combo_box_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EAccountComboBoxClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) account_combo_box_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EAccountComboBox), - 0, /* n_preallocs */ - (GInstanceInitFunc) account_combo_box_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - GTK_TYPE_COMBO_BOX, "EAccountComboBox", &type_info, 0); - } - - return type; -} - GtkWidget * e_account_combo_box_new (void) { -- cgit v1.2.3