[libgames-support] scores: Allow creating a DirectoryImporter with no CategoryConvertFunc
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgames-support] scores: Allow creating a DirectoryImporter with no CategoryConvertFunc
- Date: Sun, 14 Feb 2016 03:15:30 +0000 (UTC)
commit 3808d56f6ffb4e26f4b06d259fd4ff4acd66175d
Author: Michael Catanzaro <mcatanzaro igalia com>
Date: Sat Feb 13 21:13:24 2016 -0600
scores: Allow creating a DirectoryImporter with no CategoryConvertFunc
Turns out, most games will not want to rename their categories... this
API was too Nibbles-specific.
games/scores/directory-importer.vala | 10 ++++++++--
tests/test-scores.vala | 2 +-
2 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/games/scores/directory-importer.vala b/games/scores/directory-importer.vala
index 68a5100..c4450eb 100644
--- a/games/scores/directory-importer.vala
+++ b/games/scores/directory-importer.vala
@@ -36,9 +36,15 @@ public class DirectoryImporter : Importer
* directory, and some of those files might not be valid categories.
*/
public delegate string? CategoryConvertFunc (string old_key);
- private CategoryConvertFunc category_convert;
+ private CategoryConvertFunc? category_convert;
- public DirectoryImporter (CategoryConvertFunc category_convert)
+ public DirectoryImporter ()
+ {
+ /* Default converter for games that don't require category migration. */
+ this.category_convert = ((old_key) => { return old_key; });
+ }
+
+ public DirectoryImporter.with_convert_func (CategoryConvertFunc? category_convert)
{
this.category_convert = category_convert;
}
diff --git a/tests/test-scores.vala b/tests/test-scores.vala
index 321c1a1..17ce65f 100644
--- a/tests/test-scores.vala
+++ b/tests/test-scores.vala
@@ -185,7 +185,7 @@ private void test_import_from_score_directory ()
return category;
},
Games.Scores.Style.PLAIN_DESCENDING,
- new Games.Scores.DirectoryImporter ((old_key) => {
+ new Games.Scores.DirectoryImporter.with_convert_func ((old_key) => {
assert (old_key == "old-cat");
return "new-cat";
}));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]