[Xfce4-commits] <postler:master> Choose from smartly for header links as well

Christian Dywan noreply at xfce.org
Fri Jan 7 09:44:03 CET 2011


Updating branch refs/heads/master
         to b3a022de537f43b8157e9641ef701c912e8643c8 (commit)
       from bcde54ea236a1900bdf38273665a501e46962ce1 (commit)

commit b3a022de537f43b8157e9641ef701c912e8643c8
Author: Christian Dywan <christian at twotoasts.de>
Date:   Thu Jan 6 20:42:19 2011 +0100

    Choose from smartly for header links as well

 postler/postler-bureau.vala   |   16 +---------------
 postler/postler-content.vala  |   22 +++++++++++++++++++---
 postler/postler-messages.vala |    2 +-
 3 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/postler/postler-bureau.vala b/postler/postler-bureau.vala
index aaf368a..95c7429 100644
--- a/postler/postler-bureau.vala
+++ b/postler/postler-bureau.vala
@@ -104,23 +104,9 @@ public class Postler.Bureau : Gtk.Window {
     }
 
     void compose_message (string? prefix=null, string? recipient=null, int part=0) {
-        /* See if recipient is among the accounts, otherwise pick a fallback */
-        string sender = "";
-        if (content.recipient != null) {
-            string from = Postler.Messages.parse_address (content.recipient)[1];
-            foreach (var info in accounts.get_infos ())
-                if (info.address != null && from in info.address)
-                    sender = from;
-        }
-        if (sender == "") {
-            var info = folders.get_selected_account ();
-            if (info != null && info.address != null)
-                sender = info.address.split (",")[0];
-        }
-
         Postler.App.spawn_module ("compose", (recipient != null ? recipient : "")
             + (prefix != null ? "?subject=" + prefix + content.subject : "")
-            + "&from=" + sender + "&part=" + part.to_string (),
+            + "&from=" + content.choose_from () + "&part=" + part.to_string (),
             prefix != null ? content.last_location : null);
     }
 
diff --git a/postler/postler-content.vala b/postler/postler-content.vala
index 6b3db4a..c120020 100644
--- a/postler/postler-content.vala
+++ b/postler/postler-content.vala
@@ -1,5 +1,5 @@
 /*
- Copyright (C) 2010 Christian Dywan <christian at twotoasts.de>
+ Copyright (C) 2011 Christian Dywan <christian at twotoasts.de>
 
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
@@ -74,6 +74,7 @@ struct Postler.EmoticonMapping {
 }
 
 public class Postler.Content : WebKit.WebView {
+    AccountInfo? selected_account;
     string content_encoding;
     string date;
     string carbon_copy;
@@ -562,6 +563,20 @@ public class Postler.Content : WebKit.WebView {
         load_string (body.str, mime_type, charset, "about:blank");
     }
 
+    public string choose_from () {
+        /* See if recipient is among the accounts, otherwise pick a fallback */
+        if (recipient != null) {
+            string from = Postler.Messages.parse_address (recipient)[1];
+            var accounts = new Accounts ();
+            foreach (var info in accounts.get_infos ())
+                if (info.address != null && from in info.address)
+                    return from;
+        }
+        if (selected_account != null && selected_account.address != null)
+            return selected_account.address.split (",")[0];
+        return "";
+    }
+
     void parse_message (string location) throws GLib.FileError {
         last_location = location;
         subject = _("(No subject)");
@@ -673,7 +688,7 @@ public class Postler.Content : WebKit.WebView {
             /* Linkify From, To and Reply-To */
             /* FIXME: Use raw subject for argument? */
             /* TODO: Show addressbook icons beside addresses */
-            string arguments = "?from=" + html_escape (recipient)
+            string arguments = "?from=" + html_escape (choose_from ())
                 + "&subject=Re: " + subject;
             sender = linkify_address (from, arguments);
             if (recipient != "")
@@ -869,7 +884,8 @@ public class Postler.Content : WebKit.WebView {
         }
     }
 
-    public bool display (string location) {
+    public bool display (string location, AccountInfo? account_info=null) {
+        selected_account = account_info;
         try {
             parse_message (location);
 
diff --git a/postler/postler-messages.vala b/postler/postler-messages.vala
index e89a9c6..f4277b2 100644
--- a/postler/postler-messages.vala
+++ b/postler/postler-messages.vala
@@ -925,7 +925,7 @@ public class Postler.Messages : Gtk.TreeView {
         string location;
         sort.get (sort_iter, Columns.LOCATION, out location);
         mark_message_read (sort_iter, ref location);
-        content.display (location);
+        content.display (location, account_info);
     }
 
     public static bool ensure_folder (string folder) {



More information about the Xfce4-commits mailing list