[Xfce4-commits] <postler:master> Render attachments as status messages with buttons

Christian Dywan noreply at xfce.org
Tue Jun 28 05:10:05 CEST 2011


Updating branch refs/heads/master
         to 0e2232616df30ce0cd644d14ecad6412283fec5c (commit)
       from 1ed0643a4fa502c3a4cea5caacd1a64f44989f9c (commit)

commit 0e2232616df30ce0cd644d14ecad6412283fec5c
Author: Christian Dywan <christian at twotoasts.de>
Date:   Mon Jun 27 23:42:11 2011 +0200

    Render attachments as status messages with buttons

 postler/postler-content.vala |   56 +++++++++++++++++++++++++++---------------
 1 files changed, 36 insertions(+), 20 deletions(-)

diff --git a/postler/postler-content.vala b/postler/postler-content.vala
index 90ce146..8cdc605 100644
--- a/postler/postler-content.vala
+++ b/postler/postler-content.vala
@@ -43,7 +43,7 @@ public class Postler.Content : WebKit.WebView {
         .header {
             background-color: Window !important; color: WindowText !important;
         }
-        .reply {
+        .reply, .status {
             border-radius: 15px;
             border: 1px solid ButtonText;
             background-color: ButtonFace; color: ButtonText;
@@ -107,6 +107,15 @@ public class Postler.Content : WebKit.WebView {
         .signature:before {
             content: "——";
         }
+        .attachments {
+            float: right;
+        }
+        .attachments a, .attachments a[href] {
+            padding: 0.4em 1em;
+            -webkit-appearance: push-button;
+            color: ButtonText !important;
+            text-decoration: none !important;
+        }
         /* Dynamically sized and visible statusbar */
         a[href^=http]:hover:after {
             content: attr(href);
@@ -640,10 +649,12 @@ public class Postler.Content : WebKit.WebView {
             if (template_path == null)
                 template_path = template_dir.printf (
                     Environment.get_user_data_dir (), theme_name);
-            string content_template, content_stylesheet;
+            string content_template, status_template, content_stylesheet;
             try {
                 FileUtils.get_contents (template_path + "Incoming/Content.html",
                                         out content_template, null);
+                FileUtils.get_contents (template_path + "Status.html",
+                                        out status_template, null);
                 FileUtils.get_contents (template_path + "main.css",
                                         out content_stylesheet, null);
             }
@@ -655,6 +666,9 @@ public class Postler.Content : WebKit.WebView {
                     </div>
                     </div>
                     """;
+                status_template = """
+                    <div class="status">%message%<div class="time">%time%</div></div>
+                    """;
                 content_stylesheet = themed_style_sheet ();
             }
 
@@ -687,29 +701,30 @@ public class Postler.Content : WebKit.WebView {
                 else
                     reply_chunk.append (child.parts.nth_data (0).body.str);
 
+                string reply_markup;
+                reply_markup = content_template.replace ("%message%", reply_chunk.str);
+                reply_markup = reply_markup.replace ("\"%sender%\"", ("\"" + child.sender + "\""));
+                reply_markup = reply_markup.replace ("%sender%", linkify_address (child.sender, null));
+                reply_markup = reply_markup.replace ("%time{%X}%", format_date (child.date));
+                body_chunk.append (reply_markup);
+
                 foreach (var attachment_part in child.parts) {
                     if (attachment_part != html_part && attachment_part != text_part
                      && !attachment_part.mime_type.has_prefix ("multipart/")) {
                         message_parts.append (attachment_part);
-                        reply_chunk.append_printf ("""<p>
-                            <b>%s</b>
-                            <a href="message-part:open:%d">%s</a>
-                            <a href="message-part:save:%d">%s</a></p>
-                            """,
+                        reply_markup = status_template.replace ("%time%", "");
+                        reply_markup = reply_markup.replace ("%message%",
+                            """
+                            <b>%s</b><div class="attachments">
+                            <a href="message-part:save:%d">%s</a>
+                            <a href="message-part:open:%d">%s</a></div>
+                            """.printf (
                             attachment_part.filename ?? attachment_part.mime_type,
-                            child.parts.position (child.parts.find (attachment_part)),
-                            _("Open file"),
-                            child.parts.position (child.parts.find (attachment_part)),
-                            _("Save As..."));
+                            child.parts.position (child.parts.find (attachment_part)), _("Save"),
+                            child.parts.position (child.parts.find (attachment_part)), _("Open")));
+                        body_chunk.append (reply_markup);
                     }
                 }
-
-                string reply_markup;
-                reply_markup = content_template.replace ("%message%", reply_chunk.str);
-                reply_markup = reply_markup.replace ("\"%sender%\"", ("\"" + child.sender + "\""));
-                reply_markup = reply_markup.replace ("%sender%", linkify_address (child.sender, null));
-                reply_markup = reply_markup.replace ("%time{%X}%", format_date (child.date));
-                body_chunk.append (reply_markup);
             }
 
             message = thread.nth_data (0);
@@ -744,7 +759,7 @@ public class Postler.Content : WebKit.WebView {
 
             load_string (
                 """
-                <style text="text/css">%s</style>
+                <style text="text/css">%s %s</style>
                 <div class="headers">
                 <b>%s</b><br>
                 %s
@@ -759,7 +774,8 @@ public class Postler.Content : WebKit.WebView {
                 <div class="body">%s</div>
                 """
                 .printf (
-                         style_sheet + content_stylesheet,
+                         style_sheet.replace ("ButtonText", color_to_rgb (style.fg[state])),
+                         content_stylesheet,
                          message.subject,
                          /* FIXME: Merge all recipients here? */
                          linkify_address (message.recipients, arguments),



More information about the Xfce4-commits mailing list