[gnome-klotski] Make levels and scores_categories private and static
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-klotski] Make levels and scores_categories private and static
- Date: Sun, 14 Feb 2016 21:09:01 +0000 (UTC)
commit 18d2e225e53e41d133734887a1afd1cfea8aa724
Author: Michael Catanzaro <mcatanzaro igalia com>
Date: Sun Feb 14 14:56:41 2016 -0600
Make levels and scores_categories private and static
* levels is not used outside this class
* Why have a different const array per window?
Even if there is only one window... just seems like better style.
src/klotski-window.vala | 21 ++++++++++++---------
1 files changed, 12 insertions(+), 9 deletions(-)
---
diff --git a/src/klotski-window.vala b/src/klotski-window.vala
index 45246a5..f559b4c 100644
--- a/src/klotski-window.vala
+++ b/src/klotski-window.vala
@@ -65,10 +65,10 @@ public class KlotskiWindow : ApplicationWindow
private Gtk.ListStore liststore_challenge;
private Gtk.ListStore liststore_skill;
private TreeIter[] puzzles_items;
- private Gee.List<Games.Scores.Category> score_categories;
+ private static Gee.List<Games.Scores.Category> score_categories;
/* Warning: reordering these will screw up import of old scores. */
- public const LevelInfo levels[] =
+ private static const LevelInfo levels[] =
{
/* puzzle name */
{N_("Only 18 Steps"), 0,
@@ -451,6 +451,16 @@ public class KlotskiWindow : ApplicationWindow
{"start-game", start_puzzle_cb}
};
+ class construct
+ {
+ score_categories = new Gee.ArrayList<Games.Scores.Category> ();
+ for (var i = 0; i < levels.length; i++)
+ {
+ score_categories.add (new Games.Scores.Category (levels[i].name.down ().replace (" ", "-"),
+ _(levels[i].name)));
+ }
+ }
+
private Games.Scores.Category? category_request (string key)
{
var i = int.parse (key);
@@ -507,13 +517,6 @@ public class KlotskiWindow : ApplicationWindow
next_puzzle = lookup_action ("next-puzzle") as SimpleAction;
start_game = lookup_action ("start-game") as SimpleAction;
- score_categories = new Gee.ArrayList<Games.Scores.Category> ();
- for (var i = 0; i < levels.length; i++)
- {
- score_categories.add (new Games.Scores.Category (levels[i].name.down ().replace (" ", "-"),
- _(levels[i].name)));
- }
-
scores_context = new Games.Scores.Context.with_importer (
"gnome-klotski",
// Label on the scores dialog, next to dropdown */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]