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. --- filter/e-filter-code.c | 37 ++++++----------------------------- filter/e-filter-color.c | 39 ++++++++++--------------------------- filter/e-filter-datespec.c | 39 ++++++++----------------------------- filter/e-filter-element.c | 36 ++++++++-------------------------- filter/e-filter-file.c | 39 ++++++++++--------------------------- filter/e-filter-input.c | 42 +++++++++------------------------------- filter/e-filter-int.c | 42 +++++++++------------------------------- filter/e-filter-option.c | 48 +++++++++++++--------------------------------- filter/e-filter-part.c | 36 ++++++++-------------------------- filter/e-filter-rule.c | 39 ++++++++----------------------------- filter/e-rule-context.c | 39 ++++++++----------------------------- filter/e-rule-editor.c | 40 ++++++++------------------------------ 12 files changed, 105 insertions(+), 371 deletions(-) (limited to 'filter') diff --git a/filter/e-filter-code.c b/filter/e-filter-code.c index 7c00baf8d8..ab2e19223c 100644 --- a/filter/e-filter-code.c +++ b/filter/e-filter-code.c @@ -27,7 +27,10 @@ #include "e-filter-code.h" -static gpointer parent_class; +G_DEFINE_TYPE ( + EFilterCode, + e_filter_code, + E_TYPE_FILTER_INPUT) /* here, the string IS the code */ static void @@ -60,51 +63,23 @@ filter_code_format_sexp (EFilterElement *element, } static void -filter_code_class_init (EFilterCodeClass *class) +e_filter_code_class_init (EFilterCodeClass *class) { EFilterElementClass *filter_element_class; - parent_class = g_type_class_peek_parent (class); - filter_element_class = E_FILTER_ELEMENT_CLASS (class); filter_element_class->build_code = filter_code_build_code; filter_element_class->format_sexp = filter_code_format_sexp; } static void -filter_code_init (EFilterCode *code) +e_filter_code_init (EFilterCode *code) { EFilterInput *input = E_FILTER_INPUT (code); input->type = (gchar *) xmlStrdup ((xmlChar *) "code"); } -GType -e_filter_code_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EFilterCodeClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) filter_code_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EFilterCode), - 0, /* n_preallocs */ - (GInstanceInitFunc) filter_code_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - E_TYPE_FILTER_INPUT, "EFilterCode", &type_info, 0); - } - - return type; -} - /** * filter_code_new: * diff --git a/filter/e-filter-color.c b/filter/e-filter-color.c index c4a36607cb..b181fe7c96 100644 --- a/filter/e-filter-color.c +++ b/filter/e-filter-color.c @@ -30,7 +30,10 @@ #include "e-filter-color.h" -static gpointer parent_class; +G_DEFINE_TYPE ( + EFilterColor, + e_filter_color, + E_TYPE_FILTER_ELEMENT) static void set_color (GtkColorButton *color_button, EFilterColor *fc) @@ -45,8 +48,9 @@ filter_color_eq (EFilterElement *element_a, EFilterColor *color_a = E_FILTER_COLOR (element_a); EFilterColor *color_b = E_FILTER_COLOR (element_b); - return E_FILTER_ELEMENT_CLASS (parent_class)->eq (element_a, element_b) - && gdk_color_equal (&color_a->color, &color_b->color); + return E_FILTER_ELEMENT_CLASS (e_filter_color_parent_class)-> + eq (element_a, element_b) && + gdk_color_equal (&color_a->color, &color_b->color); } static xmlNodePtr @@ -126,12 +130,10 @@ filter_color_format_sexp (EFilterElement *element, } static void -filter_color_class_init (EFilterColorClass *class) +e_filter_color_class_init (EFilterColorClass *class) { EFilterElementClass *filter_element_class; - parent_class = g_type_class_peek_parent (class); - filter_element_class = E_FILTER_ELEMENT_CLASS (class); filter_element_class->eq = filter_color_eq; filter_element_class->xml_encode = filter_color_xml_encode; @@ -140,30 +142,9 @@ filter_color_class_init (EFilterColorClass *class) filter_element_class->format_sexp = filter_color_format_sexp; } -GType -e_filter_color_get_type (void) +static void +e_filter_color_init (EFilterColor *filter) { - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EFilterColorClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) filter_color_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EFilterColor), - 0, /* n_preallocs */ - (GInstanceInitFunc) NULL, - NULL /* value_table */ - }; - - type = g_type_register_static ( - E_TYPE_FILTER_ELEMENT, "EFilterColor", &type_info, 0); - } - - return type; } /** diff --git a/filter/e-filter-datespec.c b/filter/e-filter-datespec.c index 6ceb09450f..aa94bf5c90 100644 --- a/filter/e-filter-datespec.c +++ b/filter/e-filter-datespec.c @@ -92,7 +92,10 @@ struct _EFilterDatespecPrivate { gint span; }; -static gpointer parent_class; +G_DEFINE_TYPE ( + EFilterDatespec, + e_filter_datespec, + E_TYPE_FILTER_ELEMENT) static gint get_best_span (time_t val) @@ -326,7 +329,8 @@ filter_datespec_eq (EFilterElement *element_a, EFilterDatespec *datespec_b = E_FILTER_DATESPEC (element_b); /* Chain up to parent's eq() method. */ - if (!E_FILTER_ELEMENT_CLASS (parent_class)->eq (element_a, element_b)) + if (!E_FILTER_ELEMENT_CLASS (e_filter_datespec_parent_class)-> + eq (element_a, element_b)) return FALSE; return (datespec_a->type == datespec_b->type) && @@ -433,11 +437,10 @@ filter_datespec_format_sexp (EFilterElement *element, } static void -filter_datespec_class_init (EFilterDatespecClass *class) +e_filter_datespec_class_init (EFilterDatespecClass *class) { EFilterElementClass *filter_element_class; - parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EFilterDatespecPrivate)); filter_element_class = E_FILTER_ELEMENT_CLASS (class); @@ -450,38 +453,12 @@ filter_datespec_class_init (EFilterDatespecClass *class) } static void -filter_datespec_init (EFilterDatespec *datespec) +e_filter_datespec_init (EFilterDatespec *datespec) { datespec->priv = E_FILTER_DATESPEC_GET_PRIVATE (datespec); datespec->type = FDST_UNKNOWN; } -GType -e_filter_datespec_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EFilterDatespecClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) filter_datespec_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EFilterDatespec), - 0, /* n_preallocs */ - (GInstanceInitFunc) filter_datespec_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - E_TYPE_FILTER_ELEMENT, "EFilterDatespec", &type_info, 0); - } - - return type; -} - /** * filter_datespec_new: * diff --git a/filter/e-filter-element.c b/filter/e-filter-element.c index 61ca68295c..8062500aad 100644 --- a/filter/e-filter-element.c +++ b/filter/e-filter-element.c @@ -38,7 +38,10 @@ struct _element_type { gpointer data; }; -static gpointer parent_class; +G_DEFINE_TYPE ( + EFilterElement, + e_filter_element, + G_TYPE_OBJECT) static gboolean filter_element_validate (EFilterElement *element, @@ -188,16 +191,14 @@ filter_element_finalize (GObject *object) xmlFree (element->name); /* Chain up to parent's finalize () method. */ - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (e_filter_element_parent_class)->finalize (object); } static void -filter_element_class_init (EFilterElementClass *class) +e_filter_element_class_init (EFilterElementClass *class) { GObjectClass *object_class; - parent_class = g_type_class_peek_parent (class); - object_class = G_OBJECT_CLASS (class); object_class->finalize = filter_element_finalize; @@ -208,30 +209,9 @@ filter_element_class_init (EFilterElementClass *class) class->copy_value = filter_element_copy_value; } -GType -e_filter_element_get_type (void) +static void +e_filter_element_init (EFilterElement *element) { - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EFilterElementClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) filter_element_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EFilterElement), - 0, /* n_preallocs */ - (GInstanceInitFunc) NULL, - NULL /* value_table */ - }; - - type = g_type_register_static ( - G_TYPE_OBJECT, "EFilterElement", &type_info, 0); - } - - return type; } /** diff --git a/filter/e-filter-file.c b/filter/e-filter-file.c index 2a622f8e93..91942ec6f6 100644 --- a/filter/e-filter-file.c +++ b/filter/e-filter-file.c @@ -36,7 +36,10 @@ #include "e-filter-file.h" #include "e-filter-part.h" -static gpointer parent_class; +G_DEFINE_TYPE ( + EFilterFile, + e_filter_file, + E_TYPE_FILTER_ELEMENT) static void filter_file_filename_changed (GtkFileChooser *file_chooser, @@ -60,7 +63,7 @@ filter_file_finalize (GObject *object) g_free (file->path); /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (e_filter_file_parent_class)->finalize (object); } static gboolean @@ -103,7 +106,8 @@ filter_file_eq (EFilterElement *element_a, EFilterFile *file_b = E_FILTER_FILE (element_b); /* Chain up to parent's eq() method. */ - if (!E_FILTER_ELEMENT_CLASS (parent_class)->eq (element_a, element_b)) + if (!E_FILTER_ELEMENT_CLASS (e_filter_file_parent_class)-> + eq (element_a, element_b)) return FALSE; if (g_strcmp0 (file_a->path, file_b->path) != 0) @@ -201,13 +205,11 @@ filter_file_format_sexp (EFilterElement *element, } static void -filter_file_class_init (EFilterFileClass *class) +e_filter_file_class_init (EFilterFileClass *class) { GObjectClass *object_class; EFilterElementClass *filter_element_class; - parent_class = g_type_class_peek_parent (class); - object_class = G_OBJECT_CLASS (class); object_class->finalize = filter_file_finalize; @@ -220,30 +222,9 @@ filter_file_class_init (EFilterFileClass *class) filter_element_class->format_sexp = filter_file_format_sexp; } -GType -e_filter_file_get_type (void) +static void +e_filter_file_init (EFilterFile *filter) { - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EFilterFileClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) filter_file_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EFilterFile), - 0, /* n_preallocs */ - (GInstanceInitFunc) NULL, - NULL /* value_table */ - }; - - type = g_type_register_static ( - E_TYPE_FILTER_ELEMENT, "EFilterFile", &type_info, 0); - } - - return type; } /** diff --git a/filter/e-filter-input.c b/filter/e-filter-input.c index 79d9fffb73..ec92030333 100644 --- a/filter/e-filter-input.c +++ b/filter/e-filter-input.c @@ -38,7 +38,10 @@ #include "e-filter-input.h" -static gpointer parent_class; +G_DEFINE_TYPE ( + EFilterInput, + e_filter_input, + E_TYPE_FILTER_ELEMENT) static void filter_input_entry_changed (GtkEntry *entry, @@ -65,7 +68,7 @@ filter_input_finalize (GObject *object) g_list_free (input->values); /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (e_filter_input_parent_class)->finalize (object); } static gboolean @@ -122,7 +125,8 @@ filter_input_eq (EFilterElement *element_a, GList *link_b; /* Chain up to parent's eq() method. */ - if (!E_FILTER_ELEMENT_CLASS (parent_class)->eq (element_a, element_b)) + if (!E_FILTER_ELEMENT_CLASS (e_filter_input_parent_class)-> + eq (element_a, element_b)) return FALSE; if (g_strcmp0 (input_a->type, input_b->type) != 0) @@ -242,13 +246,11 @@ filter_input_format_sexp (EFilterElement *element, } static void -filter_input_class_init (EFilterInputClass *class) +e_filter_input_class_init (EFilterInputClass *class) { GObjectClass *object_class; EFilterElementClass *filter_element_class; - parent_class = g_type_class_peek_parent (class); - object_class = G_OBJECT_CLASS (class); object_class->finalize = filter_input_finalize; @@ -262,37 +264,11 @@ filter_input_class_init (EFilterInputClass *class) } static void -filter_input_init (EFilterInput *input) +e_filter_input_init (EFilterInput *input) { input->values = g_list_prepend (NULL, g_strdup ("")); } -GType -e_filter_input_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EFilterInputClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) filter_input_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EFilterInput), - 0, /* n_preallocs */ - (GInstanceInitFunc) filter_input_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - E_TYPE_FILTER_ELEMENT, "EFilterInput", &type_info, 0); - } - - return type; -} - /** * filter_input_new: * diff --git a/filter/e-filter-int.c b/filter/e-filter-int.c index d9d7b1f357..68f8417423 100644 --- a/filter/e-filter-int.c +++ b/filter/e-filter-int.c @@ -31,7 +31,10 @@ #include "e-filter-int.h" -static gpointer parent_class; +G_DEFINE_TYPE ( + EFilterInt, + e_filter_int, + E_TYPE_FILTER_ELEMENT) static void filter_int_spin_changed (GtkSpinButton *spin_button, @@ -50,7 +53,7 @@ filter_int_finalize (GObject *object) g_free (filter_int->type); /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (e_filter_int_parent_class)->finalize (object); } static gint @@ -61,7 +64,8 @@ filter_int_eq (EFilterElement *element_a, EFilterInt *filter_int_b = E_FILTER_INT (element_b); /* Chain up to parent's eq() method. */ - if (!E_FILTER_ELEMENT_CLASS (parent_class)->eq (element_a, element_b)) + if (!E_FILTER_ELEMENT_CLASS (e_filter_int_parent_class)-> + eq (element_a, element_b)) return FALSE; return (filter_int_a->val == filter_int_b->val); @@ -172,13 +176,11 @@ filter_int_format_sexp (EFilterElement *element, } static void -filter_int_class_init (EFilterIntClass *class) +e_filter_int_class_init (EFilterIntClass *class) { GObjectClass *object_class; EFilterElementClass *filter_element_class; - parent_class = g_type_class_peek_parent (class); - object_class = G_OBJECT_CLASS (class); object_class->finalize = filter_int_finalize; @@ -192,38 +194,12 @@ filter_int_class_init (EFilterIntClass *class) } static void -filter_int_init (EFilterInt *filter_int) +e_filter_int_init (EFilterInt *filter_int) { filter_int->min = 0; filter_int->max = G_MAXINT; } -GType -e_filter_int_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EFilterIntClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) filter_int_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EFilterInt), - 0, /* n_preallocs */ - (GInstanceInitFunc) filter_int_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - E_TYPE_FILTER_ELEMENT, "EFilterInt", &type_info, 0); - } - - return type; -} - /** * filter_int_new: * diff --git a/filter/e-filter-option.c b/filter/e-filter-option.c index a9e99e06ff..c0ce5b778f 100644 --- a/filter/e-filter-option.c +++ b/filter/e-filter-option.c @@ -36,7 +36,10 @@ #include "e-filter-option.h" #include "e-filter-part.h" -static gpointer parent_class; +G_DEFINE_TYPE ( + EFilterOption, + e_filter_option, + E_TYPE_FILTER_ELEMENT) static void free_option (struct _filter_option *opt) @@ -108,7 +111,7 @@ filter_option_finalize (GObject *object) g_free (option->dynamic_func); /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (e_filter_option_parent_class)->finalize (object); } static gint @@ -119,7 +122,8 @@ filter_option_eq (EFilterElement *element_a, EFilterOption *option_b = E_FILTER_OPTION (element_b); /* Chain up to parent's eq() method. */ - if (!E_FILTER_ELEMENT_CLASS (parent_class)->eq (element_a, element_b)) + if (!E_FILTER_ELEMENT_CLASS (e_filter_option_parent_class)-> + eq (element_a, element_b)) return FALSE; if (option_a->current == NULL && option_b->current == NULL) @@ -139,7 +143,8 @@ filter_option_xml_create (EFilterElement *element, xmlNodePtr n, work; /* Chain up to parent's xml_create() method. */ - E_FILTER_ELEMENT_CLASS (parent_class)->xml_create (element, node); + E_FILTER_ELEMENT_CLASS (e_filter_option_parent_class)-> + xml_create (element, node); n = node->children; while (n) { @@ -269,7 +274,8 @@ filter_option_clone (EFilterElement *element) GList *link; /* Chain up to parent's clone() method. */ - clone = E_FILTER_ELEMENT_CLASS (parent_class)->clone (element); + clone = E_FILTER_ELEMENT_CLASS (e_filter_option_parent_class)-> + clone (element); clone_option = E_FILTER_OPTION (clone); @@ -393,13 +399,11 @@ filter_option_format_sexp (EFilterElement *element, } static void -filter_option_class_init (EFilterOptionClass *class) +e_filter_option_class_init (EFilterOptionClass *class) { GObjectClass *object_class; EFilterElementClass *filter_element_class; - parent_class = g_type_class_peek_parent (class); - object_class = G_OBJECT_CLASS (class); object_class->finalize = filter_option_finalize; @@ -415,38 +419,12 @@ filter_option_class_init (EFilterOptionClass *class) } static void -filter_option_init (EFilterOption *option) +e_filter_option_init (EFilterOption *option) { option->type = "option"; option->dynamic_func = NULL; } -GType -e_filter_option_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EFilterOptionClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) filter_option_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EFilterOption), - 0, /* n_preallocs */ - (GInstanceInitFunc) filter_option_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - E_TYPE_FILTER_ELEMENT, "EFilterOption", &type_info, 0); - } - - return type; -} - /** * filter_option_new: * diff --git a/filter/e-filter-part.c b/filter/e-filter-part.c index 4e6b114c37..2b75b30235 100644 --- a/filter/e-filter-part.c +++ b/filter/e-filter-part.c @@ -35,7 +35,10 @@ #include "e-filter-part.h" #include "e-rule-context.h" -static gpointer parent_class; +G_DEFINE_TYPE ( + EFilterPart, + e_filter_part, + G_TYPE_OBJECT) static void filter_part_finalize (GObject *object) @@ -50,44 +53,21 @@ filter_part_finalize (GObject *object) g_free (part->code); /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (e_filter_part_parent_class)->finalize (object); } static void -filter_part_class_init (EFilterPartClass *class) +e_filter_part_class_init (EFilterPartClass *class) { GObjectClass *object_class; - parent_class = g_type_class_peek_parent (class); - object_class = G_OBJECT_CLASS (class); object_class->finalize = filter_part_finalize; } -GType -e_filter_part_get_type (void) +static void +e_filter_part_init (EFilterPart *part) { - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EFilterPartClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) filter_part_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EFilterPart), - 0, /* n_preallocs */ - (GInstanceInitFunc) NULL, - NULL /* value_table */ - }; - - type = g_type_register_static ( - G_TYPE_OBJECT, "EFilterPart", &type_info, 0); - } - - return type; } /** diff --git a/filter/e-filter-rule.c b/filter/e-filter-rule.c index 2692972b16..13c95d430e 100644 --- a/filter/e-filter-rule.c +++ b/filter/e-filter-rule.c @@ -65,9 +65,13 @@ enum { LAST_SIGNAL }; -static gpointer parent_class; static guint signals[LAST_SIGNAL]; +G_DEFINE_TYPE ( + EFilterRule, + e_filter_rule, + G_TYPE_OBJECT) + static void filter_rule_grouping_changed_cb (GtkComboBox *combo_box, EFilterRule *rule) @@ -353,7 +357,7 @@ filter_rule_finalize (GObject *object) g_list_free (rule->parts); /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (e_filter_rule_parent_class)->finalize (object); } static gint @@ -814,11 +818,10 @@ filter_rule_get_widget (EFilterRule *rule, } static void -filter_rule_class_init (EFilterRuleClass *class) +e_filter_rule_class_init (EFilterRuleClass *class) { GObjectClass *object_class; - parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EFilterRulePrivate)); object_class = G_OBJECT_CLASS (class); @@ -844,38 +847,12 @@ filter_rule_class_init (EFilterRuleClass *class) } static void -filter_rule_init (EFilterRule *rule) +e_filter_rule_init (EFilterRule *rule) { rule->priv = E_FILTER_RULE_GET_PRIVATE (rule); rule->enabled = TRUE; } -GType -e_filter_rule_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EFilterRuleClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) filter_rule_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EFilterRule), - 0, /* n_preallocs */ - (GInstanceInitFunc) filter_rule_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - G_TYPE_OBJECT, "EFilterRule", &type_info, 0); - } - - return type; -} - /** * filter_rule_new: * diff --git a/filter/e-rule-context.c b/filter/e-rule-context.c index 9abe7599e6..727c546373 100644 --- a/filter/e-rule-context.c +++ b/filter/e-rule-context.c @@ -68,7 +68,6 @@ enum { LAST_SIGNAL }; -static gpointer parent_class; static guint signals[LAST_SIGNAL]; struct _revert_data { @@ -76,6 +75,11 @@ struct _revert_data { gint rank; }; +G_DEFINE_TYPE ( + ERuleContext, + e_rule_context, + G_TYPE_OBJECT) + static void rule_context_set_error (ERuleContext *context, gchar *error) @@ -184,7 +188,7 @@ rule_context_finalize (GObject *obj) g_list_foreach (context->rules, (GFunc)g_object_unref, NULL); g_list_free (context->rules); - G_OBJECT_CLASS (parent_class)->finalize (obj); + G_OBJECT_CLASS (e_rule_context_parent_class)->finalize (obj); } static gint @@ -463,11 +467,10 @@ rule_context_new_element (ERuleContext *context, } static void -rule_context_class_init (ERuleContextClass *class) +e_rule_context_class_init (ERuleContextClass *class) { GObjectClass *object_class; - parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (ERuleContextPrivate)); object_class = G_OBJECT_CLASS (class); @@ -512,7 +515,7 @@ rule_context_class_init (ERuleContextClass *class) } static void -rule_context_init (ERuleContext *context) +e_rule_context_init (ERuleContext *context) { context->priv = E_RULE_CONTEXT_GET_PRIVATE (context); @@ -522,32 +525,6 @@ rule_context_init (ERuleContext *context) context->flags = E_RULE_CONTEXT_GROUPING; } -GType -e_rule_context_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (ERuleContextClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) rule_context_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (ERuleContext), - 0, /* n_preallocs */ - (GInstanceInitFunc) rule_context_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - G_TYPE_OBJECT, "ERuleContext", &type_info, 0); - } - - return type; -} - /** * e_rule_context_new: * diff --git a/filter/e-rule-editor.c b/filter/e-rule-editor.c index f1bf0e26a7..9becdf80e4 100644 --- a/filter/e-rule-editor.c +++ b/filter/e-rule-editor.c @@ -58,7 +58,10 @@ struct _ERuleEditorPrivate { GtkButton *buttons[BUTTON_LAST]; }; -static gpointer parent_class; +G_DEFINE_TYPE ( + ERuleEditor, + e_rule_editor, + GTK_TYPE_DIALOG) static void rule_editor_add_undo (ERuleEditor *editor, @@ -558,7 +561,7 @@ rule_editor_finalize (GObject *object) } /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (e_rule_editor_parent_class)->finalize (object); } static void @@ -572,7 +575,7 @@ rule_editor_destroy (GtkObject *gtk_object) } /* Chain up to parent's destroy() method. */ - GTK_OBJECT_CLASS (parent_class)->destroy (gtk_object); + GTK_OBJECT_CLASS (e_rule_editor_parent_class)->destroy (gtk_object); } static void @@ -634,12 +637,11 @@ rule_editor_create_rule (ERuleEditor *editor) } static void -rule_editor_class_init (ERuleEditorClass *class) +e_rule_editor_class_init (ERuleEditorClass *class) { GObjectClass *object_class; GtkObjectClass *gtk_object_class; - parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (ERuleEditorPrivate)); object_class = G_OBJECT_CLASS (class); @@ -657,37 +659,11 @@ rule_editor_class_init (ERuleEditorClass *class) } static void -rule_editor_init (ERuleEditor *editor) +e_rule_editor_init (ERuleEditor *editor) { editor->priv = E_RULE_EDITOR_GET_PRIVATE (editor); } -GType -e_rule_editor_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (ERuleEditorClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) rule_editor_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (ERuleEditor), - 0, /* n_preallocs */ - (GInstanceInitFunc) rule_editor_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - GTK_TYPE_DIALOG, "ERuleEditor", &type_info, 0); - } - - return type; -} - /** * rule_editor_new: * -- cgit