aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-03-02 07:02:37 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-03-02 07:09:36 +0800
commit7bd9b878a383628dcebda23fd556a21b58812d95 (patch)
treec3bc2585fb367fb47dbfa86a2b16d6d3e3589581 /e-util
parenta7196dd228263730b9cc4143d2f1ca590e728b7f (diff)
downloadgsoc2013-evolution-7bd9b878a383628dcebda23fd556a21b58812d95.tar.gz
gsoc2013-evolution-7bd9b878a383628dcebda23fd556a21b58812d95.tar.zst
gsoc2013-evolution-7bd9b878a383628dcebda23fd556a21b58812d95.zip
EClientSelector: Pre-fetch selected clients.
Diffstat (limited to 'e-util')
-rw-r--r--e-util/e-client-selector.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/e-util/e-client-selector.c b/e-util/e-client-selector.c
index e164c80249..6ea98eaef9 100644
--- a/e-util/e-client-selector.c
+++ b/e-util/e-client-selector.c
@@ -141,6 +141,21 @@ client_selector_client_notify_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_set_client_cache (EClientSelector *selector,
EClientCache *client_cache)
{
@@ -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,39 @@ 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 cache 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)) {
+ ESource *source = E_SOURCE (link->data);
+ ESourceExtension *extension;
+
+ extension = e_source_get_extension (source, extension_name);
+
+ /* If selectable, skip unselected sources. */
+ if (E_IS_SOURCE_SELECTABLE (extension)) {
+ ESourceSelectable *selectable;
+
+ selectable = E_SOURCE_SELECTABLE (extension);
+ if (!e_source_selectable_get_selected (selectable))
+ continue;
+ }
+
+ e_client_selector_get_client (
+ selector, source, NULL,
+ client_selector_prefetch_cb, NULL);
+ }
+
+ g_list_free_full (list, (GDestroyNotify) g_object_unref);
}
static void