[gnome-games] steam: Add SteamIcon
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] steam: Add SteamIcon
- Date: Wed, 11 May 2016 23:01:44 +0000 (UTC)
commit 69ed1cf9035cc2754b82768ee28fdeda2d25a32b
Author: Adrien Plazas <kekun plazas laposte net>
Date: Wed May 11 23:33:13 2016 +0200
steam: Add SteamIcon
This will be used in subsequent commits to represent Steam games icons.
plugins/steam/src/Makefile.am | 1 +
plugins/steam/src/steam-icon.vala | 43 +++++++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 0 deletions(-)
---
diff --git a/plugins/steam/src/Makefile.am b/plugins/steam/src/Makefile.am
index e081305..3f21aff 100644
--- a/plugins/steam/src/Makefile.am
+++ b/plugins/steam/src/Makefile.am
@@ -8,6 +8,7 @@ libgames_steam_plugin_la_DEPENDENCIES = \
libgames_steam_plugin_la_SOURCES = \
steam-game.vala \
steam-game-source.vala \
+ steam-icon.vala \
steam-plugin.vala \
steam-registry.vala \
steam-runner.vala \
diff --git a/plugins/steam/src/steam-icon.vala b/plugins/steam/src/steam-icon.vala
new file mode 100644
index 0000000..479d26e
--- /dev/null
+++ b/plugins/steam/src/steam-icon.vala
@@ -0,0 +1,43 @@
+// This file is part of GNOME Games. License: GPLv3
+
+private class Games.SteamIcon : Object, Icon {
+ private static GLib.Icon? steam_icon;
+
+ private string game_id;
+ private GLib.Icon? icon;
+ private bool searched;
+
+ static construct {
+ try {
+ steam_icon = GLib.Icon.new_for_string ("steam");
+ }
+ catch (Error e) {
+ warning ("%s\n", e.message);
+ }
+ }
+
+ public SteamIcon (string game_id) {
+ this.game_id = game_id;
+
+ searched = false;
+ }
+
+ public GLib.Icon? get_icon () {
+ if (searched)
+ return icon ?? steam_icon;
+
+ searched = true;
+
+ try {
+ var icon_name = "steam_icon_" + game_id;
+ var theme = Gtk.IconTheme.get_default ();
+ if (theme.has_icon (icon_name))
+ icon = GLib.Icon.new_for_string (icon_name);
+ }
+ catch (Error e) {
+ warning ("%s\n", e.message);
+ }
+
+ return icon ?? steam_icon;
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]