From 18813ccd8f4367ac98348f08e183d858cfe963f5 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Tue, 10 Aug 2010 21:17:40 +0100 Subject: Defer the load / creation of configuration UI with changes to e_preferences_window to take factory callbacks and store a reference to the shell. - This makes start-up substantially faster, particularly on Atom (eg.). Remove a number of idle handlers used to create these UIs in the first instance, cleaning the code. --- modules/mail/e-mail-shell-backend.c | 86 ++++++++++++++++--------------------- modules/mail/em-account-prefs.c | 7 ++- modules/mail/em-account-prefs.h | 5 ++- modules/mail/em-composer-prefs.c | 3 +- modules/mail/em-composer-prefs.h | 9 ++-- modules/mail/em-mailer-prefs.c | 3 +- modules/mail/em-mailer-prefs.h | 8 ++-- modules/mail/em-network-prefs.c | 2 +- modules/mail/em-network-prefs.h | 5 ++- 9 files changed, 62 insertions(+), 66 deletions(-) (limited to 'modules/mail') diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c index 5a659cb884..09f5068e82 100644 --- a/modules/mail/e-mail-shell-backend.c +++ b/modules/mail/e-mail-shell-backend.c @@ -23,7 +23,6 @@ #include -#include "e-util/e-account-utils.h" #include "e-util/e-binding.h" #include "e-util/e-import.h" #include "e-util/e-util.h" @@ -182,52 +181,6 @@ static GtkActionEntry source_entries[] = { G_CALLBACK (action_mail_folder_new_cb) } }; -static gboolean -mail_shell_backend_init_preferences (EShell *shell) -{ - EAccountList *account_list; - GtkWidget *preferences_window; - - /* This is a main loop idle callback. */ - - account_list = e_get_account_list (); - preferences_window = e_shell_get_preferences_window (shell); - - e_preferences_window_add_page ( - E_PREFERENCES_WINDOW (preferences_window), - "mail-accounts", - "preferences-mail-accounts", - _("Mail Accounts"), - em_account_prefs_new (account_list), - 100); - - e_preferences_window_add_page ( - E_PREFERENCES_WINDOW (preferences_window), - "mail", - "preferences-mail", - _("Mail Preferences"), - em_mailer_prefs_new (shell), - 300); - - e_preferences_window_add_page ( - E_PREFERENCES_WINDOW (preferences_window), - "composer", - "preferences-composer", - _("Composer Preferences"), - em_composer_prefs_new (shell), - 400); - - e_preferences_window_add_page ( - E_PREFERENCES_WINDOW (preferences_window), - "system-network-proxy", - "preferences-system-network-proxy", - _("Network Preferences"), - em_network_prefs_new (), - 500); - - return FALSE; -} - static void mail_shell_backend_sync_store_done_cb (CamelStore *store, gpointer user_data) @@ -474,6 +427,7 @@ mail_shell_backend_constructed (GObject *object) { EShell *shell; EShellBackend *shell_backend; + GtkWidget *preferences_window; shell_backend = E_SHELL_BACKEND (object); shell = e_shell_backend_get_shell (shell_backend); @@ -513,9 +467,41 @@ mail_shell_backend_constructed (GObject *object) e_mail_shell_settings_init (shell); - /* Initialize preferences after the main loop starts so - * that all EPlugins and EPluginHooks are loaded first. */ - g_idle_add ((GSourceFunc) mail_shell_backend_init_preferences, shell); + + /* Setup preference widget factories */ + preferences_window = e_shell_get_preferences_window (shell); + + e_preferences_window_add_page ( + E_PREFERENCES_WINDOW (preferences_window), + "mail-accounts", + "preferences-mail-accounts", + _("Mail Accounts"), + em_account_prefs_new, + 100); + + e_preferences_window_add_page ( + E_PREFERENCES_WINDOW (preferences_window), + "mail", + "preferences-mail", + _("Mail Preferences"), + em_mailer_prefs_new, + 300); + + e_preferences_window_add_page ( + E_PREFERENCES_WINDOW (preferences_window), + "composer", + "preferences-composer", + _("Composer Preferences"), + em_composer_prefs_new, + 400); + + e_preferences_window_add_page ( + E_PREFERENCES_WINDOW (preferences_window), + "system-network-proxy", + "preferences-system-network-proxy", + _("Network Preferences"), + em_network_prefs_new, + 500); } static void diff --git a/modules/mail/em-account-prefs.c b/modules/mail/em-account-prefs.c index 90aaa968f7..310f18ed7b 100644 --- a/modules/mail/em-account-prefs.c +++ b/modules/mail/em-account-prefs.c @@ -33,6 +33,7 @@ #include #include "e-util/e-alert-dialog.h" +#include "e-util/e-account-utils.h" #include "e-mail-store.h" #include "em-config.h" @@ -326,8 +327,12 @@ em_account_prefs_get_type (void) } GtkWidget * -em_account_prefs_new (EAccountList *account_list) +em_account_prefs_new (EPreferencesWindow *window) { + EAccountList *account_list; + + account_list = e_get_account_list (); + g_return_val_if_fail (E_IS_ACCOUNT_LIST (account_list), NULL); return g_object_new ( diff --git a/modules/mail/em-account-prefs.h b/modules/mail/em-account-prefs.h index 82df8fa941..5fe49b6b31 100644 --- a/modules/mail/em-account-prefs.h +++ b/modules/mail/em-account-prefs.h @@ -26,6 +26,7 @@ #include #include #include +#include /* Standard GObject macros */ #define EM_TYPE_ACCOUNT_PREFS \ @@ -61,8 +62,8 @@ struct _EMAccountPrefsClass { EAccountManagerClass parent_class; }; -GType em_account_prefs_get_type (void); -GtkWidget * em_account_prefs_new (EAccountList *account_list); +GType em_account_prefs_get_type (void); +GtkWidget *em_account_prefs_new (EPreferencesWindow *window); G_END_DECLS diff --git a/modules/mail/em-composer-prefs.c b/modules/mail/em-composer-prefs.c index a975a3a92d..a87be9e3c5 100644 --- a/modules/mail/em-composer-prefs.c +++ b/modules/mail/em-composer-prefs.c @@ -592,9 +592,10 @@ em_composer_prefs_construct (EMComposerPrefs *prefs, } GtkWidget * -em_composer_prefs_new (EShell *shell) +em_composer_prefs_new (EPreferencesWindow *window) { EMComposerPrefs *prefs; + EShell *shell = e_preferences_window_get_shell (window); g_return_val_if_fail (E_IS_SHELL (shell), NULL); diff --git a/modules/mail/em-composer-prefs.h b/modules/mail/em-composer-prefs.h index af4979ae18..4cbcb31128 100644 --- a/modules/mail/em-composer-prefs.h +++ b/modules/mail/em-composer-prefs.h @@ -27,6 +27,7 @@ #include #include +#include /* Standard GObject macros */ #define EM_TYPE_COMPOSER_PREFS \ @@ -75,10 +76,10 @@ struct _EMComposerPrefsClass { GtkVBoxClass parent_class; }; -GType em_composer_prefs_get_type (void); -GtkWidget * em_composer_prefs_new (EShell *shell); -void em_composer_prefs_new_signature (GtkWindow *parent, - gboolean html_mode); +GType em_composer_prefs_get_type (void); +GtkWidget *em_composer_prefs_new (EPreferencesWindow *window); +void em_composer_prefs_new_signature (GtkWindow *parent, + gboolean html_mode); G_END_DECLS diff --git a/modules/mail/em-mailer-prefs.c b/modules/mail/em-mailer-prefs.c index 80163a4713..7a6b86da18 100644 --- a/modules/mail/em-mailer-prefs.c +++ b/modules/mail/em-mailer-prefs.c @@ -1237,9 +1237,10 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs, } GtkWidget * -em_mailer_prefs_new (EShell *shell) +em_mailer_prefs_new (EPreferencesWindow *window) { EMMailerPrefs *new; + EShell *shell = e_preferences_window_get_shell (window); g_return_val_if_fail (E_IS_SHELL (shell), NULL); diff --git a/modules/mail/em-mailer-prefs.h b/modules/mail/em-mailer-prefs.h index db77493416..a6b3f1876e 100644 --- a/modules/mail/em-mailer-prefs.h +++ b/modules/mail/em-mailer-prefs.h @@ -26,6 +26,7 @@ #include #include #include +#include /* Standard GObject macros */ #define EM_TYPE_MAILER_PREFS \ @@ -108,10 +109,9 @@ struct _EMMailerPrefsClass { GtkVBoxClass parent_class; }; -GType em_mailer_prefs_get_type (void); -GtkWidget * create_combo_text_widget (void); - -GtkWidget * em_mailer_prefs_new (EShell *shell); +GType em_mailer_prefs_get_type (void); +GtkWidget *create_combo_text_widget (void); +GtkWidget *em_mailer_prefs_new (EPreferencesWindow *window); G_END_DECLS diff --git a/modules/mail/em-network-prefs.c b/modules/mail/em-network-prefs.c index 85a0a82ca3..efa9e0a090 100644 --- a/modules/mail/em-network-prefs.c +++ b/modules/mail/em-network-prefs.c @@ -488,7 +488,7 @@ em_network_prefs_construct (EMNetworkPrefs *prefs) } GtkWidget * -em_network_prefs_new (void) +em_network_prefs_new (EPreferencesWindow *window) { EMNetworkPrefs *new; diff --git a/modules/mail/em-network-prefs.h b/modules/mail/em-network-prefs.h index c7a70a803a..4196686ffe 100644 --- a/modules/mail/em-network-prefs.h +++ b/modules/mail/em-network-prefs.h @@ -25,6 +25,7 @@ #include #include +#include /* Standard GObject macros */ #define EM_TYPE_NETWORK_PREFS \ @@ -93,8 +94,8 @@ struct _EMNetworkPrefsClass { GtkVBoxClass parent_class; }; -GType em_network_prefs_get_type (void); -GtkWidget * em_network_prefs_new (void); +GType em_network_prefs_get_type (void); +GtkWidget *em_network_prefs_new (EPreferencesWindow *window); G_END_DECLS -- cgit v1.2.3