[gnome-games] ui: Allow GameCollection to send game-added signal
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] ui: Allow GameCollection to send game-added signal
- Date: Sun, 26 Aug 2018 19:27:29 +0000 (UTC)
commit 15a30eaa5869ed7a0a646303c6456155dbbfb644
Author: theawless <theawless gmail com>
Date: Sun Aug 26 07:13:20 2018 +0530
ui: Allow GameCollection to send game-added signal
In a subsequent commit, this will be used to wrap the Game object into
DatabaseGame object.
src/core/game-collection.vala | 11 +++--------
src/ui/application.vala | 6 +++++-
2 files changed, 8 insertions(+), 9 deletions(-)
---
diff --git a/src/core/game-collection.vala b/src/core/game-collection.vala
index 00d64478..ce954868 100644
--- a/src/core/game-collection.vala
+++ b/src/core/game-collection.vala
@@ -1,9 +1,9 @@
// This file is part of GNOME Games. License: GPL-3.0+.
private class Games.GameCollection : Object {
- private GenericSet<Game> games;
- private ListStore list_store;
+ public signal void game_added (Game game);
+ private GenericSet<Game> games;
private UriSource[] sources;
private UriGameFactory[] factories;
@@ -12,15 +12,10 @@ private class Games.GameCollection : Object {
construct {
games = new GenericSet<Game> (Game.hash, Game.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;
}
@@ -122,7 +117,7 @@ private class Games.GameCollection : Object {
if (games.contains (game))
return;
- list_store.append (game);
games.add (game);
+ game_added (game);
}
}
diff --git a/src/ui/application.vala b/src/ui/application.vala
index b8c317ea..111b38ae 100644
--- a/src/ui/application.vala
+++ b/src/ui/application.vala
@@ -219,8 +219,12 @@ public class Games.Application : Gtk.Application {
Gtk.StyleContext.add_provider_for_screen (screen, provider, 600);
load_game_list.begin ();
+ ListStore list_store = new ListStore (typeof (Game));
+ game_collection.game_added.connect ((game) => {
+ list_store.append (game);
+ });
- window = new ApplicationWindow (game_collection.get_list_store ());
+ window = new ApplicationWindow (list_store);
this.add_window (window);
window.destroy.connect (() => {
quit_application ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]