[gnome-games] generic: Add GenericUriGameSource.query_game_for_uri()
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] generic: Add GenericUriGameSource.query_game_for_uri()
- Date: Fri, 5 May 2017 11:11:55 +0000 (UTC)
commit 58afbea3a1c3791eb6d7019c7228b225b54b14e3
Author: Adrien Plazas <kekun plazas laposte net>
Date: Fri May 5 11:18:03 2017 +0200
generic: Add GenericUriGameSource.query_game_for_uri()
This will allow to lookup a game for a given URI in a generic URI game
source.
This will be used int he next commits to run games directly from URIs
passed via the command line.
https://bugzilla.gnome.org/show_bug.cgi?id=780320
src/generic/generic-uri-game-source.vala | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/src/generic/generic-uri-game-source.vala b/src/generic/generic-uri-game-source.vala
index b68b9de..ffcc3b1 100644
--- a/src/generic/generic-uri-game-source.vala
+++ b/src/generic/generic-uri-game-source.vala
@@ -29,6 +29,20 @@ public class Games.GenericUriGameSource : Object, GameSource {
yield factory.add_uri (uri);
}
+ public async Game? query_game_for_uri (string uri) {
+ Game[] games = {};
+ foreach (var factory in yield get_factories_for_uri (uri)) {
+ var game = yield factory.query_game_for_uri (uri);
+ if (game != null)
+ games += game;
+ }
+
+ if (games.length != 1)
+ return null;
+
+ return games[0];
+ }
+
public async void each_game (GameCallback callback) {
foreach (var source in sources)
foreach (var uri in source)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]