[evolution/gnome-3-32] Expand/collapse buttons in vCard preview do nothing



commit 1380ab10369b798baacf8fb24c3ba45ed7b76214
Author: Milan Crha <mcrha redhat com>
Date:   Wed Mar 13 10:49:22 2019 +0100

    Expand/collapse buttons in vCard preview do nothing
    
    Clicking the buttons didn't do anything, because the DOM binding
    was not done when the inner iframe had been loaded in case of the Mail
    preview and because the Contacts preview used incorrect signal binding.

 src/addressbook/gui/widgets/eab-contact-display.c |  4 ++--
 src/web-extensions/e-dom-utils.c                  | 21 +++++++++++++++++++++
 2 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/src/addressbook/gui/widgets/eab-contact-display.c 
b/src/addressbook/gui/widgets/eab-contact-display.c
index ca34ad12d8..ecb217ffe7 100644
--- a/src/addressbook/gui/widgets/eab-contact-display.c
+++ b/src/addressbook/gui/widgets/eab-contact-display.c
@@ -534,8 +534,8 @@ eab_contact_display_init (EABContactDisplay *display)
                display, "web-process-crashed",
                G_CALLBACK (contact_display_web_process_crashed_cb), NULL);
 
-       e_signal_connect_notify (
-               web_view, "notify::load-changed",
+       g_signal_connect (
+               web_view, "load-changed",
                G_CALLBACK (contact_display_load_changed), NULL);
        g_signal_connect (
                web_view, "style-updated",
diff --git a/src/web-extensions/e-dom-utils.c b/src/web-extensions/e-dom-utils.c
index 24e15dcb64..f1ca71031d 100644
--- a/src/web-extensions/e-dom-utils.c
+++ b/src/web-extensions/e-dom-utils.c
@@ -1613,12 +1613,27 @@ e_dom_utils_module_vcard_inline_update_button (WebKitDOMDocument *document,
        }
 }
 
+static void
+iframe_inner_doc_gone (gpointer iframe,
+                      GObject *inner_doc)
+{
+       WebKitDOMDocument *inner_document;
+
+       inner_document = webkit_dom_html_iframe_element_get_content_document (iframe);
+
+       if (inner_document)
+               e_dom_utils_eab_contact_formatter_bind_dom (inner_document);
+
+       g_object_unref (iframe);
+}
+
 void
 e_dom_utils_module_vcard_inline_set_iframe_src (WebKitDOMDocument *document,
                                                 const gchar *button_id,
                                                 const gchar *src)
 {
        WebKitDOMElement *element, *parent, *iframe;
+       WebKitDOMDocument *inner_document;
        gchar *selector;
 
        selector = g_strconcat ("button[id='", button_id, "']", NULL);
@@ -1633,6 +1648,12 @@ e_dom_utils_module_vcard_inline_set_iframe_src (WebKitDOMDocument *document,
        if (!iframe)
                return;
 
+       inner_document = webkit_dom_html_iframe_element_get_content_document (WEBKIT_DOM_HTML_IFRAME_ELEMENT 
(iframe));
+
+       /* This is an ugly hack, relying on the WebKitGTK+ behavior to
+          free the inner document GObject when the new source is loaded. */
+       g_object_weak_ref (G_OBJECT (inner_document), iframe_inner_doc_gone, g_object_ref (iframe));
+
        webkit_dom_html_iframe_element_set_src (
                WEBKIT_DOM_HTML_IFRAME_ELEMENT (iframe), src);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]