From fed14f49579736df4ea623cf1a21d50a78d23fad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 13 Aug 2026 12:37:29 -0700 Subject: [PATCH 1/4] ConvesationListStore: prep for ListView --- src/ConversationList/ConversationListStore.vala | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/ConversationList/ConversationListStore.vala b/src/ConversationList/ConversationListStore.vala index ccf31704c..c44cc9238 100644 --- a/src/ConversationList/ConversationListStore.vala +++ b/src/ConversationList/ConversationListStore.vala @@ -30,7 +30,7 @@ public class Mail.ConversationListStore : ListModel, Object { private unowned GLib.CompareDataFunc compare_func; private unowned RowVisibilityFunc filter_func; - public GLib.Type get_item_type () { + private GLib.Type get_item_type () { return typeof (GLib.Object); } @@ -38,14 +38,10 @@ public class Mail.ConversationListStore : ListModel, Object { return data.get_length (); } - public GLib.Object? get_item (uint index) { + private GLib.Object? get_item (uint index) { return get_item_internal (index); } - public GLib.Object? get_item_unfiltered (uint index) { - return get_item_internal (index, true); - } - private GLib.Object? get_item_internal (uint index, bool unfiltered = false) { GLib.SequenceIter? iter = null; @@ -175,14 +171,14 @@ public class Mail.ConversationListStore : ListModel, Object { return -1; } - public int get_index_of_unfiltered (GLib.Object? item) { + private int get_index_of_unfiltered (GLib.Object? item) { if (item == null) { return -1; } var length = get_n_items (); for (int i = 0; i < length; i++) { - if (item == get_item_unfiltered (i)) { + if (item == get_item_internal (i, true)) { return i; } } From 0c903a050c8603d130377dd947e1407efc8cbf48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 13 Aug 2026 12:42:21 -0700 Subject: [PATCH 2/4] ConversationListStore: add insert_sorted --- src/ConversationList/ConversationList.vala | 3 +-- src/ConversationList/ConversationListStore.vala | 13 ++----------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/ConversationList/ConversationList.vala b/src/ConversationList/ConversationList.vala index 3656d09c1..9edf8b971 100644 --- a/src/ConversationList/ConversationList.vala +++ b/src/ConversationList/ConversationList.vala @@ -52,7 +52,6 @@ public class Mail.ConversationList : Gtk.Box { folder_info_flags = new Gee.HashMap (); threads = new Gee.HashMap (); list_store = new ConversationListStore (); - list_store.set_sort_func (thread_sort_function); list_store.set_filter_func (filter_function); list_box = new VirtualizingListBox () { @@ -414,7 +413,7 @@ public class Mail.ConversationList : Gtk.Box { private void add_conversation_item (Camel.FolderInfoFlags folder_info_flags, Camel.FolderThreadNode child, Camel.FolderThread thread, string service_uid) { var item = new ConversationItemModel (folder_info_flags, child, thread, service_uid); conversations[child.message.uid] = item; - list_store.add (item); + list_store.insert_sorted (item, thread_sort_function); } private static bool filter_function (GLib.Object obj) { diff --git a/src/ConversationList/ConversationListStore.vala b/src/ConversationList/ConversationListStore.vala index c44cc9238..505b6d265 100644 --- a/src/ConversationList/ConversationListStore.vala +++ b/src/ConversationList/ConversationListStore.vala @@ -27,7 +27,6 @@ public class Mail.ConversationListStore : ListModel, Object { private GLib.Sequence data = new GLib.Sequence (); private uint last_position = uint.MAX; private GLib.SequenceIter? last_iter; - private unowned GLib.CompareDataFunc compare_func; private unowned RowVisibilityFunc filter_func; private GLib.Type get_item_type () { @@ -77,12 +76,8 @@ public class Mail.ConversationListStore : ListModel, Object { } } - public void add (ConversationItemModel data) { - if (compare_func != null) { - this.data.insert_sorted (data, compare_func); - } else { - this.data.append (data); - } + public void insert_sorted (ConversationItemModel item, CompareDataFunc compare_func) { + data.insert_sorted (item, compare_func); last_iter = null; last_position = uint.MAX; @@ -104,10 +99,6 @@ public class Mail.ConversationListStore : ListModel, Object { last_position = uint.MAX; } - public void set_sort_func (GLib.CompareDataFunc function) { - this.compare_func = function; - } - public void set_filter_func (RowVisibilityFunc? function) { filter_func = function; } From aa16e8edd56b050e06731223c6349153d02bb27a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 13 Aug 2026 13:12:24 -0700 Subject: [PATCH 3/4] Better compare func --- src/ConversationList/ConversationItemModel.vala | 6 ++++++ src/ConversationList/ConversationList.vala | 6 +----- src/ConversationList/ConversationListStore.vala | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/ConversationList/ConversationItemModel.vala b/src/ConversationList/ConversationItemModel.vala index d299b9cfe..406a7dbf7 100644 --- a/src/ConversationList/ConversationItemModel.vala +++ b/src/ConversationList/ConversationItemModel.vala @@ -248,4 +248,10 @@ public class Mail.ConversationItemModel : GLib.Object { return has_flag; } + + public static int compare_func (Object a, Object b) { + var item1 = (ConversationItemModel) a; + var item2 = (ConversationItemModel) b; + return (int)(item2.timestamp - item1.timestamp); + } } diff --git a/src/ConversationList/ConversationList.vala b/src/ConversationList/ConversationList.vala index 9edf8b971..281c806a0 100644 --- a/src/ConversationList/ConversationList.vala +++ b/src/ConversationList/ConversationList.vala @@ -413,7 +413,7 @@ public class Mail.ConversationList : Gtk.Box { private void add_conversation_item (Camel.FolderInfoFlags folder_info_flags, Camel.FolderThreadNode child, Camel.FolderThread thread, string service_uid) { var item = new ConversationItemModel (folder_info_flags, child, thread, service_uid); conversations[child.message.uid] = item; - list_store.insert_sorted (item, thread_sort_function); + list_store.insert_sorted (item, ConversationItemModel.compare_func); } private static bool filter_function (GLib.Object obj) { @@ -425,10 +425,6 @@ public class Mail.ConversationList : Gtk.Box { } } - private static int thread_sort_function (ConversationItemModel item1, ConversationItemModel item2) { - return (int)(item2.timestamp - item1.timestamp); - } - public void mark_read_selected_messages () { var selected_rows = list_box.get_selected_rows (); foreach (var row in selected_rows) { diff --git a/src/ConversationList/ConversationListStore.vala b/src/ConversationList/ConversationListStore.vala index 505b6d265..0039b26a1 100644 --- a/src/ConversationList/ConversationListStore.vala +++ b/src/ConversationList/ConversationListStore.vala @@ -76,7 +76,7 @@ public class Mail.ConversationListStore : ListModel, Object { } } - public void insert_sorted (ConversationItemModel item, CompareDataFunc compare_func) { + public void insert_sorted (ConversationItemModel item, CompareDataFunc compare_func) { data.insert_sorted (item, compare_func); last_iter = null; From 3f5868c2b131e5ed2977dc810563c1190f5b3457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 13 Aug 2026 13:15:58 -0700 Subject: [PATCH 4/4] lint --- src/ConversationList/ConversationListStore.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ConversationList/ConversationListStore.vala b/src/ConversationList/ConversationListStore.vala index 0039b26a1..0ee613cd9 100644 --- a/src/ConversationList/ConversationListStore.vala +++ b/src/ConversationList/ConversationListStore.vala @@ -76,7 +76,7 @@ public class Mail.ConversationListStore : ListModel, Object { } } - public void insert_sorted (ConversationItemModel item, CompareDataFunc compare_func) { + public void insert_sorted (ConversationItemModel item, CompareDataFunc compare_func) { data.insert_sorted (item, compare_func); last_iter = null;