[evolution/webkit-composer: 189/210] Bug #689804 - [webkit-composer] Signature not auto-added



commit b72ac067b161b85f67378de7f7db2da05846d72e
Author: Tomas Popela <tpopela redhat com>
Date:   Tue Apr 23 10:51:53 2013 +0200

    Bug #689804 - [webkit-composer] Signature not auto-added
    
    We have to wait until the email body is loaded in WebKit.

 composer/e-composer-private.c |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c
index 5559b85..b7d7b83 100644
--- a/composer/e-composer-private.c
+++ b/composer/e-composer-private.c
@@ -925,11 +925,34 @@ exit:
        g_object_unref (composer);
 }
 
+static void
+composer_web_view_load_status_changed_cb (WebKitWebView *webkit_web_view,
+                                         GParamSpec *pspec,
+                                         EMsgComposer *composer)
+{
+       WebKitLoadStatus status;
+
+       g_return_if_fail (E_IS_MSG_COMPOSER (composer));
+
+       status = webkit_web_view_get_load_status (webkit_web_view);
+
+       if (status != WEBKIT_LOAD_FINISHED)
+               return;
+
+       g_signal_handlers_disconnect_by_func (
+               webkit_web_view, G_CALLBACK (composer_web_view_load_status_changed_cb), NULL);
+
+       e_composer_update_signature (composer);
+}
+
 void
 e_composer_update_signature (EMsgComposer *composer)
 {
        EComposerHeaderTable *table;
        EMailSignatureComboBox *combo_box;
+       EEditor *editor;
+       EEditorWidget *editor_widget;
+       WebKitLoadStatus status;
 
        g_return_if_fail (E_IS_MSG_COMPOSER (composer));
 
@@ -939,6 +962,17 @@ e_composer_update_signature (EMsgComposer *composer)
 
        table = e_msg_composer_get_header_table (composer);
        combo_box = e_composer_header_table_get_signature_combo_box (table);
+       editor = e_msg_composer_get_editor (composer);
+       editor_widget = e_editor_get_editor_widget (editor);
+
+       status = webkit_web_view_get_load_status (WEBKIT_WEB_VIEW (editor_widget));
+       /* If document is not loaded, we will wait for him */
+       if (status != WEBKIT_LOAD_FINISHED) {
+               g_signal_connect (
+                       WEBKIT_WEB_VIEW(editor_widget), "notify::load-status",
+                       G_CALLBACK (composer_web_view_load_status_changed_cb), composer);
+               return;
+       }
 
        /* XXX Signature files should be local and therefore load quickly,
         *     so while we do load them asynchronously we don't allow for


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