[evolution] EMailConfigFormatHTML: Use G_DEFINE_DYNAMIC_TYPE.



commit c3eacfd37e5275942635c069e6f20eb0dd22f6be
Author: Matthew Barnes <mbarnes redhat com>
Date:   Tue Oct 9 10:01:05 2012 -0400

    EMailConfigFormatHTML: Use G_DEFINE_DYNAMIC_TYPE.
    
    Follow the usual GObject conventions.

 modules/mail/e-mail-config-format-html.c |   61 ++++++++++++++++++------------
 modules/mail/e-mail-config-format-html.h |   40 ++++++++++++++++++-
 modules/mail/evolution-module-mail.c     |    2 +-
 3 files changed, 76 insertions(+), 27 deletions(-)
---
diff --git a/modules/mail/e-mail-config-format-html.c b/modules/mail/e-mail-config-format-html.c
index e146739..40edc7d 100644
--- a/modules/mail/e-mail-config-format-html.c
+++ b/modules/mail/e-mail-config-format-html.c
@@ -22,14 +22,23 @@
 
 #include "e-mail-config-format-html.h"
 
-#include <libebackend/libebackend.h>
-
 #include <shell/e-shell.h>
 #include <e-util/e-util.h>
 #include <em-format/e-mail-formatter.h>
 #include <mail/e-mail-reader-utils.h>
 
-static gpointer parent_class;
+#define E_MAIL_CONFIG_FORMAT_HTML_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE \
+	((obj), E_TYPE_MAIL_CONFIG_FORMAT_HTML, EMailConfigFormatHTMLPrivate))
+
+struct _EMailConfigFormatHTMLPrivate {
+	gint placeholder;
+};
+
+G_DEFINE_DYNAMIC_TYPE (
+	EMailConfigFormatHTML,
+	e_mail_config_format_html,
+	E_TYPE_EXTENSION)
 
 static void
 headers_changed_cb (GSettings *settings,
@@ -134,39 +143,43 @@ mail_config_format_html_constructed (GObject *object)
 	headers_changed_cb (settings, NULL, object);
 
 	/* Chain up to parent's constructed() method. */
-	G_OBJECT_CLASS (parent_class)->constructed (object);
+	G_OBJECT_CLASS (e_mail_config_format_html_parent_class)->
+		constructed (object);
 }
 
 static void
-mail_config_format_html_class_init (EExtensionClass *class)
+e_mail_config_format_html_class_init (EMailConfigFormatHTMLClass *class)
 {
 	GObjectClass *object_class;
+	EExtensionClass *extension_class;
 
-	parent_class = g_type_class_peek_parent (class);
+	g_type_class_add_private (
+		class, sizeof (EMailConfigFormatHTMLPrivate));
 
 	object_class = G_OBJECT_CLASS (class);
 	object_class->constructed = mail_config_format_html_constructed;
 
-	class->extensible_type = E_TYPE_MAIL_FORMATTER;
+	extension_class = E_EXTENSION_CLASS (class);
+	extension_class->extensible_type = E_TYPE_MAIL_FORMATTER;
+}
+
+static void
+e_mail_config_format_html_class_finalize (EMailConfigFormatHTMLClass *class)
+{
+}
+
+static void
+e_mail_config_format_html_init (EMailConfigFormatHTML *extension)
+{
+	extension->priv = E_MAIL_CONFIG_FORMAT_HTML_GET_PRIVATE (extension);
 }
 
 void
-e_mail_config_format_html_register_type (GTypeModule *type_module)
+e_mail_config_format_html_type_register (GTypeModule *type_module)
 {
-	static const GTypeInfo type_info = {
-		sizeof (EExtensionClass),
-		(GBaseInitFunc) NULL,
-		(GBaseFinalizeFunc) NULL,
-		(GClassInitFunc) mail_config_format_html_class_init,
-		(GClassFinalizeFunc) NULL,
-		NULL,  /* class_data */
-		sizeof (EExtension),
-		0,     /* n_preallocs */
-		(GInstanceInitFunc) NULL,
-		NULL   /* value_table */
-	};
-
-	g_type_module_register_type (
-		type_module, E_TYPE_EXTENSION,
-		"EMailConfigFormatHTML", &type_info, 0);
+	/* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration
+	 *     function, so we have to wrap it with a public function in
+	 *     order to register types from a separate compilation unit. */
+	e_mail_config_format_html_register_type (type_module);
 }
+
diff --git a/modules/mail/e-mail-config-format-html.h b/modules/mail/e-mail-config-format-html.h
index bed76d8..0948210 100644
--- a/modules/mail/e-mail-config-format-html.h
+++ b/modules/mail/e-mail-config-format-html.h
@@ -19,12 +19,48 @@
 #ifndef E_MAIL_CONFIG_FORMAT_HTML_H
 #define E_MAIL_CONFIG_FORMAT_HTML_H
 
-#include <glib-object.h>
+#include <libebackend/libebackend.h>
+
+/* Standard GObject macros */
+#define E_TYPE_MAIL_CONFIG_FORMAT_HTML \
+	(e_mail_config_format_html_get_type ())
+#define E_MAIL_CONFIG_FORMAT_HTML(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_MAIL_CONFIG_FORMAT_HTML, EMailConfigFormatHTML))
+#define E_MAIL_CONFIG_FORMAT_HTML_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_MAIL_CONFIG_FORMAT_HTML, EMailConfigFormatHTMLClass))
+#define E_IS_MAIL_CONFIG_FORMAT_HTML(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_MAIL_CONFIG_FORMAT_HTML))
+#define E_IS_MAIL_CONFIG_FORMAT_HTML_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_MAIL_CONFIG_FORMAT_HTML))
+#define E_MAIL_CONFIG_FORMAT_HTML_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_MAIL_CONFIG_FORMAT_HTML, EMailConfigFormatHTMLClass))
 
 G_BEGIN_DECLS
 
-void e_mail_config_format_html_register_type (GTypeModule *type_module);
+typedef struct _EMailConfigFormatHTML EMailConfigFormatHTML;
+typedef struct _EMailConfigFormatHTMLClass EMailConfigFormatHTMLClass;
+typedef struct _EMailConfigFormatHTMLPrivate EMailConfigFormatHTMLPrivate;
+
+struct _EMailConfigFormatHTML {
+	EExtension parent;
+	EMailConfigFormatHTMLPrivate *priv;
+};
+
+struct _EMailConfigFormatHTMLClass {
+	EExtensionClass parent_class;
+};
+
+GType		e_mail_config_format_html_get_type
+						(void) G_GNUC_CONST;
+void		e_mail_config_format_html_type_register
+						(GTypeModule *type_module);
 
 G_END_DECLS
 
 #endif /* E_MAIL_CONFIG_FORMAT_HTML_H */
+
diff --git a/modules/mail/evolution-module-mail.c b/modules/mail/evolution-module-mail.c
index edb22c4..35789b1 100644
--- a/modules/mail/evolution-module-mail.c
+++ b/modules/mail/evolution-module-mail.c
@@ -59,7 +59,7 @@ e_module_load (GTypeModule *type_module)
 	e_mail_shell_sidebar_type_register (type_module);
 	e_mail_shell_view_register_type (type_module);
 
-	e_mail_config_format_html_register_type (type_module);
+	e_mail_config_format_html_type_register (type_module);
 	e_mail_config_reader_register_type (type_module);
 	e_mail_config_web_view_register_type (type_module);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]