[gnome-games] collection-manager: Add collection_empty_changed()



commit 3fc3ce49968d381b24405e4a4cd401def7afcf93
Author: Neville <nevilleantony98 gmail com>
Date:   Thu Jul 30 20:47:36 2020 +0530

    collection-manager: Add collection_empty_changed()
    
    This will be used to handle hiding non-user collections in the
    upcoming commits.

 src/collection/collection-manager.vala | 13 +++++++++++++
 1 file changed, 13 insertions(+)
---
diff --git a/src/collection/collection-manager.vala b/src/collection/collection-manager.vala
index 9dc16551a..f26f7c99f 100644
--- a/src/collection/collection-manager.vala
+++ b/src/collection/collection-manager.vala
@@ -3,6 +3,7 @@
 private class Games.CollectionManager : Object {
        public signal void collection_added (Collection collection);
        public signal void collection_removed (Collection collection);
+       public signal void collection_empty_changed (Collection collection);
 
        private HashTable<string, Collection> collections;
        private Database database;
@@ -39,6 +40,12 @@ private class Games.CollectionManager : Object {
 
        private void add_favorites_collection () {
                favorites_collection = new FavoritesCollection (database);
+               favorites_collection.notify["is-empty"].connect (() => {
+                       Idle.add (() => {
+                               collection_empty_changed (favorites_collection);
+                               return Source.REMOVE;
+                       });
+               });
                collections[favorites_collection.get_id ()] = favorites_collection;
                Idle.add (() => {
                        collection_added (favorites_collection);
@@ -48,6 +55,12 @@ private class Games.CollectionManager : Object {
 
        private void add_recently_played_collection () {
                recently_played_collection = new RecentlyPlayedCollection (database);
+               recently_played_collection.notify["is-empty"].connect (() => {
+                       Idle.add (() => {
+                               collection_empty_changed (recently_played_collection);
+                               return Source.REMOVE;
+                       });
+               });
                collections[recently_played_collection.get_id ()] = recently_played_collection;
                Idle.add (() => {
                        collection_added (recently_played_collection);


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