[geary/wip/3.32-avatars: 48/50] Clean up client email util source file
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/3.32-avatars: 48/50] Clean up client email util source file
- Date: Sat, 9 Mar 2019 09:18:25 +0000 (UTC)
commit 31aa176ee274a9349d1551f1b7fbd28c89de8bb9
Author: Michael Gratton <mike vee net>
Date: Sat Mar 9 16:41:56 2019 +1100
Clean up client email util source file
src/client/application/geary-controller.vala | 2 +-
.../conversation-list/conversation-list-store.vala | 8 ++--
.../formatted-conversation-data.vala | 2 +-
src/client/notification/libnotify.vala | 11 +++--
src/client/util/util-email.vala | 48 +++++++++++++---------
5 files changed, 43 insertions(+), 28 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index 80d5d381..a0b9f789 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -2631,7 +2631,7 @@ public class GearyController : Geary.BaseObject {
// string substitution is a list of recipients of the email.
string message = _(
"Successfully sent mail to %s."
- ).printf(EmailUtil.to_short_recipient_display(rfc822.to));
+ ).printf(Util.Email.to_short_recipient_display(rfc822.to));
InAppNotification notification = new InAppNotification(message);
this.main_window.add_notification(notification);
Libnotify.play_sound("message-sent-email");
diff --git a/src/client/conversation-list/conversation-list-store.vala
b/src/client/conversation-list/conversation-list-store.vala
index a63a6a22..cbf11b88 100644
--- a/src/client/conversation-list/conversation-list-store.vala
+++ b/src/client/conversation-list/conversation-list-store.vala
@@ -83,7 +83,7 @@ public class ConversationListStore : Gtk.ListStore {
Geary.App.Conversation a, b;
model.get(aiter, Column.CONVERSATION_OBJECT, out a);
model.get(biter, Column.CONVERSATION_OBJECT, out b);
- return compare_conversation_ascending(a, b);
+ return Util.Email.compare_conversation_ascending(a, b);
}
@@ -225,8 +225,10 @@ public class ConversationListStore : Gtk.ListStore {
// sort the conversations so the previews are fetched from the newest to the oldest, matching
// the user experience
- Gee.TreeSet<Geary.App.Conversation> sorted_conversations = new Gee.TreeSet<Geary.App.Conversation>(
- compare_conversation_descending);
+ Gee.TreeSet<Geary.App.Conversation> sorted_conversations =
+ new Gee.TreeSet<Geary.App.Conversation>(
+ Util.Email.compare_conversation_descending
+ );
sorted_conversations.add_all(this.conversations.read_only_view);
foreach (Geary.App.Conversation conversation in sorted_conversations) {
// find oldest unread message for the preview
diff --git a/src/client/conversation-list/formatted-conversation-data.vala
b/src/client/conversation-list/formatted-conversation-data.vala
index 5af42625..cbb126b6 100644
--- a/src/client/conversation-list/formatted-conversation-data.vala
+++ b/src/client/conversation-list/formatted-conversation-data.vala
@@ -111,7 +111,7 @@ public class FormattedConversationData : Geary.BaseObject {
// Load preview-related data.
update_date_string();
- this.subject = EmailUtil.strip_subject_prefixes(preview);
+ this.subject = Util.Email.strip_subject_prefixes(preview);
this.body = Geary.String.reduce_whitespace(preview.get_preview_as_string());
this.preview = preview;
diff --git a/src/client/notification/libnotify.vala b/src/client/notification/libnotify.vala
index fd53be55..d82a5a9c 100644
--- a/src/client/notification/libnotify.vala
+++ b/src/client/notification/libnotify.vala
@@ -105,10 +105,15 @@ public class Libnotify : Geary.BaseObject {
string body;
int count = monitor.get_new_message_count(folder);
if (count <= 1) {
- body = EmailUtil.strip_subject_prefixes(email);
+ body = Util.Email.strip_subject_prefixes(email);
} else {
- body = ngettext("%s\n(%d other new message for %s)", "%s\n(%d other new messages for %s)", count
- 1).printf(
- EmailUtil.strip_subject_prefixes(email), count - 1, folder.account.information.display_name);
+ body = ngettext(
+ "%s\n(%d other new message for %s)",
+ "%s\n(%d other new messages for %s)", count - 1).printf(
+ Util.Email.strip_subject_prefixes(email),
+ count - 1,
+ folder.account.information.display_name
+ );
}
Gdk.Pixbuf? avatar = yield this.avatars.load(
diff --git a/src/client/util/util-email.vala b/src/client/util/util-email.vala
index f89fe6eb..05a82828 100644
--- a/src/client/util/util-email.vala
+++ b/src/client/util/util-email.vala
@@ -4,31 +4,39 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
-public int compare_conversation_ascending(Geary.App.Conversation a, Geary.App.Conversation b) {
- Geary.Email? a_latest = a.get_latest_recv_email(Geary.App.Conversation.Location.IN_FOLDER_OUT_OF_FOLDER);
- Geary.Email? b_latest = b.get_latest_recv_email(Geary.App.Conversation.Location.IN_FOLDER_OUT_OF_FOLDER);
+namespace Util.Email {
- if (a_latest == null)
- return (b_latest == null) ? 0 : -1;
- else if (b_latest == null)
- return 1;
+ public int compare_conversation_ascending(Geary.App.Conversation a,
+ Geary.App.Conversation b) {
+ Geary.Email? a_latest = a.get_latest_recv_email(
+ Geary.App.Conversation.Location.IN_FOLDER_OUT_OF_FOLDER
+ );
+ Geary.Email? b_latest = b.get_latest_recv_email(
+ Geary.App.Conversation.Location.IN_FOLDER_OUT_OF_FOLDER
+ );
- // use date-received so newly-arrived messages float to the top, even if they're send date
- // was earlier (think of mailing lists that batch up forwarded mail)
- return Geary.Email.compare_recv_date_ascending(a_latest, b_latest);
-}
-
-public int compare_conversation_descending(Geary.App.Conversation a, Geary.App.Conversation b) {
- return compare_conversation_ascending(b, a);
-}
+ if (a_latest == null) {
+ return (b_latest == null) ? 0 : -1;
+ } else if (b_latest == null) {
+ return 1;
+ }
-namespace EmailUtil {
+ // use date-received so newly-arrived messages float to the
+ // top, even if they're send date was earlier (think of
+ // mailing lists that batch up forwarded mail)
+ return Geary.Email.compare_recv_date_ascending(a_latest, b_latest);
+ }
-public string strip_subject_prefixes(Geary.Email email) {
- string? cleaned = (email.subject != null) ? email.subject.strip_prefixes() : null;
+ public int compare_conversation_descending(Geary.App.Conversation a,
+ Geary.App.Conversation b) {
+ return compare_conversation_ascending(b, a);
+ }
- return !Geary.String.is_empty(cleaned) ? cleaned : _("(no subject)");
-}
+ /** Returns the stripped subject line, or a placeholder if none. */
+ public string strip_subject_prefixes(Geary.Email email) {
+ string? cleaned = (email.subject != null) ? email.subject.strip_prefixes() : null;
+ return !Geary.String.is_empty(cleaned) ? cleaned : _("(no subject)");
+ }
/**
* Returns a shortened recipient list suitable for display.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]