[Xfce4-commits] <postler:master> Show attachment after the subject in the same column
Christian Dywan
noreply at xfce.org
Sat Jun 12 23:08:01 CEST 2010
Updating branch refs/heads/master
to 65ee48b0b37c33dac52fc070c12174ff5a2caeef (commit)
from 0de7876637097283947fb5bfd8f6cd74de5161ea (commit)
commit 65ee48b0b37c33dac52fc070c12174ff5a2caeef
Author: Christian Dywan <christian at twotoasts.de>
Date: Fri Jun 11 23:44:47 2010 +0200
Show attachment after the subject in the same column
The content-type very often comes late in the headers for
whatever reason, so having an attachment icon notably decreases
performance for many messages. Thus it is optional.
postler/postler-messages.vala | 35 ++++++++++++++++++++++++++---------
1 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/postler/postler-messages.vala b/postler/postler-messages.vala
index 39c60c5..2d85755 100644
--- a/postler/postler-messages.vala
+++ b/postler/postler-messages.vala
@@ -19,6 +19,7 @@ public class Postler.Messages : Gtk.TreeView {
public Postler.Content content { get; set; }
public bool hide_read { get; set; }
public bool rich_rows { get; set; default = true; }
+ public bool show_attachments { get; set; default = true; }
public string? selected_location { get; set; }
string last_location;
@@ -89,7 +90,7 @@ public class Postler.Messages : Gtk.TreeView {
return escaped.str;
}
- void render_subject (Gtk.TreeViewColumn column, Gtk.CellRenderer cell,
+ void render_subject (Gtk.CellLayout layout, Gtk.CellRenderer cell,
Gtk.TreeModel model, Gtk.TreeIter iter) {
string charset, subject;
int weight = Pango.Weight.NORMAL;
@@ -177,10 +178,15 @@ public class Postler.Messages : Gtk.TreeView {
new Gtk.CellRendererPixbuf (), "stock-id", Columns.FLAGGED, null);
insert_column_with_attributes (-1, _("Status"),
new Gtk.CellRendererPixbuf (), "stock-id", Columns.STATUS, null);
- insert_column_with_attributes (-1, _("Attachment"),
- new Gtk.CellRendererPixbuf (), "stock-id", Columns.ATTACHMENT, null);
- insert_column_with_data_func (-1, _("Subject"),
- new Gtk.CellRendererText (), render_subject);
+ var column = new Gtk.TreeViewColumn ();
+ column.set_title (_("Subject"));
+ var renderer_text = new Gtk.CellRendererText ();
+ column.pack_start (renderer_text, true);
+ column.set_cell_data_func (renderer_text, render_subject);
+ var renderer_icon = new Gtk.CellRendererPixbuf ();
+ column.pack_start (renderer_icon, false);
+ column.add_attribute (renderer_icon, "stock-id", Columns.ATTACHMENT);
+ insert_column (column, -1);
insert_column_with_data_func (-1, _("From"),
new Gtk.CellRendererText (), render_from);
insert_column_with_data_func (-1, _("Date"),
@@ -431,6 +437,7 @@ public class Postler.Messages : Gtk.TreeView {
string subject = null;
string from = null;
time_t timestamp = 0;
+ string content_type = show_attachments ? null : "";
var contents = folder_dir.resolve_relative_path (name);
try {
var stream = new DataInputStream (contents.read (null));
@@ -459,20 +466,26 @@ public class Postler.Messages : Gtk.TreeView {
if (field == "subject") {
subject = parts[1].strip ();
if (from != null && timestamp != 0
- && filters[0] == null)
+ && content_type != null && filters[0] == null)
break;
}
else if (field == to_or_from) {
from = parts[1];
if (subject != null && timestamp != 0
- && filters[0] == null)
+ && content_type != null && filters[0] == null)
break;
}
else if (field == "date") {
var parsed = new Soup.Date.from_string (parts[1]);
timestamp = parsed != null ? (time_t)parsed.to_time_t () : 0;
if (subject != null && from != null
- && filters[0] == null)
+ && content_type != null && filters[0] == null)
+ break;
+ }
+ else if (field == "content-type") {
+ content_type = parts[1].strip ();
+ if (subject != null && from != null
+ && timestamp != 0 && filters[0] == null)
break;
}
}
@@ -483,10 +496,14 @@ public class Postler.Messages : Gtk.TreeView {
contents.get_path (), contents_error.message);
}
+ unowned string attachment = null;
+ if (content_type != null && content_type.has_prefix ("multipart/mixed"))
+ attachment = STOCK_MAIL_ATTACHMENT;
+
store.insert_with_values (out account_iter, null, -1,
Columns.FLAGGED, flagged,
Columns.STATUS, status,
- Columns.ATTACHMENT, null,
+ Columns.ATTACHMENT, attachment,
Columns.SUBJECT, subject != null ? subject : _("No subject"),
Columns.WEIGHT, font_weight,
Columns.FROM, from != null ? from : _("Unknown"),
More information about the Xfce4-commits
mailing list