[gnome-boxes/wip/feborges/flowbox: 11/13] collection: Insert items sorted
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/wip/feborges/flowbox: 11/13] collection: Insert items sorted
- Date: Wed, 20 Dec 2017 17:43:26 +0000 (UTC)
commit 10bf17c16acf617570fce746f8a7c61fcd84df73
Author: Felipe Borges <felipeborges gnome org>
Date: Wed Dec 20 17:54:50 2017 +0100
collection: Insert items sorted
This way we will be able to get rid of GtkListBox.sort_func and
do the sorting at the model side when ListView will be binded to
Collection directly.
src/collection.vala | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/src/collection.vala b/src/collection.vala
index 91cb74c..078be0e 100644
--- a/src/collection.vala
+++ b/src/collection.vala
@@ -50,7 +50,13 @@ private class Boxes.Collection: GLib.Object {
}
public void add_item (CollectionItem item) {
- items.append (item);
+ items.insert_sorted (item, (item1, item2) => {
+ if (item1 == null || item2 == null)
+ return 0;
+
+ return (item1 as CollectionItem).compare (item2 as CollectionItem);
+ });
+
item_added (item);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]