[Xfce4-commits] <postler:master> Spawn composer with appropriate subject and sender
Christian Dywan
noreply at xfce.org
Mon Jun 21 20:12:06 CEST 2010
Updating branch refs/heads/master
to eba7d9512478272460ca8dbac13dfd1e86f402a6 (commit)
from e5946737192a7fb4aafe16921f4b3f83a18c1f95 (commit)
commit eba7d9512478272460ca8dbac13dfd1e86f402a6
Author: Christian Dywan <christian at twotoasts.de>
Date: Sat Jun 19 22:12:36 2010 +0200
Spawn composer with appropriate subject and sender
The sender is either the original recipient of a message or
the default of the selected folder.
postler/postler-bureau.vala | 35 +++++++++++++++++++++++++++++------
postler/postler-content.vala | 4 ++--
postler/postler-folders.vala | 10 ++++++++++
postler/postler-reader.vala | 2 +-
4 files changed, 42 insertions(+), 9 deletions(-)
diff --git a/postler/postler-bureau.vala b/postler/postler-bureau.vala
index 54168e3..d2665d3 100644
--- a/postler/postler-bureau.vala
+++ b/postler/postler-bureau.vala
@@ -91,26 +91,49 @@ public class Postler.Bureau : Gtk.Window {
accounts.receive ();
}
- void action_message_new () {
- Postler.App.show_uri (get_screen (), "mailto:");
+ void compose_message (string? prefix=null, string? recipient=null) {
+ /* 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);
}
- void action_delete () {
- messages.delete_selected ();
+ void action_message_new () {
+ compose_message ();
}
void action_message_reply () {
- Postler.App.show_uri (get_screen (), content.reply_to);
+ compose_message ("Re: ", content.reply_to);
+ /* TODO */
}
void action_message_reply_all () {
- Postler.App.show_uri (get_screen (), content.reply_to_all);
+ compose_message ("Re: ", content.reply_to_all);
+ /* TODO */
}
void action_message_forward () {
+ compose_message ("Fw: ");
/* TODO */
}
+ void action_delete () {
+ messages.delete_selected ();
+ }
+
void action_search () {
search.grab_focus ();
}
diff --git a/postler/postler-content.vala b/postler/postler-content.vala
index a2073a8..a4ca1a3 100644
--- a/postler/postler-content.vala
+++ b/postler/postler-content.vala
@@ -22,16 +22,16 @@ public class Postler.Content : WebKit.WebView {
int body_parts = -1;
string content_encoding;
string date;
- string recipient;
string carbon_copy;
string reply;
- string sender;
string organization;
string x_mailer;
public string default_charset { get; set; default = "ISO-8859-1"; }
public string? last_location { get; set; }
+ public string? sender { get; set; }
+ public string? recipient { get; set; }
public string? subject { get; set; }
public string? reply_to { get; set; }
public string? reply_to_all { get; set; }
diff --git a/postler/postler-folders.vala b/postler/postler-folders.vala
index 8f2199c..1c9df89 100644
--- a/postler/postler-folders.vala
+++ b/postler/postler-folders.vala
@@ -36,6 +36,16 @@ public class Postler.Folders : Gtk.TreeView {
return null;
}
}
+ public Postler.AccountInfo? get_selected_account () {
+ return_val_if_fail (messages != null, null);
+ Gtk.TreeIter iter;
+ if (get_selection ().get_selected (null, out iter)) {
+ AccountInfo account_info;
+ store.get (iter, Columns.INFO, out account_info, -1);
+ return account_info;
+ }
+ return null;
+ }
enum Columns {
ICON,
diff --git a/postler/postler-reader.vala b/postler/postler-reader.vala
index deba425..9396475 100644
--- a/postler/postler-reader.vala
+++ b/postler/postler-reader.vala
@@ -89,7 +89,7 @@ public class Postler.Reader {
foreach (var field in fields) {
string[] pieces = field.split ("=");
bool success;
- if (pieces[1] != null)
+ if (pieces[0] != null && pieces[1] != null)
success = composer.add_field (pieces[0], pieces[1]);
else
success = composer.add_field ("to", field);
More information about the Xfce4-commits
mailing list