[Xfce4-commits] <postler:master> Quote or forward selected message excerpt

Christian Dywan noreply at xfce.org
Mon Feb 21 01:14:01 CET 2011


Updating branch refs/heads/master
         to 3dfdb1162476efd0d91ffc7984836623f9d8a321 (commit)
       from 30b168b9f8c736ccb0d00787db9b603619f27b22 (commit)

commit 3dfdb1162476efd0d91ffc7984836623f9d8a321
Author: Christian Dywan <christian at twotoasts.de>
Date:   Mon Feb 21 01:08:51 2011 +0100

    Quote or forward selected message excerpt
    
    To only quote or forward part of a message text can be
    selected and will be used for the new message.

 postler/postler-bureau.vala   |    9 ++++++++-
 postler/postler-composer.vala |    8 +-------
 postler/postler-content.vala  |    9 +++++----
 3 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/postler/postler-bureau.vala b/postler/postler-bureau.vala
index d7247f5..3462bc0 100644
--- a/postler/postler-bureau.vala
+++ b/postler/postler-bureau.vala
@@ -108,9 +108,16 @@ public class Postler.Bureau : Gtk.Window {
             else
                 chosen_from = "";
         }
+
+        var clipboard = content.get_clipboard (Gdk.SELECTION_PRIMARY);
+        string? selected = null;
+        if (content.can_copy_clipboard ())
+            selected = clipboard.wait_for_text ();
+
         Postler.App.spawn_module ("compose", (recipient != null ? recipient : "")
             + (prefix != null ? "?subject=" + prefix + content.subject : "")
-            + "&from=" + chosen_from + "&part=" + part.to_string (),
+            + "&from=" + chosen_from + "&part=" + part.to_string ()
+            + (selected != null ? "&body=" + selected : ""),
             prefix != null ? content.last_location : null);
     }
 
diff --git a/postler/postler-composer.vala b/postler/postler-composer.vala
index 0b2c18e..2eb65a8 100644
--- a/postler/postler-composer.vala
+++ b/postler/postler-composer.vala
@@ -695,13 +695,7 @@ public class Postler.Composer : Gtk.Window {
 
     public bool prepare_reply (string? location=null, bool quote=false) {
         var info = selected_account_for_address (combo_from.get_active_text ());
-        if (!content.prepare_reply (location, info, entry_to.text, quote, part))
-            return false;
-        if (body != null)
-            GLib.Idle.add (() => {
-                insert_text (body);
-                return false;
-            });
+        content.prepare_reply (location, info, entry_to.text, quote, part, body);
         return true;
     }
 
diff --git a/postler/postler-content.vala b/postler/postler-content.vala
index 71509a7..56cf431 100644
--- a/postler/postler-content.vala
+++ b/postler/postler-content.vala
@@ -449,8 +449,8 @@ public class Postler.Content : WebKit.WebView {
         return new DateTime.from_timeval_local (time).add_minutes (parsed.offset);
     }
 
-    public bool prepare_reply (string? location, AccountInfo account_info,
-        string recipient, bool quote, int part) {
+    public void prepare_reply (string? location, AccountInfo account_info,
+        string recipient, bool quote, int part, string? excerpt) {
 
         var body = new StringBuilder ();
 
@@ -466,7 +466,9 @@ public class Postler.Content : WebKit.WebView {
                 parse_message(location);
                 bool last_line_empty = true;
                 StringBuilder b_temp = new StringBuilder ();
-                if (mime_type_is_text ((message_parts.nth_data (part)).mime_type)) {
+                if (excerpt != null)
+                    b_temp.append (excerpt);
+                else if (mime_type_is_text ((message_parts.nth_data (part)).mime_type)) {
                     b_temp.append ((message_parts.nth_data (part)).get_plain_text ());
                 } else {
                     foreach (var bpart in message_parts) {
@@ -556,7 +558,6 @@ public class Postler.Content : WebKit.WebView {
         else if (signature != null)
             body.append ("\n\n" + signature);
         load_string (body.str, "text/plain", "UTF-8", "about:blank");
-        return true;
     }
 
     static void parse_content_type (string? content_type, ref string charset,



More information about the Xfce4-commits mailing list