[gnome-games/wip/exalm/loading: 11/29] desktop: Add runner factory



commit 8b3833e1b57b65ce68a6621ba4fbe06354ecb614
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Tue Nov 12 01:46:49 2019 +0500

    desktop: Add runner factory

 plugins/desktop/src/desktop-plugin.vala | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
---
diff --git a/plugins/desktop/src/desktop-plugin.vala b/plugins/desktop/src/desktop-plugin.vala
index 3b741c40..0dec7f02 100644
--- a/plugins/desktop/src/desktop-plugin.vala
+++ b/plugins/desktop/src/desktop-plugin.vala
@@ -40,6 +40,13 @@ private class Games.DesktopPlugin : Object, Plugin {
                return { factory };
        }
 
+       public RunnerFactory[] get_runner_factories () {
+               var factory = new GenericRunnerFactory (create_runner);
+               factory.add_platform (platform);
+
+               return { factory };
+       }
+
        private static Game game_for_uri (Uri uri) throws Error {
                check_uri (uri);
 
@@ -63,6 +70,21 @@ private class Games.DesktopPlugin : Object, Plugin {
                return game;
        }
 
+       private static Runner? create_runner (Game game) throws Error {
+               var uri = game.get_uri ();
+               var file = uri.to_file ();
+               var path = file.get_path ();
+
+               var app_info = new DesktopAppInfo.from_filename (path);
+
+               string[] args;
+               var command = app_info.get_commandline ();
+               if (!Shell.parse_argv (command, out args))
+                       throw new CommandError.INVALID_COMMAND (_("Invalid command ā€œ%sā€."), command);
+
+               return new CommandRunner (args);
+       }
+
        private static void check_uri (Uri uri) throws Error {
                var file = uri.to_file ();
 


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