summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNiels De Graef <nielsdegraef@gmail.com>2022-01-13 13:22:30 +0100
committerNiels De Graef <nielsdegraef@gmail.com>2022-01-19 13:17:24 +0100
commit2f2ac8f44d984d1b6f043493e92d33e4f233f0ef (patch)
treee6532878be99ca763a61aab24494a37626cddbff /src
parentafd7ee44058eafea41ad70126f58ab8454bec5cd (diff)
downloadgnome-contacts-2f2ac8f44d984d1b6f043493e92d33e4f233f0ef.tar.gz
sheet: Group fields from the same property
Group e-mails, phone numbers, ... that are in the same persona together (per property), rather than making a list box for each.
Diffstat (limited to 'src')
-rw-r--r--src/contacts-contact-sheet.vala27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/contacts-contact-sheet.vala b/src/contacts-contact-sheet.vala
index 88d414a..54724c2 100644
--- a/src/contacts-contact-sheet.vala
+++ b/src/contacts-contact-sheet.vala
@@ -91,18 +91,29 @@ public class Contacts.ContactSheet : Gtk.Grid {
return store_name;
}
- // Helper function that attaches a row to our grid
- private void attach_row (Gtk.ListBoxRow row) {
+ // Helper function that attaches a set of property rows to our grid
+ private void attach_rows (GLib.List<Gtk.ListBoxRow>? rows) {
+ if (rows == null)
+ return;
+
var list_box = new Gtk.ListBox ();
list_box.selection_mode = Gtk.SelectionMode.NONE;
list_box.add_css_class ("boxed-list");
list_box.add_css_class ("contacts-sheet-property");
- list_box.append (row);
+
+ foreach (unowned var row in rows)
+ list_box.append (row);
this.attach (list_box, 0, this.last_row, 3, 1);
this.last_row++;
}
+ private void attach_row (Gtk.ListBoxRow row) {
+ var rows = new GLib.List<Gtk.ListBoxRow> ();
+ rows.prepend (row);
+ this.attach_rows (rows);
+ }
+
private void update () {
this.last_row = 0;
@@ -204,6 +215,7 @@ public class Contacts.ContactSheet : Gtk.Grid {
return;
var emails = Utils.sort_fields<EmailFieldDetails>(details.email_addresses);
+ var rows = new GLib.List<Gtk.ListBoxRow> ();
foreach (var email in emails) {
if (email.value == "")
continue;
@@ -218,8 +230,10 @@ public class Contacts.ContactSheet : Gtk.Grid {
Utils.compose_mail ("%s <%s>".printf(this.individual.display_name, email.value));
});
- this.attach_row (row);
+ rows.append (row);
}
+
+ this.attach_rows (rows);
}
private void add_phone_nrs (Persona persona, string property) {
@@ -228,6 +242,7 @@ public class Contacts.ContactSheet : Gtk.Grid {
return;
var phones = Utils.sort_fields<PhoneFieldDetails>(phone_details.phone_numbers);
+ var rows = new GLib.List<Gtk.ListBoxRow> ();
foreach (var phone in phones) {
if (phone.value == "")
continue;
@@ -246,8 +261,10 @@ public class Contacts.ContactSheet : Gtk.Grid {
}
#endif
- this.attach_row (row);
+ rows.append (row);
}
+
+ this.attach_rows (rows);
}
private void add_im_addresses (Persona persona, string property) {