[libgnome-games-support] scores: Make importers usable with g_object_new



commit d40cd8954b0fd6abe2921618892bd4570d392d7a
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Sun Feb 4 17:08:27 2018 -0600

    scores: Make importers usable with g_object_new
    
    Language bindings might not expose our constructors, so we should make
    the importers usable via GObject-style construction. That means adding a
    new function call to set the importer's conversion function, to be
    called after creating the importer but before passing it to a
    Scores.Context.

 games/scores/directory-importer.vala    |    9 +++++++--
 games/scores/history-file-importer.vala |    5 +++++
 2 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/games/scores/directory-importer.vala b/games/scores/directory-importer.vala
index e7861d8..13b7318 100644
--- a/games/scores/directory-importer.vala
+++ b/games/scores/directory-importer.vala
@@ -41,10 +41,15 @@ public class DirectoryImporter : Importer
     public DirectoryImporter ()
     {
         /* Default converter for games that don't require category migration. */
-        this.category_convert = ((old_key) => { return old_key; });
+        set_category_convert_func ((old_key) => { return old_key; });
     }
 
-    public DirectoryImporter.with_convert_func (CategoryConvertFunc? category_convert)
+    public DirectoryImporter.with_convert_func (CategoryConvertFunc category_convert)
+    {
+        set_category_convert_func (category_convert);
+    }
+
+    public void set_category_convert_func (CategoryConvertFunc category_convert)
     {
         this.category_convert = (old_key) => { return category_convert (old_key); };
     }
diff --git a/games/scores/history-file-importer.vala b/games/scores/history-file-importer.vala
index 848dc3d..fe9af35 100644
--- a/games/scores/history-file-importer.vala
+++ b/games/scores/history-file-importer.vala
@@ -37,6 +37,11 @@ public class HistoryFileImporter : Importer
 
     public HistoryFileImporter (HistoryConvertFunc history_convert)
     {
+        set_history_convert_func (history_convert);
+    }
+
+    public void set_history_convert_func (HistoryConvertFunc history_convert)
+    {
         this.history_convert = (line, out score, out category) => {
             history_convert (line, out score, out category);
         };


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