diff options
-rw-r--r-- | src/contacts-contact-pane.vala | 17 | ||||
-rw-r--r-- | src/contacts-contact-sheet.vala | 54 | ||||
-rw-r--r-- | src/core/contacts-bin-chunk.vala | 2 | ||||
-rw-r--r-- | src/io/contacts-io.vala | 4 |
4 files changed, 38 insertions, 39 deletions
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala index ee9ee6c..48f5aac 100644 --- a/src/contacts-contact-pane.vala +++ b/src/contacts-contact-pane.vala @@ -90,9 +90,8 @@ public class Contacts.ContactPane : Adw.Bin { show_contact_sheet (this.contact); } - private void show_contact_sheet (Contact contact) { - return_if_fail (contact != null); - + private void show_contact_sheet (Contact contact) + requires (this.contact != null) { remove_contact_sheet (); var contacts_sheet = new ContactSheet (contact); contacts_sheet.hexpand = true; @@ -123,8 +122,8 @@ public class Contacts.ContactPane : Adw.Bin { this.sheet = null; } - private void create_contact_editor () { - return_if_fail (this.contact != null); + private void create_contact_editor () + requires (this.contact != null) { remove_contact_editor (); var contact_editor = new ContactEditor (this.contact); @@ -142,8 +141,8 @@ public class Contacts.ContactPane : Adw.Bin { this.editor = null; } - public void stop_editing (bool cancel = false) { - return_if_fail (this.on_edit_mode); + public void stop_editing (bool cancel = false) + requires (this.on_edit_mode) { this.on_edit_mode = false; remove_contact_editor (); @@ -196,8 +195,8 @@ public class Contacts.ContactPane : Adw.Bin { } } - public void edit_contact () { - return_if_fail (this.contact != null); + public void edit_contact () + requires (this.contact != null) { if (this.on_edit_mode) return; diff --git a/src/contacts-contact-sheet.vala b/src/contacts-contact-sheet.vala index b604bdc..550b19f 100644 --- a/src/contacts-contact-sheet.vala +++ b/src/contacts-contact-sheet.vala @@ -177,9 +177,9 @@ public class Contacts.ContactSheet : Gtk.Widget { return header; } - private Gtk.Widget create_widget_for_roles (Chunk chunk) { - unowned var roles_chunk = chunk as RolesChunk; - return_if_fail (roles_chunk != null); + private Gtk.Widget create_widget_for_roles (Chunk chunk) + requires (chunk is RolesChunk) { + unowned var roles_chunk = (RolesChunk) chunk; var group = new ContactSheetGroup (); @@ -197,9 +197,9 @@ public class Contacts.ContactSheet : Gtk.Widget { return group; } - private Gtk.Widget create_widget_for_emails (Chunk chunk) { - unowned var emails_chunk = chunk as EmailAddressesChunk; - return_if_fail (emails_chunk != null); + private Gtk.Widget create_widget_for_emails (Chunk chunk) + requires (chunk is EmailAddressesChunk) { + unowned var emails_chunk = (EmailAddressesChunk) chunk; var group = new ContactSheetGroup (); @@ -225,9 +225,9 @@ public class Contacts.ContactSheet : Gtk.Widget { return group; } - private Gtk.Widget create_widget_for_phone_nrs (Chunk chunk) { - unowned var phones_chunk = chunk as PhonesChunk; - return_if_fail (phones_chunk != null); + private Gtk.Widget create_widget_for_phone_nrs (Chunk chunk) + requires (chunk is PhonesChunk) { + unowned var phones_chunk = (PhonesChunk) chunk; var group = new ContactSheetGroup (); @@ -245,13 +245,13 @@ public class Contacts.ContactSheet : Gtk.Widget { return group; } - private Gtk.Widget? create_widget_for_im_addresses (Chunk chunk) { + private Gtk.Widget? create_widget_for_im_addresses (Chunk chunk) + requires (chunk is ImAddressesChunk) { // NOTE: We _could_ enable this again, but only for specific services. // Right now, this just enables a million "Windows Live Messenger" and // "Jabber", ... fields, which are all resting in their respective coffins. #if 0 - unowned var im_addrs_chunk = chunk as ImAddressesChunk; - return_if_fail (im_addrs_chunk != null); + unowned var im_addrs_chunk = (ImAddressesChunk) chunk; var group = new ContactSheetGroup (); @@ -272,9 +272,9 @@ public class Contacts.ContactSheet : Gtk.Widget { return null; } - private Gtk.Widget create_widget_for_urls (Chunk chunk) { - unowned var urls_chunk = chunk as UrlsChunk; - return_if_fail (urls_chunk != null); + private Gtk.Widget create_widget_for_urls (Chunk chunk) + requires (chunk is UrlsChunk) { + unowned var urls_chunk = (UrlsChunk) chunk; var group = new ContactSheetGroup (); @@ -301,17 +301,17 @@ public class Contacts.ContactSheet : Gtk.Widget { return group; } - private Gtk.Widget create_widget_for_nickname (Chunk chunk) { - unowned var nickname_chunk = chunk as NicknameChunk; - return_if_fail (nickname_chunk != null || nickname_chunk.nickname != null); + private Gtk.Widget create_widget_for_nickname (Chunk chunk) + requires (chunk is NicknameChunk) { + unowned var nickname_chunk = (NicknameChunk) chunk; var row = new ContactSheetRow (chunk.property_name, nickname_chunk.nickname); return new ContactSheetGroup.single_row (row); } - private Gtk.Widget create_widget_for_birthday (Chunk chunk) { - unowned var birthday_chunk = chunk as BirthdayChunk; - return_if_fail (birthday_chunk != null || birthday_chunk.birthday != null); + private Gtk.Widget create_widget_for_birthday (Chunk chunk) + requires (chunk is BirthdayChunk) { + unowned var birthday_chunk = (BirthdayChunk) chunk; var birthday_str = birthday_chunk.birthday.to_local ().format ("%x"); @@ -326,9 +326,9 @@ public class Contacts.ContactSheet : Gtk.Widget { return new ContactSheetGroup.single_row (row); } - private Gtk.Widget create_widget_for_notes (Chunk chunk) { - unowned var notes_chunk = chunk as NotesChunk; - return_if_fail (notes_chunk != null); + private Gtk.Widget create_widget_for_notes (Chunk chunk) + requires (chunk is NotesChunk) { + unowned var notes_chunk = (NotesChunk) chunk; var group = new ContactSheetGroup (); @@ -344,9 +344,9 @@ public class Contacts.ContactSheet : Gtk.Widget { return group; } - private Gtk.Widget create_widget_for_postal_addresses (Chunk chunk) { - unowned var addresses_chunk = chunk as AddressesChunk; - return_if_fail (addresses_chunk != null); + private Gtk.Widget create_widget_for_postal_addresses (Chunk chunk) + requires (chunk is AddressesChunk) { + unowned var addresses_chunk = (AddressesChunk) chunk; // Check outside of the loop if we have a "maps:" URI handler var appinfo = AppInfo.get_default_for_uri_scheme ("maps"); diff --git a/src/core/contacts-bin-chunk.vala b/src/core/contacts-bin-chunk.vala index eac0060..cfaba43 100644 --- a/src/core/contacts-bin-chunk.vala +++ b/src/core/contacts-bin-chunk.vala @@ -49,7 +49,7 @@ public abstract class Contacts.BinChunk : Chunk, GLib.ListModel { public override bool dirty { get { // If we're hitting this, a subclass forgot to set the field - return_if_fail (this.original_elements_set); + return_val_if_fail (this.original_elements_set, false); var non_empty_count = nr_nonempty_children (); if (this.original_elements.length != non_empty_count) diff --git a/src/io/contacts-io.vala b/src/io/contacts-io.vala index 743a38c..094298d 100644 --- a/src/io/contacts-io.vala +++ b/src/io/contacts-io.vala @@ -79,8 +79,8 @@ namespace Contacts.Io { /** * Deserializes the {@link GLib.Variant} back into a {@link GLib.HashTable}. */ - public HashTable<string, Value?>[] deserialize_gvariant (GLib.Variant variant) { - return_val_if_fail (variant.get_type ().equal (new VariantType ("aa{sv}")), null); + public HashTable<string, Value?>[] deserialize_gvariant (GLib.Variant variant) + requires (variant.get_type ().equal (new VariantType ("aa{sv}"))) { var result = new GenericArray<HashTable<string, Value?>> (); |