From df1dc37704daf3b1f20d1632b1cef1ea0a2181ad Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 5 Jul 2013 13:26:43 -0400 Subject: EShellView can load the GalViewCollection itself now. EShellView no longer needs help from subclasses other than getting the needed GalView subclasses registered. A nice side-effect of this is EShellView subclasses can now use the G_DEFINE_DYNAMIC_TYPE macro. --- modules/mail/e-mail-shell-view-private.c | 6 +--- modules/mail/e-mail-shell-view-private.h | 3 +- modules/mail/e-mail-shell-view.c | 61 +++++++++++++------------------- modules/mail/e-mail-shell-view.h | 3 +- modules/mail/evolution-module-mail.c | 2 +- 5 files changed, 29 insertions(+), 46 deletions(-) (limited to 'modules/mail') diff --git a/modules/mail/e-mail-shell-view-private.c b/modules/mail/e-mail-shell-view-private.c index 9c0132aa26..aa75643f9f 100644 --- a/modules/mail/e-mail-shell-view-private.c +++ b/modules/mail/e-mail-shell-view-private.c @@ -581,12 +581,8 @@ mail_shell_view_search_filter_changed_cb (EMailShellView *mail_shell_view) } void -e_mail_shell_view_private_init (EMailShellView *mail_shell_view, - EShellViewClass *shell_view_class) +e_mail_shell_view_private_init (EMailShellView *mail_shell_view) { - if (!gal_view_collection_loaded (shell_view_class->view_collection)) - gal_view_collection_load (shell_view_class->view_collection); - g_signal_connect ( mail_shell_view, "notify::view-id", G_CALLBACK (mail_shell_view_notify_view_id_cb), NULL); diff --git a/modules/mail/e-mail-shell-view-private.h b/modules/mail/e-mail-shell-view-private.h index 28d90d463b..9986feb17f 100644 --- a/modules/mail/e-mail-shell-view-private.h +++ b/modules/mail/e-mail-shell-view-private.h @@ -149,8 +149,7 @@ struct _EMailShellViewPrivate { }; void e_mail_shell_view_private_init - (EMailShellView *mail_shell_view, - EShellViewClass *shell_view_class); + (EMailShellView *mail_shell_view); void e_mail_shell_view_private_constructed (EMailShellView *mail_shell_view); void e_mail_shell_view_private_dispose diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c index b294a5476b..b2bfbf1973 100644 --- a/modules/mail/e-mail-shell-view.c +++ b/modules/mail/e-mail-shell-view.c @@ -25,8 +25,10 @@ #include "e-mail-shell-view-private.h" -static gpointer parent_class; -static GType mail_shell_view_type; +G_DEFINE_DYNAMIC_TYPE ( + EMailShellView, + e_mail_shell_view, + E_TYPE_SHELL_VIEW) /* ETable spec for search results */ static const gchar *SEARCH_RESULTS_STATE = @@ -223,7 +225,7 @@ mail_shell_view_dispose (GObject *object) e_mail_shell_view_private_dispose (E_MAIL_SHELL_VIEW (object)); /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); + G_OBJECT_CLASS (e_mail_shell_view_parent_class)->dispose (object); } static void @@ -232,14 +234,14 @@ mail_shell_view_finalize (GObject *object) e_mail_shell_view_private_finalize (E_MAIL_SHELL_VIEW (object)); /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (e_mail_shell_view_parent_class)->finalize (object); } static void mail_shell_view_constructed (GObject *object) { /* Chain up to parent's constructed() method. */ - G_OBJECT_CLASS (parent_class)->constructed (object); + G_OBJECT_CLASS (e_mail_shell_view_parent_class)->constructed (object); e_mail_shell_view_private_constructed (E_MAIL_SHELL_VIEW (object)); } @@ -277,7 +279,8 @@ mail_shell_view_toggled (EShellView *shell_view) } /* Chain up to parent's toggled() method. */ - E_SHELL_VIEW_CLASS (parent_class)->toggled (shell_view); + E_SHELL_VIEW_CLASS (e_mail_shell_view_parent_class)-> + toggled (shell_view); } static void @@ -869,7 +872,8 @@ mail_shell_view_update_actions (EShellView *shell_view) gboolean any_store_is_subscribable = FALSE; /* Chain up to parent's update_actions() method. */ - E_SHELL_VIEW_CLASS (parent_class)->update_actions (shell_view); + E_SHELL_VIEW_CLASS (e_mail_shell_view_parent_class)-> + update_actions (shell_view); shell_window = e_shell_view_get_shell_window (shell_view); @@ -1055,13 +1059,11 @@ mail_shell_view_update_actions (EShellView *shell_view) } static void -mail_shell_view_class_init (EMailShellViewClass *class, - GTypeModule *type_module) +e_mail_shell_view_class_init (EMailShellViewClass *class) { GObjectClass *object_class; EShellViewClass *shell_view_class; - parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EMailShellViewPrivate)); object_class = G_OBJECT_CLASS (class); @@ -1088,38 +1090,25 @@ mail_shell_view_class_init (EMailShellViewClass *class, } static void -mail_shell_view_init (EMailShellView *mail_shell_view, - EShellViewClass *shell_view_class) +e_mail_shell_view_class_finalize (EMailShellViewClass *class) { - mail_shell_view->priv = - E_MAIL_SHELL_VIEW_GET_PRIVATE (mail_shell_view); - - e_mail_shell_view_private_init (mail_shell_view, shell_view_class); } -GType -e_mail_shell_view_get_type (void) +static void +e_mail_shell_view_init (EMailShellView *mail_shell_view) { - return mail_shell_view_type; + mail_shell_view->priv = + E_MAIL_SHELL_VIEW_GET_PRIVATE (mail_shell_view); + + e_mail_shell_view_private_init (mail_shell_view); } void -e_mail_shell_view_register_type (GTypeModule *type_module) +e_mail_shell_view_type_register (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); + /* 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_shell_view_register_type (type_module); } + diff --git a/modules/mail/e-mail-shell-view.h b/modules/mail/e-mail-shell-view.h index b2478a56c8..5653f8085b 100644 --- a/modules/mail/e-mail-shell-view.h +++ b/modules/mail/e-mail-shell-view.h @@ -59,8 +59,7 @@ struct _EMailShellViewClass { }; GType e_mail_shell_view_get_type (void); -void e_mail_shell_view_register_type - (GTypeModule *type_module); +void e_mail_shell_view_type_register (GTypeModule *type_module); G_END_DECLS diff --git a/modules/mail/evolution-module-mail.c b/modules/mail/evolution-module-mail.c index 9cae40e09e..8135e7df1d 100644 --- a/modules/mail/evolution-module-mail.c +++ b/modules/mail/evolution-module-mail.c @@ -49,10 +49,10 @@ e_module_load (GTypeModule *type_module) e_mail_config_hook_register_type (type_module); e_mail_event_hook_register_type (type_module); + e_mail_shell_view_type_register (type_module); e_mail_shell_backend_type_register (type_module); e_mail_shell_content_type_register (type_module); e_mail_shell_sidebar_type_register (type_module); - e_mail_shell_view_register_type (type_module); em_account_prefs_type_register (type_module); } -- cgit v1.2.3