[gnome-contacts/nielsdg/core-should-stay-core: 3/11] contact: Don't use Gtk.INVALID_LIST_POSITION




commit 3ae5790f0d884220e236725607a1f28f118e3ac7
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Wed Sep 7 09:02:10 2022 +0200

    contact: Don't use Gtk.INVALID_LIST_POSITION
    
    Try to avoid using GTK in the core logic. Since we know it's not really
    realistic we'll get an overflow for the properties on a specific
    contact, we can just solve this case by using a signed integer and
    returning -1.

 src/core/contacts-contact.vala | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/src/core/contacts-contact.vala b/src/core/contacts-contact.vala
index 071f6f42..866ec187 100644
--- a/src/core/contacts-contact.vala
+++ b/src/core/contacts-contact.vala
@@ -109,18 +109,18 @@ public class Contacts.Contact : GLib.Object, GLib.ListModel {
 
   public unowned Chunk? create_chunk (string property_name, Persona? persona) {
     var pos = create_chunk_internal (property_name, persona);
-    if (pos == Gtk.INVALID_LIST_POSITION)
+    if (pos == -1)
       return null;
     items_changed (pos, 0, 1);
     return this.chunks[pos];
   }
 
   // Helper to create a chunk and return its position, without items_changed()
-  private uint create_chunk_internal (string property_name, Persona? persona) {
+  private int create_chunk_internal (string property_name, Persona? persona) {
     var chunk_gtype = chunk_gtype_for_property (property_name);
     if (chunk_gtype == GLib.Type.NONE) {
       debug ("unsupported property '%s', ignoring", property_name);
-      return Gtk.INVALID_LIST_POSITION;
+      return -1;
     }
 
     var chunk = (Chunk) Object.new (chunk_gtype,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]