[gnome-games/wip/aplazas/run-uri: 2/21] Replace old plugin register iteration



commit 9d5c6bc7a595ac463da41b36a87f22ee5a375e5c
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.

 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 ea4d6a6..85db677 100644
--- a/src/ui/application.vala
+++ b/src/ui/application.vala
@@ -137,7 +137,7 @@ public class Games.Application : Gtk.Application {
                GameSource[] sources = {};
 
                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 ();
@@ -147,7 +147,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]