Mercurial > repos > IBBoard.WarFoundry.GUI.GTK
changeset 76:7055b24cfc79
Re #308: Make GTK# UI translatable
* Extend new TranslatableDialog
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 23 Nov 2010 21:03:46 +0000 |
parents | 2ceae5d685d8 |
children | 68804784bf6f |
files | FrmAddEquipment.cs FrmEditEquipment.cs FrmNewArmy.cs FrmNewUnit.cs FrmReplaceEquipment.cs |
diffstat | 5 files changed, 36 insertions(+), 52 deletions(-) [+] |
line wrap: on
line diff
--- a/FrmAddEquipment.cs Tue Nov 23 20:17:18 2010 +0000 +++ b/FrmAddEquipment.cs Tue Nov 23 21:03:46 2010 +0000 @@ -3,25 +3,23 @@ // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. using System; -using IBBoard.WarFoundry.GUI.GTK.UIControl.Interfaces; +using Gtk; +using IBBoard.GtkSharp; +using IBBoard.GtkSharp.Translatable; using IBBoard.WarFoundry.API.Objects; -using Gtk; +using IBBoard.WarFoundry.GUI.GTK.UIControl.Interfaces; using IBBoard.WarFoundry.GUI.GTK.Util; -using IBBoard.GtkSharp; -using log4net.Repository.Hierarchy; using log4net; namespace IBBoard.WarFoundry.GUI.GTK { - public partial class FrmAddEquipment : Dialog, IAddEquipmentUI + public partial class FrmAddEquipment : TranslatableDialog, IAddEquipmentUI { private static ILog log = LogManager.GetLogger(typeof(FrmAddEquipment)); - public event SingleArgMethodInvoker<UnitEquipmentItem> UnitEquipmentItemChoiceChanged; + public event MethodInvoker UnitEquipmentAmountTypeChanged; + public event MethodInvoker UnitEquipmentAmountChanged; - public event MethodInvoker UnitEquipmentAmountTypeChanged; - - public event MethodInvoker UnitEquipmentAmountChanged; private bool isRatioLimited; public FrmAddEquipment()
--- a/FrmEditEquipment.cs Tue Nov 23 20:17:18 2010 +0000 +++ b/FrmEditEquipment.cs Tue Nov 23 21:03:46 2010 +0000 @@ -10,18 +10,17 @@ using IBBoard.GtkSharp; using log4net.Repository.Hierarchy; using log4net; +using IBBoard.GtkSharp.Translatable; namespace IBBoard.WarFoundry.GUI.GTK { - public partial class FrmEditEquipment : Dialog, IEditEquipmentUI + public partial class FrmEditEquipment : TranslatableDialog, IEditEquipmentUI { private static ILog log = LogManager.GetLogger(typeof(FrmAddEquipment)); - public event SingleArgMethodInvoker<UnitEquipmentItem> UnitEquipmentItemChoiceChanged; + public event MethodInvoker UnitEquipmentAmountTypeChanged; + public event MethodInvoker UnitEquipmentAmountChanged; - public event MethodInvoker UnitEquipmentAmountTypeChanged; - - public event MethodInvoker UnitEquipmentAmountChanged; private bool isRatioLimited; public FrmEditEquipment()
--- a/FrmNewArmy.cs Tue Nov 23 20:17:18 2010 +0000 +++ b/FrmNewArmy.cs Tue Nov 23 21:03:46 2010 +0000 @@ -10,10 +10,11 @@ using IBBoard.GtkSharp; using log4net; using IBBoard.WarFoundry.GUI.GTK.Util; +using IBBoard.GtkSharp.Translatable; namespace IBBoard.WarFoundry.GTK { - public partial class FrmNewArmy : Dialog, ITranslatable + public partial class FrmNewArmy : TranslatableDialog, ITranslatable { private ILog logger = LogManager.GetLogger(typeof(FrmNewArmy)); private Race race; @@ -45,19 +46,7 @@ ComboBoxUtils.SelectIndex(systemCombo, 0); } } - - public string Text - { - get - { - return Title; - } - set - { - Title = value; - } - } - + protected virtual void OnSelectionChanged(object o, EventArgs e) { logger.Debug("Race selection changed");
--- a/FrmNewUnit.cs Tue Nov 23 20:17:18 2010 +0000 +++ b/FrmNewUnit.cs Tue Nov 23 21:03:46 2010 +0000 @@ -4,18 +4,18 @@ using System; using System.Collections.Generic; +using Gtk; +using IBBoard.GtkSharp.Translatable; using IBBoard.WarFoundry.API.Objects; using IBBoard.WarFoundry.API.Requirements; -using Gtk; using log4net; namespace IBBoard.WarFoundry.GTK { - public partial class FrmNewUnit : Gtk.Dialog + public partial class FrmNewUnit : TranslatableDialog { private ILog logger = LogManager.GetLogger(typeof(FrmNewUnit)); - - private UnitType unitType; + private UnitType unitType; private Army unitArmy; public FrmNewUnit(Race race, Category cat, Army army) @@ -23,12 +23,12 @@ this.Build(); unitArmy = army; - TreeViewColumn unitTypeColumn = new TreeViewColumn (); + TreeViewColumn unitTypeColumn = new TreeViewColumn(); unitTypeColumn.Title = "Unit Type"; - CellRendererText unitTypeCell = new CellRendererText (); + CellRendererText unitTypeCell = new CellRendererText(); unitTypeColumn.PackStart(unitTypeCell, true); lstUnitTypes.AppendColumn(unitTypeColumn); - unitTypeColumn.SetCellDataFunc (unitTypeCell, new TreeCellDataFunc(RenderUnitTypeName)); + unitTypeColumn.SetCellDataFunc(unitTypeCell, new TreeCellDataFunc(RenderUnitTypeName)); ListStore store = new ListStore(typeof(UnitType)); UnitType[] types = race.GetUnitTypes(cat); logger.DebugFormat("Listing {0} unit types in {1}", types.Length, cat.Name); @@ -40,7 +40,7 @@ } lstUnitTypes.Model = store; - lstUnitTypes.Selection.Changed+= new EventHandler(OnSelectionChanged); + lstUnitTypes.Selection.Changed += new EventHandler(OnSelectionChanged); } private void RenderUnitTypeName(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter) @@ -63,12 +63,12 @@ { TreeModel model; TreeIter iter; - lstUnitTypes.Selection.GetSelected (out model, out iter); + lstUnitTypes.Selection.GetSelected(out model, out iter); UnitType toReturn = null; - if (model!=null) + if (model != null) { - toReturn = (UnitType) model.GetValue(iter, 0); + toReturn = (UnitType)model.GetValue(iter, 0); } return toReturn; @@ -78,7 +78,7 @@ { UnitType type = GetSelectedUnitType(); - if (type!=null) + if (type != null) { buttonOk.Sensitive = true; List<FailedUnitRequirement> fails = unitArmy.CanAddUnitType(type); @@ -97,18 +97,18 @@ } } - protected virtual void OnButtonCancelActivated (object sender, System.EventArgs e) + protected virtual void OnButtonCancelActivated(object sender, System.EventArgs e) { Respond(ResponseType.Cancel); } - protected virtual void OnRowActivated (object o, Gtk.RowActivatedArgs args) + protected virtual void OnRowActivated(object o, Gtk.RowActivatedArgs args) { unitType = GetSelectedUnitType(); Respond(ResponseType.Ok); } - protected virtual void OnButtonOkClicked (object sender, System.EventArgs e) + protected virtual void OnButtonOkClicked(object sender, System.EventArgs e) { unitType = GetSelectedUnitType(); Respond(ResponseType.Ok);
--- a/FrmReplaceEquipment.cs Tue Nov 23 20:17:18 2010 +0000 +++ b/FrmReplaceEquipment.cs Tue Nov 23 21:03:46 2010 +0000 @@ -3,25 +3,23 @@ // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. using System; -using IBBoard.WarFoundry.GUI.GTK.UIControl.Interfaces; +using Gtk; +using IBBoard.GtkSharp; +using IBBoard.GtkSharp.Translatable; using IBBoard.WarFoundry.API.Objects; -using Gtk; +using IBBoard.WarFoundry.GUI.GTK.UIControl.Interfaces; using IBBoard.WarFoundry.GUI.GTK.Util; -using IBBoard.GtkSharp; -using log4net.Repository.Hierarchy; using log4net; namespace IBBoard.WarFoundry.GUI.GTK { - public partial class FrmReplaceEquipment : Dialog, IReplaceEquipmentUI + public partial class FrmReplaceEquipment : TranslatableDialog, IReplaceEquipmentUI { private static ILog log = LogManager.GetLogger(typeof(FrmReplaceEquipment)); - public event SingleArgMethodInvoker<UnitEquipmentItem> UnitEquipmentItemChoiceChanged; + public event MethodInvoker UnitEquipmentAmountTypeChanged; + public event MethodInvoker UnitEquipmentAmountChanged; - public event MethodInvoker UnitEquipmentAmountTypeChanged; - - public event MethodInvoker UnitEquipmentAmountChanged; private bool isRatioLimited; public FrmReplaceEquipment()