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. --- addressbook/gui/component/Makefile.am | 49 ++++++++-------- addressbook/gui/component/e-book-shell-backend.c | 67 +++++++++------------- addressbook/gui/component/e-book-shell-backend.h | 7 +-- addressbook/gui/component/e-book-shell-content.c | 46 ++++++++------- addressbook/gui/component/e-book-shell-content.h | 34 ++++++----- addressbook/gui/component/e-book-shell-sidebar.c | 43 +++++++------- addressbook/gui/component/e-book-shell-sidebar.h | 10 ++-- .../gui/component/e-book-shell-view-private.c | 6 +- .../gui/component/e-book-shell-view-private.h | 2 +- addressbook/gui/component/e-book-shell-view.c | 45 ++++++++------- addressbook/gui/component/e-book-shell-view.h | 9 ++- .../gui/component/evolution-module-addressbook.c | 45 +++++++++++++++ 12 files changed, 201 insertions(+), 162 deletions(-) create mode 100644 addressbook/gui/component/evolution-module-addressbook.c (limited to 'addressbook') diff --git a/addressbook/gui/component/Makefile.am b/addressbook/gui/component/Makefile.am index 4f89f823c7..e48ef4619e 100644 --- a/addressbook/gui/component/Makefile.am +++ b/addressbook/gui/component/Makefile.am @@ -20,35 +20,36 @@ INCLUDES = \ $(LDAP_CFLAGS) \ $(EVOLUTION_ADDRESSBOOK_CFLAGS) -module_LTLIBRARIES = libevolution-module-contacts.la - -libevolution_module_contacts_la_SOURCES = \ - addressbook-config.c \ - addressbook-config.h \ - autocompletion-config.c \ - autocompletion-config.h \ - eab-composer-util.c \ - eab-composer-util.h \ - e-book-shell-backend.c \ - e-book-shell-backend.h \ - e-book-shell-content.c \ - e-book-shell-content.h \ - e-book-shell-migrate.c \ - e-book-shell-migrate.h \ - e-book-shell-sidebar.c \ - e-book-shell-sidebar.h \ - e-book-shell-view.c \ - e-book-shell-view.h \ - e-book-shell-view-actions.c \ - e-book-shell-view-actions.h \ - e-book-shell-view-private.c \ +module_LTLIBRARIES = libevolution-module-addressbook.la + +libevolution_module_addressbook_la_SOURCES = \ + evolution-module-addressbook.c \ + addressbook-config.c \ + addressbook-config.h \ + autocompletion-config.c \ + autocompletion-config.h \ + eab-composer-util.c \ + eab-composer-util.h \ + e-book-shell-backend.c \ + e-book-shell-backend.h \ + e-book-shell-content.c \ + e-book-shell-content.h \ + e-book-shell-migrate.c \ + e-book-shell-migrate.h \ + e-book-shell-sidebar.c \ + e-book-shell-sidebar.h \ + e-book-shell-view.c \ + e-book-shell-view.h \ + e-book-shell-view-actions.c \ + e-book-shell-view-actions.h \ + e-book-shell-view-private.c \ e-book-shell-view-private.h if ENABLE_SMIME SMIME_LIB=$(top_builddir)/smime/gui/libevolution-smime.la endif -libevolution_module_contacts_la_LIBADD = \ +libevolution_module_addressbook_la_LIBADD = \ $(SMIME_LIB) \ $(top_builddir)/e-util/libeutil.la \ $(top_builddir)/composer/libcomposer.la \ @@ -70,7 +71,7 @@ libevolution_module_contacts_la_LIBADD = \ $(EVOLUTION_ADDRESSBOOK_LIBS) $(LDAP_LIBS) -libevolution_module_contacts_la_LDFLAGS = \ +libevolution_module_addressbook_la_LDFLAGS = \ -module -avoid-version $(NO_UNDEFINED) # GConf schemas diff --git a/addressbook/gui/component/e-book-shell-backend.c b/addressbook/gui/component/e-book-shell-backend.c index 3e104c39f3..fd86d57e2a 100644 --- a/addressbook/gui/component/e-book-shell-backend.c +++ b/addressbook/gui/component/e-book-shell-backend.c @@ -39,9 +39,9 @@ #include "addressbook/gui/contact-list-editor/e-contact-list-editor.h" #include "addressbook/importers/evolution-addressbook-importers.h" -#include -#include -#include +#include "eab-config.h" +#include "addressbook-config.h" +#include "autocompletion-config.h" #include "e-book-shell-migrate.h" #include "e-book-shell-view.h" @@ -67,12 +67,8 @@ enum { PROP_SOURCE_LIST }; -/* Module Entry Points */ -void e_module_load (GTypeModule *type_module); -void e_module_unload (GTypeModule *type_module); - -GType e_book_shell_backend_type = 0; static gpointer parent_class; +static GType book_shell_backend_type; static void book_shell_backend_ensure_sources (EShellBackend *shell_backend) @@ -544,29 +540,30 @@ book_shell_backend_init (EBookShellBackend *book_shell_backend) } GType -e_book_shell_backend_get_type (GTypeModule *type_module) +e_book_shell_backend_get_type (void) { - if (e_book_shell_backend_type == 0) { - const GTypeInfo type_info = { - sizeof (EBookShellBackendClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) book_shell_backend_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EBookShellBackend), - 0, /* n_preallocs */ - (GInstanceInitFunc) book_shell_backend_init, - NULL /* value_table */ - }; - - e_book_shell_backend_type = - g_type_module_register_type ( - type_module, E_TYPE_SHELL_BACKEND, - "EBookShellBackend", &type_info, 0); - } + return book_shell_backend_type; +} - return e_book_shell_backend_type; +void +e_book_shell_backend_register_type (GTypeModule *type_module) +{ + const GTypeInfo type_info = { + sizeof (EBookShellBackendClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) book_shell_backend_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EBookShellBackend), + 0, /* n_preallocs */ + (GInstanceInitFunc) book_shell_backend_init, + NULL /* value_table */ + }; + + book_shell_backend_type = g_type_module_register_type ( + type_module, E_TYPE_SHELL_BACKEND, + "EBookShellBackend", &type_info, 0); } ESourceList * @@ -577,15 +574,3 @@ e_book_shell_backend_get_source_list (EBookShellBackend *book_shell_backend) return book_shell_backend->priv->source_list; } - -void -e_module_load (GTypeModule *type_module) -{ - e_book_shell_backend_get_type (type_module); - e_book_shell_view_get_type (type_module); -} - -void -e_module_unload (GTypeModule *type_module) -{ -} diff --git a/addressbook/gui/component/e-book-shell-backend.h b/addressbook/gui/component/e-book-shell-backend.h index 9a5e744ae2..c3fde1c2a1 100644 --- a/addressbook/gui/component/e-book-shell-backend.h +++ b/addressbook/gui/component/e-book-shell-backend.h @@ -27,7 +27,7 @@ /* Standard GObject macros */ #define E_TYPE_BOOK_SHELL_BACKEND \ - (e_book_shell_backend_type) + (e_book_shell_backend_get_type ()) #define E_BOOK_SHELL_BACKEND(obj) \ (G_TYPE_CHECK_INSTANCE_CAST \ ((obj), E_TYPE_BOOK_SHELL_BACKEND, EBookShellBackend)) @@ -46,8 +46,6 @@ G_BEGIN_DECLS -extern GType e_book_shell_backend_type; - typedef struct _EBookShellBackend EBookShellBackend; typedef struct _EBookShellBackendClass EBookShellBackendClass; typedef struct _EBookShellBackendPrivate EBookShellBackendPrivate; @@ -61,7 +59,8 @@ struct _EBookShellBackendClass { EShellBackendClass parent_class; }; -GType e_book_shell_backend_get_type +GType e_book_shell_backend_get_type (void); +void e_book_shell_backend_register_type (GTypeModule *type_module); ESourceList * e_book_shell_backend_get_source_list (EBookShellBackend *book_shell_backend); diff --git a/addressbook/gui/component/e-book-shell-content.c b/addressbook/gui/component/e-book-shell-content.c index 8830c797e0..7f7b9483bb 100644 --- a/addressbook/gui/component/e-book-shell-content.c +++ b/addressbook/gui/component/e-book-shell-content.c @@ -22,7 +22,8 @@ #include "e-book-shell-content.h" #include -#include + +#include "e-util/gconf-bridge.h" #define E_BOOK_SHELL_CONTENT_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ @@ -42,6 +43,7 @@ enum { }; static gpointer parent_class; +static GType book_shell_view_type; static void book_shell_content_send_message_cb (EBookShellContent *book_shell_content, @@ -296,28 +298,28 @@ book_shell_content_init (EBookShellContent *book_shell_content) GType e_book_shell_content_get_type (void) { - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EBookShellContentClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) book_shell_content_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EBookShellContent), - 0, /* n_preallocs */ - (GInstanceInitFunc) book_shell_content_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - E_TYPE_SHELL_CONTENT, "EBookShellContent", - &type_info, 0); - } + return book_shell_view_type; +} - return type; +void +e_book_shell_content_register_type (GTypeModule *type_module) +{ + static const GTypeInfo type_info = { + sizeof (EBookShellContentClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) book_shell_content_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EBookShellContent), + 0, /* n_preallocs */ + (GInstanceInitFunc) book_shell_content_init, + NULL /* value_table */ + }; + + book_shell_view_type = g_type_module_register_type ( + type_module, E_TYPE_SHELL_CONTENT, + "EBookShellContent", &type_info, 0); } GtkWidget * diff --git a/addressbook/gui/component/e-book-shell-content.h b/addressbook/gui/component/e-book-shell-content.h index e8fe856a86..a8f8271959 100644 --- a/addressbook/gui/component/e-book-shell-content.h +++ b/addressbook/gui/component/e-book-shell-content.h @@ -77,29 +77,33 @@ struct _EBookShellContentClass { }; GType e_book_shell_content_get_type (void); -GtkWidget * e_book_shell_content_new (EShellView *shell_view); -void e_book_shell_content_insert_view(EBookShellContent *book_shell_content, - EAddressbookView *addressbook_view); -void e_book_shell_content_remove_view(EBookShellContent *book_shell_content, - EAddressbookView *addressbook_view); +void e_book_shell_content_register_type + (GTypeModule *type_module); +GtkWidget * e_book_shell_content_new(EShellView *shell_view); +void e_book_shell_content_insert_view + (EBookShellContent *book_shell_content, + EAddressbookView *addressbook_view); +void e_book_shell_content_remove_view + (EBookShellContent *book_shell_content, + EAddressbookView *addressbook_view); EAddressbookView * e_book_shell_content_get_current_view - (EBookShellContent *book_shell_content); + (EBookShellContent *book_shell_content); void e_book_shell_content_set_current_view - (EBookShellContent *book_shell_content, - EAddressbookView *addressbook_view); + (EBookShellContent *book_shell_content, + EAddressbookView *addressbook_view); EContact * e_book_shell_content_get_preview_contact - (EBookShellContent *book_shell_content); + (EBookShellContent *book_shell_content); void e_book_shell_content_set_preview_contact - (EBookShellContent *book_shell_content, - EContact *preview_contact); + (EBookShellContent *book_shell_content, + EContact *preview_contact); gboolean e_book_shell_content_get_preview_visible - (EBookShellContent *book_shell_content); + (EBookShellContent *book_shell_content); void e_book_shell_content_set_preview_visible - (EBookShellContent *book_shell_content, - gboolean preview_visible); + (EBookShellContent *book_shell_content, + gboolean preview_visible); void e_book_shell_content_clipboard_copy - (EBookShellContent *book_shell_content); + (EBookShellContent *book_shell_content); G_END_DECLS diff --git a/addressbook/gui/component/e-book-shell-sidebar.c b/addressbook/gui/component/e-book-shell-sidebar.c index f804b5aeed..2a784e3b1d 100644 --- a/addressbook/gui/component/e-book-shell-sidebar.c +++ b/addressbook/gui/component/e-book-shell-sidebar.c @@ -42,6 +42,7 @@ enum { }; static gpointer parent_class; +static GType book_shell_sidebar_type; static void book_shell_sidebar_get_property (GObject *object, @@ -187,28 +188,28 @@ book_shell_sidebar_init (EBookShellSidebar *book_shell_sidebar) GType e_book_shell_sidebar_get_type (void) { - static GType type = 0; - - if (G_UNLIKELY (type == 0)) { - static const GTypeInfo type_info = { - sizeof (EBookShellSidebarClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) book_shell_sidebar_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EBookShellSidebar), - 0, /* n_preallocs */ - (GInstanceInitFunc) book_shell_sidebar_init, - NULL /* value_table */ - }; - - type = g_type_register_static ( - E_TYPE_SHELL_SIDEBAR, "EBookShellSidebar", - &type_info, 0); - } + return book_shell_sidebar_type; +} - return type; +void +e_book_shell_sidebar_register_type (GTypeModule *type_module) +{ + static const GTypeInfo type_info = { + sizeof (EBookShellSidebarClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) book_shell_sidebar_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EBookShellSidebar), + 0, /* n_preallocs */ + (GInstanceInitFunc) book_shell_sidebar_init, + NULL /* value_table */ + }; + + book_shell_sidebar_type = g_type_module_register_type ( + type_module, E_TYPE_SHELL_SIDEBAR, + "EBookShellSidebar", &type_info, 0); } GtkWidget * diff --git a/addressbook/gui/component/e-book-shell-sidebar.h b/addressbook/gui/component/e-book-shell-sidebar.h index 159c9c7afc..e2523f586b 100644 --- a/addressbook/gui/component/e-book-shell-sidebar.h +++ b/addressbook/gui/component/e-book-shell-sidebar.h @@ -24,8 +24,8 @@ #include -#include -#include +#include +#include /* Standard GObject macros */ #define E_TYPE_BOOK_SHELL_SIDEBAR \ @@ -67,10 +67,12 @@ struct _EBookShellSidebarClass { }; GType e_book_shell_sidebar_get_type (void); -GtkWidget * e_book_shell_sidebar_new (EShellView *shell_view); +void e_book_shell_sidebar_register_type + (GTypeModule *type_module); +GtkWidget * e_book_shell_sidebar_new(EShellView *shell_view); ESourceSelector * e_book_shell_sidebar_get_selector - (EBookShellSidebar *book_shell_sidebar); + (EBookShellSidebar *book_shell_sidebar); G_END_DECLS diff --git a/addressbook/gui/component/e-book-shell-view-private.c b/addressbook/gui/component/e-book-shell-view-private.c index 5f9bb4c5db..cdb8c8fbe4 100644 --- a/addressbook/gui/component/e-book-shell-view-private.c +++ b/addressbook/gui/component/e-book-shell-view-private.c @@ -21,10 +21,10 @@ #include "e-book-shell-view-private.h" -#include -#include +#include "widgets/menus/gal-view-factory-etable.h" +#include "addressbook/gui/widgets/gal-view-factory-minicard.h" -#include +#include "addressbook.h" static void open_contact (EBookShellView *book_shell_view, diff --git a/addressbook/gui/component/e-book-shell-view-private.h b/addressbook/gui/component/e-book-shell-view-private.h index f93b720ccc..628c1c2b09 100644 --- a/addressbook/gui/component/e-book-shell-view-private.h +++ b/addressbook/gui/component/e-book-shell-view-private.h @@ -35,7 +35,7 @@ #include "e-util/gconf-bridge.h" #include "shell/e-shell-content.h" #include "shell/e-shell-sidebar.h" -#include "widgets/misc/e-popup-action.h" +#include "misc/e-popup-action.h" #include "addressbook/gui/contact-editor/e-contact-editor.h" #include "addressbook/gui/contact-list-editor/e-contact-list-editor.h" diff --git a/addressbook/gui/component/e-book-shell-view.c b/addressbook/gui/component/e-book-shell-view.c index 7520c1e304..44c06be9a3 100644 --- a/addressbook/gui/component/e-book-shell-view.c +++ b/addressbook/gui/component/e-book-shell-view.c @@ -21,8 +21,8 @@ #include "e-book-shell-view-private.h" -GType e_book_shell_view_type = 0; static gpointer parent_class; +static GType book_shell_view_type; static void book_shell_view_source_list_changed_cb (EBookShellView *book_shell_view, @@ -291,27 +291,28 @@ book_shell_view_init (EBookShellView *book_shell_view, } GType -e_book_shell_view_get_type (GTypeModule *type_module) +e_book_shell_view_get_type (void) { - if (e_book_shell_view_type == 0) { - const GTypeInfo type_info = { - sizeof (EBookShellViewClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) book_shell_view_class_init, - (GClassFinalizeFunc) NULL, - NULL, /* class_data */ - sizeof (EBookShellView), - 0, /* n_preallocs */ - (GInstanceInitFunc) book_shell_view_init, - NULL /* value_table */ - }; - - e_book_shell_view_type = - g_type_module_register_type ( - type_module, E_TYPE_SHELL_VIEW, - "EBookShellView", &type_info, 0); - } + return book_shell_view_type; +} - return e_book_shell_view_type; +void +e_book_shell_view_register_type (GTypeModule *type_module) +{ + const GTypeInfo type_info = { + sizeof (EBookShellViewClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) book_shell_view_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EBookShellView), + 0, /* n_preallocs */ + (GInstanceInitFunc) book_shell_view_init, + NULL /* value_table */ + }; + + book_shell_view_type = g_type_module_register_type ( + type_module, E_TYPE_SHELL_VIEW, + "EBookShellView", &type_info, 0); } diff --git a/addressbook/gui/component/e-book-shell-view.h b/addressbook/gui/component/e-book-shell-view.h index c0b5a44c38..3cefba8179 100644 --- a/addressbook/gui/component/e-book-shell-view.h +++ b/addressbook/gui/component/e-book-shell-view.h @@ -22,11 +22,11 @@ #ifndef E_BOOK_SHELL_VIEW_H #define E_BOOK_SHELL_VIEW_H -#include +#include /* Standard GObject macros */ #define E_TYPE_BOOK_SHELL_VIEW \ - (e_book_shell_view_type) + (e_book_shell_view_get_type ()) #define E_BOOK_SHELL_VIEW(obj) \ (G_TYPE_CHECK_INSTANCE_CAST \ ((obj), E_TYPE_BOOK_SHELL_VIEW, EBookShellView)) @@ -45,8 +45,6 @@ G_BEGIN_DECLS -extern GType e_book_shell_view_type; - typedef struct _EBookShellView EBookShellView; typedef struct _EBookShellViewClass EBookShellViewClass; typedef struct _EBookShellViewPrivate EBookShellViewPrivate; @@ -60,7 +58,8 @@ struct _EBookShellViewClass { EShellViewClass parent_class; }; -GType e_book_shell_view_get_type (GTypeModule *type_module); +GType e_book_shell_view_get_type (void); +void e_book_shell_view_register_type (GTypeModule *type_module); G_END_DECLS diff --git a/addressbook/gui/component/evolution-module-addressbook.c b/addressbook/gui/component/evolution-module-addressbook.c new file mode 100644 index 0000000000..fb33f7d9a0 --- /dev/null +++ b/addressbook/gui/component/evolution-module-addressbook.c @@ -0,0 +1,45 @@ +/* + * evolution-module-addressbook.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-book-shell-backend.h" +#include "e-book-shell-content.h" +#include "e-book-shell-sidebar.h" +#include "e-book-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_book_shell_backend_register_type (type_module); + e_book_shell_content_register_type (type_module); + e_book_shell_sidebar_register_type (type_module); + e_book_shell_view_register_type (type_module); +} + +void +e_module_unload (GTypeModule *type_module) +{ +} -- cgit