[gnome-games] love: Add LoveTitle
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] love: Add LoveTitle
- Date: Thu, 12 May 2016 16:53:14 +0000 (UTC)
commit 0f26c43d43ccb8f6512d733065ab4194168ce0ba
Author: Adrien Plazas <kekun plazas laposte net>
Date: Thu May 12 18:25:07 2016 +0200
love: Add LoveTitle
This will be used in the next commit to provide LÖVE game titles to
GenericGame and hence to allow to replace LoveGame by GenericGame.
plugins/love/src/Makefile.am | 1 +
plugins/love/src/love-package.vala | 4 ++++
plugins/love/src/love-title.vala | 32 ++++++++++++++++++++++++++++++++
3 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/plugins/love/src/Makefile.am b/plugins/love/src/Makefile.am
index bc6a9fd..5fc3680 100644
--- a/plugins/love/src/Makefile.am
+++ b/plugins/love/src/Makefile.am
@@ -11,6 +11,7 @@ libgames_love_plugin_la_SOURCES = \
love-icon.vala \
love-package.vala \
love-plugin.vala \
+ love-title.vala \
$(NULL)
libgames_love_plugin_la_VALAFLAGS = \
diff --git a/plugins/love/src/love-package.vala b/plugins/love/src/love-package.vala
index 6bf2b29..8779b2d 100644
--- a/plugins/love/src/love-package.vala
+++ b/plugins/love/src/love-package.vala
@@ -30,6 +30,10 @@ private class Games.LovePackage : Object {
}
}
+ public string get_uri () {
+ return uri;
+ }
+
public string? get_config (string key) {
if (!config.contains (key))
return null;
diff --git a/plugins/love/src/love-title.vala b/plugins/love/src/love-title.vala
new file mode 100644
index 0000000..2f61f09
--- /dev/null
+++ b/plugins/love/src/love-title.vala
@@ -0,0 +1,32 @@
+// This file is part of GNOME Games. License: GPLv3
+
+private class Games.LoveTitle : Object, Title {
+ private LovePackage package;
+ private string? title;
+
+ public LoveTitle (LovePackage package) {
+ this.package = package;
+ }
+
+ public string get_title () throws Error {
+ if (title != null)
+ return title;
+
+ title = package.get_config ("title");
+ if (title != null)
+ return title;
+
+ title = package.get_config ("identity");
+ if (title != null)
+ return title;
+
+ var uri = package.get_uri ();
+ var file = File.new_for_uri (uri);
+ title = file.get_basename ();
+ title = title.split (".")[0];
+ title = title.split ("(")[0];
+ title = title.strip ();
+
+ return title;
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]