[gnome-contacts] LinkSuggestionGrid: try more fields for the extra info.
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] LinkSuggestionGrid: try more fields for the extra info.
- Date: Thu, 28 Dec 2017 20:43:22 +0000 (UTC)
commit 67744bd8a811f7acca62df084caddff29adc4532
Author: Niels De Graef <nielsdegraef gmail com>
Date: Thu Dec 28 21:42:04 2017 +0100
LinkSuggestionGrid: try more fields for the extra info.
src/contacts-link-suggestion-grid.vala | 37 +++++++++++++++++++++++++-------
1 files changed, 29 insertions(+), 8 deletions(-)
---
diff --git a/src/contacts-link-suggestion-grid.vala b/src/contacts-link-suggestion-grid.vala
index 1546168..e8733b5 100644
--- a/src/contacts-link-suggestion-grid.vala
+++ b/src/contacts-link-suggestion-grid.vala
@@ -56,17 +56,38 @@ public class Contacts.LinkSuggestionGrid : Grid {
_("Is this the same person as %s from %s?").printf (contact.display_name,
contact.format_persona_stores ())
: _("Is this the same person as %s?").printf (contact.display_name);
- var emails = contact.individual.email_addresses;
- if (!emails.is_empty) {
- // This is of course a best guess.
- var email = Utils.get_first<EmailFieldDetails>(emails);
- if (email.value != null) {
- this.extra_info_label.show ();
- this.extra_info_label.label = email.value;
- }
+ var extra_info = find_extra_description (contact);
+ if (extra_info != null) {
+ this.extra_info_label.show ();
+ this.extra_info_label.label = extra_info;
}
this.reject_button.clicked.connect ( () => suggestion_rejected ());
this.accept_button.clicked.connect ( () => suggestion_accepted ());
}
+
+ private string? find_extra_description (Contact contact) {
+ // First try an email address
+ var emails = contact.individual.email_addresses;
+ if (!emails.is_empty)
+ return Utils.get_first<EmailFieldDetails> (emails).value;
+
+ // Maybe a website? Works well with e.g. social media profiles
+ var urls = contact.individual.urls;
+ if (!urls.is_empty)
+ return Utils.get_first<UrlFieldDetails> (urls).value;
+
+ // Try a phone number
+ var phones = contact.individual.phone_numbers;
+ if (!phones.is_empty)
+ return Utils.get_first<PhoneFieldDetails> (phones).value;
+
+ // A postal address maybe?
+ var addresses = contact.individual.postal_addresses;
+ if (!addresses.is_empty)
+ return Utils.get_first<PostalAddressFieldDetails> (addresses).value.to_string ();
+
+ // We're out of ideas now.
+ return null;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]