[geary/wip/765516-gtk-widget-conversation-viewer: 70/103] Ensure ConversationMessage.web_view load stops when message load cancelled.



commit 87ea7109877d40726e3e233f22a356fdb0a7ef2b
Author: Michael James Gratton <mike vee net>
Date:   Mon Apr 18 12:17:04 2016 +1000

    Ensure ConversationMessage.web_view load stops when message load cancelled.
    
    * src/client/conversation-viewer/conversation-message.vala: Load message
      body from ::start_loading, pass the cancellable through so the web_view
      load can be stopped. Make ::load_message_body async so the UI can be
      updated before attempting the page load.

 .../conversation-viewer/conversation-message.vala  |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/src/client/conversation-viewer/conversation-message.vala 
b/src/client/conversation-viewer/conversation-message.vala
index 377f1a7..f357a3f 100644
--- a/src/client/conversation-viewer/conversation-message.vala
+++ b/src/client/conversation-viewer/conversation-message.vala
@@ -205,8 +205,6 @@ public class ConversationMessage : Gtk.Box {
         body_box.set_has_tooltip(true); // Used to show link URLs
         body_box.pack_start(web_view, true, true, 0);
 
-        load_message_body();
-
         // if (email.from != null && email.from.contains_normalized(current_account_information.email)) {
         //  // XXX set a RO property?
         //  get_style_context().add_class("sent");
@@ -243,6 +241,7 @@ public class ConversationMessage : Gtk.Box {
     }
 
     public async void start_loading(Cancellable load_cancelled) {
+        yield load_message_body(load_cancelled);
         yield load_attachments(email.attachments, load_cancelled);
     }
 
@@ -423,7 +422,7 @@ public class ConversationMessage : Gtk.Box {
         //            Geary.SpecialFolderType.SENT.get_display_name()));
     }
 
-    private void load_message_body() {
+    private async void load_message_body(Cancellable load_cancelled) {
         bool remote_images = false;
         bool load_images = false;
         string body_text = "";
@@ -449,6 +448,7 @@ public class ConversationMessage : Gtk.Box {
             }
         }
 
+        load_cancelled.cancelled.connect(() => { web_view.stop_loading(); });
         web_view.notify["load-status"].connect((source, param) => {
                 if (web_view.load_status == WebKit.LoadStatus.FINISHED) {
                     if (load_images) {
@@ -479,10 +479,10 @@ public class ConversationMessage : Gtk.Box {
                 }
             });
 
-        // Only load it after we've hooked up the load-status signal above
+        // Only load it after we've hooked up the signals above
         web_view.load_string(body_text, "text/html", "UTF8", "");
     }
-    
+
     // This delegate is called from within Geary.RFC822.Message.get_body while assembling the plain
     // or HTML document when a non-text MIME part is encountered within a multipart/mixed container.
     // If this returns null, the MIME part is dropped from the final returned document; otherwise,


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