diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2010-08-24 23:21:41 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2010-08-25 02:37:02 +0800 |
commit | ecf3434da05b1f39f793c24b38bfd278e10b5786 (patch) | |
tree | 485ed2399920ecb10dbee2b4db4c437c22574a20 /e-util/e-config.c | |
parent | f1d2541c487fbf7433a1b9aad8e8982ef08b85f5 (diff) | |
download | gsoc2013-evolution-ecf3434da05b1f39f793c24b38bfd278e10b5786.tar.gz gsoc2013-evolution-ecf3434da05b1f39f793c24b38bfd278e10b5786.tar.zst gsoc2013-evolution-ecf3434da05b1f39f793c24b38bfd278e10b5786.zip |
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.
Diffstat (limited to 'e-util/e-config.c')
-rw-r--r-- | e-util/e-config.c | 102 |
1 files changed, 29 insertions, 73 deletions
diff --git a/e-util/e-config.c b/e-util/e-config.c index 44e55a182f..2b8d948fe5 100644 --- a/e-util/e-config.c +++ b/e-util/e-config.c @@ -88,10 +88,13 @@ struct _EConfigPrivate { GList *finish_pages; }; -static gpointer parent_class; - static GtkWidget *ech_config_section_factory (EConfig *config, EConfigItem *item, GtkWidget *parent, GtkWidget *old, gpointer data, GtkWidget **real_frame); +G_DEFINE_TYPE ( + EConfig, + e_config, + G_TYPE_OBJECT) + static void config_finalize (GObject *object) { @@ -151,7 +154,7 @@ config_finalize (GObject *object) } /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (e_config_parent_class)->finalize (object); } static void @@ -173,11 +176,10 @@ config_set_target (EConfig *config, } static void -config_class_init (EConfigClass *class) +e_config_class_init (EConfigClass *class) { GObjectClass *object_class; - parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EConfigPrivate)); object_class = G_OBJECT_CLASS (class); @@ -188,46 +190,12 @@ config_class_init (EConfigClass *class) } static void -config_init (EConfig *config) +e_config_init (EConfig *config) { config->priv = E_CONFIG_GET_PRIVATE (config); } /** - * e_config_get_type: - * - * Standard GObject method. Used to subclass for the concrete - * implementations. - * - * Return value: EConfig type. - **/ -GType -e_config_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EConfigClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) config_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EConfig), - 0, /* n_preallocs */ - (GInstanceInitFunc) config_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - G_TYPE_OBJECT, "EConfig", &type_info, 0); - } - - return type; -} - -/** * e_config_construct: * @ep: The instance to initialise. * @type: The type of configuration manager, @E_CONFIG_BOOK or @@ -1585,7 +1553,6 @@ e_config_target_free(EConfig *ep, gpointer o) */ -static gpointer emph_parent_class; #define emph ((EConfigHook *)eph) static const EPluginHookTargetKey ech_item_types[] = { @@ -1602,6 +1569,11 @@ static const EPluginHookTargetKey ech_item_types[] = { { NULL }, }; +G_DEFINE_TYPE ( + EConfigHook, + e_config_hook, + E_TYPE_PLUGIN_HOOK) + static void ech_commit(EConfig *ec, GSList *items, gpointer data) { @@ -1854,7 +1826,7 @@ emph_construct(EPluginHook *eph, EPlugin *ep, xmlNodePtr root) d(printf("loading config hook\n")); - if (((EPluginHookClass *)emph_parent_class)->construct(eph, ep, root) == -1) + if (((EPluginHookClass *)e_config_hook_parent_class)->construct(eph, ep, root) == -1) return -1; class = ((EConfigHookClass *)G_OBJECT_GET_CLASS(eph))->config_class; @@ -1886,47 +1858,31 @@ emph_finalize(GObject *o) g_slist_foreach(emph->groups, (GFunc)emph_free_group, NULL); g_slist_free(emph->groups); - ((GObjectClass *)emph_parent_class)->finalize(o); + ((GObjectClass *)e_config_hook_parent_class)->finalize(o); } static void -emph_class_init(EPluginHookClass *class) +e_config_hook_class_init (EConfigHookClass *class) { - ((GObjectClass *)class)->finalize = emph_finalize; - class->construct = emph_construct; + GObjectClass *object_class; + EPluginHookClass *plugin_hook_class; - /* this is actually an abstract implementation but list it anyway */ - class->id = "org.gnome.evolution.config:1.0"; + object_class = G_OBJECT_CLASS (class); + object_class->finalize = emph_finalize; - d(printf("EConfigHook: init class %p '%s'\n", class, g_type_name(((GObjectClass *)class)->g_type_class.g_type))); + plugin_hook_class = E_PLUGIN_HOOK_CLASS (class); + plugin_hook_class->construct = emph_construct; + + /* this is actually an abstract implementation but list it anyway */ + plugin_hook_class->id = "org.gnome.evolution.config:1.0"; - ((EConfigHookClass *)class)->target_map = g_hash_table_new(g_str_hash, g_str_equal); - ((EConfigHookClass *)class)->config_class = g_type_class_ref(e_config_get_type()); + class->target_map = g_hash_table_new (g_str_hash, g_str_equal); + class->config_class = g_type_class_ref (e_config_get_type()); } -/** - * e_config_hook_get_type: - * - * Standard GObject function to get the object type. - * - * Return value: The EConfigHook class type. - **/ -GType -e_config_hook_get_type(void) +static void +e_config_hook_init (EConfigHook *hook) { - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof(EConfigHookClass), NULL, NULL, (GClassInitFunc) emph_class_init, NULL, NULL, - sizeof(EConfigHook), 0, (GInstanceInitFunc) NULL, - }; - - emph_parent_class = g_type_class_ref(e_plugin_hook_get_type()); - type = g_type_register_static(e_plugin_hook_get_type(), "EConfigHook", &info, 0); - } - - return type; } /** |