aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2009-02-23 11:21:04 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2009-02-23 11:21:04 +0800
commita63a9dbb82cddad30c25cec46df4220a94e6f296 (patch)
tree4031162b55e77a45a2439c78480e9826762b305b /shell
parente0ffe55ce596c6319016004dfe3350b0d7cc762d (diff)
downloadgsoc2013-evolution-a63a9dbb82cddad30c25cec46df4220a94e6f296.tar
gsoc2013-evolution-a63a9dbb82cddad30c25cec46df4220a94e6f296.tar.gz
gsoc2013-evolution-a63a9dbb82cddad30c25cec46df4220a94e6f296.tar.bz2
gsoc2013-evolution-a63a9dbb82cddad30c25cec46df4220a94e6f296.tar.lz
gsoc2013-evolution-a63a9dbb82cddad30c25cec46df4220a94e6f296.tar.xz
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
Diffstat (limited to 'shell')
-rw-r--r--shell/e-shell-module.c27
-rw-r--r--shell/e-shell-module.h8
-rw-r--r--shell/e-shell-window.c7
-rw-r--r--shell/test/e-test-shell-module.c7
4 files changed, 49 insertions, 0 deletions
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