From bf30024dd7973006bf99d0ae509a7f0022368a41 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 7 Dec 2012 16:30:18 -0500 Subject: Teach EMailExtensionRegistry to find extensions. Now we have the following extension points in the GType hierarchy: E_TYPE_MAIL_FORMATTER_EXTENSION E_TYPE_MAIL_FORMATTER_PRINT_EXTENSION E_TYPE_MAIL_FORMATTER_QUOTE_EXTENSION E_TYPE_MAIL_PARSER_EXTENSION A registry just needs to be given one of these extension points, and it can use g_type_children() to find and load all registered extensions. This eliminates e-mail-format-extensions.[ch] as well as the dynamic loaders I added a few commits back. Dynamically loaded extensions are now easier to register, at the cost of internal extensions being a tad more cumbersome to register. Fair tradeoff, imo. This also makes e_mail_extension_registry_add_extension() a private function used only by e_mail_formatter_extension_registry_load() and e_mail_parser_extension_registry_load(). --- .../e-mail-formatter-text-highlight.c | 41 ---------------------- .../text-highlight/e-mail-parser-text-highlight.c | 41 ---------------------- 2 files changed, 82 deletions(-) (limited to 'modules/text-highlight') diff --git a/modules/text-highlight/e-mail-formatter-text-highlight.c b/modules/text-highlight/e-mail-formatter-text-highlight.c index fc5ca1d482..dd5ed1d4d5 100644 --- a/modules/text-highlight/e-mail-formatter-text-highlight.c +++ b/modules/text-highlight/e-mail-formatter-text-highlight.c @@ -45,18 +45,12 @@ typedef EExtension EMailFormatterTextHighlightLoader; typedef EExtensionClass EMailFormatterTextHighlightLoaderClass; GType e_mail_formatter_text_highlight_get_type (void); -GType e_mail_formatter_text_highlight_loader_get_type (void); G_DEFINE_DYNAMIC_TYPE ( EMailFormatterTextHighlight, e_mail_formatter_text_highlight, E_TYPE_MAIL_FORMATTER_EXTENSION) -G_DEFINE_DYNAMIC_TYPE ( - EMailFormatterTextHighlightLoader, - e_mail_formatter_text_highlight_loader, - E_TYPE_EXTENSION) - static gchar * get_default_font (void) { @@ -375,44 +369,9 @@ e_mail_formatter_text_highlight_init (EMailFormatterExtension *extension) { } -static void -mail_formatter_text_highlight_loader_constructed (GObject *object) -{ - EExtensible *extensible; - - extensible = e_extension_get_extensible (E_EXTENSION (object)); - - e_mail_extension_registry_add_extension ( - E_MAIL_EXTENSION_REGISTRY (extensible), - get_mime_types (), - e_mail_formatter_text_highlight_get_type ()); -} - -static void -e_mail_formatter_text_highlight_loader_class_init (EExtensionClass *class) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (class); - object_class->constructed = mail_formatter_text_highlight_loader_constructed; - - class->extensible_type = E_TYPE_MAIL_FORMATTER_EXTENSION_REGISTRY; -} - -static void -e_mail_formatter_text_highlight_loader_class_finalize (EExtensionClass *class) -{ -} - -static void -e_mail_formatter_text_highlight_loader_init (EExtension *extension) -{ -} - void e_mail_formatter_text_highlight_type_register (GTypeModule *type_module) { e_mail_formatter_text_highlight_register_type (type_module); - e_mail_formatter_text_highlight_loader_register_type (type_module); } diff --git a/modules/text-highlight/e-mail-parser-text-highlight.c b/modules/text-highlight/e-mail-parser-text-highlight.c index 99d920fe0b..28d10409b1 100644 --- a/modules/text-highlight/e-mail-parser-text-highlight.c +++ b/modules/text-highlight/e-mail-parser-text-highlight.c @@ -41,18 +41,12 @@ typedef EExtension EMailParserTextHighlightLoader; typedef EExtensionClass EMailParserTextHighlightLoaderClass; GType e_mail_parser_text_highlight_get_type (void); -GType e_mail_parser_text_highlight_loader_get_type (void); G_DEFINE_DYNAMIC_TYPE ( EMailParserTextHighlight, e_mail_parser_text_highlight, E_TYPE_MAIL_PARSER_EXTENSION) -G_DEFINE_DYNAMIC_TYPE ( - EMailParserTextHighlightLoader, - e_mail_parser_text_highlight_loader, - E_TYPE_EXTENSION) - static gboolean empe_text_highlight_parse (EMailParserExtension *extension, EMailParser *parser, @@ -110,44 +104,9 @@ e_mail_parser_text_highlight_init (EMailParserExtension *extension) { } -static void -mail_parser_text_highlight_loader_constructed (GObject *object) -{ - EExtensible *extensible; - - extensible = e_extension_get_extensible (E_EXTENSION (object)); - - e_mail_extension_registry_add_extension ( - E_MAIL_EXTENSION_REGISTRY (extensible), - get_mime_types (), - e_mail_parser_text_highlight_get_type ()); -} - -static void -e_mail_parser_text_highlight_loader_class_init (EExtensionClass *class) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (class); - object_class->constructed = mail_parser_text_highlight_loader_constructed; - - class->extensible_type = E_TYPE_MAIL_PARSER_EXTENSION_REGISTRY; -} - -static void -e_mail_parser_text_highlight_loader_class_finalize (EExtensionClass *class) -{ -} - -static void -e_mail_parser_text_highlight_loader_init (EExtension *extension) -{ -} - void e_mail_parser_text_highlight_type_register (GTypeModule *type_module) { e_mail_parser_text_highlight_register_type (type_module); - e_mail_parser_text_highlight_loader_register_type (type_module); } -- cgit v1.2.3