[gnome-contacts] Support roles as secondary strings
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] Support roles as secondary strings
- Date: Tue, 13 Sep 2011 14:18:25 +0000 (UTC)
commit 7489db0b54500b2df024f18325475cdcbe71da75
Author: Alexander Larsson <alexl redhat com>
Date: Tue Sep 13 16:08:14 2011 +0200
Support roles as secondary strings
src/contacts-contact-pane.vala | 14 ++++++++---
src/contacts-contact.vala | 45 ++++++++++++++++++++++++++++++++--------
2 files changed, 46 insertions(+), 13 deletions(-)
---
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index ecda365..4f1bb57 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -1331,9 +1331,12 @@ public class Contacts.ContactPane : Grid {
delete_menu_item.set_sensitive (can_remove_all);
+ string [] secondary_sources;
+ contact.get_secondary_string (out secondary_sources);
+
var nickname = contact.individual.nickname;
if (nickname != null && nickname != "" &&
- contact.get_secondary_string_source () != "nickname")
+ !("nickname" in secondary_sources))
fields_layout.add_label_detail (_("Nickname"), nickname);
var emails = Contact.sort_fields<EmailFieldDetails>(contact.individual.email_addresses);
@@ -1446,7 +1449,8 @@ public class Contacts.ContactPane : Grid {
foreach (var role_detail in roles_details) {
var role = role_detail.value;
if (role.organisation_name != null &&
- role.organisation_name != "") {
+ role.organisation_name != "" &&
+ !("organisation-name" in secondary_sources)) {
fields_layout.add_label (_("Company"));
fields_layout.add_detail (role.organisation_name);
}
@@ -1461,12 +1465,14 @@ public class Contacts.ContactPane : Grid {
}
}
if (role.role != null &&
- role.role != "") {
+ role.role != "" &&
+ !("role" in secondary_sources)) {
fields_layout.add_label (_("Profession"));
fields_layout.add_detail (role.role);
}
if (role.title != null &&
- role.title != "") {
+ role.title != "" &&
+ !("title" in secondary_sources)) {
fields_layout.add_label (_("Title"));
fields_layout.add_detail (role.title);
}
diff --git a/src/contacts-contact.vala b/src/contacts-contact.vala
index d7cdeb0..35fe266 100644
--- a/src/contacts-contact.vala
+++ b/src/contacts-contact.vala
@@ -154,21 +154,48 @@ public class Contacts.Contact : GLib.Object {
}
}
- // Synchronize with get_secondary_string ()
- public string? get_secondary_string_source () {
- var nick = individual.nickname;
- if (nick != null && nick.length > 0)
- return "nickname";
- return null;
+ private static bool is_set (string? str) {
+ return str != null && str != "";
}
// Synchronize with get_secondary_string_source ()
- public string? get_secondary_string () {
+ public string? get_secondary_string (out string [] sources = null) {
var nick = individual.nickname;
- if (nick != null && nick.length > 0)
+ if (is_set (nick)) {
+ sources = new string[1];
+ sources[0] = "nickname";
return "\xE2\x80\x9C" + nick + "\xE2\x80\x9D";
+ }
- /* TODO: "<title>, <Company>" */
+ foreach (var role_detail in individual.roles) {
+ var role = role_detail.value;
+
+ if (is_set (role.organisation_name)) {
+ if (is_set (role.title)) {
+ sources = new string[2];
+ sources[0] = "title";
+ sources[1] = "organisation-name";
+ return "%s, %s".printf (role.title, role.organisation_name);
+ } else if (is_set (role.role)) {
+ sources = new string[2];
+ sources[0] = "role";
+ sources[1] = "organisation-name";
+ return "%s, %s".printf (role.role, role.organisation_name);
+ } else {
+ sources = new string[0];
+ sources[0] = "organisation-name";
+ return role.organisation_name;
+ }
+ } else if (is_set (role.title)) {
+ sources = new string[0];
+ sources[0] = "title";
+ return role.title;
+ } else if (is_set (role.role)) {
+ sources = new string[0];
+ sources[0] = "role";
+ return role.role;
+ }
+ }
return null;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]