[gnome-games] core: Add GameCollection.get_list_store()
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] core: Add GameCollection.get_list_store()
- Date: Sun, 7 May 2017 14:47:34 +0000 (UTC)
commit 0dd44709939ff0a5cdd5e3345f35b3a667d36065
Author: Adrien Plazas <kekun plazas laposte net>
Date: Sun May 7 16:06:44 2017 +0200
core: Add GameCollection.get_list_store()
Also make GameCollection store games in the list store.
This will be used in the next commits to move game collection handling
out of the Application class.
https://bugzilla.gnome.org/show_bug.cgi?id=782295
src/core/game-collection.vala | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/src/core/game-collection.vala b/src/core/game-collection.vala
index deddd3f..1b8ead6 100644
--- a/src/core/game-collection.vala
+++ b/src/core/game-collection.vala
@@ -3,6 +3,9 @@
public class Games.GameCollection : Object {
public signal void game_added (Game game);
+ private GenericSet<Game> games;
+ private ListStore list_store;
+
private UriSource[] sources;
private UriGameFactory[] factories;
@@ -10,10 +13,16 @@ public class Games.GameCollection : Object {
private HashTable<string, Array<UriGameFactory>> factories_for_scheme;
construct {
+ games = new GenericSet<Game> (direct_hash, direct_equal);
+ list_store = new ListStore (typeof (Game));
factories_for_mime_type = new HashTable<string, Array<UriGameFactory>> (str_hash, str_equal);
factories_for_scheme = new HashTable<string, Array<UriGameFactory>> (str_hash, str_equal);
}
+ public ListStore get_list_store () {
+ return list_store;
+ }
+
public void add_source (UriSource source) {
sources += source;
}
@@ -34,6 +43,7 @@ public class Games.GameCollection : Object {
}
factory.game_added.connect ((game) => game_added (game));
+ factory.game_added.connect ((game) => store_game (game));
}
public async void add_uri (Uri uri) {
@@ -109,4 +119,12 @@ public class Games.GameCollection : Object {
return factories_for_mime_type[mime_type].data;
}
+
+ private void store_game (Game game) {
+ if (games.contains (game))
+ return;
+
+ list_store.append (game);
+ games.add (game);
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]