[gnome-games] ui: Make Application use GameCollection to handle games



commit 62344645a7b9c203d4c4baca7b7df5081b77fdda
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Sun May 7 16:32:46 2017 +0200

    ui: Make Application use GameCollection to handle games
    
    This helps splitting the concerns of each class better.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=782295

 src/ui/application.vala |   17 ++---------------
 1 files changed, 2 insertions(+), 15 deletions(-)
---
diff --git a/src/ui/application.vala b/src/ui/application.vala
index fa3ec55..25695a0 100644
--- a/src/ui/application.vala
+++ b/src/ui/application.vala
@@ -3,8 +3,6 @@
 private extern const string VERSION;
 
 public class Games.Application : Gtk.Application {
-       private ListStore collection;
-       private GenericSet<Game> games;
        private ApplicationWindow window;
        private bool game_list_loaded;
 
@@ -139,11 +137,9 @@ public class Games.Application : Gtk.Application {
                var provider = load_css ("gtk-style.css");
                Gtk.StyleContext.add_provider_for_screen (screen, provider, 600);
 
-               collection = new ListStore (typeof (Game));
-               games = new GenericSet<Game> (direct_hash, direct_equal);
                load_game_list.begin ();
 
-               window = new ApplicationWindow (collection);
+               window = new ApplicationWindow (game_collection.get_list_store ());
                this.add_window (window);
                window.destroy.connect (() => {
                        quit_application ();
@@ -174,7 +170,6 @@ public class Games.Application : Gtk.Application {
                }
 
                game_collection = new GameCollection ();
-               game_collection.game_added.connect ((game) => add_game (game));
                if (tracker_uri_source != null)
                        game_collection.add_source (tracker_uri_source);
 
@@ -219,21 +214,13 @@ public class Games.Application : Gtk.Application {
        internal async void load_game_list () {
                init_game_sources ();
 
-               yield game_collection.each_game (add_game);
+               yield game_collection.search_games ();
 
                game_list_loaded = true;
                if (window != null)
                        window.loading_notification = false;
        }
 
-       private void add_game (Game game) {
-               if (games.contains (game))
-                       return;
-
-               collection.append (game);
-               games.add (game);
-       }
-
        private void preferences () {
                new PreferencesWindow ();
        }


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