[gnome-games/wip/aplazas/781334-refactor-game-sources: 1/5] libretro: Add LibretroUriIterator
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/aplazas/781334-refactor-game-sources: 1/5] libretro: Add LibretroUriIterator
- Date: Sun, 7 May 2017 10:26:54 +0000 (UTC)
commit 2956b2c815460136b687e457ca0f14518283518f
Author: Adrien Plazas <kekun plazas laposte net>
Date: Sun May 7 12:14:09 2017 +0200
libretro: Add LibretroUriIterator
This will be used to iterate through the available Libretro games.
plugins/libretro/src/Makefile.am | 1 +
plugins/libretro/src/libretro-uri-iterator.vala | 40 +++++++++++++++++++++++
2 files changed, 41 insertions(+), 0 deletions(-)
---
diff --git a/plugins/libretro/src/Makefile.am b/plugins/libretro/src/Makefile.am
index a5dbff0..89e8611 100644
--- a/plugins/libretro/src/Makefile.am
+++ b/plugins/libretro/src/Makefile.am
@@ -11,6 +11,7 @@ libgames_libretro_plugin_la_SOURCES = \
libretro-plugin.vala \
libretro-title.vala \
libretro-uid.vala \
+ libretro-uri-iterator.vala \
$(NULL)
libgames_libretro_plugin_la_VALAFLAGS = \
diff --git a/plugins/libretro/src/libretro-uri-iterator.vala b/plugins/libretro/src/libretro-uri-iterator.vala
new file mode 100644
index 0000000..d3fd113
--- /dev/null
+++ b/plugins/libretro/src/libretro-uri-iterator.vala
@@ -0,0 +1,40 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+public class Games.LibretroUriIterator : Object, UriIterator {
+ private Retro.ModuleIterator iterator;
+ private Uri? uri;
+
+ construct {
+ var modules = new Retro.ModuleQuery (true);
+ iterator = modules.iterator ();
+ uri = null;
+ }
+
+ public new Uri? get () {
+ return uri;
+ }
+
+ public bool next () {
+ while (iterator.next ()) {
+ var core_descriptor = iterator.get ();
+ try {
+ if (!core_descriptor.get_is_game ())
+ continue;
+ }
+ catch (Error e) {
+ debug (e.message);
+
+ continue;
+ }
+
+ var string_uri = core_descriptor.get_uri ();
+ uri = new Uri (@"libretro+$string_uri");
+
+ return true;
+ }
+
+ uri = null;
+
+ return false;
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]