[gnome-games/wip/exalm/rebrand: 59/124] applications: Use MIME types from platforms rather than plugins




commit 33bf8ac8482d856b37b33abcd5533b6a41ba4e99
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Tue Mar 30 00:34:12 2021 +0500

    applications: Use MIME types from platforms rather than plugins
    
    Add a flag to disable autodiscovery for MS-DOS for now.

 plugins/ms-dos/src/ms-dos-plugin.vala |  2 +-
 src/core/platform.vala                |  5 ++++-
 src/ui/application.vala               | 24 +++++++++++++-----------
 3 files changed, 18 insertions(+), 13 deletions(-)
---
diff --git a/plugins/ms-dos/src/ms-dos-plugin.vala b/plugins/ms-dos/src/ms-dos-plugin.vala
index e900ae3d..287baff4 100644
--- a/plugins/ms-dos/src/ms-dos-plugin.vala
+++ b/plugins/ms-dos/src/ms-dos-plugin.vala
@@ -9,7 +9,7 @@ private class Games.MsDosPlugin : Object, Plugin {
        private static Platform platform;
 
        static construct {
-               platform = new Platform (PLATFORM_ID, PLATFORM_NAME, { MIME_TYPE }, PLATFORM_UID_PREFIX);
+               platform = new Platform (PLATFORM_ID, PLATFORM_NAME, { MIME_TYPE }, PLATFORM_UID_PREFIX, 
false);
        }
 
        public Platform[] get_platforms () {
diff --git a/src/core/platform.vala b/src/core/platform.vala
index 94507436..a553d9f5 100644
--- a/src/core/platform.vala
+++ b/src/core/platform.vala
@@ -6,11 +6,14 @@ public class Games.Platform : Object {
        private string[] mime_types;
        private string prefix;
 
-       public Platform (string id, string name, string[] mime_types, string prefix) {
+       public bool autodiscovery { get; private set; }
+
+       public Platform (string id, string name, string[] mime_types, string prefix, bool autodiscovery = 
true) {
                this.id = id;
                this.name = name;
                this.mime_types = mime_types;
                this.prefix = prefix;
+               this.autodiscovery = autodiscovery;
        }
 
        public string get_id () {
diff --git a/src/ui/application.vala b/src/ui/application.vala
index 93a95d48..1651d817 100644
--- a/src/ui/application.vala
+++ b/src/ui/application.vala
@@ -476,19 +476,21 @@ public class Games.Application : Gtk.Application {
                        try {
                                var plugin = plugin_registrar.get_plugin ();
 
-                               if (tracker_uri_source != null)
-                                       foreach (var mime_type in plugin.get_mime_types ()) {
-                                               if (mime_types.contains (mime_type))
-                                                       continue;
-
-                                               mime_types.add (mime_type);
-                                               var query = new MimeTypeTrackerUriQuery (mime_type);
-                                               tracker_uri_source.add_query (query);
-                                       }
-
-                               foreach (var platform in plugin.get_platforms ())
+                               foreach (var platform in plugin.get_platforms ()) {
                                        platform_register.add_platform (platform);
 
+                                       if (platform.autodiscovery && tracker_uri_source != null) {
+                                               foreach (var mime_type in platform.get_mime_types ()) {
+                                                       if (mime_types.contains (mime_type))
+                                                               continue;
+
+                                                       mime_types.add (mime_type);
+                                                       var query = new MimeTypeTrackerUriQuery (mime_type);
+                                                       tracker_uri_source.add_query (query);
+                                               }
+                                       }
+                               }
+
                                foreach (var factory in plugin.get_uri_game_factories ())
                                        game_collection.add_factory (factory);
                        }


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