[gbrainy] Injects translation property in game for custom game dialog + some refactoring
- From: Jordi Mas <jmas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gbrainy] Injects translation property in game for custom game dialog + some refactoring
- Date: Sun, 23 Oct 2011 11:15:19 +0000 (UTC)
commit bf9c0735c4b1b50949df537c78515b0867232a27
Author: Jordi Mas <jmas softcatala org>
Date: Sun Oct 23 13:15:29 2011 +0200
Injects translation property in game for custom game dialog + some refactoring
src/Clients/Classical/Dialogs/BuilderDialog.cs | 2 +
src/Clients/Classical/Dialogs/CustomGameDialog.cs | 78 +++++++++++++--------
2 files changed, 52 insertions(+), 28 deletions(-)
---
diff --git a/src/Clients/Classical/Dialogs/BuilderDialog.cs b/src/Clients/Classical/Dialogs/BuilderDialog.cs
index 44ce288..3c0e9f7 100644
--- a/src/Clients/Classical/Dialogs/BuilderDialog.cs
+++ b/src/Clients/Classical/Dialogs/BuilderDialog.cs
@@ -25,6 +25,8 @@ namespace gbrainy.Clients.Classical.Dialogs
{
ITranslations translations;
+ protected ITranslations Translations { get {return translations; }}
+
public BuilderDialog (ITranslations translations, string resourceName, string dialogName) :
this ((System.Reflection.Assembly) null, resourceName, dialogName)
{
diff --git a/src/Clients/Classical/Dialogs/CustomGameDialog.cs b/src/Clients/Classical/Dialogs/CustomGameDialog.cs
index 3449a58..7f4756e 100644
--- a/src/Clients/Classical/Dialogs/CustomGameDialog.cs
+++ b/src/Clients/Classical/Dialogs/CustomGameDialog.cs
@@ -59,6 +59,48 @@ namespace gbrainy.Clients.Classical.Dialogs
drawing_area.Visible = true;
treeview.HeadersClickable = true;
+ CreateColumnName ();
+ CreateColumnType ();
+ CreateColumnSelected ();
+ LoadGames ();
+
+ treeview.Model = games_store;
+ game = (Game) Activator.CreateInstance (games [0].TypeOf, true);
+ game.translations = Translations;
+ game.Variant = 0;
+ game.Begin ();
+ drawing_area.Drawable = game;
+ drawing_area.Question = game.Question;
+ treeview.ColumnsAutosize ();
+ }
+
+ void LoadGames ()
+ {
+ if (games_store != null)
+ return;
+
+ games_store = new ListStore (typeof(string), typeof (string), typeof(bool), typeof (Game), typeof (int));
+ games_store.SetSortFunc (0, new Gtk.TreeIterCompareFunc (GameSort));
+ games_store.SetSortColumnId (COL_TYPE, SortType.Ascending);
+
+ // Data
+ string type;
+ Game game;
+ for (int i = 0; i < games.Length; i++)
+ {
+ if (games [i].IsGame == false)
+ continue;
+
+ game = (Game) Activator.CreateInstance (games [i].TypeOf, true);
+ game.translations = Translations;
+ game.Variant = games [i].Variant;
+ type = GameTypesDescription.GetLocalized (Translations, game.Type);
+ games_store.AppendValues (game.Name, type, true, game, i);
+ }
+ }
+
+ void CreateColumnName ()
+ {
// Column: Game Name
TreeViewColumn name_column = new TreeViewColumn (Catalog.GetString("Game Name"),
new CellRendererText(), "text", 0);
@@ -81,6 +123,10 @@ namespace gbrainy.Clients.Classical.Dialogs
treeview.AppendColumn (name_column);
+ }
+
+ void CreateColumnType ()
+ {
// Column: Type
TreeViewColumn type_column = new TreeViewColumn (Catalog.GetString("Type"),
new CellRendererText(), "text", 1);
@@ -101,7 +147,11 @@ namespace gbrainy.Clients.Classical.Dialogs
column.SortOrder = order;
games_store.SetSortColumnId (COL_TYPE, order);
};
+ }
+
+ void CreateColumnSelected ()
+ {
// Column: Selected
CellRendererToggle toggle_cell = new CellRendererToggle();
TreeViewColumn toggle_column = new TreeViewColumn(Catalog.GetString("Selected"),
@@ -111,34 +161,6 @@ namespace gbrainy.Clients.Classical.Dialogs
toggle_column.Expand = false;
treeview.CursorChanged += OnCursorChanged;
treeview.AppendColumn (toggle_column);
-
- if (games_store == null) {
- games_store = new ListStore (typeof(string), typeof (string), typeof(bool), typeof (Game), typeof (int));
-
- games_store.SetSortFunc (0, new Gtk.TreeIterCompareFunc (GameSort));
- games_store.SetSortColumnId (COL_TYPE, SortType.Ascending);
-
- // Data
- string type;
- for (int i = 0; i < games.Length; i++)
- {
- if (games [i].IsGame == false)
- continue;
-
- game = (Game) Activator.CreateInstance (games [i].TypeOf, true);
- game.Variant = games [i].Variant;
- type = GameTypesDescription.GetLocalized (translations, game.Type);
- games_store.AppendValues (game.Name, type, true, game, i);
- }
- }
-
- treeview.Model = games_store;
- game = (Game) Activator.CreateInstance (games [0].TypeOf, true);
- game.Variant = 0;
- game.Begin ();
- drawing_area.Drawable = game;
- drawing_area.Question = game.Question;
- treeview.ColumnsAutosize ();
}
public bool SelectionDone {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]