From a01525c9316b13153cb00fa99cdc587e3ce7c350 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 7 Dec 2011 15:25:02 -0500 Subject: Miscellaneous EShellView-related cleanups. --- modules/mail/e-mail-shell-backend.c | 55 ++++++++++------------ modules/mail/e-mail-shell-backend.h | 4 +- modules/mail/e-mail-shell-content.c | 78 +++++++++++++------------------- modules/mail/e-mail-shell-content.h | 2 +- modules/mail/e-mail-shell-sidebar.c | 67 ++++++++++++--------------- modules/mail/e-mail-shell-sidebar.h | 2 +- modules/mail/e-mail-shell-view-actions.c | 13 ++++-- modules/mail/e-mail-shell-view-private.c | 3 +- modules/mail/e-mail-shell-view-private.h | 4 ++ modules/mail/e-mail-shell-view.c | 9 ++-- modules/mail/evolution-module-mail.c | 6 +-- 11 files changed, 109 insertions(+), 134 deletions(-) (limited to 'modules/mail') diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c index 5ea75ee5b4..aba140b865 100644 --- a/modules/mail/e-mail-shell-backend.c +++ b/modules/mail/e-mail-shell-backend.c @@ -60,6 +60,10 @@ #include "mail-vfolder.h" #include "importers/mail-importer.h" +#define E_MAIL_SHELL_BACKEND_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MAIL_SHELL_BACKEND, EMailShellBackendPrivate)) + #define BACKEND_NAME "mail" struct _EMailShellBackendPrivate { @@ -67,12 +71,14 @@ struct _EMailShellBackendPrivate { guint mail_sync_source_id; }; -static gpointer parent_class; -static GType mail_shell_backend_type; - static void mbox_create_preview_cb (GObject *preview, GtkWidget **preview_widget); static void mbox_fill_preview_cb (GObject *preview, CamelMimeMessage *msg); +G_DEFINE_DYNAMIC_TYPE ( + EMailShellBackend, + e_mail_shell_backend, + E_TYPE_MAIL_BACKEND) + static void mail_shell_backend_init_importers (void) { @@ -279,7 +285,7 @@ mail_shell_backend_prepare_for_quit_cb (EShell *shell, { EMailShellBackendPrivate *priv; - priv = E_MAIL_SHELL_BACKEND (shell_backend)->priv; + priv = E_MAIL_SHELL_BACKEND_GET_PRIVATE (shell_backend); /* Prevent a sync from starting while trying to shutdown. */ if (priv->mail_sync_source_id > 0) { @@ -370,7 +376,7 @@ mail_shell_backend_constructed (GObject *object) shell = e_shell_backend_get_shell (shell_backend); /* Chain up to parent's constructed() method. */ - G_OBJECT_CLASS (parent_class)->constructed (object); + G_OBJECT_CLASS (e_mail_shell_backend_parent_class)->constructed (object); /* Register format types for EMFormatHook. */ em_format_hook_register_type (em_format_get_type ()); @@ -446,7 +452,7 @@ mail_shell_backend_start (EShellBackend *shell_backend) gboolean enable_search_folders; const gchar *data_dir; - priv = E_MAIL_SHELL_BACKEND (shell_backend)->priv; + priv = E_MAIL_SHELL_BACKEND_GET_PRIVATE (shell_backend); shell = e_shell_backend_get_shell (shell_backend); shell_settings = e_shell_get_shell_settings (shell); @@ -554,13 +560,12 @@ mail_shell_backend_empty_trash_policy_decision (EMailBackend *backend) } static void -mail_shell_backend_class_init (EMailShellBackendClass *class) +e_mail_shell_backend_class_init (EMailShellBackendClass *class) { GObjectClass *object_class; EShellBackendClass *shell_backend_class; EMailBackendClass *mail_backend_class; - parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EMailShellBackendPrivate)); object_class = G_OBJECT_CLASS (class); @@ -583,38 +588,24 @@ mail_shell_backend_class_init (EMailShellBackendClass *class) } static void -mail_shell_backend_init (EMailShellBackend *mail_shell_backend) +e_mail_shell_backend_class_finalize (EMailShellBackendClass *class) { - mail_shell_backend->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - mail_shell_backend, E_TYPE_MAIL_SHELL_BACKEND, - EMailShellBackendPrivate); } -GType -e_mail_shell_backend_get_type (void) +static void +e_mail_shell_backend_init (EMailShellBackend *mail_shell_backend) { - return mail_shell_backend_type; + mail_shell_backend->priv = + E_MAIL_SHELL_BACKEND_GET_PRIVATE (mail_shell_backend); } void -e_mail_shell_backend_register_type (GTypeModule *type_module) +e_mail_shell_backend_type_register (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_MAIL_BACKEND, - "EMailShellBackend", &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_backend_register_type (type_module); } /******************* Code below here belongs elsewhere. *******************/ diff --git a/modules/mail/e-mail-shell-backend.h b/modules/mail/e-mail-shell-backend.h index edec7c67a3..9d9a8e1dad 100644 --- a/modules/mail/e-mail-shell-backend.h +++ b/modules/mail/e-mail-shell-backend.h @@ -59,8 +59,8 @@ struct _EMailShellBackendClass { }; GType e_mail_shell_backend_get_type (void); -void e_mail_shell_backend_register_type - (GTypeModule *type_module); +void e_mail_shell_backend_type_register + (GTypeModule *type_module); /* XXX Find a better place for this function. */ GSList * e_mail_labels_get_filter_options (void); diff --git a/modules/mail/e-mail-shell-content.c b/modules/mail/e-mail-shell-content.c index e3b9f1f5ff..56a0c52de6 100644 --- a/modules/mail/e-mail-shell-content.c +++ b/modules/mail/e-mail-shell-content.c @@ -62,8 +62,18 @@ enum { PROP_REPLY_STYLE }; -static gpointer parent_class; -static GType mail_shell_content_type; +/* Forward Declarations */ +static void e_mail_shell_content_reader_init + (EMailReaderInterface *interface); + +G_DEFINE_DYNAMIC_TYPE_EXTENDED ( + EMailShellContent, + e_mail_shell_content, + E_TYPE_SHELL_CONTENT, + 0, + G_IMPLEMENT_INTERFACE_DYNAMIC ( + E_TYPE_MAIL_READER, + e_mail_shell_content_reader_init)) static void reconnect_changed_event (EMailReader *child, @@ -74,7 +84,7 @@ reconnect_changed_event (EMailReader *child, static void reconnect_folder_loaded_event (EMailReader *child, - EMailReader *parent) + EMailReader *parent) { g_signal_emit_by_name (parent, "folder-loaded"); } @@ -165,7 +175,7 @@ mail_shell_content_dispose (GObject *object) } /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); + G_OBJECT_CLASS (e_mail_shell_content_parent_class)->dispose (object); } static void @@ -180,7 +190,7 @@ mail_shell_content_constructed (GObject *object) priv = E_MAIL_SHELL_CONTENT_GET_PRIVATE (object); /* Chain up to parent's constructed () method. */ - G_OBJECT_CLASS (parent_class)->constructed (object); + G_OBJECT_CLASS (e_mail_shell_content_parent_class)->constructed (object); shell_content = E_SHELL_CONTENT (object); shell_view = e_shell_content_get_shell_view (shell_content); @@ -395,12 +405,11 @@ mail_shell_content_set_folder (EMailReader *reader, } static void -mail_shell_content_class_init (EMailShellContentClass *class) +e_mail_shell_content_class_init (EMailShellContentClass *class) { GObjectClass *object_class; EShellContentClass *shell_content_class; - parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EMailShellContentPrivate)); object_class = G_OBJECT_CLASS (class); @@ -444,22 +453,12 @@ mail_shell_content_class_init (EMailShellContentClass *class) } static void -mail_shell_content_init (EMailShellContent *mail_shell_content) +e_mail_shell_content_class_finalize (EMailShellContentClass *class) { - mail_shell_content->priv = - E_MAIL_SHELL_CONTENT_GET_PRIVATE (mail_shell_content); - - /* Postpone widget construction until we have a shell view. */ -} - -GType -e_mail_shell_content_get_type (void) -{ - return mail_shell_content_type; } static void -mail_shell_content_reader_init (EMailReaderInterface *interface) +e_mail_shell_content_reader_init (EMailReaderInterface *interface) { interface->get_action_group = mail_shell_content_get_action_group; interface->get_backend = mail_shell_content_get_backend; @@ -473,35 +472,22 @@ mail_shell_content_reader_init (EMailReaderInterface *interface) interface->open_selected_mail = mail_shell_content_open_selected_mail; } +static void +e_mail_shell_content_init (EMailShellContent *mail_shell_content) +{ + mail_shell_content->priv = + E_MAIL_SHELL_CONTENT_GET_PRIVATE (mail_shell_content); + + /* Postpone widget construction until we have a shell view. */ +} + void -e_mail_shell_content_register_type (GTypeModule *type_module) +e_mail_shell_content_type_register (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 reader_info = { - (GInterfaceInitFunc) mail_shell_content_reader_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, &reader_info); + /* 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_content_register_type (type_module); } GtkWidget * diff --git a/modules/mail/e-mail-shell-content.h b/modules/mail/e-mail-shell-content.h index 58f7ee9fd2..b3eecbef63 100644 --- a/modules/mail/e-mail-shell-content.h +++ b/modules/mail/e-mail-shell-content.h @@ -63,7 +63,7 @@ struct _EMailShellContentClass { }; GType e_mail_shell_content_get_type (void); -void e_mail_shell_content_register_type +void e_mail_shell_content_type_register (GTypeModule *type_module); GtkWidget * e_mail_shell_content_new (EShellView *shell_view); diff --git a/modules/mail/e-mail-shell-sidebar.c b/modules/mail/e-mail-shell-sidebar.c index 437df3e944..698c02119d 100644 --- a/modules/mail/e-mail-shell-sidebar.c +++ b/modules/mail/e-mail-shell-sidebar.c @@ -29,6 +29,10 @@ #include "mail/e-mail-sidebar.h" #include "mail/em-folder-utils.h" +#define E_MAIL_SHELL_SIDEBAR_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MAIL_SHELL_SIDEBAR, EMailShellSidebarPrivate)) + struct _EMailShellSidebarPrivate { GtkWidget *folder_tree; }; @@ -38,8 +42,10 @@ enum { PROP_FOLDER_TREE }; -static gpointer parent_class; -static GType mail_shell_sidebar_type; +G_DEFINE_DYNAMIC_TYPE ( + EMailShellSidebar, + e_mail_shell_sidebar, + E_TYPE_SHELL_SIDEBAR) static void mail_shell_sidebar_selection_changed_cb (EShellSidebar *shell_sidebar, @@ -99,7 +105,7 @@ mail_shell_sidebar_dispose (GObject *object) { EMailShellSidebarPrivate *priv; - priv = E_MAIL_SHELL_SIDEBAR (object)->priv; + priv = E_MAIL_SHELL_SIDEBAR_GET_PRIVATE (object); if (priv->folder_tree != NULL) { g_object_unref (priv->folder_tree); @@ -107,7 +113,7 @@ mail_shell_sidebar_dispose (GObject *object) } /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (parent_class)->dispose (object); + G_OBJECT_CLASS (e_mail_shell_sidebar_parent_class)->dispose (object); } static void @@ -126,7 +132,7 @@ mail_shell_sidebar_constructed (GObject *object) GtkWidget *widget; /* Chain up to parent's constructed method. */ - G_OBJECT_CLASS (parent_class)->constructed (object); + G_OBJECT_CLASS (e_mail_shell_sidebar_parent_class)->constructed (object); shell_sidebar = E_SHELL_SIDEBAR (object); shell_view = e_shell_sidebar_get_shell_view (shell_sidebar); @@ -232,8 +238,8 @@ mail_shell_sidebar_get_preferred_height (GtkWidget *widget, gint *minimum_height, gint *natural_height) { - GTK_WIDGET_CLASS (parent_class)->get_preferred_height ( - widget, minimum_height, natural_height); + GTK_WIDGET_CLASS (e_mail_shell_sidebar_parent_class)-> + get_preferred_height (widget, minimum_height, natural_height); } static void @@ -265,8 +271,8 @@ mail_shell_sidebar_get_preferred_width (GtkWidget *widget, sidebar = E_MAIL_SHELL_SIDEBAR (widget); - GTK_WIDGET_CLASS (parent_class)->get_preferred_width ( - widget, minimum_width, natural_width); + GTK_WIDGET_CLASS (e_mail_shell_sidebar_parent_class)-> + get_preferred_width (widget, minimum_width, natural_width); /* This string is a mockup only; it doesn't need to be translated */ layout = gtk_widget_create_pango_layout ( @@ -291,20 +297,19 @@ mail_shell_sidebar_check_state (EShellSidebar *shell_sidebar) EMailShellSidebarPrivate *priv; EMailSidebar *sidebar; - priv = E_MAIL_SHELL_SIDEBAR (shell_sidebar)->priv; + priv = E_MAIL_SHELL_SIDEBAR_GET_PRIVATE (shell_sidebar); sidebar = E_MAIL_SIDEBAR (priv->folder_tree); return e_mail_sidebar_check_state (sidebar); } static void -mail_shell_sidebar_class_init (EMailShellSidebarClass *class) +e_mail_shell_sidebar_class_init (EMailShellSidebarClass *class) { GObjectClass *object_class; GtkWidgetClass *widget_class; EShellSidebarClass *shell_sidebar_class; - parent_class = g_type_class_peek_parent (class); g_type_class_add_private (class, sizeof (EMailShellSidebarPrivate)); object_class = G_OBJECT_CLASS (class); @@ -331,40 +336,26 @@ mail_shell_sidebar_class_init (EMailShellSidebarClass *class) } static void -mail_shell_sidebar_init (EMailShellSidebar *mail_shell_sidebar) +e_mail_shell_sidebar_class_finalize (EMailShellSidebarClass *class) { - mail_shell_sidebar->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - mail_shell_sidebar, E_TYPE_MAIL_SHELL_SIDEBAR, - EMailShellSidebarPrivate); - - /* Postpone widget construction until we have a shell view. */ } -GType -e_mail_shell_sidebar_get_type (void) +static void +e_mail_shell_sidebar_init (EMailShellSidebar *mail_shell_sidebar) { - return mail_shell_sidebar_type; + mail_shell_sidebar->priv = + E_MAIL_SHELL_SIDEBAR_GET_PRIVATE (mail_shell_sidebar); + + /* Postpone widget construction until we have a shell view. */ } void -e_mail_shell_sidebar_register_type (GTypeModule *type_module) +e_mail_shell_sidebar_type_register (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); + /* 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_sidebar_register_type (type_module); } GtkWidget * diff --git a/modules/mail/e-mail-shell-sidebar.h b/modules/mail/e-mail-shell-sidebar.h index ca3a43654d..c36f0ff4a4 100644 --- a/modules/mail/e-mail-shell-sidebar.h +++ b/modules/mail/e-mail-shell-sidebar.h @@ -61,7 +61,7 @@ struct _EMailShellSidebarClass { }; GType e_mail_shell_sidebar_get_type (void); -void e_mail_shell_sidebar_register_type +void e_mail_shell_sidebar_type_register (GTypeModule *type_module); GtkWidget * e_mail_shell_sidebar_new (EShellView *shell_view); diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c index 7bed18d8b8..abe3d2b6c5 100644 --- a/modules/mail/e-mail-shell-view-actions.c +++ b/modules/mail/e-mail-shell-view-actions.c @@ -1634,7 +1634,6 @@ e_mail_shell_view_actions_init (EMailShellView *mail_shell_view) GtkActionGroup *action_group; GtkAction *action; GSettings *settings; - GObject *object; g_return_if_fail (E_IS_MAIL_SHELL_VIEW (mail_shell_view)); @@ -1694,11 +1693,15 @@ e_mail_shell_view_actions_init (EMailShellView *mail_shell_view) settings = g_settings_new ("org.gnome.evolution.mail"); - object = G_OBJECT (ACTION (MAIL_SHOW_DELETED)); - g_settings_bind (settings, "show-deleted", object, "active", G_SETTINGS_BIND_DEFAULT); + g_settings_bind ( + settings, "show-deleted", + ACTION (MAIL_SHOW_DELETED), "active", + G_SETTINGS_BIND_DEFAULT); - object = G_OBJECT (ACTION (MAIL_VIEW_VERTICAL)); - g_settings_bind (settings, "layout", object, "current-value", G_SETTINGS_BIND_DEFAULT); + g_settings_bind ( + settings, "layout", + ACTION (MAIL_VIEW_VERTICAL), "current-value", + G_SETTINGS_BIND_DEFAULT); g_object_unref (settings); diff --git a/modules/mail/e-mail-shell-view-private.c b/modules/mail/e-mail-shell-view-private.c index 50525c7c7f..ab669d3cb9 100644 --- a/modules/mail/e-mail-shell-view-private.c +++ b/modules/mail/e-mail-shell-view-private.c @@ -985,7 +985,8 @@ e_mail_shell_view_update_sidebar (EMailShellView *mail_shell_view) num_deleted = camel_folder_summary_get_deleted_count (folder->summary); num_junked = camel_folder_summary_get_junk_count (folder->summary); - num_junked_not_deleted = camel_folder_summary_get_junk_not_deleted_count (folder->summary); + num_junked_not_deleted = + camel_folder_summary_get_junk_not_deleted_count (folder->summary); num_unread = camel_folder_summary_get_unread_count (folder->summary); num_visible = camel_folder_summary_get_visible_count (folder->summary); diff --git a/modules/mail/e-mail-shell-view-private.h b/modules/mail/e-mail-shell-view-private.h index 12dfbd3183..5bc477dbcd 100644 --- a/modules/mail/e-mail-shell-view-private.h +++ b/modules/mail/e-mail-shell-view-private.h @@ -68,6 +68,10 @@ #include "e-mail-shell-sidebar.h" #include "e-mail-shell-view-actions.h" +#define E_MAIL_SHELL_VIEW_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MAIL_SHELL_VIEW, EMailShellViewPrivate)) + /* Shorthand, requires a variable named "shell_window". */ #define ACTION(name) \ (E_SHELL_WINDOW_ACTION_##name (shell_window)) diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c index 1e80e77a3c..74a69a9127 100644 --- a/modules/mail/e-mail-shell-view.c +++ b/modules/mail/e-mail-shell-view.c @@ -181,7 +181,7 @@ mail_shell_view_toggled (EShellView *shell_view) const gchar *basename; gboolean view_is_active; - priv = E_MAIL_SHELL_VIEW (shell_view)->priv; + priv = E_MAIL_SHELL_VIEW_GET_PRIVATE (shell_view); shell_window = e_shell_view_get_shell_window (shell_view); ui_manager = e_shell_window_get_ui_manager (shell_window); @@ -248,7 +248,7 @@ mail_shell_view_execute_search (EShellView *shell_view) const gchar *use_tag; gint value; - priv = E_MAIL_SHELL_VIEW (shell_view)->priv; + priv = E_MAIL_SHELL_VIEW_GET_PRIVATE (shell_view); shell_window = e_shell_view_get_shell_window (shell_view); shell_backend = e_shell_view_get_shell_backend (shell_view); @@ -1066,9 +1066,8 @@ static void mail_shell_view_init (EMailShellView *mail_shell_view, EShellViewClass *shell_view_class) { - mail_shell_view->priv = G_TYPE_INSTANCE_GET_PRIVATE ( - mail_shell_view, E_TYPE_MAIL_SHELL_VIEW, - EMailShellViewPrivate); + 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); } diff --git a/modules/mail/evolution-module-mail.c b/modules/mail/evolution-module-mail.c index bda0db5d95..6a44c935e7 100644 --- a/modules/mail/evolution-module-mail.c +++ b/modules/mail/evolution-module-mail.c @@ -52,9 +52,9 @@ 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_backend_register_type (type_module); - e_mail_shell_content_register_type (type_module); - e_mail_shell_sidebar_register_type (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); e_mail_config_format_html_register_type (type_module); -- cgit v1.2.3