diff 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
line wrap: on
line diff
--- a/FrmMainWindow.cs	Sat Dec 18 16:46:16 2010 +0000
+++ b/FrmMainWindow.cs	Mon Dec 27 20:56:31 2010 +0000
@@ -29,10 +29,11 @@
 using IBBoard.Xml;
 using log4net;
 using WFObjects = IBBoard.WarFoundry.API.Objects;
+using System.Collections;
 
 namespace IBBoard.WarFoundry.GUI.GTK
 {
-	public partial class FrmMainWindow: Gtk.Window
+	public partial class FrmMainWindow: TranslatableWindowWithActions
 	{
 		private static readonly string AppTitle = "WarFoundry";
 		private const int CATEGORY_BUTTON_SEPARATOR_INDEX = 6;
@@ -151,8 +152,7 @@
 			WarFoundryCore.GameSystemChanged += new GameSystemChangedDelegate(OnGameSystemChanged);
 			WarFoundryCore.ArmyChanged += new ArmyChangedDelegate(OnArmyChanged);
 			Destroyed += new EventHandler(OnWindowDestroyed);
-			//TODO: Translate and subscribe to other events
-			ControlTranslator.TranslateWidget(this);
+			TranslateWindow();
 			UnitAddedMethod = new ObjectAddDelegate(OnUnitAdded);
 			UnitRemovedMethod = new ObjectRemoveDelegate(OnUnitRemoved);
 			PointsValueChangedMethod = new DoubleValChangedDelegate(OnPointsValueChanged);
@@ -223,6 +223,12 @@
 			}
 		}
 
+		private void TranslateWindow()
+		{
+			ControlTranslator.TranslateWidget(this);
+			SetAppTitle();
+		}
+
 		private void FileLoadingFinished(List<FileLoadFailure> failures)
 		{
 			foreach (FileLoadFailure failure in failures)
@@ -1111,5 +1117,20 @@
 			form.Run();
 			form.Hide();
 		}
+
+		public override ICollection<Action> Actions
+		{
+			get
+			{
+				List<Action> actions = new List<Action>();
+
+				foreach (ActionGroup actionGroup in this.UIManager.ActionGroups)
+				{
+					actions.AddRange(actionGroup.ListActions());
+				}
+
+				return actions;
+			}
+		}
 	}
 }