aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
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