[gnome-games] ui: Add games when found by the GenericUriGameSource
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] ui: Add games when found by the GenericUriGameSource
- Date: Fri, 5 May 2017 20:18:53 +0000 (UTC)
commit 05c3ff687e963cc104d8cab82d1027264cd478a4
Author: Adrien Plazas <kekun plazas laposte net>
Date: Fri May 5 20:50:40 2017 +0200
ui: Add games when found by the GenericUriGameSource
Connect to the GenericUriGameSource.game_added() signal to add games to
the collection directly when they are found by the generic URI game
source.
https://bugzilla.gnome.org/show_bug.cgi?id=781334
src/ui/application.vala | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/src/ui/application.vala b/src/ui/application.vala
index a9e47b4..d4e9263 100644
--- a/src/ui/application.vala
+++ b/src/ui/application.vala
@@ -4,6 +4,7 @@ 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;
@@ -140,6 +141,7 @@ public class Games.Application : Gtk.Application {
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);
@@ -173,6 +175,7 @@ public class Games.Application : Gtk.Application {
}
uri_game_source = new GenericUriGameSource ();
+ uri_game_source.game_added.connect ((game) => add_game (game));
if (tracker_uri_source != null)
uri_game_source.add_source (tracker_uri_source);
@@ -238,7 +241,11 @@ public class Games.Application : Gtk.Application {
}
private void add_game (Game game) {
+ if (games.contains (game))
+ return;
+
collection.append (game);
+ games.add (game);
}
private void preferences () {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]