comparison FrmMainWindow.cs @ 79:592930d28da4

Re #308: Make GTK# UI translatable * Extend new TranslatableWindowWithActions so that we can start to translate the menu items as well
author IBBoard <dev@ibboard.co.uk>
date Mon, 27 Dec 2010 20:56:31 +0000
parents e63209ab2cfa
children 3ff8e10de45a
comparison
equal deleted inserted replaced
78:e63209ab2cfa 79:592930d28da4
27 using IBBoard.WarFoundry.GUI.GTK.Widgets; 27 using IBBoard.WarFoundry.GUI.GTK.Widgets;
28 using IBBoard.WarFoundry.Plugin.Rollcall; 28 using IBBoard.WarFoundry.Plugin.Rollcall;
29 using IBBoard.Xml; 29 using IBBoard.Xml;
30 using log4net; 30 using log4net;
31 using WFObjects = IBBoard.WarFoundry.API.Objects; 31 using WFObjects = IBBoard.WarFoundry.API.Objects;
32 using System.Collections;
32 33
33 namespace IBBoard.WarFoundry.GUI.GTK 34 namespace IBBoard.WarFoundry.GUI.GTK
34 { 35 {
35 public partial class FrmMainWindow: Gtk.Window 36 public partial class FrmMainWindow: TranslatableWindowWithActions
36 { 37 {
37 private static readonly string AppTitle = "WarFoundry"; 38 private static readonly string AppTitle = "WarFoundry";
38 private const int CATEGORY_BUTTON_SEPARATOR_INDEX = 6; 39 private const int CATEGORY_BUTTON_SEPARATOR_INDEX = 6;
39 private Preferences preferences; 40 private Preferences preferences;
40 private ILog logger = LogManager.GetLogger(typeof(FrmMainWindow)); 41 private ILog logger = LogManager.GetLogger(typeof(FrmMainWindow));
149 commandStack = new CommandStack(); 150 commandStack = new CommandStack();
150 commandStack.CommandStackUpdated += new MethodInvoker(commandStack_CommandStackUpdated); 151 commandStack.CommandStackUpdated += new MethodInvoker(commandStack_CommandStackUpdated);
151 WarFoundryCore.GameSystemChanged += new GameSystemChangedDelegate(OnGameSystemChanged); 152 WarFoundryCore.GameSystemChanged += new GameSystemChangedDelegate(OnGameSystemChanged);
152 WarFoundryCore.ArmyChanged += new ArmyChangedDelegate(OnArmyChanged); 153 WarFoundryCore.ArmyChanged += new ArmyChangedDelegate(OnArmyChanged);
153 Destroyed += new EventHandler(OnWindowDestroyed); 154 Destroyed += new EventHandler(OnWindowDestroyed);
154 //TODO: Translate and subscribe to other events 155 TranslateWindow();
155 ControlTranslator.TranslateWidget(this);
156 UnitAddedMethod = new ObjectAddDelegate(OnUnitAdded); 156 UnitAddedMethod = new ObjectAddDelegate(OnUnitAdded);
157 UnitRemovedMethod = new ObjectRemoveDelegate(OnUnitRemoved); 157 UnitRemovedMethod = new ObjectRemoveDelegate(OnUnitRemoved);
158 PointsValueChangedMethod = new DoubleValChangedDelegate(OnPointsValueChanged); 158 PointsValueChangedMethod = new DoubleValChangedDelegate(OnPointsValueChanged);
159 FailedUnitRequirementMethod = new FailedUnitRequirementDelegate(OnFailedUnitRequirement); 159 FailedUnitRequirementMethod = new FailedUnitRequirementDelegate(OnFailedUnitRequirement);
160 UnitNameChangedMethod = new StringValChangedDelegate(OnUnitNameChanged); 160 UnitNameChangedMethod = new StringValChangedDelegate(OnUnitNameChanged);
219 WarFoundryCore.CurrentGameSystem = sys; 219 WarFoundryCore.CurrentGameSystem = sys;
220 logger.InfoFormat("Loaded game system {0} from properties", gameSystemID); 220 logger.InfoFormat("Loaded game system {0} from properties", gameSystemID);
221 } 221 }
222 } 222 }
223 } 223 }
224 }
225
226 private void TranslateWindow()
227 {
228 ControlTranslator.TranslateWidget(this);
229 SetAppTitle();
224 } 230 }
225 231
226 private void FileLoadingFinished(List<FileLoadFailure> failures) 232 private void FileLoadingFinished(List<FileLoadFailure> failures)
227 { 233 {
228 foreach (FileLoadFailure failure in failures) 234 foreach (FileLoadFailure failure in failures)
1109 { 1115 {
1110 FrmAbout form = FrmAbout.GetForm(); 1116 FrmAbout form = FrmAbout.GetForm();
1111 form.Run(); 1117 form.Run();
1112 form.Hide(); 1118 form.Hide();
1113 } 1119 }
1120
1121 public override ICollection<Action> Actions
1122 {
1123 get
1124 {
1125 List<Action> actions = new List<Action>();
1126
1127 foreach (ActionGroup actionGroup in this.UIManager.ActionGroups)
1128 {
1129 actions.AddRange(actionGroup.ListActions());
1130 }
1131
1132 return actions;
1133 }
1134 }
1114 } 1135 }
1115 } 1136 }