diff options
author | Matthew Barnes <mbarnes@src.gnome.org> | 2009-02-23 11:21:04 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@src.gnome.org> | 2009-02-23 11:21:04 +0800 |
commit | a63a9dbb82cddad30c25cec46df4220a94e6f296 (patch) | |
tree | 4031162b55e77a45a2439c78480e9826762b305b | |
parent | e0ffe55ce596c6319016004dfe3350b0d7cc762d (diff) | |
download | gsoc2013-evolution-a63a9dbb82cddad30c25cec46df4220a94e6f296.tar.gz gsoc2013-evolution-a63a9dbb82cddad30c25cec46df4220a94e6f296.tar.zst gsoc2013-evolution-a63a9dbb82cddad30c25cec46df4220a94e6f296.zip |
Make filter options for mail labels work again.
Define a new shell module method named start() that tells the module when to
start loading data and running background tasks. Only really applies to the
mail module right now since the others use evolution-data-server. Basically
it prevents the mail module from loading and refreshing mail stores until
you actually switch to the mail view.
svn path=/branches/kill-bonobo/; revision=37309
-rw-r--r-- | addressbook/gui/component/e-book-shell-module.c | 1 | ||||
-rw-r--r-- | calendar/modules/e-cal-shell-module.c | 1 | ||||
-rw-r--r-- | calendar/modules/e-memo-shell-module.c | 1 | ||||
-rw-r--r-- | calendar/modules/e-task-shell-module.c | 1 | ||||
-rw-r--r-- | doc/reference/shell/eshell-sections.txt | 1 | ||||
-rw-r--r-- | doc/reference/shell/tmpl/e-shell-module.sgml | 1 | ||||
-rw-r--r-- | mail/e-mail-shell-module.c | 89 | ||||
-rw-r--r-- | mail/e-mail-shell-module.h | 3 | ||||
-rw-r--r-- | mail/filtertypes.xml | 4 | ||||
-rw-r--r-- | mail/searchtypes.xml | 2 | ||||
-rw-r--r-- | mail/vfoldertypes.xml | 2 | ||||
-rw-r--r-- | shell/e-shell-module.c | 27 | ||||
-rw-r--r-- | shell/e-shell-module.h | 8 | ||||
-rw-r--r-- | shell/e-shell-window.c | 7 | ||||
-rw-r--r-- | shell/test/e-test-shell-module.c | 7 |
15 files changed, 135 insertions, 20 deletions
diff --git a/addressbook/gui/component/e-book-shell-module.c b/addressbook/gui/component/e-book-shell-module.c index e4648e138d..80bbc8318e 100644 --- a/addressbook/gui/component/e-book-shell-module.c +++ b/addressbook/gui/component/e-book-shell-module.c @@ -436,6 +436,7 @@ static EShellModuleInfo module_info = { MODULE_SORT_ORDER, /* Methods */ + /* start */ NULL, book_module_is_busy, book_module_shutdown, e_book_shell_module_migrate diff --git a/calendar/modules/e-cal-shell-module.c b/calendar/modules/e-cal-shell-module.c index 9d78f6e6c8..b3d296c3b0 100644 --- a/calendar/modules/e-cal-shell-module.c +++ b/calendar/modules/e-cal-shell-module.c @@ -507,6 +507,7 @@ static EShellModuleInfo module_info = { MODULE_SCHEMES, MODULE_SORT_ORDER, + /* start */ NULL, /* is_busy */ NULL, /* shutdown */ NULL, e_cal_shell_module_migrate diff --git a/calendar/modules/e-memo-shell-module.c b/calendar/modules/e-memo-shell-module.c index 8c373f6604..873bdb26d0 100644 --- a/calendar/modules/e-memo-shell-module.c +++ b/calendar/modules/e-memo-shell-module.c @@ -479,6 +479,7 @@ static EShellModuleInfo module_info = { MODULE_SCHEMES, MODULE_SORT_ORDER, + /* start */ NULL, /* is_busy */ NULL, /* shutdown */ NULL, e_memo_shell_module_migrate diff --git a/calendar/modules/e-task-shell-module.c b/calendar/modules/e-task-shell-module.c index 9c6258a156..345150222a 100644 --- a/calendar/modules/e-task-shell-module.c +++ b/calendar/modules/e-task-shell-module.c @@ -486,6 +486,7 @@ static EShellModuleInfo module_info = { MODULE_SCHEMES, MODULE_SORT_ORDER, + /* start */ NULL, /* is_busy */ NULL, /* shutdown */ NULL, e_task_shell_module_migrate diff --git a/doc/reference/shell/eshell-sections.txt b/doc/reference/shell/eshell-sections.txt index 1e888cf03a..99feb83d58 100644 --- a/doc/reference/shell/eshell-sections.txt +++ b/doc/reference/shell/eshell-sections.txt @@ -20,6 +20,7 @@ e_shell_get_online e_shell_set_online e_shell_get_preferences_window e_shell_event +e_shell_start e_shell_is_busy e_shell_do_quit e_shell_quit diff --git a/doc/reference/shell/tmpl/e-shell-module.sgml b/doc/reference/shell/tmpl/e-shell-module.sgml index 883ae1a9af..9957aeb9d9 100644 --- a/doc/reference/shell/tmpl/e-shell-module.sgml +++ b/doc/reference/shell/tmpl/e-shell-module.sgml @@ -50,6 +50,7 @@ EShellModule @aliases: @schemes: @sort_order: +@start: @is_busy: @shutdown: @migrate: diff --git a/mail/e-mail-shell-module.c b/mail/e-mail-shell-module.c index f699edf7c3..2ae8bd5a5a 100644 --- a/mail/e-mail-shell-module.c +++ b/mail/e-mail-shell-module.c @@ -827,6 +827,32 @@ mail_shell_module_window_created_cb (EShell *shell, } } +static void +mail_shell_module_start (EShellModule *shell_module) +{ + EShell *shell; + EShellSettings *shell_settings; + gboolean enable_search_folders; + + shell = e_shell_module_get_shell (shell_module); + shell_settings = e_shell_get_shell_settings (shell); + + g_debug ("Jumpstarting Mail"); + + enable_search_folders = e_shell_settings_get_boolean ( + shell_settings, "mail-enable-search-folders"); + if (enable_search_folders) + vfolder_load_storage (); + + mail_autoreceive_init (session); + + if (g_getenv ("CAMEL_FLUSH_CHANGES") != NULL) + mail_sync_timeout_source_id = g_timeout_add_seconds ( + mail_config_get_sync_timeout (), + (GSourceFunc) mail_shell_module_mail_sync, + shell_module); +} + static EShellModuleInfo module_info = { MODULE_NAME, @@ -834,6 +860,7 @@ static EShellModuleInfo module_info = { MODULE_SCHEMES, MODULE_SORT_ORDER, + mail_shell_module_start, /* is_busy */ NULL, /* shutdown */ NULL, e_mail_shell_module_migrate @@ -844,12 +871,9 @@ e_shell_module_init (GTypeModule *type_module) { EShell *shell; EShellModule *shell_module; - EShellSettings *shell_settings; - gboolean enable_search_folders; shell_module = E_SHELL_MODULE (type_module); shell = e_shell_module_get_shell (shell_module); - shell_settings = e_shell_get_shell_settings (shell); e_shell_module_set_info ( shell_module, &module_info, @@ -913,19 +937,6 @@ e_shell_module_init (GTypeModule *type_module) * since the preferences bind to the shell settings. */ e_mail_shell_module_init_settings (shell); mail_shell_module_init_preferences (shell); - - enable_search_folders = e_shell_settings_get_boolean ( - shell_settings, "mail-enable-search-folders"); - if (enable_search_folders) - vfolder_load_storage (); - - mail_autoreceive_init (session); - - if (g_getenv ("CAMEL_FLUSH_CHANGES") != NULL) - mail_sync_timeout_source_id = g_timeout_add_seconds ( - mail_config_get_sync_timeout (), - (GSourceFunc) mail_shell_module_mail_sync, - shell_module); } /******************************** Public API *********************************/ @@ -1101,3 +1112,49 @@ e_mail_shell_module_stores_foreach (EShellModule *shell_module, while (g_hash_table_iter_next (&iter, &key, &value)) func (key, ((StoreInfo *) value)->name, user_data); } + +/******************* Code below here belongs elsewhere. *******************/ + +#include "filter/filter-option.h" +#include "shell/e-shell-settings.h" +#include "mail/e-mail-label-list-store.h" + +GSList * +e_mail_labels_get_filter_options (void) +{ + EShell *shell; + EShellSettings *shell_settings; + EMailLabelListStore *list_store; + GtkTreeModel *model; + GtkTreeIter iter; + GSList *list = NULL; + gboolean valid; + + shell = e_shell_get_default (); + shell_settings = e_shell_get_shell_settings (shell); + list_store = e_shell_settings_get_object ( + shell_settings, "mail-label-list-store"); + + model = GTK_TREE_MODEL (list_store); + valid = gtk_tree_model_get_iter_first (model, &iter); + + while (valid) { + struct _filter_option *option; + gchar *name, *tag; + + name = e_mail_label_list_store_get_name (list_store, &iter); + tag = e_mail_label_list_store_get_tag (list_store, &iter); + + option = g_new0 (struct _filter_option, 1); + option->title = e_str_without_underscores (name); + option->value = tag; /* takes ownership */ + + g_free (name); + + valid = gtk_tree_model_iter_next (model, &iter); + } + + g_object_unref (list_store); + + return list; +} diff --git a/mail/e-mail-shell-module.h b/mail/e-mail-shell-module.h index de19861ac6..d72df698a5 100644 --- a/mail/e-mail-shell-module.h +++ b/mail/e-mail-shell-module.h @@ -76,6 +76,9 @@ void e_mail_shell_module_stores_foreach GHFunc func, gpointer user_data); +/* XXX Find a better place for this function. */ +GSList * e_mail_labels_get_filter_options(void); + G_END_DECLS #endif /* E_MAIL_SHELL_MODULE_H */ diff --git a/mail/filtertypes.xml b/mail/filtertypes.xml index f2f69c4c06..a93b887271 100644 --- a/mail/filtertypes.xml +++ b/mail/filtertypes.xml @@ -636,7 +636,7 @@ </option> </input> <input type="optionlist" name="versus"> - <dynamic func="e_util_labels_get_filter_options"/> + <dynamic func="e_mail_labels_get_filter_options"/> </input> </part> @@ -923,7 +923,7 @@ <title>Set Label</title> <code>(set-label ${label})</code> <input type="optionlist" name="label"> - <dynamic func="e_util_labels_get_filter_options"/> + <dynamic func="e_mail_labels_get_filter_options"/> </input> </part> <part name="colour"> diff --git a/mail/searchtypes.xml b/mail/searchtypes.xml index 83941d875c..ba349993f7 100644 --- a/mail/searchtypes.xml +++ b/mail/searchtypes.xml @@ -569,7 +569,7 @@ </option> </input> <input type="optionlist" name="versus"> - <dynamic func="e_util_labels_get_filter_options"/> + <dynamic func="e_mail_labels_get_filter_options"/> </input> </part> diff --git a/mail/vfoldertypes.xml b/mail/vfoldertypes.xml index 11ed7cc0af..9fd117b67d 100644 --- a/mail/vfoldertypes.xml +++ b/mail/vfoldertypes.xml @@ -569,7 +569,7 @@ </option> </input> <input type="optionlist" name="versus"> - <dynamic func="e_util_labels_get_filter_options"/> + <dynamic func="e_mail_labels_get_filter_options"/> </input> </part> diff --git a/shell/e-shell-module.c b/shell/e-shell-module.c index 11226557c2..e3f6fe37b9 100644 --- a/shell/e-shell-module.c +++ b/shell/e-shell-module.c @@ -53,6 +53,8 @@ struct _EShellModulePrivate { /* Initializes the loaded type module. */ void (*init) (GTypeModule *type_module); + + guint started : 1; }; enum { @@ -445,6 +447,30 @@ e_shell_module_add_activity (EShellModule *shell_module, } /** + * e_shell_module_start: + * @shell_module: an #EShellModule + * + * Tells the @shell_module to begin loading data or running background + * tasks which may consume significant resources. This gets called in + * reponse to the user switching to the corresponding shell view for + * the first time. The function is idempotent for each shell module. + **/ +void +e_shell_module_start (EShellModule *shell_module) +{ + EShellModuleInfo *module_info; + + g_return_if_fail (E_IS_SHELL_MODULE (shell_module)); + + module_info = &shell_module->priv->info; + + if (module_info->start != NULL && !shell_module->priv->started) + module_info->start (shell_module); + + shell_module->priv->started = TRUE; +} + +/** * e_shell_module_is_busy: * @shell_module: an #EShellModule * @@ -576,6 +602,7 @@ e_shell_module_set_info (EShellModule *shell_module, module_info->schemes = g_intern_string (info->schemes); module_info->sort_order = info->sort_order; + module_info->start = info->start; module_info->is_busy = info->is_busy; module_info->shutdown = info->shutdown; module_info->migrate = info->migrate; diff --git a/shell/e-shell-module.h b/shell/e-shell-module.h index 0f7016532d..4d6274bdf6 100644 --- a/shell/e-shell-module.h +++ b/shell/e-shell-module.h @@ -73,6 +73,12 @@ typedef struct _EShellModulePrivate EShellModulePrivate; * @sort_order: Used to determine the order of modules listed in * the main menu and in the switcher. See * e_shell_module_compare(). + * @start: Callback for notifying the module to begin loading data + * and running background tasks. This is called the first + * time the corresponding shell view class is instantiated. + * It allows the module to delay initialization steps that + * consume significant resources until they are actually + * needed. * @is_busy: Callback for querying whether the module has * operations in progress that cannot be cancelled * or finished immediately. Returning %TRUE prevents @@ -96,6 +102,7 @@ struct _EShellModuleInfo { const gchar *schemes; gint sort_order; + void (*start) (EShellModule *shell_module); gboolean (*is_busy) (EShellModule *shell_module); gboolean (*shutdown) (EShellModule *shell_module); gboolean (*migrate) (EShellModule *shell_module, @@ -133,6 +140,7 @@ GType e_shell_module_get_shell_view_type (EShellModule *shell_module); void e_shell_module_add_activity (EShellModule *shell_module, EActivity *activity); +void e_shell_module_start (EShellModule *shell_module); gboolean e_shell_module_is_busy (EShellModule *shell_module); gboolean e_shell_module_shutdown (EShellModule *shell_module); gboolean e_shell_module_migrate (EShellModule *shell_module, diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c index 2de5349ecf..30dd3e627e 100644 --- a/shell/e-shell-window.c +++ b/shell/e-shell-window.c @@ -45,12 +45,19 @@ shell_window_new_view (EShellWindow *shell_window, const gchar *title) { GHashTable *loaded_views; + EShell *shell; + EShellModule *shell_module; EShellView *shell_view; GtkNotebook *notebook; GtkAction *action; GtkWidget *widget; gint page_num; + /* First off, start the shell module. */ + shell = e_shell_window_get_shell (shell_window); + shell_module = e_shell_get_module_by_name (shell, view_name); + e_shell_module_start (shell_module); + /* Determine the page number for the new shell view. */ notebook = GTK_NOTEBOOK (shell_window->priv->content_notebook); diff --git a/shell/test/e-test-shell-module.c b/shell/test/e-test-shell-module.c index a7d2389fb7..0098866400 100644 --- a/shell/test/e-test-shell-module.c +++ b/shell/test/e-test-shell-module.c @@ -69,6 +69,12 @@ static GtkActionEntry source_entries[] = { G_CALLBACK (action_test_source_new_cb) } }; +static void +test_module_start (EShellModule *shell_module) +{ + g_debug ("%s", G_STRFUNC); +} + static gboolean test_module_is_busy (EShellModule *shell_module) { @@ -149,6 +155,7 @@ static EShellModuleInfo module_info = { MODULE_SORT_ORDER, /* Methods */ + test_module_start, test_module_is_busy, test_module_shutdown, test_module_migrate |