# HG changeset patch # User IBBoard # Date 1293915307 0 # Node ID ea4069bbe6e934e2feb10595132d142e410647ff # Parent 26e4525b49cf55a05749334f554039a048a41240 Re #309: Add initial preference dialog with language support * Add first preference dialog * Add French translations (based on WinForms file) Re #308: Make GTK# UI translatable * Add some missing English translations (API strings) diff -r 26e4525b49cf -r ea4069bbe6e9 FrmMainWindow.cs --- a/FrmMainWindow.cs Fri Dec 31 15:43:05 2010 +0000 +++ b/FrmMainWindow.cs Sat Jan 01 20:55:07 2011 +0000 @@ -1118,6 +1118,13 @@ form.Hide(); } + protected virtual void miPreferencesClicked(object sender, System.EventArgs e) + { + FrmPreferences form = new FrmPreferences(Preferences); + form.Run(); + form.Hide(); + } + public override ICollection Actions { get diff -r 26e4525b49cf -r ea4069bbe6e9 FrmPreferences.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FrmPreferences.cs Sat Jan 01 20:55:07 2011 +0000 @@ -0,0 +1,104 @@ +// This file (FrmPreferences.cs) is a part of the IBBoard.WarFoundry.GUI.GTK project and is copyright 2011 IBBoard +// +// 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.GtkSharp.Translatable; +using IBBoard.Lang; +using Gtk; +using System.Collections.Generic; +using IBBoard.GtkSharp; +using System.Globalization; +using log4net; + +namespace IBBoard.WarFoundry.GUI.GTK +{ + public partial class FrmPreferences : TranslatableDialog + { + private ILog logger = LogManager.GetLogger(typeof(FrmPreferences)); + private Preferences prefs; + private string initialLang; + + public FrmPreferences(Preferences preferences) + { + prefs = preferences; + initialLang = Translation.GetTranslationLanguage(); + this.Build(); + BuildPreferenceCategoryTree(); + BuildLanguageList(); + Translate(); + } + + protected override void Translate() + { + base.Translate(); + frameLabel.Text = Translation.GetTranslation("languagesGroup", "languages"); + + } + + private void RenderPreference(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter) + { + object obj = model.GetValue(iter, 0); + + if (obj is string) + { + (cell as CellRendererText).Text = (string)obj; + } + } + + private void BuildPreferenceCategoryTree() + { + TreeViewColumn mainColumn = new TreeViewColumn(); + CellRendererText mainCell = new CellRendererText(); + mainColumn.PackStart(mainCell, true); + preferencesTree.AppendColumn(mainColumn); + mainColumn.SetCellDataFunc(mainCell, new TreeCellDataFunc(RenderPreference)); + TreeStore model = new TreeStore(typeof(string)); + preferencesTree.Model = model; + model.AppendValues(Translation.GetTranslation("languagePrefSection", "Language")); + } + + private void BuildLanguageList() + { + ICollection langs = Translation.GetLanguages(); + List sortedLangs = new List(langs); + sortedLangs.Sort(CompareLanguages); + ComboBoxUtils.FillCombo(languageList, sortedLangs, delegate(TranslationLanguage lang){return lang.Name;}); + ComboBoxUtils.SelectItem(languageList, Translation.GetTranslationSet(initialLang).Language); + } + + private int CompareLanguages(TranslationLanguage lang1, TranslationLanguage lang2) + { + CompareOptions options = CompareOptions.IgnoreCase | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth; + return CultureInfo.CurrentCulture.CompareInfo.Compare(lang1.Name, lang2.Name, options); + } + + protected virtual void bttnOkayClicked(object sender, System.EventArgs e) + { + prefs["language"] = Translation.GetTranslationLanguage(); + prefs.Save(); + Respond(ResponseType.Ok); + } + + protected virtual void bttnCancelClicked(object sender, System.EventArgs e) + { + Translation.LoadTranslation(initialLang); + Respond(ResponseType.Cancel); + } + + protected virtual void languageListChanged(object sender, System.EventArgs e) + { + TranslationLanguage selectedLang = ComboBoxUtils.GetSelectedItem(languageList); + string code = selectedLang == null ? "" : selectedLang.Code; + logger.Debug("New language: " + code); + Translation.LoadTranslation(code); + bttnOkay.Sensitive = !initialLang.Equals(code); + + } + + + + + } +} + diff -r 26e4525b49cf -r ea4069bbe6e9 IBBoard.WarFoundry.GUI.GTK.csproj --- a/IBBoard.WarFoundry.GUI.GTK.csproj Fri Dec 31 15:43:05 2010 +0000 +++ b/IBBoard.WarFoundry.GUI.GTK.csproj Sat Jan 01 20:55:07 2011 +0000 @@ -69,6 +69,8 @@ + + @@ -87,6 +89,9 @@ PreserveNewest + + PreserveNewest + diff -r 26e4525b49cf -r ea4069bbe6e9 gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmMainWindow.cs --- a/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmMainWindow.cs Fri Dec 31 15:43:05 2010 +0000 +++ b/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmMainWindow.cs Sat Jan 01 20:55:07 2011 +0000 @@ -28,6 +28,7 @@ private global::Gtk.Action add; private global::Gtk.Action miExportArmyAs; private global::Gtk.Action miExportAsBasicHtml; + private global::Gtk.Action miPreferences; private global::Gtk.VBox vbox1; private global::Gtk.MenuBar menubar1; private global::Gtk.Toolbar toolbar; @@ -108,11 +109,14 @@ w1.Add(this.add, null); this.miExportArmyAs = new global::Gtk.Action("miExportArmyAs", global::Mono.Unix.Catalog.GetString("Export army as..."), null, "gtk-convert"); this.miExportArmyAs.Sensitive = false; - this.miExportArmyAs.ShortLabel = global::Mono.Unix.Catalog.GetString("Export army"); + this.miExportArmyAs.ShortLabel = global::Mono.Unix.Catalog.GetString("Export army as..."); w1.Add(this.miExportArmyAs, null); this.miExportAsBasicHtml = new global::Gtk.Action("miExportAsBasicHtml", global::Mono.Unix.Catalog.GetString("Basic HTML"), null, null); this.miExportAsBasicHtml.ShortLabel = global::Mono.Unix.Catalog.GetString("Basic HTML"); w1.Add(this.miExportAsBasicHtml, null); + this.miPreferences = new global::Gtk.Action("miPreferences", global::Mono.Unix.Catalog.GetString("preferences"), null, "gtk-preferences"); + this.miPreferences.ShortLabel = global::Mono.Unix.Catalog.GetString("preferences"); + w1.Add(this.miPreferences, null); this.UIManager.InsertActionGroup(w1, 0); this.AddAccelGroup(this.UIManager.AccelGroup); this.Name = "IBBoard.WarFoundry.GUI.GTK.FrmMainWindow"; @@ -122,7 +126,7 @@ this.vbox1 = new global::Gtk.VBox(); this.vbox1.Name = "vbox1"; // Container child vbox1.Gtk.Box+BoxChild - this.UIManager.AddUiFromString(""); + this.UIManager.AddUiFromString(""); this.menubar1 = ((global::Gtk.MenuBar)(this.UIManager.GetWidget("/menubar1"))); this.menubar1.Name = "menubar1"; this.vbox1.Add(this.menubar1); @@ -197,6 +201,7 @@ this.bttnUndo.Activated += new global::System.EventHandler(this.undoTBButtonActivated); this.bttnRedo.Activated += new global::System.EventHandler(this.redoTBButtonActivated); this.miExportAsBasicHtml.Activated += new global::System.EventHandler(this.OnMiExportAsBasicHtmlActivated); + this.miPreferences.Activated += new global::System.EventHandler(this.miPreferencesClicked); this.treeUnits.RowActivated += new global::Gtk.RowActivatedHandler(this.ArmyRowActivated); this.treeUnits.PopupMenu += new global::Gtk.PopupMenuHandler(this.OnTreeUnitsPopupMenu); this.treeUnits.ButtonPressEvent += new global::Gtk.ButtonPressEventHandler(this.UnitTreeButtonPressed); diff -r 26e4525b49cf -r ea4069bbe6e9 gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmPreferences.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmPreferences.cs Sat Jan 01 20:55:07 2011 +0000 @@ -0,0 +1,132 @@ + +// This file has been generated by the GUI designer. Do not modify. +namespace IBBoard.WarFoundry.GUI.GTK +{ + public partial class FrmPreferences + { + private global::Gtk.HPaned hpaned1; + private global::Gtk.ScrolledWindow GtkScrolledWindow; + private global::Gtk.TreeView preferencesTree; + private global::Gtk.Frame prefsFrame; + private global::Gtk.Alignment GtkAlignment2; + private global::Gtk.Table table1; + private global::Gtk.ComboBox languageList; + private global::IBBoard.GtkSharp.Translatable.TranslatableLabel lblLanguage; + private global::Gtk.Label frameLabel; + private global::Gtk.Button bttnCancel; + private global::Gtk.Button bttnOkay; + + protected virtual void Build() + { + global::Stetic.Gui.Initialize(this); + // Widget IBBoard.WarFoundry.GUI.GTK.FrmPreferences + this.Name = "IBBoard.WarFoundry.GUI.GTK.FrmPreferences"; + this.WindowPosition = ((global::Gtk.WindowPosition)(4)); + // Internal child IBBoard.WarFoundry.GUI.GTK.FrmPreferences.VBox + global::Gtk.VBox w1 = this.VBox; + w1.Name = "dialog1_VBox"; + w1.BorderWidth = ((uint)(2)); + // Container child dialog1_VBox.Gtk.Box+BoxChild + this.hpaned1 = new global::Gtk.HPaned(); + this.hpaned1.CanFocus = true; + this.hpaned1.Name = "hpaned1"; + this.hpaned1.Position = 164; + // Container child hpaned1.Gtk.Paned+PanedChild + this.GtkScrolledWindow = new global::Gtk.ScrolledWindow(); + this.GtkScrolledWindow.Name = "GtkScrolledWindow"; + this.GtkScrolledWindow.ShadowType = ((global::Gtk.ShadowType)(1)); + // Container child GtkScrolledWindow.Gtk.Container+ContainerChild + this.preferencesTree = new global::Gtk.TreeView(); + this.preferencesTree.CanFocus = true; + this.preferencesTree.Name = "preferencesTree"; + this.preferencesTree.HeadersVisible = false; + this.GtkScrolledWindow.Add(this.preferencesTree); + this.hpaned1.Add(this.GtkScrolledWindow); + global::Gtk.Paned.PanedChild w3 = ((global::Gtk.Paned.PanedChild)(this.hpaned1[this.GtkScrolledWindow])); + w3.Resize = false; + // Container child hpaned1.Gtk.Paned+PanedChild + this.prefsFrame = new global::Gtk.Frame(); + this.prefsFrame.Name = "prefsFrame"; + this.prefsFrame.ShadowType = ((global::Gtk.ShadowType)(1)); + this.prefsFrame.BorderWidth = ((uint)(2)); + // Container child prefsFrame.Gtk.Container+ContainerChild + this.GtkAlignment2 = new global::Gtk.Alignment(0F, 0F, 1F, 1F); + this.GtkAlignment2.Name = "GtkAlignment2"; + this.GtkAlignment2.LeftPadding = ((uint)(12)); + // Container child GtkAlignment2.Gtk.Container+ContainerChild + this.table1 = new global::Gtk.Table(((uint)(3)), ((uint)(2)), false); + this.table1.Name = "table1"; + this.table1.RowSpacing = ((uint)(6)); + this.table1.ColumnSpacing = ((uint)(6)); + // Container child table1.Gtk.Table+TableChild + this.languageList = global::Gtk.ComboBox.NewText(); + this.languageList.Name = "languageList"; + this.table1.Add(this.languageList); + global::Gtk.Table.TableChild w4 = ((global::Gtk.Table.TableChild)(this.table1[this.languageList])); + w4.LeftAttach = ((uint)(1)); + w4.RightAttach = ((uint)(2)); + w4.XOptions = ((global::Gtk.AttachOptions)(4)); + w4.YOptions = ((global::Gtk.AttachOptions)(4)); + // Container child table1.Gtk.Table+TableChild + this.lblLanguage = new global::IBBoard.GtkSharp.Translatable.TranslatableLabel(); + this.lblLanguage.Name = "lblLanguage"; + this.lblLanguage.LabelProp = global::Mono.Unix.Catalog.GetString("language:"); + this.table1.Add(this.lblLanguage); + global::Gtk.Table.TableChild w5 = ((global::Gtk.Table.TableChild)(this.table1[this.lblLanguage])); + w5.XOptions = ((global::Gtk.AttachOptions)(4)); + w5.YOptions = ((global::Gtk.AttachOptions)(4)); + this.GtkAlignment2.Add(this.table1); + this.prefsFrame.Add(this.GtkAlignment2); + this.frameLabel = new global::Gtk.Label(); + this.frameLabel.Name = "frameLabel"; + this.frameLabel.LabelProp = global::Mono.Unix.Catalog.GetString("language"); + this.frameLabel.UseMarkup = true; + this.prefsFrame.LabelWidget = this.frameLabel; + this.hpaned1.Add(this.prefsFrame); + w1.Add(this.hpaned1); + global::Gtk.Box.BoxChild w9 = ((global::Gtk.Box.BoxChild)(w1[this.hpaned1])); + w9.Position = 0; + // Internal child IBBoard.WarFoundry.GUI.GTK.FrmPreferences.ActionArea + global::Gtk.HButtonBox w10 = this.ActionArea; + w10.Name = "dialog1_ActionArea"; + w10.Spacing = 10; + w10.BorderWidth = ((uint)(5)); + w10.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(4)); + // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild + this.bttnCancel = new global::Gtk.Button(); + this.bttnCancel.CanDefault = true; + this.bttnCancel.CanFocus = true; + this.bttnCancel.Name = "bttnCancel"; + this.bttnCancel.UseStock = true; + this.bttnCancel.UseUnderline = true; + this.bttnCancel.Label = "gtk-cancel"; + this.AddActionWidget(this.bttnCancel, -6); + global::Gtk.ButtonBox.ButtonBoxChild w11 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w10[this.bttnCancel])); + w11.Expand = false; + w11.Fill = false; + // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild + this.bttnOkay = new global::Gtk.Button(); + this.bttnOkay.CanDefault = true; + this.bttnOkay.CanFocus = true; + this.bttnOkay.Name = "bttnOkay"; + this.bttnOkay.UseStock = true; + this.bttnOkay.UseUnderline = true; + this.bttnOkay.Label = "gtk-ok"; + this.AddActionWidget(this.bttnOkay, -5); + global::Gtk.ButtonBox.ButtonBoxChild w12 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w10[this.bttnOkay])); + w12.Position = 1; + w12.Expand = false; + w12.Fill = false; + if ((this.Child != null)) + { + this.Child.ShowAll(); + } + this.DefaultWidth = 400; + this.DefaultHeight = 300; + this.Show(); + this.languageList.Changed += new global::System.EventHandler(this.languageListChanged); + this.bttnCancel.Clicked += new global::System.EventHandler(this.bttnCancelClicked); + this.bttnOkay.Clicked += new global::System.EventHandler(this.bttnOkayClicked); + } + } +} diff -r 26e4525b49cf -r ea4069bbe6e9 gtk-gui/gui.stetic --- a/gtk-gui/gui.stetic Fri Dec 31 15:43:05 2010 +0000 +++ b/gtk-gui/gui.stetic Sat Jan 01 20:55:07 2011 +0000 @@ -149,7 +149,7 @@ Action Export army as... False - Export army + Export army as... gtk-convert @@ -158,6 +158,13 @@ Basic HTML + + Action + preferences + preferences + gtk-preferences + + MainWindow @@ -186,6 +193,8 @@ + + @@ -2337,4 +2346,172 @@ + + + CenterOnParent + 2 + False + + + + 2 + + + + True + 164 + + + + In + + + + True + True + False + + + + + False + + + + + + In + 2 + + + + 0 + 0 + 12 + + + + 3 + 2 + 6 + 6 + + + + + + + + + + + + + + + + True + + + + + 1 + 2 + True + Fill + Fill + False + True + False + False + True + False + + + + + + language: + + + True + Fill + Fill + False + True + False + False + True + False + + + + + + + + + + <b>language</b> + True + + + label_item + + + + + + + 0 + True + + + + + + + + 10 + 5 + 2 + End + + + + True + True + True + StockItem + gtk-cancel + -6 + + gtk-cancel + + + False + False + + + + + + True + True + True + StockItem + gtk-ok + -5 + + gtk-ok + + + 1 + False + False + + + + + \ No newline at end of file diff -r 26e4525b49cf -r ea4069bbe6e9 translations/en.translation --- a/translations/en.translation Fri Dec 31 15:43:05 2010 +0000 +++ b/translations/en.translation Sat Jan 01 20:55:07 2011 +0000 @@ -14,6 +14,7 @@ _Quit _Undo _Redo +_Preferences _About Create new army Open army @@ -45,6 +46,14 @@ Army size: Create Race +The current percentage ({0}%) was larger than the maximum for the equipment item ({1}%). The maximum value will be used instead. +Equipment percentage too large +The current percentage ({0}%) was smaller than the minimum for the equipment item ({1}%). The minimum value will be used instead. +Equipment percentage too small +The current amount ({0}) was larger than the maximum for the equipment item ({1}). The maximum value will be used instead. +Equipment amount too large +The current amount ({0}) was smaller than the minimum for the equipment item ({1}). The minimum value will be used instead. +Equipment amount too small Add New {0} Choice Unit Type Unit Type: @@ -69,4 +78,31 @@ Developers: Testers (General WarFoundry): Testers (GTK UI): +Preferences +Language +Language: +Language +{0} - {1}pts +Name +Notes +Points +all ({1}) +{0}% ({1}) +{0} +{0} for {1} +all ({1}) +{0}% ({1}) +{0} +Set {0} amount for {1} to {2} +Set {0} amount for {1} to {2} +Replace {0} with {1} for {2} +Replace {0} with {1} for {2} +Add unit of {0} +Remove unit of {0} +Remove {0} +Re-add {0} +Rename "{0}" to "{1}" +Rename "{0}" to "{1}" +Set size of {0} to {1} +Set size of {0} to {1} \ No newline at end of file diff -r 26e4525b49cf -r ea4069bbe6e9 translations/fr.translation --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/translations/fr.translation Sat Jan 01 20:55:07 2011 +0000 @@ -0,0 +1,117 @@ + + + _Fichier + _Édition + _Aide + _Créer une armée + _Ouvrir une armée + _Enregistrer une armée + Enregistrer une armée sous… + _Exporter une armée + HTML Basic + _Fermer une armée + _Recharger les fichiers + _Sortir + _Annuler + _Rétablir + _À propos + OK + Annuler + Créer une armée + Ouvrir une armée + Sauvegarder une armée + Annuler + Rétablir + Arborescence de l'armée + _Supprimer une unité + _Éditer une unité + Ouvrir une armée + Sauvegarder une armée + WarFoundry Army Files (*.army) + {0} pts / {1} pts + Nombre de point d'armée actuel + Unité de {0} {1} + Créer une nouvelle armée + Système de jeux : + Races : + Nom de l'armée : + Taille de l'armée : + Créer une armée + Ajouter un nouveau choix {0} + Types d'unité : + Créer une unité + Nouvelle équipement pour unité + Quantité : + Équipement : + Tout équiper + Le pourcentage actuel ({0}%) est trop important par rapport au maximum d'équipement accordé ({1}%). La valeur maximum sera utilisée à la place. + Le pourcentage d'équipement est trop important + Le pourcentage actuel ({0}%) est trop faible par rapport au minimum d'équipement demandé ({1}%). La valeur minimum sera utilisée à la place. + Pourcentage d'équipement trop petit + La valeur en point ({0}) est trop importante par rapport au maximum d'équipement accordé ({1}). La valeur maximum sera utilisée à la place. + Pourcentage d'équipement trop petit + La valeur en point ({0}) est trop faible par rapport au minimum d'équipement demandé ({1}). La valeur minimum sera utilisée à la place. + Nombre de point d'équipement trop faible + Édition équipement pour unité + À propos de WarFoundry + Version : {0} + Développeurs : + Remerciement : + {0} + Taille d'unité : + Équipement : + Ajouter + Capacités : + Notes : + Supprimer + Remplacer + Éditer + {0} ({1} à {2} pts chacun) + {0} ({1} gratuit) + pour ({1}) + pour {0}% ({1}) + {0} + Fichier de race invalide + Fichier d'armée invalide + L'armée "{0}" a été modifiée. Sauvegarder les changements avant de fermer ? + Changements non-sauvegardés + WarFoundry ne peut pas sauvegarder le fichier. Veillez vérifier le log pour plus d'informations + Échec de la sauvegarde du fichier + {0} - {1} pts + Nom + Notes + Points + tout ({1}) + {0}% ({1}) + {0} + {0} pour {1} + tout ({1}) + {0}% ({1}) + {0} + Fixer {0} la quantité {1} par {2} + Fixer {0} la quantité {1} par {2} + Remplacer {0} de {1} par {2} + Remplacer {0} de {1} par {2} + Ajouter une unité de {0} + Supprimer une unité de {0} + Supprimer {0} + Rajouter {0} + Renommer "{0}" par "{1}" + Renommer "{0}" par "{1}" + Changer la taille de {0} par {1} + Changer la taille {0} par {1} + {0}; et {1} + {0}; ou {1} + {0} peut être sélectionné si aucun des objets suivants ne sont selectionnés : {1} + {1} peut être sélectionné {0} fois + {1} doit être sélectionné au moins {0} fois + {1} {0} + {0}, {1} + {0} peut être sélectionné seulement si l'objet suivant est sélectionné : {1} + +Preferences +Language +Language: +Language +_Preferences +