From 5eb12906c4242a576ad6fac4d229f096d3aab17a Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 10 May 2009 13:18:28 -0400 Subject: Use the proper idiom for loading types in a GTypeModule. Also, combine calendar, memo, and task backends into a single module, similar to how it worked under Bonobo. --- mail/Makefile.am | 5 ++-- mail/e-mail-shell-backend.c | 56 ++++++++++++++---------------------- mail/e-mail-shell-backend.h | 7 ++--- mail/e-mail-shell-content.c | 62 +++++++++++++++++++++------------------- mail/e-mail-shell-content.h | 30 ++++++++++--------- mail/e-mail-shell-sidebar.c | 43 ++++++++++++++-------------- mail/e-mail-shell-sidebar.h | 6 ++-- mail/e-mail-shell-view-private.c | 2 +- mail/e-mail-shell-view.c | 45 +++++++++++++++-------------- mail/e-mail-shell-view.h | 10 ++----- mail/evolution-module-mail.c | 45 +++++++++++++++++++++++++++++ 11 files changed, 173 insertions(+), 138 deletions(-) create mode 100644 mail/evolution-module-mail.c (limited to 'mail') diff --git a/mail/Makefile.am b/mail/Makefile.am index e290e4cb5d..11ee7f5edc 100644 --- a/mail/Makefile.am +++ b/mail/Makefile.am @@ -35,6 +35,7 @@ module_LTLIBRARIES = \ libevolution-module-mail.la libevolution_module_mail_la_SOURCES = \ + evolution-module-mail.c \ e-attachment-handler-mail.c \ e-attachment-handler-mail.h \ e-mail-attachment-bar.c \ @@ -208,8 +209,8 @@ endif # $(REGEX_LIBS) \ # $(THREADS_LIBS) -#libevolution_mail_la_LDFLAGS = \ -# -avoid-version -module $(NO_UNDEFINED) +libevolution_module_mail_la_LDFLAGS = \ + -avoid-version -module $(NO_UNDEFINED) #libevolution_mail_la_DEPENDENCIES = em-filter-i18n.h diff --git a/mail/e-mail-shell-backend.c b/mail/e-mail-shell-backend.c index 0d0521ebc0..8b5f6542c7 100644 --- a/mail/e-mail-shell-backend.c +++ b/mail/e-mail-shell-backend.c @@ -38,6 +38,7 @@ #include "e-mail-shell-migrate.h" #include "e-mail-shell-settings.h" +#include "e-mail-shell-sidebar.h" #include "e-mail-shell-view.h" #include "e-attachment-handler-mail.h" @@ -104,12 +105,8 @@ struct _EMailShellBackendPrivate { guint mail_sync_timeout_source_id; }; -/* Module Entry Points */ -void e_module_load (GTypeModule *type_module); -void e_module_unload (GTypeModule *type_module); - -GType e_mail_shell_backend_type = 0; static gpointer parent_class; +static GType mail_shell_backend_type; /* The array elements correspond to EMailFolderType. */ static struct { @@ -1031,41 +1028,30 @@ mail_shell_backend_init (EMailShellBackend *mail_shell_backend) } GType -e_mail_shell_backend_get_type (GTypeModule *type_module) -{ - if (e_mail_shell_backend_type == 0) { - const GTypeInfo type_info = { - sizeof (EMailShellBackendClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) mail_shell_backend_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EMailShellBackend), - 0, /* n_preallocs */ - (GInstanceInitFunc) mail_shell_backend_init, - NULL /* value_table */ - }; - - e_mail_shell_backend_type = - g_type_module_register_type ( - type_module, E_TYPE_SHELL_BACKEND, - "EMailShellBackend", &type_info, 0); - } - - return e_mail_shell_backend_type; -} - -void -e_module_load (GTypeModule *type_module) +e_mail_shell_backend_get_type (void) { - e_mail_shell_backend_get_type (type_module); - e_mail_shell_view_get_type (type_module); + return mail_shell_backend_type; } void -e_module_unload (GTypeModule *type_module) +e_mail_shell_backend_register_type (GTypeModule *type_module) { + const GTypeInfo type_info = { + sizeof (EMailShellBackendClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) mail_shell_backend_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EMailShellBackend), + 0, /* n_preallocs */ + (GInstanceInitFunc) mail_shell_backend_init, + NULL /* value_table */ + }; + + mail_shell_backend_type = g_type_module_register_type ( + type_module, E_TYPE_SHELL_BACKEND, + "EMailShellBackend", &type_info, 0); } /******************************** Public API *********************************/ diff --git a/mail/e-mail-shell-backend.h b/mail/e-mail-shell-backend.h index fdf8ec6f76..7521559b23 100644 --- a/mail/e-mail-shell-backend.h +++ b/mail/e-mail-shell-backend.h @@ -31,7 +31,7 @@ /* Standard GObject macros */ #define E_TYPE_MAIL_SHELL_BACKEND \ - (e_mail_shell_backend_type) + (e_mail_shell_backend_get_type ()) #define E_MAIL_SHELL_BACKEND(obj) \ (G_TYPE_CHECK_INSTANCE_CAST \ ((obj), E_TYPE_MAIL_SHELL_BACKEND, EMailShellBackend)) @@ -50,8 +50,6 @@ G_BEGIN_DECLS -extern GType e_mail_shell_backend_type; - typedef struct _EMailShellBackend EMailShellBackend; typedef struct _EMailShellBackendClass EMailShellBackendClass; typedef struct _EMailShellBackendPrivate EMailShellBackendPrivate; @@ -83,7 +81,8 @@ struct _EMFolderTreeModel; * directory and local folders is too much of a pain for now. */ extern EMailShellBackend *global_mail_shell_backend; -GType e_mail_shell_backend_get_type +GType e_mail_shell_backend_get_type (void); +void e_mail_shell_backend_register_type (GTypeModule *type_module); CamelFolder * e_mail_shell_backend_get_folder (EMailShellBackend *mail_shell_backend, diff --git a/mail/e-mail-shell-content.c b/mail/e-mail-shell-content.c index 50bf0471bb..de07873dc2 100644 --- a/mail/e-mail-shell-content.c +++ b/mail/e-mail-shell-content.c @@ -78,6 +78,7 @@ enum { }; static gpointer parent_class; +static GType mail_shell_content_type; static void mail_shell_content_etree_unfreeze (MessageList *message_list, @@ -677,37 +678,38 @@ mail_shell_content_init (EMailShellContent *mail_shell_content) GType e_mail_shell_content_get_type (void) { - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EMailShellContentClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) mail_shell_content_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EMailShellContent), - 0, /* n_preallocs */ - (GInstanceInitFunc) mail_shell_content_init, - NULL /* value_table */ - }; - - static const GInterfaceInfo iface_info = { - (GInterfaceInitFunc) mail_shell_content_iface_init, - (GInterfaceFinalizeFunc) NULL, - NULL /* interface_data */ - }; - - type = g_type_register_static ( - E_TYPE_SHELL_CONTENT, "EMailShellContent", - &type_info, 0); - - g_type_add_interface_static ( - type, E_TYPE_MAIL_READER, &iface_info); - } + return mail_shell_content_type; +} - return type; +void +e_mail_shell_content_register_type (GTypeModule *type_module) +{ + static const GTypeInfo type_info = { + sizeof (EMailShellContentClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) mail_shell_content_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EMailShellContent), + 0, /* n_preallocs */ + (GInstanceInitFunc) mail_shell_content_init, + NULL /* value_table */ + }; + + static const GInterfaceInfo iface_info = { + (GInterfaceInitFunc) mail_shell_content_iface_init, + (GInterfaceFinalizeFunc) NULL, + NULL /* interface_data */ + }; + + mail_shell_content_type = g_type_module_register_type ( + type_module, E_TYPE_SHELL_CONTENT, + "EMailShellContent", &type_info, 0); + + g_type_module_add_interface ( + type_module, mail_shell_content_type, + E_TYPE_MAIL_READER, &iface_info); } GtkWidget * diff --git a/mail/e-mail-shell-content.h b/mail/e-mail-shell-content.h index 485a9a8233..2c5da1b27f 100644 --- a/mail/e-mail-shell-content.h +++ b/mail/e-mail-shell-content.h @@ -25,7 +25,7 @@ #include #include -#include "em-format-html-display.h" +#include /* Standard GObject macros */ #define E_TYPE_MAIL_SHELL_CONTENT \ @@ -62,30 +62,32 @@ struct _EMailShellContentClass { }; GType e_mail_shell_content_get_type (void); -GtkWidget * e_mail_shell_content_new (EShellView *shell_view); +void e_mail_shell_content_register_type + (GTypeModule *type_module); +GtkWidget * e_mail_shell_content_new(EShellView *shell_view); gboolean e_mail_shell_content_get_preview_visible - (EMailShellContent *mail_shell_content); + (EMailShellContent *mail_shell_content); void e_mail_shell_content_set_preview_visible - (EMailShellContent *mail_shell_content, + (EMailShellContent *mail_shell_content, gboolean preview_visible); gboolean e_mail_shell_content_get_show_deleted - (EMailShellContent *mail_shell_content); + (EMailShellContent *mail_shell_content); void e_mail_shell_content_set_show_deleted - (EMailShellContent *mail_shell_content, - gboolean show_deleted); + (EMailShellContent *mail_shell_content, + gboolean show_deleted); gboolean e_mail_shell_content_get_vertical_view - (EMailShellContent *mail_shell_content); + (EMailShellContent *mail_shell_content); void e_mail_shell_content_set_vertical_view - (EMailShellContent *mail_shell_content, - gboolean vertical_view); + (EMailShellContent *mail_shell_content, + gboolean vertical_view); GalViewInstance * e_mail_shell_content_get_view_instance - (EMailShellContent *mail_shell_content); + (EMailShellContent *mail_shell_content); void e_mail_shell_content_set_search_strings - (EMailShellContent *mail_shell_content, - GSList *search_strings); + (EMailShellContent *mail_shell_content, + GSList *search_strings); void e_mail_shell_content_update_view_instance - (EMailShellContent *mail_shell_content); + (EMailShellContent *mail_shell_content); G_END_DECLS diff --git a/mail/e-mail-shell-sidebar.c b/mail/e-mail-shell-sidebar.c index 0429cdabf9..6f6bdf7bf8 100644 --- a/mail/e-mail-shell-sidebar.c +++ b/mail/e-mail-shell-sidebar.c @@ -43,6 +43,7 @@ enum { }; static gpointer parent_class; +static GType mail_shell_sidebar_type; static void mail_shell_sidebar_selection_changed_cb (EShellSidebar *shell_sidebar, @@ -302,28 +303,28 @@ mail_shell_sidebar_init (EMailShellSidebar *mail_shell_sidebar) GType e_mail_shell_sidebar_get_type (void) { - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EMailShellSidebarClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) mail_shell_sidebar_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EMailShellSidebar), - 0, /* n_preallocs */ - (GInstanceInitFunc) mail_shell_sidebar_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - E_TYPE_SHELL_SIDEBAR, "EMailShellSidebar", - &type_info, 0); - } + return mail_shell_sidebar_type; +} - return type; +void +e_mail_shell_sidebar_register_type (GTypeModule *type_module) +{ + static const GTypeInfo type_info = { + sizeof (EMailShellSidebarClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) mail_shell_sidebar_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EMailShellSidebar), + 0, /* n_preallocs */ + (GInstanceInitFunc) mail_shell_sidebar_init, + NULL /* value_table */ + }; + + mail_shell_sidebar_type = g_type_module_register_type ( + type_module, E_TYPE_SHELL_SIDEBAR, + "EMailShellSidebar", &type_info, 0); } GtkWidget * diff --git a/mail/e-mail-shell-sidebar.h b/mail/e-mail-shell-sidebar.h index e53c803db0..5075225fc4 100644 --- a/mail/e-mail-shell-sidebar.h +++ b/mail/e-mail-shell-sidebar.h @@ -70,9 +70,11 @@ struct _EMailShellSidebarClass { }; GType e_mail_shell_sidebar_get_type (void); -GtkWidget * e_mail_shell_sidebar_new (EShellView *shell_view); +void e_mail_shell_sidebar_register_type + (GTypeModule *type_module); +GtkWidget * e_mail_shell_sidebar_new(EShellView *shell_view); EMFolderTree * e_mail_shell_sidebar_get_folder_tree - (EMailShellSidebar *mail_shell_sidebar); + (EMailShellSidebar *mail_shell_sidebar); G_END_DECLS diff --git a/mail/e-mail-shell-view-private.c b/mail/e-mail-shell-view-private.c index 615001ecb2..552ff1aff7 100644 --- a/mail/e-mail-shell-view-private.c +++ b/mail/e-mail-shell-view-private.c @@ -21,7 +21,7 @@ #include "e-mail-shell-view-private.h" -#include +#include "widgets/menus/gal-view-factory-etable.h" static void mail_shell_view_folder_tree_selected_cb (EMailShellView *mail_shell_view, diff --git a/mail/e-mail-shell-view.c b/mail/e-mail-shell-view.c index 6f4e6f9b88..f58d1f6288 100644 --- a/mail/e-mail-shell-view.c +++ b/mail/e-mail-shell-view.c @@ -21,8 +21,8 @@ #include "e-mail-shell-view-private.h" -GType e_mail_shell_view_type = 0; static gpointer parent_class; +static GType mail_shell_view_type; static void mail_shell_view_dispose (GObject *object) @@ -233,27 +233,28 @@ mail_shell_view_init (EMailShellView *mail_shell_view, } GType -e_mail_shell_view_get_type (GTypeModule *type_module) +e_mail_shell_view_get_type (void) { - if (e_mail_shell_view_type == 0) { - const GTypeInfo type_info = { - sizeof (EMailShellViewClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) mail_shell_view_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EMailShellView), - 0, /* n_preallocs */ - (GInstanceInitFunc) mail_shell_view_init, - NULL /* value_table */ - }; - - e_mail_shell_view_type = - g_type_module_register_type ( - type_module, E_TYPE_SHELL_VIEW, - "EMailShellView", &type_info, 0); - } + return mail_shell_view_type; +} - return e_mail_shell_view_type; +void +e_mail_shell_view_register_type (GTypeModule *type_module) +{ + const GTypeInfo type_info = { + sizeof (EMailShellViewClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) mail_shell_view_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EMailShellView), + 0, /* n_preallocs */ + (GInstanceInitFunc) mail_shell_view_init, + NULL /* value_table */ + }; + + mail_shell_view_type = g_type_module_register_type ( + type_module, E_TYPE_SHELL_VIEW, + "EMailShellView", &type_info, 0); } diff --git a/mail/e-mail-shell-view.h b/mail/e-mail-shell-view.h index 2c5a3642ab..2bc769557c 100644 --- a/mail/e-mail-shell-view.h +++ b/mail/e-mail-shell-view.h @@ -24,12 +24,9 @@ #include -#include -#include - /* Standard GObject macros */ #define E_TYPE_MAIL_SHELL_VIEW \ - (e_mail_shell_view_type) + (e_mail_shell_view_get_type ()) #define E_MAIL_SHELL_VIEW(obj) \ (G_TYPE_CHECK_INSTANCE_CAST \ ((obj), E_TYPE_MAIL_SHELL_VIEW, EMailShellView)) @@ -48,8 +45,6 @@ G_BEGIN_DECLS -extern GType e_mail_shell_view_type; - typedef struct _EMailShellView EMailShellView; typedef struct _EMailShellViewClass EMailShellViewClass; typedef struct _EMailShellViewPrivate EMailShellViewPrivate; @@ -63,7 +58,8 @@ struct _EMailShellViewClass { EShellViewClass parent_class; }; -GType e_mail_shell_view_get_type +GType e_mail_shell_view_get_type (void); +void e_mail_shell_view_register_type (GTypeModule *type_module); gboolean e_mail_shell_view_get_show_deleted (EMailShellView *mail_shell_view); diff --git a/mail/evolution-module-mail.c b/mail/evolution-module-mail.c new file mode 100644 index 0000000000..6f6c956202 --- /dev/null +++ b/mail/evolution-module-mail.c @@ -0,0 +1,45 @@ +/* + * evolution-module-mail.c + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#include "e-mail-shell-backend.h" +#include "e-mail-shell-content.h" +#include "e-mail-shell-sidebar.h" +#include "e-mail-shell-view.h" + +/* Module Entry Points */ +void e_module_load (GTypeModule *type_module); +void e_module_unload (GTypeModule *type_module); + +void +e_module_load (GTypeModule *type_module) +{ + /* Register dynamically loaded types. */ + + e_mail_shell_backend_register_type (type_module); + e_mail_shell_content_register_type (type_module); + e_mail_shell_sidebar_register_type (type_module); + e_mail_shell_view_register_type (type_module); +} + +void +e_module_unload (GTypeModule *type_module) +{ +} -- cgit v1.2.3