diff options
-rw-r--r-- | src/contacts-contact.vala | 28 | ||||
-rw-r--r-- | src/contacts-link-dialog.vala | 6 | ||||
-rw-r--r-- | src/contacts-list-pane.vala | 4 | ||||
-rw-r--r-- | src/contacts-view.vala | 16 |
4 files changed, 33 insertions, 21 deletions
diff --git a/src/contacts-contact.vala b/src/contacts-contact.vala index aca3867..6fc0e96 100644 --- a/src/contacts-contact.vala +++ b/src/contacts-contact.vala @@ -107,7 +107,7 @@ public class Contacts.ContactPresence : Grid { public class Contacts.Contact : GLib.Object { public Store store; - public bool is_primary; + public bool is_main; public PresenceType presence_type; public string presence_message; public bool is_phone; @@ -377,16 +377,32 @@ public class Contacts.Contact : GLib.Object { } } + private static bool persona_is_main (Persona persona) { + var store = persona.store; + if (!store.is_primary_store) + return false; + + return true; + } + + private bool calc_is_main () { + var res = false; + foreach (var p in individual.personas) { + if (persona_is_main (p)) + res = true; + } + return res; + } + public Contact (Store store, Individual i) { this.store = store; individual = i; individual.set_data ("contact", this); this.refs = new ContactDataRef[0]; + is_main = calc_is_main (); foreach (var p in individual.personas) { connect_persona (p); - if (p.store.is_primary_store) - this.is_primary = true; } individual.personas_changed.connect ( (added, removed) => { @@ -787,11 +803,7 @@ public class Contacts.Contact : GLib.Object { var changed_personas = this.changed_personas; this.changed_personas = false; if (changed_personas) { - this.is_primary = false; - foreach (var p in individual.personas) { - if (p.store.is_primary_store) - this.is_primary = true; - } + this.is_main = calc_is_main (); } update (); changed (); diff --git a/src/contacts-link-dialog.vala b/src/contacts-link-dialog.vala index 6cc20db..c0fe479 100644 --- a/src/contacts-link-dialog.vala +++ b/src/contacts-link-dialog.vala @@ -110,10 +110,10 @@ public class Contacts.LinkDialog : Dialog { view = new View (contact.store); view.hide_contact (contact); - if (contact.is_primary) - view.set_show_subset (View.Subset.NON_PRIMARY); + if (contact.is_main) + view.set_show_subset (View.Subset.OTHER); else - view.set_show_subset (View.Subset.PRIMARY); + view.set_show_subset (View.Subset.MAIN); var matches = contact.store.aggregator.get_potential_matches (contact.individual, MatchResult.HIGH); foreach (var ind in matches.keys) { diff --git a/src/contacts-list-pane.vala b/src/contacts-list-pane.vala index 4749ca8..93b2761 100644 --- a/src/contacts-list-pane.vala +++ b/src/contacts-list-pane.vala @@ -46,7 +46,7 @@ public class Contacts.ListPane : Frame { contacts_view.set_filter_values (values); if (values == null) - contacts_view.set_show_subset (View.Subset.PRIMARY); + contacts_view.set_show_subset (View.Subset.MAIN); else contacts_view.set_show_subset (View.Subset.ALL_SEPARATED); } @@ -96,7 +96,7 @@ public class Contacts.ListPane : Frame { toolbar.set_vexpand (false); toolbar.set_hexpand (true); - contacts_view.set_show_subset (View.Subset.PRIMARY); + contacts_view.set_show_subset (View.Subset.MAIN); filter_entry = new Entry (); filter_entry.set_icon_from_icon_name (EntryIconPosition.SECONDARY, "edit-find-symbolic"); diff --git a/src/contacts-view.vala b/src/contacts-view.vala index deaa8e8..bf0df70 100644 --- a/src/contacts-view.vala +++ b/src/contacts-view.vala @@ -30,8 +30,8 @@ public class Contacts.View : GLib.Object { } public enum Subset { - PRIMARY, - NON_PRIMARY, + MAIN, + OTHER, ALL_SEPARATED, ALL } @@ -103,13 +103,13 @@ public class Contacts.View : GLib.Object { private bool is_other (ContactData data) { if (show_subset == Subset.ALL_SEPARATED && data.contact != null && - !data.contact.is_primary) + !data.contact.is_main) return true; return false; } /* The hardcoded prio if set, otherwise 0 for the - primary/combined group, or -2 for the separated other group */ + main/combined group, or -2 for the separated other group */ private int get_sort_prio (ContactData *data) { if (data->sort_prio != 0) return data->sort_prio; @@ -187,10 +187,10 @@ public class Contacts.View : GLib.Object { if (contact in hidden_contacts) return false; - if ((show_subset == Subset.PRIMARY && - !contact.is_primary) || - (show_subset == Subset.NON_PRIMARY && - contact.is_primary)) + if ((show_subset == Subset.MAIN && + !contact.is_main) || + (show_subset == Subset.OTHER && + contact.is_main)) return false; if (filter_values == null || filter_values.length == 0) |