[evolution/wip-webkit2] EMailDisplay - Do DOM bindings asynchronously
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip-webkit2] EMailDisplay - Do DOM bindings asynchronously
- Date: Fri, 8 Nov 2013 13:50:28 +0000 (UTC)
commit 6fc3131ee355258125ccd8232e9dc22fd5bd5c8d
Author: Tomas Popela <tpopela redhat com>
Date: Fri Nov 8 13:16:34 2013 +0100
EMailDisplay - Do DOM bindings asynchronously
em-format/e-mail-part.c | 2 +-
mail/e-mail-display.c | 113 ++++++++++++++++-------------
web-extensions/evolution-web-extension.c | 3 +-
3 files changed, 65 insertions(+), 53 deletions(-)
---
diff --git a/em-format/e-mail-part.c b/em-format/e-mail-part.c
index 614cc1b..4a9e1d7 100644
--- a/em-format/e-mail-part.c
+++ b/em-format/e-mail-part.c
@@ -496,7 +496,7 @@ e_mail_part_bind_dom_element (EMailPart *part,
g_return_if_fail (E_IS_MAIL_PART (part));
g_return_if_fail (web_extension);
- g_return_if_fail (page_id == 0);
+ g_return_if_fail (page_id != 0);
g_return_if_fail (element_id && *element_id);
class = E_MAIL_PART_GET_CLASS (part);
diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c
index f1d0c96..d663362 100644
--- a/mail/e-mail-display.c
+++ b/mail/e-mail-display.c
@@ -813,7 +813,6 @@ setup_dom_bindings (WebKitWebView *web_view,
{
GDBusProxy *web_extension;
EMailDisplay *display;
- GVariant* result;
if (load_event != WEBKIT_LOAD_FINISHED)
return;
@@ -822,33 +821,59 @@ setup_dom_bindings (WebKitWebView *web_view,
web_extension = e_web_view_get_web_extension_proxy (E_WEB_VIEW (web_view));
- display->priv->web_extension_headers_collapsed_signal_id =
- g_dbus_connection_signal_subscribe (
- g_dbus_proxy_get_connection (web_extension),
- g_dbus_proxy_get_name (web_extension),
- EVOLUTION_WEB_EXTENSION_INTERFACE,
- "RecurToggled",
- EVOLUTION_WEB_EXTENSION_OBJECT_PATH,
+ if (display->priv->web_extension_headers_collapsed_signal_id == 0) {
+ display->priv->web_extension_headers_collapsed_signal_id =
+ g_dbus_connection_signal_subscribe (
+ g_dbus_proxy_get_connection (web_extension),
+ g_dbus_proxy_get_name (web_extension),
+ EVOLUTION_WEB_EXTENSION_INTERFACE,
+ "RecurToggled",
+ EVOLUTION_WEB_EXTENSION_OBJECT_PATH,
+ NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ (GDBusSignalCallback) headers_collapsed_signal_cb,
+ display,
+ NULL);
+ }
+
+ if (web_extension) {
+ g_dbus_proxy_call (
+ web_extension,
+ "EMailDisplayBindDOM",
+ g_variant_new (
+ "(t)",
+ webkit_web_view_get_page_id (web_view)),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
NULL,
- G_DBUS_SIGNAL_FLAGS_NONE,
- (GDBusSignalCallback) headers_collapsed_signal_cb,
- display,
NULL);
+ }
+}
- if (web_extension) {
- result = g_dbus_proxy_call_sync (
- web_extension,
- "EMailDisplayBindDOM",
- g_variant_new (
- "(t)",
- webkit_web_view_get_page_id (web_view)),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- NULL);
- if (result)
- g_variant_unref (result);
+static void
+mail_element_exists_cb (GDBusProxy *web_extension,
+ GAsyncResult *result,
+ EMailPart *part)
+{
+ gboolean element_exists = FALSE;
+ GVariant *result_variant;
+ guint64 page_id;
+
+ result_variant = g_dbus_proxy_call_finish (web_extension, result, NULL);
+ if (result_variant) {
+ g_variant_get (result_variant, "(bt)", &element_exists, &page_id);
+ g_variant_unref (result_variant);
}
+
+ if (element_exists)
+ e_mail_part_bind_dom_element (
+ part,
+ web_extension,
+ page_id,
+ e_mail_part_get_id (part));
+
+ g_object_unref (part);
}
static void
@@ -881,36 +906,22 @@ mail_parts_bind_dom (WebKitWebView *web_view,
for (link = head; link != NULL; link = g_list_next (link)) {
EMailPart *part = E_MAIL_PART (link->data);
const gchar *part_id;
- GVariant *result;
- gboolean element_exists = FALSE;
part_id = e_mail_part_get_id (part);
- result = g_dbus_proxy_call_sync (
- web_extension,
- "ElementExists",
- g_variant_new (
- "(ts)",
- webkit_web_view_get_page_id (
- WEBKIT_WEB_VIEW (display)),
- part_id),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- NULL);
-
- if (result) {
- g_variant_get (result, "(b)", &element_exists);
- g_variant_unref (result);
- }
-
- if (element_exists)
- e_mail_part_bind_dom_element (
- part,
- web_extension,
+ g_dbus_proxy_call (
+ web_extension,
+ "ElementExists",
+ g_variant_new (
+ "(ts)",
webkit_web_view_get_page_id (
WEBKIT_WEB_VIEW (display)),
- part_id);
+ part_id),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ (GAsyncReadyCallback)mail_element_exists_cb,
+ g_object_ref (part));
}
while (!g_queue_is_empty (&queue))
@@ -1519,10 +1530,10 @@ e_mail_display_init (EMailDisplay *display)
e_web_view_update_fonts (E_WEB_VIEW (display));
g_signal_connect (
- display, "notify::load-changed",
+ display, "load-changed",
G_CALLBACK (setup_dom_bindings), NULL);
g_signal_connect (
- display, "notify::load-changed",
+ display, "load-changed",
G_CALLBACK (mail_parts_bind_dom), NULL);
actions = e_web_view_get_action_group (E_WEB_VIEW (display), "mailto");
diff --git a/web-extensions/evolution-web-extension.c b/web-extensions/evolution-web-extension.c
index 0167fdd..3c633f6 100644
--- a/web-extensions/evolution-web-extension.c
+++ b/web-extensions/evolution-web-extension.c
@@ -72,6 +72,7 @@ static const char introspection_xml[] =
" <arg type='t' name='page_id' direction='in'/>"
" <arg type='s' name='element_id' direction='in'/>"
" <arg type='b' name='element_exists' direction='out'/>"
+" <arg type='t' name='page_id' direction='out'/>"
" </method>"
" <method name='GetActiveElementName'>"
" <arg type='t' name='page_id' direction='in'/>"
@@ -314,7 +315,7 @@ handle_method_call (GDBusConnection *connection,
element_exists = e_dom_utils_element_exists (document, element_id);
g_dbus_method_invocation_return_value (
- invocation, g_variant_new ("(b)", element_exists));
+ invocation, g_variant_new ("(bt)", element_exists, page_id));
} else if (g_strcmp0 (method_name, "GetActiveElementName") == 0) {
gchar *element_name;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]