[geary/wip/738188-multireplies: 3/5] Deal with MailboxAddresses, not strings, in composer
- From: Robert Schroll <rschroll src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/738188-multireplies: 3/5] Deal with MailboxAddresses, not strings, in composer
- Date: Wed, 14 Jan 2015 22:09:00 +0000 (UTC)
commit 6b4d84152037280b2e92cecee8b5d15250daec33
Author: Robert Schroll <rschroll gmail com>
Date: Mon Jan 12 18:25:18 2015 -0800
Deal with MailboxAddresses, not strings, in composer
src/client/composer/composer-widget.vala | 19 ++++++++++---------
src/client/composer/email-entry.vala | 27 +++++++++++++++++++++++++--
src/engine/rfc822/rfc822-utils.vala | 8 ++++----
3 files changed, 39 insertions(+), 15 deletions(-)
---
diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala
index 9cfa2cc..ece7d33 100644
--- a/src/client/composer/composer-widget.vala
+++ b/src/client/composer/composer-widget.vala
@@ -230,8 +230,8 @@ public class ComposerWidget : Gtk.EventBox {
private bool action_flag = false;
private bool is_attachment_overlay_visible = false;
private Gee.List<Geary.Attachment>? pending_attachments = null;
- private string reply_to_addresses = "";
- private string reply_cc_addresses = "";
+ private Geary.RFC822.MailboxAddresses reply_to_addresses;
+ private Geary.RFC822.MailboxAddresses reply_cc_addresses;
private string reply_subject = "";
private string forward_subject = "";
private string reply_message_id = "";
@@ -425,11 +425,11 @@ public class ComposerWidget : Gtk.EventBox {
switch (compose_type) {
case ComposeType.NEW_MESSAGE:
if (referred.to != null)
- to = referred.to.to_rfc822_string();
+ to_entry.addresses = referred.to;
if (referred.cc != null)
- cc = referred.cc.to_rfc822_string();
+ cc_entry.addresses = referred.cc;
if (referred.bcc != null)
- bcc = referred.bcc.to_rfc822_string();
+ bcc_entry.addresses = referred.bcc;
if (referred.in_reply_to != null)
in_reply_to = referred.in_reply_to.to_rfc822_string();
if (referred.references != null)
@@ -450,9 +450,9 @@ public class ComposerWidget : Gtk.EventBox {
case ComposeType.REPLY:
case ComposeType.REPLY_ALL:
- to = reply_to_addresses;
+ to_entry.addresses = reply_to_addresses;
if (compose_type == ComposeType.REPLY_ALL)
- cc = reply_cc_addresses;
+ cc_entry.addresses = reply_cc_addresses;
to_entry.modified = cc_entry.modified = false;
subject = reply_subject;
in_reply_to = reply_message_id;
@@ -811,8 +811,9 @@ public class ComposerWidget : Gtk.EventBox {
case ComposeType.REPLY_ALL:
subject = reply_subject;
if (!recipients_modified) {
- to = reply_to_addresses;
- cc = (new_type == ComposeType.REPLY_ALL ? reply_cc_addresses : "");
+ to_entry.addresses = reply_to_addresses;
+ cc_entry.addresses = (new_type == ComposeType.REPLY_ALL) ?
+ reply_cc_addresses : null;
to_entry.modified = cc_entry.modified = false;
} else {
to_entry.select_region(0, -1);
diff --git a/src/client/composer/email-entry.vala b/src/client/composer/email-entry.vala
index 3b41f5a..51b2113 100644
--- a/src/client/composer/email-entry.vala
+++ b/src/client/composer/email-entry.vala
@@ -11,34 +11,57 @@ public class EmailEntry : Gtk.Entry {
public bool modified = false;
// null or valid addresses
- public Geary.RFC822.MailboxAddresses? addresses { get; private set; default = null; }
+ public Geary.RFC822.MailboxAddresses? addresses { get; set; default = null; }
private weak ComposerWidget composer;
+
+ private bool updating = false;
public EmailEntry(ComposerWidget composer) {
changed.connect(on_changed);
key_press_event.connect(on_key_press);
this.composer = composer;
+
+ notify["addresses"].connect(() => {
+ validate_addresses();
+ if (updating)
+ return;
+
+ updating = true;
+ modified = true;
+ text = (addresses == null) ? "" : addresses.to_rfc822_string();
+ updating = false;
+ });
}
private void on_changed() {
+ if (updating)
+ return;
modified = true;
((ContactEntryCompletion) get_completion()).reset_selection();
if (Geary.String.is_empty(text.strip())) {
+ updating = true;
addresses = null;
+ updating = false;
valid_or_empty = true;
empty = true;
return;
}
+ updating = true;
addresses = new Geary.RFC822.MailboxAddresses.from_rfc822_string(text);
+ updating = false;
+ }
+
+ private void validate_addresses() {
if (addresses.size == 0) {
valid_or_empty = true;
+ empty = true;
return;
}
empty = false;
-
+
foreach (Geary.RFC822.MailboxAddress address in addresses) {
if (!address.is_valid()) {
valid_or_empty = false;
diff --git a/src/engine/rfc822/rfc822-utils.vala b/src/engine/rfc822/rfc822-utils.vala
index 6aa4043..e97e2e3 100644
--- a/src/engine/rfc822/rfc822-utils.vala
+++ b/src/engine/rfc822/rfc822-utils.vala
@@ -69,7 +69,7 @@ private void remove_address(Gee.List<Geary.RFC822.MailboxAddress> addresses,
}
}
-public string create_to_addresses_for_reply(Geary.Email email,
+public Geary.RFC822.MailboxAddresses create_to_addresses_for_reply(Geary.Email email,
string? sender_address = null) {
Gee.List<Geary.RFC822.MailboxAddress> new_to =
new Gee.ArrayList<Geary.RFC822.MailboxAddress>();
@@ -87,10 +87,10 @@ public string create_to_addresses_for_reply(Geary.Email email,
if (!String.is_empty(sender_address))
remove_address(new_to, sender_address);
- return new_to.size > 0 ? new Geary.RFC822.MailboxAddresses(new_to).to_rfc822_string() : "";
+ return new Geary.RFC822.MailboxAddresses(new_to);
}
-public string create_cc_addresses_for_reply_all(Geary.Email email,
+public Geary.RFC822.MailboxAddresses create_cc_addresses_for_reply_all(Geary.Email email,
string? sender_address = null) {
Gee.List<Geary.RFC822.MailboxAddress> new_cc = new Gee.ArrayList<Geary.RFC822.MailboxAddress>();
@@ -108,7 +108,7 @@ public string create_cc_addresses_for_reply_all(Geary.Email email,
if (!String.is_empty(sender_address))
remove_address(new_cc, sender_address, true);
- return new_cc.size > 0 ? new Geary.RFC822.MailboxAddresses(new_cc).to_rfc822_string() : "";
+ return new Geary.RFC822.MailboxAddresses(new_cc);
}
public string reply_references(Geary.Email source) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]