Display unread messages in boldface: #3807
This ticket enables this, however IMAP properties are not yet coming up from the local database yet, so this isn't technically complete. That work will be included in the commit for #3805, which requires those properties.
This commit is contained in:
parent
9176d4778d
commit
fdc2853904
5 changed files with 38 additions and 8 deletions
|
|
@ -214,7 +214,7 @@ public class MainWindow : Gtk.Window {
|
||||||
|
|
||||||
yield current_folder.open_async(true);
|
yield current_folder.open_async(true);
|
||||||
|
|
||||||
current_folder.lazy_list_email_async(1, 1000, Geary.Email.Field.ENVELOPE,
|
current_folder.lazy_list_email_async(1, 1000, MessageListStore.REQUIRED_FIELDS,
|
||||||
on_list_email_ready);
|
on_list_email_ready);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class MessageListStore : Gtk.TreeStore {
|
public class MessageListStore : Gtk.TreeStore {
|
||||||
|
public const Geary.Email.Field REQUIRED_FIELDS =
|
||||||
|
Geary.Email.Field.ENVELOPE | Geary.Email.Field.PROPERTIES;
|
||||||
|
|
||||||
public enum Column {
|
public enum Column {
|
||||||
DATE,
|
DATE,
|
||||||
FROM,
|
FROM,
|
||||||
|
|
@ -56,17 +59,28 @@ public class MessageListStore : Gtk.TreeStore {
|
||||||
set_sort_column_id(TreeSortable.DEFAULT_SORT_COLUMN_ID, Gtk.SortType.DESCENDING);
|
set_sort_column_id(TreeSortable.DEFAULT_SORT_COLUMN_ID, Gtk.SortType.DESCENDING);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The Email should've been fetched with Geary.Email.Field.ENVELOPE, at least.
|
// The Email should've been fetched with REQUIRED_FIELDS.
|
||||||
public void append_envelope(Geary.Email envelope) {
|
public void append_envelope(Geary.Email envelope) {
|
||||||
assert(envelope.fields.fulfills(Geary.Email.Field.ENVELOPE));
|
assert(envelope.fields.fulfills(Geary.Email.Field.ENVELOPE));
|
||||||
|
|
||||||
Gtk.TreeIter iter;
|
Gtk.TreeIter iter;
|
||||||
append(out iter, null);
|
append(out iter, null);
|
||||||
|
|
||||||
|
string? pre = null;;
|
||||||
|
string? post = null;
|
||||||
|
if (envelope.properties != null) {
|
||||||
|
pre = envelope.properties.is_unread() ? "<b>" : null;
|
||||||
|
post = envelope.properties.is_unread() ? "</b>" : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
string date = to_markup(Date.pretty_print(envelope.date.value), pre, post);
|
||||||
|
string from = to_markup(envelope.from[0].get_short_address(), pre, post);
|
||||||
|
string subject = to_markup(envelope.subject.value, pre, post);
|
||||||
|
|
||||||
set(iter,
|
set(iter,
|
||||||
Column.DATE, Date.pretty_print(envelope.date.value),
|
Column.DATE, date,
|
||||||
Column.FROM, envelope.from[0].get_short_address(),
|
Column.FROM, from,
|
||||||
Column.SUBJECT, envelope.subject.value,
|
Column.SUBJECT, subject,
|
||||||
Column.MESSAGE_OBJECT, envelope
|
Column.MESSAGE_OBJECT, envelope
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -96,5 +110,13 @@ public class MessageListStore : Gtk.TreeStore {
|
||||||
// stabilize sort by using the mail's position, which is always unique in a folder
|
// stabilize sort by using the mail's position, which is always unique in a folder
|
||||||
return aenvelope.location.position - benvelope.location.position;
|
return aenvelope.location.position - benvelope.location.position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string to_markup(string str, string? pre = null, string? post = null) {
|
||||||
|
return "%s%s%s".printf(
|
||||||
|
(pre != null) ? pre : "",
|
||||||
|
Markup.escape_text(str),
|
||||||
|
(post != null) ? post : ""
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,10 @@ public class MessageListView : Gtk.TreeView {
|
||||||
Gtk.CellRendererText date_renderer = new Gtk.CellRendererText();
|
Gtk.CellRendererText date_renderer = new Gtk.CellRendererText();
|
||||||
date_renderer.xalign = 1.0f;
|
date_renderer.xalign = 1.0f;
|
||||||
append_column(create_column(MessageListStore.Column.FROM, new Gtk.CellRendererText(),
|
append_column(create_column(MessageListStore.Column.FROM, new Gtk.CellRendererText(),
|
||||||
"text", 200));
|
"markup", 200));
|
||||||
append_column(create_column(MessageListStore.Column.SUBJECT, new Gtk.CellRendererText(),
|
append_column(create_column(MessageListStore.Column.SUBJECT, new Gtk.CellRendererText(),
|
||||||
"text", 400));
|
"markup", 400));
|
||||||
append_column(create_column(MessageListStore.Column.DATE, date_renderer, "text", 100));
|
append_column(create_column(MessageListStore.Column.DATE, date_renderer, "markup", 100));
|
||||||
|
|
||||||
get_selection().changed.connect(on_selection_changed);
|
get_selection().changed.connect(on_selection_changed);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,5 +5,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public abstract class Geary.EmailProperties : Object {
|
public abstract class Geary.EmailProperties : Object {
|
||||||
|
public EmailProperties() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract bool is_unread();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,5 +10,9 @@ public class Geary.Imap.EmailProperties : Geary.EmailProperties {
|
||||||
public EmailProperties(MessageFlags flags) {
|
public EmailProperties(MessageFlags flags) {
|
||||||
this.flags = flags;
|
this.flags = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool is_unread() {
|
||||||
|
return !flags.contains(MessageFlag.SEEN);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue