[Xfce4-commits] <postler:master> Render image attachments inside the content view

Christian Dywan noreply at xfce.org
Sat Nov 27 04:34:08 CET 2010


Updating branch refs/heads/master
         to f58d19e11846b4f5afaaa19ae8cfb8480a047bd4 (commit)
       from 9ff36f55d09219797c87050f1a90d1680ac80839 (commit)

commit f58d19e11846b4f5afaaa19ae8cfb8480a047bd4
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sat Nov 27 02:19:54 2010 +0100

    Render image attachments inside the content view

 postler/postler-content.vala |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/postler/postler-content.vala b/postler/postler-content.vala
index 003fefa..f6bc64a 100644
--- a/postler/postler-content.vala
+++ b/postler/postler-content.vala
@@ -100,6 +100,10 @@ public class Postler.Content : WebKit.WebView {
             background-color: ButtonFace !important; color: ButtonText !important;
             outline: ButtonFace solid thick; z-index: 9999;
         }
+        /* Contain images to the size of the view */
+        img {
+            max-height:100%; max-width:100%;
+        }
         """;
 
     public Content () {
@@ -772,6 +776,8 @@ public class Postler.Content : WebKit.WebView {
     }
 
     public void display_part (MessagePart message_part) {
+        current_part = message_part;
+
         string body_chunk;
         string mime_type = message_part.mime_type;
         bool plain_text = false;
@@ -782,6 +788,11 @@ public class Postler.Content : WebKit.WebView {
             plain_text = true;
             body_chunk = "<span class=\"plain_text\">" + message_part.body.str + "</span>";
         }
+        else if (mime_type.has_prefix ("image/")) {
+            mime_type = "text/html";
+            body_chunk = "<img src=\"data:image/jpg;base64,%s\">".printf (
+                message_part.body.str);
+        }
         else {
             mime_type = "text/html";
             body_chunk = """
@@ -855,7 +866,6 @@ public class Postler.Content : WebKit.WebView {
             display_error (_("Failed to display message part \"%s\": %s").printf (
                 mime_type, contents_error.message));
         }
-        current_part = message_part;
     }
 
     void display_error (string message) {



More information about the Xfce4-commits mailing list