[Xfce4-commits] <postler:master> Add Important toggle button to the composer
Christian Dywan
noreply at xfce.org
Sun Jan 30 09:26:03 CET 2011
Updating branch refs/heads/master
to 6b25c523c5b94deb100149585a4d58067d81db6e (commit)
from 1c91d20fd5f516ab370412e19c2a8939b96649a6 (commit)
commit 6b25c523c5b94deb100149585a4d58067d81db6e
Author: Christian Dywan <christian at twotoasts.de>
Date: Sun Jan 30 09:15:10 2011 +0100
Add Important toggle button to the composer
Fixes: https://bugs.launchpad.net/postler/+bug/706648
postler/postler-app.vala | 2 +-
postler/postler-composer.vala | 77 +++++++++++++++++++++-------------------
2 files changed, 41 insertions(+), 38 deletions(-)
diff --git a/postler/postler-app.vala b/postler/postler-app.vala
index 019c695..2118cb5 100644
--- a/postler/postler-app.vala
+++ b/postler/postler-app.vala
@@ -87,7 +87,7 @@ public class Postler.App : Unique.App {
{ STOCK_MAIL_ATTACHMENT, null, 0, 0, "stock_attach" },
{ STOCK_MAIL_FORWARD, N_("_Forward") },
{ STOCK_MAIL_FORWARDED, "mail-forwarded", 0, 0, STOCK_MAIL_FORWARD },
- { STOCK_MAIL_MARK_IMPORTANT, null, 0, 0, STOCK_EMBLEM_IMPORTANT },
+ { STOCK_MAIL_MARK_IMPORTANT, N_("Mark as _Important"), 0, 0, STOCK_EMBLEM_IMPORTANT },
{ STOCK_MAIL_MARK_JUNK, N_("Mark as Junk"), 0, 0, null },
{ STOCK_MAIL_MARK_NOT_JUNK, N_("Mark as Not Junk"), 0, 0, null },
{ STOCK_MAIL_MARK_UNREAD, null, 0, 0, Gtk.STOCK_NEW },
diff --git a/postler/postler-composer.vala b/postler/postler-composer.vala
index 257014d..e1279eb 100644
--- a/postler/postler-composer.vala
+++ b/postler/postler-composer.vala
@@ -43,6 +43,7 @@ public class Postler.Composer : Gtk.Window {
<menuitem action="Close"/>
</menu>
<menu action="Edit">
+ <menuitem action="MarkImportant"/>
<menuitem action="Quote"/>
<menuitem action="InsertEmoticonSmileBig"/>
<menuitem action="InsertEmoticonWink"/>
@@ -52,6 +53,7 @@ public class Postler.Composer : Gtk.Window {
<toolbar>
<toolitem action="Quote"/>
<toolitem action="FileAttach"/>
+ <toolitem action="MarkImportant"/>
<separator expand="true"/>
</toolbar>
<popup name="emoticons">
@@ -116,27 +118,34 @@ public class Postler.Composer : Gtk.Window {
dialog.destroy ();
return;
}
- var now = new Soup.Date.from_now (0);
- string copy = entry_copy.text;
- string header = "";
- Gtk.TreeIter iter;
- if (!(attachments.model.get_iter_first (out iter))) {
- header = ("From: %s\nTo: %s\n%s%s"
- + "MIME-Version: 1.0\nContent-Transfer-Encoding: 8bit\n"
- + "Content-Type: text/plain; charset=UTF-8\n"
- + "Subject: %s\nDate: %s\nX-Mailer: %s\n"
- + (info.reply != null ? "Reply-To: " + info.reply + "\n" : "")
- + (info.organization != null ?
- "Organization: " + info.organization + "\n" : "")
- + "\n").printf (
- sender,
- entry_to.text,
- copy != "" ? "CC: " : "", copy != "" ? copy + "\n" : "",
- entry_subject.text,
- now.to_string (Soup.DateFormat.RFC2822),
- Postler.App.get_user_agent ()
- );
- }
+
+ var now = new Soup.Date.from_now (0);
+ string copy = entry_copy.text;
+ string header = ("From: %s\nTo: %s\n%s%s"
+ + "MIME-Version: 1.0\n"
+ + "Subject: %s\n"
+ + "Date: %s\n"
+ + "X-Mailer: %s\n"
+ + (info.reply != null ? "Reply-To: " + info.reply + "\n" : "")
+ + (info.organization != null ?
+ "Organization: " + info.organization + "\n" : "")).printf (
+ sender,
+ entry_to.text,
+ copy != "" ? "CC: " : "", copy != "" ? copy + "\n" : "",
+ entry_subject.text,
+ now.to_string (Soup.DateFormat.RFC2822),
+ Postler.App.get_user_agent ());
+
+ if ((actions.get_action ("MarkImportant") as Gtk.ToggleAction).active)
+ header += "X-Priority: 1\n";
+
+ Gtk.TreeIter iter;
+ if (!(attachments.model.get_iter_first (out iter))) {
+ header = header
+ + "Content-Transfer-Encoding: 8bit\n"
+ + "Content-Type: text/plain; charset=UTF-8\n";
+ }
+
content.select_all ();
content.copy_clipboard ();
var clipboard = content.get_clipboard (Gdk.SELECTION_CLIPBOARD);
@@ -173,21 +182,9 @@ public class Postler.Composer : Gtk.Window {
string boundary = GLib.Checksum.compute_for_string (
GLib.ChecksumType.MD5,
body + now.to_string (Soup.DateFormat.RFC2822));
- header = ("From: %s\nTo: %s\n%s%s"
- + "MIME-Version: 1.0\n"
- + "Content-Type: multipart/mixed; boundary=" + boundary + "\n"
- + "Subject: %s\nDate: %s\nX-Mailer: %s\n"
- + (info.reply != null ? "Reply-To: " + info.reply + "\n" : "")
- + (info.organization != null ?
- "Organization: " + info.organization + "\n" : "")
- + "\n").printf (
- sender,
- entry_to.text,
- copy != "" ? "CC: " : "", copy != "" ? copy + "\n" : "",
- entry_subject.text,
- now.to_string (Soup.DateFormat.RFC2822),
- Postler.App.get_user_agent ()
- );
+ header = header
+ + "Content-Type: multipart/mixed; "
+ + "boundary=" + boundary + "\n";
StringBuilder body_builder = new StringBuilder (body);
body_builder.prepend ("Content-Type: text/plain; charset=UTF-8\n\n");
body_builder.prepend ("--" + boundary + "\n");
@@ -233,7 +230,7 @@ public class Postler.Composer : Gtk.Window {
/* TODO: Put in /Queue/new/ first and move on success */
string filename = sent + "/cur/"
+ Postler.Messages.generate_maildir_filename ("S");
- FileUtils.set_contents (filename, header + body, -1);
+ FileUtils.set_contents (filename, header + "\n" + body, -1);
FileUtils.chmod (filename, 0700);
if (!client.send (info.name, filename))
throw new GLib.FileError.FAILED (_("Sending failed."));
@@ -376,6 +373,11 @@ public class Postler.Composer : Gtk.Window {
N_("Insert a sad face"), action_insert_emoticon }
};
+ const Gtk.ToggleActionEntry[] toggle_action_entries = {
+ { "MarkImportant", STOCK_MAIL_MARK_IMPORTANT, null, "",
+ N_("Mark message as important"), null, false }
+ };
+
Gtk.Entry entry_with_address_completion () {
var entry = new Gtk.Entry ();
var completion = new Gtk.EntryCompletion ();
@@ -435,6 +437,7 @@ public class Postler.Composer : Gtk.Window {
actions = new Gtk.ActionGroup ("Composer");
actions.set_translation_domain (Config.GETTEXT_PACKAGE);
actions.add_actions (action_entries, this);
+ actions.add_toggle_actions (toggle_action_entries, this);
ui.insert_action_group (actions, 0);
try {
ui.add_ui_from_string (ui_markup, -1);
More information about the Xfce4-commits
mailing list