diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-02-22 23:37:19 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-02-22 23:59:30 +0800 |
commit | e82cb12e16285e137ea7b50ecac5bfbdf3aab7a4 (patch) | |
tree | b4c4d54726b51a9d428d03a83ab06b15dc706f8b /e-util | |
parent | eff9783d94eff6f7b0a2d03f4afac81cd0964b0b (diff) | |
download | gsoc2013-evolution-e82cb12e16285e137ea7b50ecac5bfbdf3aab7a4.tar.gz gsoc2013-evolution-e82cb12e16285e137ea7b50ecac5bfbdf3aab7a4.tar.zst gsoc2013-evolution-e82cb12e16285e137ea7b50ecac5bfbdf3aab7a4.zip |
EClientSelector: Pre-fetch relevant EClient instance.
Asyncrhonously fetch all relevant EClient instances during instance
initialization to try and get them cached ahead of time, and so that
all status icons are present when the tree view is shown.
Diffstat (limited to 'e-util')
-rw-r--r-- | e-util/e-client-selector.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/e-util/e-client-selector.c b/e-util/e-client-selector.c index 802310fc47..1c3a71e916 100644 --- a/e-util/e-client-selector.c +++ b/e-util/e-client-selector.c @@ -132,6 +132,21 @@ client_selector_client_created_cb (EClientCache *client_cache, } static void +client_selector_prefetch_cb (GObject *source_object, + GAsyncResult *result, + gpointer user_data) +{ + EClient *client; + + /* We don't care about errors here. This is just to try and + * get the EClient instances we'll need cached ahead of time. */ + client = e_client_selector_get_client_finish ( + E_CLIENT_SELECTOR (source_object), result, NULL); + + g_clear_object (&client); +} + +static void client_selector_client_notify_cb (EClientCache *client_cache, EClient *client, GParamSpec *pspec, @@ -224,9 +239,12 @@ client_selector_constructed (GObject *object) { EClientSelector *selector; EClientCache *client_cache; + ESourceRegistry *registry; GtkTreeView *tree_view; GtkTreeViewColumn *column; GtkCellRenderer *renderer; + const gchar *extension_name; + GList *list, *link; gulong handler_id; selector = E_CLIENT_SELECTOR (object); @@ -270,6 +288,24 @@ client_selector_constructed (GObject *object) selector->priv->client_notify_online_handler_id = handler_id; g_object_unref (client_cache); + + /* Pre-fetch EClient instances for all relevant ESources. + * This is just to try and make sure they get cached ahead + * of time, so we need not worry about reporting errors. */ + + registry = e_source_selector_get_registry ( + E_SOURCE_SELECTOR (selector)); + extension_name = e_source_selector_get_extension_name ( + E_SOURCE_SELECTOR (selector)); + + list = e_source_registry_list_sources (registry, extension_name); + + for (link = list; link != NULL; link = g_list_next (link)) + e_client_selector_get_client ( + selector, E_SOURCE (link->data), NULL, + client_selector_prefetch_cb, NULL); + + g_list_free_full (list, (GDestroyNotify) g_object_unref); } static void |