[Xfce4-commits] <postler:master> Let lines wrap naturally in plain text messages

Christian Dywan noreply at xfce.org
Wed Nov 17 01:36:01 CET 2010


Updating branch refs/heads/master
         to 5acd966f7f1c891834a92dd60293feb0fb56af22 (commit)
       from 1d6ba3c504fbd833b7b3147e33f91cbfc182da3c (commit)

commit 5acd966f7f1c891834a92dd60293feb0fb56af22
Author: Christian Dywan <christian at twotoasts.de>
Date:   Tue Nov 16 23:19:37 2010 +0100

    Let lines wrap naturally in plain text messages
    
    Remove = at line endings in quoted printable.
    
    Add a plain_text style class used for plain text.
    
    Fixes: https://bugs.launchpad.net/postler/+bug/671564

 postler/postler-content.vala |   24 +++++++++++++++++++-----
 1 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/postler/postler-content.vala b/postler/postler-content.vala
index 79a2e23..d8a2a04 100644
--- a/postler/postler-content.vala
+++ b/postler/postler-content.vala
@@ -67,6 +67,11 @@ public class Postler.Content : WebKit.WebView {
             color: GrayText;
             border-left: 0.1em solid GrayText;
         }
+        /* Plain text */
+        .plain_text {
+            white-space: pre-wrap;
+            font-family: monospace;
+        }
         /* Signature */
         .signature {
             color: GrayText;
@@ -692,9 +697,16 @@ public class Postler.Content : WebKit.WebView {
                     else if (in_quote > 0 && line[0] == '>' && line[1] == '\0')
                         line = line.substring (1);
                 }
-                body[body_parts].append (line);
-                if (plain_text && content_encoding != "base64")
-                    body[body_parts].append_c ('\n');
+                if (content_encoding == "base64") {
+                    if (plain_text)
+                        line = line.replace ("\n", "<br>");
+                    body[body_parts].append (line);
+                } else {
+                    body[body_parts].append (line);
+                    if (content_encoding == "quoted-printable" && line.has_suffix ("="))
+                        body[body_parts].truncate (body[body_parts].len - 1);
+                    body[body_parts].append (plain_text ? "<br>" : " ");
+                }
             }
 
             int part;
@@ -721,14 +733,16 @@ public class Postler.Content : WebKit.WebView {
 
     public void display_part (uint part)
         requires (part < n_parts) {
-        string body_chunk = body[part].str;
+        string body_chunk;
         string mime_type = mime_types[part];
         bool plain_text = false;
         if (mime_type == "text/plain") {
             mime_type = "text/html";
             plain_text = true;
-            body_chunk = "<pre>" + body_chunk + "</pre>";
+            body_chunk = "<span class=\"plain_text\">" + body[part].str + "</span>";
         }
+        else
+            body_chunk = body[part].str;
 
         try {
             /* Linkify */



More information about the Xfce4-commits mailing list