[gnome-games] utils: Add GenericGame
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] utils: Add GenericGame
- Date: Fri, 25 Mar 2016 06:44:52 +0000 (UTC)
commit e6af6a130494847a6c782688c9aa9c6e5bf8cefa
Author: Adrien Plazas <kekun plazas laposte net>
Date: Tue Mar 22 22:21:39 2016 +0100
utils: Add GenericGame
This will be used in the next commits to replace simple game types which
shouldn't need a custom class and make the code simpler.
Fixes #283
src/Makefile.am | 1 +
src/utils/generic-game.vala | 43 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 795341c..792a368 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -80,6 +80,7 @@ gnome_games_SOURCES = \
\
utils/filename-title.vala \
utils/fingerprint.vala \
+ utils/generic-game.vala \
utils/grep.vala \
\
config.vala \
diff --git a/src/utils/generic-game.vala b/src/utils/generic-game.vala
new file mode 100644
index 0000000..7d0eeae
--- /dev/null
+++ b/src/utils/generic-game.vala
@@ -0,0 +1,43 @@
+// This file is part of GNOME Games. License: GPLv3
+
+public class Games.GenericGame : Object, Game {
+ private string _name;
+ public string name {
+ get {
+ try {
+ _name = game_title.get_title ();
+ }
+ catch (Error e) {
+ warning (e.message);
+ }
+
+ if (_name == null)
+ _name = "";
+
+ return _name;
+ }
+ }
+
+ private Icon? _icon;
+ public Icon? icon {
+ get {
+ _icon = game_cover.get_cover ();
+
+ return _icon;
+ }
+ }
+
+ private Title game_title;
+ private Cover game_cover;
+ private Runner game_runner;
+
+ public GenericGame (Title title, Cover cover, Runner runner) {
+ game_title = title;
+ game_cover = cover;
+ game_runner = runner;
+ }
+
+ public Runner get_runner () throws Error {
+ return game_runner;
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]