[retro-gtk] core-descriptor: Add methods for standalone cores



commit 398d7b109223669973d6be0ce0ec120366535155
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Sun Feb 19 20:44:37 2017 +0100

    core-descriptor: Add methods for standalone cores
    
    Add several methods useful to handle standalone Libretro cores.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=777371

 retro-gtk/retro-core-descriptor.vala |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/retro-gtk/retro-core-descriptor.vala b/retro-gtk/retro-core-descriptor.vala
index 7849a17..b971276 100644
--- a/retro-gtk/retro-core-descriptor.vala
+++ b/retro-gtk/retro-core-descriptor.vala
@@ -18,6 +18,7 @@ public class Retro.CoreDescriptor : Object {
 
        private const string TYPE_KEY = "Type";
        private const string NAME_KEY = "Name";
+       private const string ICON_KEY = "Icon";
        private const string MODULE_KEY = "Module";
        private const string LIBRETRO_VERSION_KEY = "LibretroVersion";
 
@@ -29,6 +30,7 @@ public class Retro.CoreDescriptor : Object {
        private const string FIRMWARE_SHA512_KEY = "SHA-512";
        private const string FIRMWARE_MANDATORY_KEY = "Mandatory";
 
+       private const string TYPE_GAME = "Game";
        private const string TYPE_EMULATOR = "Emulator";
 
        private string filename;
@@ -49,10 +51,32 @@ public class Retro.CoreDescriptor : Object {
                }
        }
 
+       public bool has_icon () {
+               return key_file.has_key (LIBRETRO_GROUP, ICON_KEY);
+       }
+
+       public string get_id () {
+               return Path.get_basename (filename);
+       }
+
+       public bool get_is_game () throws KeyFileError {
+               return key_file.get_string (LIBRETRO_GROUP, TYPE_KEY) == TYPE_GAME;
+       }
+
        public bool get_is_emulator () throws KeyFileError {
                return key_file.get_string (LIBRETRO_GROUP, TYPE_KEY) == TYPE_EMULATOR;
        }
 
+       public string get_name () throws KeyFileError {
+               return key_file.get_string (LIBRETRO_GROUP, NAME_KEY);
+       }
+
+       public GLib.Icon get_icon () throws KeyFileError {
+               var icon_name = key_file.get_string (LIBRETRO_GROUP, ICON_KEY);
+
+               return new ThemedIcon (icon_name);
+       }
+
        public string get_module () throws KeyFileError {
                return key_file.get_string (LIBRETRO_GROUP, MODULE_KEY);
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]