diff options
author | Carlos Garcia Campos <cgarcia@igalia.com> | 2013-03-28 02:49:04 +0800 |
---|---|---|
committer | Carlos Garcia Campos <carlosgc@gnome.org> | 2013-06-05 00:20:45 +0800 |
commit | 9bea3575b17b3c717d9947337b46a9b8c40e50a1 (patch) | |
tree | f54b5546d3a2dbbd20f75286b17f4520a615e880 | |
parent | 030cc2e27a3bbad68d8aa40cc39e8b4778070d26 (diff) | |
download | gsoc2013-epiphany-9bea3575b17b3c717d9947337b46a9b8c40e50a1.tar gsoc2013-epiphany-9bea3575b17b3c717d9947337b46a9b8c40e50a1.tar.gz gsoc2013-epiphany-9bea3575b17b3c717d9947337b46a9b8c40e50a1.tar.bz2 gsoc2013-epiphany-9bea3575b17b3c717d9947337b46a9b8c40e50a1.tar.lz gsoc2013-epiphany-9bea3575b17b3c717d9947337b46a9b8c40e50a1.tar.xz gsoc2013-epiphany-9bea3575b17b3c717d9947337b46a9b8c40e50a1.tar.zst gsoc2013-epiphany-9bea3575b17b3c717d9947337b46a9b8c40e50a1.zip |
Make about:applications handler asynchrounous
https://bugzilla.gnome.org/show_bug.cgi?id=696728
-rw-r--r-- | embed/ephy-about-handler.c | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/embed/ephy-about-handler.c b/embed/ephy-about-handler.c index d876107d4..2c6637f1e 100644 --- a/embed/ephy-about-handler.c +++ b/embed/ephy-about-handler.c @@ -282,9 +282,10 @@ ephy_about_handler_handle_epiphany (EphyAboutHandler *handler, return TRUE; } -static gboolean -ephy_about_handler_handle_applications (EphyAboutHandler *handler, - WebKitURISchemeRequest *request) +static void +handle_applications_finished_cb (EphyAboutHandler *handler, + GAsyncResult *result, + WebKitURISchemeRequest *request) { GString *data_str; gsize data_length; @@ -302,7 +303,7 @@ ephy_about_handler_handle_applications (EphyAboutHandler *handler, g_string_append (data_str, "<table>"); - applications = ephy_web_application_get_application_list (); + applications = g_task_propagate_pointer (G_TASK (result), NULL); for (p = applications; p; p = p->next) { char *img_data = NULL, *img_data_base64 = NULL; gsize data_length; @@ -330,6 +331,31 @@ ephy_about_handler_handle_applications (EphyAboutHandler *handler, data_length = data_str->len; ephy_about_handler_finish_request (request, g_string_free (data_str, FALSE), data_length); + g_object_unref (request); +} + +static void +handle_applications_sync (GTask *task, + gpointer source_object, + gpointer task_data, + GCancellable *cancellable) +{ + g_task_return_pointer (task, + ephy_web_application_get_application_list (), + (GDestroyNotify)ephy_web_application_free_application_list); +} + +static gboolean +ephy_about_handler_handle_applications (EphyAboutHandler *handler, + WebKitURISchemeRequest *request) +{ + GTask *task; + + task = g_task_new (handler, NULL, + (GAsyncReadyCallback)handle_applications_finished_cb, + g_object_ref (request)); + g_task_run_in_thread (task, handle_applications_sync); + g_object_unref (task); return TRUE; } |