[gnome-games] collections-main-page: Add and set filter function



commit fda906da8bb5ebd6847efac27d66d0d94f874852
Author: Neville <nevilleantony98 gmail com>
Date:   Thu Jul 30 20:52:39 2020 +0530

    collections-main-page: Add and set filter function
    
    Filter func will show non empty collections in the flowbox.

 src/ui/collections-main-page.vala | 13 +++++++++++++
 1 file changed, 13 insertions(+)
---
diff --git a/src/ui/collections-main-page.vala b/src/ui/collections-main-page.vala
index 3c84b461f..a178f00d8 100644
--- a/src/ui/collections-main-page.vala
+++ b/src/ui/collections-main-page.vala
@@ -26,6 +26,7 @@ private class Games.CollectionsMainPage : Gtk.Bin {
                set {
                        _collection_model = value;
                        flow_box.bind_model (collection_model, add_collection);
+                       flow_box.set_filter_func (collection_filter_func);
                }
        }
 
@@ -97,6 +98,18 @@ private class Games.CollectionsMainPage : Gtk.Bin {
                adjustment.value = 0;
        }
 
+       public void invalidate_filter () {
+               flow_box.invalidate_filter ();
+       }
+
+       private bool collection_filter_func (Gtk.FlowBoxChild child) {
+               var collection_icon_view = child as CollectionIconView;
+               if (collection_icon_view == null)
+                       return false;
+
+               return !collection_icon_view.collection.is_empty;
+       }
+
        [GtkCallback]
        public void on_map () {
                window_active_binding = null;


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