[Xfce4-commits] <postler:master> Reply to/ forward the selected part
Christian Dywan
noreply at xfce.org
Sat Dec 18 20:52:02 CET 2010
Updating branch refs/heads/master
to 920c0cea87e3e2c312357fcd54c1c61665d2c57e (commit)
from 41ef1713007535ae758ce4fc958a1ceca9b625b4 (commit)
commit 920c0cea87e3e2c312357fcd54c1c61665d2c57e
Author: Bernd Prünster <bernd.pruenster at gmail.com>
Date: Sat Dec 18 20:24:15 2010 +0100
Reply to/ forward the selected part
Fixes: https://bugs.launchpad.net/postler/+bug/690746
postler/postler-bureau.vala | 10 +++++-----
postler/postler-composer.vala | 6 +++++-
postler/postler-content.vala | 28 +++++++++++++++++++++-------
postler/postler-reader.vala | 2 +-
4 files changed, 32 insertions(+), 14 deletions(-)
diff --git a/postler/postler-bureau.vala b/postler/postler-bureau.vala
index e12e197..6c937a0 100644
--- a/postler/postler-bureau.vala
+++ b/postler/postler-bureau.vala
@@ -103,7 +103,7 @@ public class Postler.Bureau : Gtk.Window {
client.receive ();
}
- void compose_message (string? prefix=null, string? recipient=null) {
+ 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) {
@@ -120,7 +120,7 @@ public class Postler.Bureau : Gtk.Window {
Postler.App.spawn_module ("compose", (recipient != null ? recipient : "")
+ (prefix != null ? "?subject=" + prefix + content.subject : "")
- + "&from=" + sender,
+ + "&from=" + sender + "&part=" + part.to_string (),
prefix != null ? content.last_location : null);
}
@@ -166,17 +166,17 @@ public class Postler.Bureau : Gtk.Window {
void action_message_reply () {
unowned string? reply = list_or_sender (content.reply_to);
if (reply != null)
- compose_message ("Re: ", reply);
+ compose_message ("Re: ", reply, content.current_part.partnum);
}
void action_message_reply_all () {
unowned string? reply = list_or_sender (content.reply_to_all);
if (reply != null)
- compose_message ("Re: ", reply);
+ compose_message ("Re: ", reply, content.current_part.partnum);
}
void action_message_forward () {
- compose_message ("Fw: ");
+ compose_message ("Fw: ", null, content.current_part.partnum);
}
void action_message_unread () {
diff --git a/postler/postler-composer.vala b/postler/postler-composer.vala
index 0d1bdd9..7d5631c 100644
--- a/postler/postler-composer.vala
+++ b/postler/postler-composer.vala
@@ -28,6 +28,7 @@ public class Postler.Composer : Gtk.Window {
Gtk.Entry entry_subject;
public string subject { get { return entry_subject.text; } }
+ int part = 0;
const string ui_markup = """
<ui>
@@ -515,7 +516,7 @@ public class Postler.Composer : Gtk.Window {
}
public bool prepare_reply (string? location=null, bool quote=false) {
- return content.prepare_reply (location, entry_to.text, quote);
+ return content.prepare_reply (location, entry_to.text, quote, part);
}
public bool add_field (string field, string data) {
@@ -556,6 +557,9 @@ public class Postler.Composer : Gtk.Window {
}
GLib.warning (_("File %s doesn't exist"), data);
return false;
+ } else if (name == "part") {
+ part = data.to_int ();
+ return true;
}
else
return false;
diff --git a/postler/postler-content.vala b/postler/postler-content.vala
index 761b7ba..b205c5c 100644
--- a/postler/postler-content.vala
+++ b/postler/postler-content.vala
@@ -14,6 +14,7 @@ public class Postler.MessagePart {
public string? mime_type;
public bool plain_text;
public string? filename;
+ public int partnum { get; set; default = 0; }
public MessagePart (string mime_type) {
body = new StringBuilder ();
this.mime_type = mime_type;
@@ -369,7 +370,7 @@ public class Postler.Content : WebKit.WebView {
return "";
}
- public bool prepare_reply (string? location, string recipient, bool quote) {
+ public bool prepare_reply (string? location, string recipient, bool quote, int part) {
var body = new StringBuilder ();
if (location != null) {
@@ -383,12 +384,16 @@ public class Postler.Content : WebKit.WebView {
parse_message(location);
bool last_line_empty = true;
StringBuilder b_temp = new StringBuilder ();
- foreach (var bpart in message_parts) {
- if (mime_type_is_text (bpart.mime_type)) {
- if (!bpart.is_empty ()) {
- b_temp.append_c ('\n');
- b_temp.append (bpart.get_plain_text ());
- break;
+ 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) {
+ if (mime_type_is_text (bpart.mime_type)) {
+ if (!bpart.is_empty ()) {
+ b_temp.append_c ('\n');
+ b_temp.append (bpart.get_plain_text ());
+ break;
+ }
}
}
}
@@ -676,6 +681,7 @@ public class Postler.Content : WebKit.WebView {
throw new GLib.FileError.FAILED (_("Failed to read message: %s").
printf (contents_error.message));
}
+ number_messageparts ();
notify_property ("message-parts");
}
@@ -846,6 +852,14 @@ public class Postler.Content : WebKit.WebView {
}
}
+ void number_messageparts () {
+ int i = 0;
+ foreach (var part in message_parts) {
+ part.partnum = i;
+ i++;
+ }
+ }
+
public bool display (string location) {
try {
parse_message (location);
diff --git a/postler/postler-reader.vala b/postler/postler-reader.vala
index a0ddfbd..99bc9bb 100644
--- a/postler/postler-reader.vala
+++ b/postler/postler-reader.vala
@@ -31,7 +31,7 @@ public class Postler.Reader {
var context = new GLib.OptionContext (_(
"[mailto:][ADDRESS][?subject=SUBJECT]"
- + "[&from=FROM][&to=TO][&cc=COPY][&attach=ATTACHMENT]"));
+ + "[&from=FROM][&to=TO][&cc=COPY][&attach=ATTACHMENT][&part=PART]"));
context.set_help_enabled (true);
context.add_main_entries (options, null);
context.add_group (Gtk.get_option_group (true));
More information about the Xfce4-commits
mailing list