[gnome-games/wip/exalm/platform-preferences: 8/17] plugins: Register platforms



commit 7b0687c1d46fc692fb41bcb42314a6896c5b539b
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Tue Aug 7 20:54:02 2018 +0500

    plugins: Register platforms
    
    Also use RetroPlatform where appropriate.

 plugins/desktop/src/desktop-plugin.vala               |  4 ++++
 plugins/dreamcast/src/dreamcast-plugin.vala           |  8 ++++++--
 plugins/game-cube/src/game-cube-plugin.vala           |  8 ++++++--
 plugins/libretro/src/libretro-plugin.vala             |  4 ++++
 plugins/love/src/love-plugin.vala                     |  4 ++++
 plugins/mame/src/mame-game-uri-adapter.vala           |  4 ++--
 plugins/mame/src/mame-plugin.vala                     | 16 +++++++++++-----
 plugins/ms-dos/src/ms-dos-plugin.vala                 |  8 ++++++--
 plugins/nintendo-ds/src/nintendo-ds-plugin.vala       |  8 ++++++--
 plugins/playstation/src/playstation-game-factory.vala |  4 ++--
 plugins/playstation/src/playstation-plugin.vala       | 14 ++++++++++----
 plugins/sega-cd/src/sega-cd-plugin.vala               | 16 +++++++++++-----
 plugins/sega-saturn/src/sega-saturn-plugin.vala       |  9 +++++++--
 plugins/steam/src/steam-plugin.vala                   |  4 ++++
 plugins/turbografx-cd/src/turbografx-cd-plugin.vala   |  9 +++++++--
 plugins/virtual-boy/src/virtual-boy-plugin.vala       |  8 ++++++--
 plugins/wii/src/wii-plugin.vala                       |  8 ++++++--
 src/core/plugin.vala                                  |  4 ++++
 src/ui/application.vala                               |  3 +++
 19 files changed, 109 insertions(+), 34 deletions(-)
---
diff --git a/plugins/desktop/src/desktop-plugin.vala b/plugins/desktop/src/desktop-plugin.vala
index 62d51582..7cfc27ad 100644
--- a/plugins/desktop/src/desktop-plugin.vala
+++ b/plugins/desktop/src/desktop-plugin.vala
@@ -11,6 +11,10 @@ private class Games.DesktopPlugin : Object, Plugin {
                platform = new GenericPlatform (PLATFORM_ID, PLATFORM_NAME);
        }
 
+       public Platform[] get_platforms () {
+               return { platform };
+       }
+
        public string[] get_mime_types () {
                return { MIME_TYPE };
        }
diff --git a/plugins/dreamcast/src/dreamcast-plugin.vala b/plugins/dreamcast/src/dreamcast-plugin.vala
index cf20a234..ad84d3f4 100644
--- a/plugins/dreamcast/src/dreamcast-plugin.vala
+++ b/plugins/dreamcast/src/dreamcast-plugin.vala
@@ -5,10 +5,14 @@ private class Games.DreamcastPlugin : Object, Plugin {
        private const string PLATFORM_ID = "Dreamcast";
        private const string PLATFORM_NAME = _("Dreamcast");
 
-       private static Platform platform;
+       private static RetroPlatform platform;
 
        static construct {
-               platform = new GenericPlatform (PLATFORM_ID, PLATFORM_NAME);
+               platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, { MIME_TYPE });
+       }
+
+       public Platform[] get_platforms () {
+               return { platform };
        }
 
        public string[] get_mime_types () {
diff --git a/plugins/game-cube/src/game-cube-plugin.vala b/plugins/game-cube/src/game-cube-plugin.vala
index b05cb103..62fbe0a4 100644
--- a/plugins/game-cube/src/game-cube-plugin.vala
+++ b/plugins/game-cube/src/game-cube-plugin.vala
@@ -5,10 +5,14 @@ private class Games.GameCubePlugin : Object, Plugin {
        private const string PLATFORM_ID = "GameCube";
        private const string PLATFORM_NAME = _("Nintendo GameCube");
 
-       private static Platform platform;
+       private static RetroPlatform platform;
 
        static construct {
-               platform = new GenericPlatform (PLATFORM_ID, PLATFORM_NAME);
+               platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, { MIME_TYPE });
+       }
+
+       public Platform[] get_platforms () {
+               return { platform };
        }
 
        public string[] get_mime_types () {
diff --git a/plugins/libretro/src/libretro-plugin.vala b/plugins/libretro/src/libretro-plugin.vala
index 0ba4c557..75ec64b9 100644
--- a/plugins/libretro/src/libretro-plugin.vala
+++ b/plugins/libretro/src/libretro-plugin.vala
@@ -11,6 +11,10 @@ private class Games.LibretroPlugin : Object, Plugin {
                platform = new GenericPlatform (PLATFORM_ID, PLATFORM_NAME);
        }
 
+       public Platform[] get_platforms () {
+               return { platform };
+       }
+
        public UriSource[] get_uri_sources () {
                var source = new LibretroUriSource ();
 
diff --git a/plugins/love/src/love-plugin.vala b/plugins/love/src/love-plugin.vala
index dbb1253f..add7c237 100644
--- a/plugins/love/src/love-plugin.vala
+++ b/plugins/love/src/love-plugin.vala
@@ -12,6 +12,10 @@ private class Games.LovePlugin : Object, Plugin {
                platform = new GenericPlatform (PLATFORM_ID, PLATFORM_NAME);
        }
 
+       public Platform[] get_platforms () {
+               return { platform };
+       }
+
        public string[] get_mime_types () {
                return { MIME_TYPE };
        }
diff --git a/plugins/mame/src/mame-game-uri-adapter.vala b/plugins/mame/src/mame-game-uri-adapter.vala
index b03e0223..d1bab433 100644
--- a/plugins/mame/src/mame-game-uri-adapter.vala
+++ b/plugins/mame/src/mame-game-uri-adapter.vala
@@ -4,9 +4,9 @@ private class Games.MameGameUriAdapter : GameUriAdapter, Object {
        private const string SEARCHED_MIME_TYPE = "application/zip";
        private const string SPECIFIC_MIME_TYPE = "application/x-mame-rom";
 
-       private Platform platform;
+       private RetroPlatform platform;
 
-       public MameGameUriAdapter (Platform platform) {
+       public MameGameUriAdapter (RetroPlatform platform) {
                this.platform = platform;
        }
 
diff --git a/plugins/mame/src/mame-plugin.vala b/plugins/mame/src/mame-plugin.vala
index 61271639..2e4e77a9 100644
--- a/plugins/mame/src/mame-plugin.vala
+++ b/plugins/mame/src/mame-plugin.vala
@@ -1,24 +1,30 @@
 // This file is part of GNOME Games. License: GPL-3.0+.
 
 private class Games.MamePlugin : Object, Plugin {
-       private const string MIME_TYPE = "application/zip";
+       private const string SEARCHED_MIME_TYPE = "application/zip";
+       private const string SPECIFIC_MIME_TYPE = "application/x-mame-rom";
        private const string PLATFORM_ID = "MAME";
        private const string PLATFORM_NAME = _("Arcade");
 
-       private static Platform platform;
+       private static RetroPlatform platform;
 
        static construct {
-               platform = new GenericPlatform (PLATFORM_ID, PLATFORM_NAME);
+               string[] mime_types = { SEARCHED_MIME_TYPE, SPECIFIC_MIME_TYPE };
+               platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, mime_types);
+       }
+
+       public Platform[] get_platforms () {
+               return { platform };
        }
 
        public string[] get_mime_types () {
-               return { MIME_TYPE };
+               return { SEARCHED_MIME_TYPE };
        }
 
        public UriGameFactory[] get_uri_game_factories () {
                var game_uri_adapter = new MameGameUriAdapter (platform);
                var factory = new GenericUriGameFactory (game_uri_adapter);
-               factory.add_mime_type (MIME_TYPE);
+               factory.add_mime_type (SEARCHED_MIME_TYPE);
 
                return { factory };
        }
diff --git a/plugins/ms-dos/src/ms-dos-plugin.vala b/plugins/ms-dos/src/ms-dos-plugin.vala
index 31789f56..71bcab8d 100644
--- a/plugins/ms-dos/src/ms-dos-plugin.vala
+++ b/plugins/ms-dos/src/ms-dos-plugin.vala
@@ -6,10 +6,14 @@ private class Games.MsDosPlugin : Object, Plugin {
        private const string PLATFORM_ID = "MSDOS";
        private const string PLATFORM_NAME = _("MS-DOS");
 
-       private static Platform platform;
+       private static RetroPlatform platform;
 
        static construct {
-               platform = new GenericPlatform (PLATFORM_ID, PLATFORM_NAME);
+               platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, { MIME_TYPE });
+       }
+
+       public Platform[] get_platforms () {
+               return { platform };
        }
 
        public UriGameFactory[] get_uri_game_factories () {
diff --git a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
index ec8d2519..4eb9cf33 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
@@ -6,10 +6,14 @@ private class Games.NintendoDsPlugin : Object, Plugin {
        private const string PLATFORM_ID = "NintendoDS";
        private const string PLATFORM_NAME = _("Nintendo DS");
 
-       private static Platform platform;
+       private static RetroPlatform platform;
 
        static construct {
-               platform = new GenericPlatform (PLATFORM_ID, PLATFORM_NAME);
+               platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, { MIME_TYPE });
+       }
+
+       public Platform[] get_platforms () {
+               return { platform };
        }
 
        public string[] get_mime_types () {
diff --git a/plugins/playstation/src/playstation-game-factory.vala 
b/plugins/playstation/src/playstation-game-factory.vala
index 7df8018d..49fc7df5 100644
--- a/plugins/playstation/src/playstation-game-factory.vala
+++ b/plugins/playstation/src/playstation-game-factory.vala
@@ -12,9 +12,9 @@ public class Games.PlayStationGameFactory : Object, UriGameFactory {
        private HashTable<Uri, Game> game_for_uri;
        private HashTable<string, Game> game_for_disc_set_id;
        private GenericSet<Game> games;
-       private Platform platform;
+       private RetroPlatform platform;
 
-       public PlayStationGameFactory (Platform platform) {
+       public PlayStationGameFactory (RetroPlatform platform) {
                media_for_disc_id = new HashTable<string, Media> (str_hash, str_equal);
                game_for_uri = new HashTable<Uri, Game> (Uri.hash, Uri.equal);
                game_for_disc_set_id = new HashTable<string, Game> (GLib.str_hash, GLib.str_equal);
diff --git a/plugins/playstation/src/playstation-plugin.vala b/plugins/playstation/src/playstation-plugin.vala
index b3f37d6a..967b4bef 100644
--- a/plugins/playstation/src/playstation-plugin.vala
+++ b/plugins/playstation/src/playstation-plugin.vala
@@ -1,18 +1,24 @@
 // This file is part of GNOME Games. License: GPL-3.0+.
 
 private class Games.PlayStation : Object, Plugin {
-       private const string MIME_TYPE = "application/x-cue";
+       private const string CUE_MIME_TYPE = "application/x-cue";
+       private const string PHONY_MIME_TYPE = "application/x-playstation-rom";
        private const string PLATFORM_ID = "PlayStation";
        private const string PLATFORM_NAME = _("PlayStation");
 
-       private static Platform platform;
+       private static RetroPlatform platform;
 
        static construct {
-               platform = new GenericPlatform (PLATFORM_ID, PLATFORM_NAME);
+               string[] mime_types = { CUE_MIME_TYPE, PHONY_MIME_TYPE };
+               platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, mime_types);
+       }
+
+       public Platform[] get_platforms () {
+               return { platform };
        }
 
        public string[] get_mime_types () {
-               return { MIME_TYPE };
+               return { CUE_MIME_TYPE };
        }
 
        public UriGameFactory[] get_uri_game_factories () {
diff --git a/plugins/sega-cd/src/sega-cd-plugin.vala b/plugins/sega-cd/src/sega-cd-plugin.vala
index 8201b939..497e1429 100644
--- a/plugins/sega-cd/src/sega-cd-plugin.vala
+++ b/plugins/sega-cd/src/sega-cd-plugin.vala
@@ -13,12 +13,18 @@ private class Games.SegaCDPlugin : Object, Plugin {
        /* translators: known as "Mega-CD 32X" in most of the world */
        private const string SEGA_CD_32X_PLATFORM_NAME = _("Sega CD 32X");
 
-       private static Platform platform_sega_cd;
-       private static Platform platform_sega_cd_32x;
+       private static RetroPlatform platform_sega_cd;
+       private static RetroPlatform platform_sega_cd_32x;
 
        static construct {
-               platform_sega_cd = new GenericPlatform (SEGA_CD_PLATFORM_ID, SEGA_CD_PLATFORM_NAME);
-               platform_sega_cd_32x = new GenericPlatform (SEGA_CD_32X_PLATFORM_ID, 
SEGA_CD_32X_PLATFORM_NAME);
+               string[] mime_types = { CUE_MIME_TYPE, SEGA_CD_MIME_TYPE };
+               string[] mime_types_32x = { CUE_MIME_TYPE, SEGA_CD_MIME_TYPE, 32X_MIME_TYPE };
+               platform_sega_cd = new RetroPlatform (SEGA_CD_PLATFORM_ID, SEGA_CD_PLATFORM_NAME, mime_types);
+               platform_sega_cd_32x = new RetroPlatform (SEGA_CD_32X_PLATFORM_ID, SEGA_CD_32X_PLATFORM_NAME, 
mime_types_32x);
+       }
+
+       public Platform[] get_platforms () {
+               return { platform_sega_cd, platform_sega_cd_32x };
        }
 
        public string[] get_mime_types () {
@@ -58,7 +64,7 @@ private class Games.SegaCDPlugin : Object, Plugin {
                header.check_validity ();
 
                string[] mime_types;
-               Platform platform;
+               RetroPlatform platform;
                if (header.is_sega_cd ()) {
                        mime_types = { CUE_MIME_TYPE, SEGA_CD_MIME_TYPE };
                        platform = platform_sega_cd;
diff --git a/plugins/sega-saturn/src/sega-saturn-plugin.vala b/plugins/sega-saturn/src/sega-saturn-plugin.vala
index 80b4ecd5..f5c705d9 100644
--- a/plugins/sega-saturn/src/sega-saturn-plugin.vala
+++ b/plugins/sega-saturn/src/sega-saturn-plugin.vala
@@ -6,10 +6,15 @@ private class Games.SegaSaturnPlugin : Object, Plugin {
        private const string PLATFORM_ID = "SegaSaturn";
        private const string PLATFORM_NAME = _("Sega Saturn");
 
-       private static Platform platform;
+       private static RetroPlatform platform;
 
        static construct {
-               platform = new GenericPlatform (PLATFORM_ID, PLATFORM_NAME);
+               string[] mime_types = { CUE_MIME_TYPE, SEGA_SATURN_MIME_TYPE };
+               platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, mime_types);
+       }
+
+       public Platform[] get_platforms () {
+               return { platform };
        }
 
        public string[] get_mime_types () {
diff --git a/plugins/steam/src/steam-plugin.vala b/plugins/steam/src/steam-plugin.vala
index 6f858e8d..0e60dd90 100644
--- a/plugins/steam/src/steam-plugin.vala
+++ b/plugins/steam/src/steam-plugin.vala
@@ -22,6 +22,10 @@ private class Games.SteamPlugin : Object, Plugin {
                icon_theme.append_search_path (home + STEAM_FLATPAK_DIR + "/data/icons");
        }
 
+       public Platform[] get_platforms () {
+               return { platform };
+       }
+
        public UriSource[] get_uri_sources () {
                // Steam's installation path can be found in its registry.
                var home = Environment.get_home_dir ();
diff --git a/plugins/turbografx-cd/src/turbografx-cd-plugin.vala 
b/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
index fc1f72f4..1f81173a 100644
--- a/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
+++ b/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
@@ -9,10 +9,15 @@ private class Games.TurboGrafxCDPlugin : Object, Plugin {
        /* translators: known as "CD-ROMĀ²" in eastern Asia and France */
        private const string PLATFORM_NAME = _("TurboGrafx-CD");
 
-       private static Platform platform;
+       private static RetroPlatform platform;
 
        static construct {
-               platform = new GenericPlatform (PLATFORM_ID, PLATFORM_NAME);
+               string[] mime_types = { CUE_MIME_TYPE, PHONY_MIME_TYPE };
+               platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, mime_types);
+       }
+
+       public Platform[] get_platforms () {
+               return { platform };
        }
 
        public string[] get_mime_types () {
diff --git a/plugins/virtual-boy/src/virtual-boy-plugin.vala b/plugins/virtual-boy/src/virtual-boy-plugin.vala
index c61c5bb5..55f26cd7 100644
--- a/plugins/virtual-boy/src/virtual-boy-plugin.vala
+++ b/plugins/virtual-boy/src/virtual-boy-plugin.vala
@@ -6,10 +6,14 @@ private class Games.VirtualBoyPlugin : Object, Plugin {
        private const string PLATFORM_ID = "VirtualBoy";
        private const string PLATFORM_NAME = _("Virtual Boy");
 
-       private static Platform platform;
+       private static RetroPlatform platform;
 
        static construct {
-               platform = new GenericPlatform (PLATFORM_ID, PLATFORM_NAME);
+               platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, { MIME_TYPE });
+       }
+
+       public Platform[] get_platforms () {
+               return { platform };
        }
 
        public string[] get_mime_types () {
diff --git a/plugins/wii/src/wii-plugin.vala b/plugins/wii/src/wii-plugin.vala
index 519d6552..034a5882 100644
--- a/plugins/wii/src/wii-plugin.vala
+++ b/plugins/wii/src/wii-plugin.vala
@@ -5,10 +5,14 @@ private class Games.WiiPlugin : Object, Plugin {
        private const string PLATFORM_ID = "Wii";
        private const string PLATFORM_NAME = _("Wii");
 
-       private static Platform platform;
+       private static RetroPlatform platform;
 
        static construct {
-               platform = new GenericPlatform (PLATFORM_ID, PLATFORM_NAME);
+               platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, { MIME_TYPE });
+       }
+
+       public Platform[] get_platforms () {
+               return { platform };
        }
 
        public string[] get_mime_types () {
diff --git a/src/core/plugin.vala b/src/core/plugin.vala
index 74d8a3eb..98407724 100644
--- a/src/core/plugin.vala
+++ b/src/core/plugin.vala
@@ -5,6 +5,10 @@ public interface Games.Plugin : Object {
                return {};
        }
 
+       public virtual Platform[] get_platforms () {
+               return {};
+       }
+
        public virtual UriSource[] get_uri_sources () {
                return {};
        }
diff --git a/src/ui/application.vala b/src/ui/application.vala
index a5e08251..86fff343 100644
--- a/src/ui/application.vala
+++ b/src/ui/application.vala
@@ -316,6 +316,9 @@ public class Games.Application : Gtk.Application {
                                                tracker_uri_source.add_query (query);
                                        }
 
+                               foreach (var platform in plugin.get_platforms ())
+                                       platform_register.add_platform (platform);
+
                                foreach (var uri_source in plugin.get_uri_sources ())
                                        game_collection.add_source (uri_source);
 


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