[gnome-games] Replace old plugin register iteration



commit 99b5de7a5b340db0bf4594c0ea551450c0b14324
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Thu Apr 13 10:33:27 2017 +0200

    Replace old plugin register iteration
    
    Drop PluginRegister.foreach_plugin_registrar() and replace it with
    PluginRegisterIterator.
    
    This will allow to use asynchronous calls while looping through the
    plugin registrars.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=781334

 src/core/plugin-register.vala        |   23 -----------------------
 src/ui/application.vala              |    4 ++--
 src/ui/preferences-page-plugins.vala |    3 +--
 3 files changed, 3 insertions(+), 27 deletions(-)
---
diff --git a/src/core/plugin-register.vala b/src/core/plugin-register.vala
index 3a1fd6c..abba217 100644
--- a/src/core/plugin-register.vala
+++ b/src/core/plugin-register.vala
@@ -21,29 +21,6 @@ private class Games.PluginRegister : Object {
                return new PluginRegisterIterator (this);
        }
 
-       public void foreach_plugin_registrar (PluginRegistrarFunc func) {
-               var directory = File.new_for_path (PLUGINS_DIR);
-               try {
-                       var enumerator = directory.enumerate_children (FileAttribute.STANDARD_NAME, 0);
-
-                       FileInfo info;
-                       while ((info = enumerator.next_file ()) != null) {
-                               var name = info.get_name ();
-                               if (name.has_suffix (".plugin")) {
-                                       var descriptor = directory.get_child (name);
-                                       var descriptor_path = descriptor.get_path ();
-
-                                       var registrar = get_plugin_registrar (descriptor_path);
-                                       func (registrar);
-                               }
-                       }
-
-               }
-               catch (Error e) {
-                       debug ("Error: %s", e.message);
-               }
-       }
-
        public PluginRegistrar get_plugin_registrar (string descriptor_filename) throws Error {
                if (plugin_registrars.contains (descriptor_filename))
                        return plugin_registrars[descriptor_filename];
diff --git a/src/ui/application.vala b/src/ui/application.vala
index 6328bf6..0dd2192 100644
--- a/src/ui/application.vala
+++ b/src/ui/application.vala
@@ -153,7 +153,7 @@ public class Games.Application : Gtk.Application {
                var mime_types = new GenericSet<string> (str_hash, str_equal);
 
                var register = PluginRegister.get_register ();
-               register.foreach_plugin_registrar ((plugin_registrar) => {
+               foreach (var plugin_registrar in register) {
                        try {
                                var plugin = plugin_registrar.get_plugin ();
                                var source = plugin.get_game_source ();
@@ -179,7 +179,7 @@ public class Games.Application : Gtk.Application {
                        catch (Error e) {
                                debug ("Error: %s", e.message);
                        }
-               });
+               }
 
                foreach (var source in sources)
                        yield source.each_game (add_game);
diff --git a/src/ui/preferences-page-plugins.vala b/src/ui/preferences-page-plugins.vala
index a4394ad..16500b8 100644
--- a/src/ui/preferences-page-plugins.vala
+++ b/src/ui/preferences-page-plugins.vala
@@ -11,9 +11,8 @@ private class Games.PreferencesPagePlugins: Gtk.Bin, PreferencesPage {
 
        construct {
                var register = PluginRegister.get_register ();
-               register.foreach_plugin_registrar ((plugin_registrar) => {
+               foreach (var plugin_registrar in register)
                        add_plugin_registrar (plugin_registrar);
-               });
        }
 
        private void add_plugin_registrar (PluginRegistrar plugin_registrar) {


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