# HG changeset patch # User IBBoard # Date 1317482388 -3600 # Node ID d4e6bfeb1c61f5ca525589ae54510605793830b2 # Parent 42d2aa87dfa7f160482dd74b318e814af2c1745d Re #361: Add XML export UI to GTK# * Separate out the "transform" section so we can add it as an ExtraWidget on the file chooser diff -r 42d2aa87dfa7 -r d4e6bfeb1c61 FrmExportXml.cs --- a/FrmExportXml.cs Sat Oct 01 14:52:39 2011 +0100 +++ b/FrmExportXml.cs Sat Oct 01 16:19:48 2011 +0100 @@ -16,38 +16,26 @@ public partial class FrmExportXml : Gtk.Dialog { private Army army; + private TransformXmlWidget transformWidget; public FrmExportXml(Army army) { this.army = army; this.Build(); - FillXsltList(); + transformWidget = new TransformXmlWidget(); + transformWidget.TransformChanged += HandleTransformWidgetTransformChanged; + saveAsPath.ExtraWidget = transformWidget; saveAsPath.SetCurrentFolder(Environment.GetFolderPath(Environment.SpecialFolder.Personal)); } - private void FillXsltList() + private void HandleTransformWidgetTransformChanged (object sender, EventArgs e) { - DirectoryInfo dir = new DirectoryInfo(System.IO.Path.Combine(Constants.ExecutablePath, "xsl")); - List files = new List(dir.GetFiles("*.xsl")); - ComboBoxUtils.FillCombo(transformList, files, delegate(FileInfo file) { return file.Name; }); - } - - protected void OnDoTransformWidgetToggled(object sender, System.EventArgs e) - { - bool enabled = doTransformWidget.Active; - lblTransform.Sensitive = enabled; - transformList.Sensitive = enabled; SetOkayButtonSensitive(); } private void SetOkayButtonSensitive() { - buttonOk.Sensitive = saveAsName.Text != "" && saveAsPath.Filename != null && saveAsPath.Filename != "" && (!doTransformWidget.Active || ComboBoxUtils.GetSelectedItem(transformList) != null); - } - - protected void OnTransformListChanged(object sender, System.EventArgs e) - { - SetOkayButtonSensitive(); + buttonOk.Sensitive = saveAsPath.Filename != null && saveAsPath.Filename != "" && transformWidget.IsValid; } protected void OnSaveAsPathSelectionChanged(object sender, System.EventArgs e) @@ -61,11 +49,11 @@ // Catch potential errors with the file export or XSL compiliation try { - string fileName = System.IO.Path.Combine(saveAsPath.Filename, saveAsName.Text); + string fileName = saveAsPath.Filename; - if (doTransformWidget.Active) + if (transformWidget.TransformEnabled) { - WarFoundryXmlWithXslExporter.GetDefault().ExportArmyWithTransform(army, fileName, ComboBoxUtils.GetSelectedItem(transformList).FullName); + WarFoundryXmlWithXslExporter.GetDefault().ExportArmyWithTransform(army, fileName, transformWidget.GetXsltPath()); } else { @@ -113,9 +101,10 @@ Respond(ResponseType.Cancel); } - protected void OnSaveAsNameChanged (object sender, System.EventArgs e) + protected void OnSizeAllocated (object o, Gtk.SizeAllocatedArgs args) { - SetOkayButtonSensitive(); + Console.WriteLine(args.Allocation.Height + "," + args.Allocation.Width); + //this. } } } diff -r 42d2aa87dfa7 -r d4e6bfeb1c61 IBBoard.WarFoundry.GUI.GTK.csproj --- a/IBBoard.WarFoundry.GUI.GTK.csproj Sat Oct 01 14:52:39 2011 +0100 +++ b/IBBoard.WarFoundry.GUI.GTK.csproj Sat Oct 01 16:19:48 2011 +0100 @@ -74,6 +74,8 @@ + + @@ -109,6 +111,7 @@ libs\log4net.dll + diff -r 42d2aa87dfa7 -r d4e6bfeb1c61 gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmExportXml.cs --- a/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmExportXml.cs Sat Oct 01 14:52:39 2011 +0100 +++ b/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmExportXml.cs Sat Oct 01 16:19:48 2011 +0100 @@ -4,14 +4,7 @@ { public partial class FrmExportXml { - private global::Gtk.Table table; - private global::Gtk.CheckButton doTransformWidget; - private global::IBBoard.GtkSharp.Translatable.TranslatableLabel lblOutputFile; - private global::IBBoard.GtkSharp.Translatable.TranslatableLabel lblSaveIn; - private global::IBBoard.GtkSharp.Translatable.TranslatableLabel lblTransform; - private global::Gtk.Entry saveAsName; - private global::Gtk.FileChooserButton saveAsPath; - private global::Gtk.ComboBox transformList; + private global::Gtk.FileChooserWidget saveAsPath; private global::Gtk.Button buttonCancel; private global::Gtk.Button buttonOk; @@ -22,108 +15,26 @@ this.Name = "IBBoard.WarFoundry.GUI.GTK.FrmExportXml"; this.TypeHint = ((global::Gdk.WindowTypeHint)(1)); this.WindowPosition = ((global::Gtk.WindowPosition)(4)); + this.SkipPagerHint = true; + this.SkipTaskbarHint = true; // Internal child IBBoard.WarFoundry.GUI.GTK.FrmExportXml.VBox global::Gtk.VBox w1 = this.VBox; w1.Name = "dialog1_VBox"; w1.BorderWidth = ((uint)(2)); // Container child dialog1_VBox.Gtk.Box+BoxChild - this.table = new global::Gtk.Table (((uint)(4)), ((uint)(2)), false); - this.table.Name = "table"; - this.table.RowSpacing = ((uint)(6)); - this.table.ColumnSpacing = ((uint)(6)); - // Container child table.Gtk.Table+TableChild - this.doTransformWidget = new global::Gtk.CheckButton (); - this.doTransformWidget.CanFocus = true; - this.doTransformWidget.Name = "doTransformWidget"; - this.doTransformWidget.Label = global::Mono.Unix.Catalog.GetString ("Transform output?"); - this.doTransformWidget.DrawIndicator = true; - this.doTransformWidget.UseUnderline = true; - this.table.Add (this.doTransformWidget); - global::Gtk.Table.TableChild w2 = ((global::Gtk.Table.TableChild)(this.table [this.doTransformWidget])); - w2.TopAttach = ((uint)(2)); - w2.BottomAttach = ((uint)(3)); - w2.LeftAttach = ((uint)(1)); - w2.RightAttach = ((uint)(2)); - w2.XOptions = ((global::Gtk.AttachOptions)(4)); - w2.YOptions = ((global::Gtk.AttachOptions)(4)); - // Container child table.Gtk.Table+TableChild - this.lblOutputFile = new global::IBBoard.GtkSharp.Translatable.TranslatableLabel (); - this.lblOutputFile.Name = "lblOutputFile"; - this.lblOutputFile.Xalign = 1F; - this.lblOutputFile.LabelProp = global::Mono.Unix.Catalog.GetString ("save as:"); - this.table.Add (this.lblOutputFile); - global::Gtk.Table.TableChild w3 = ((global::Gtk.Table.TableChild)(this.table [this.lblOutputFile])); - w3.XOptions = ((global::Gtk.AttachOptions)(4)); - w3.YOptions = ((global::Gtk.AttachOptions)(4)); - // Container child table.Gtk.Table+TableChild - this.lblSaveIn = new global::IBBoard.GtkSharp.Translatable.TranslatableLabel (); - this.lblSaveIn.Name = "lblSaveIn"; - this.lblSaveIn.Xalign = 1F; - this.lblSaveIn.LabelProp = global::Mono.Unix.Catalog.GetString ("in folder"); - this.table.Add (this.lblSaveIn); - global::Gtk.Table.TableChild w4 = ((global::Gtk.Table.TableChild)(this.table [this.lblSaveIn])); - w4.TopAttach = ((uint)(1)); - w4.BottomAttach = ((uint)(2)); - w4.XOptions = ((global::Gtk.AttachOptions)(4)); - w4.YOptions = ((global::Gtk.AttachOptions)(4)); - // Container child table.Gtk.Table+TableChild - this.lblTransform = new global::IBBoard.GtkSharp.Translatable.TranslatableLabel (); - this.lblTransform.Sensitive = false; - this.lblTransform.Name = "lblTransform"; - this.lblTransform.LabelProp = global::Mono.Unix.Catalog.GetString ("transform:"); - this.table.Add (this.lblTransform); - global::Gtk.Table.TableChild w5 = ((global::Gtk.Table.TableChild)(this.table [this.lblTransform])); - w5.TopAttach = ((uint)(3)); - w5.BottomAttach = ((uint)(4)); - w5.XOptions = ((global::Gtk.AttachOptions)(4)); - w5.YOptions = ((global::Gtk.AttachOptions)(4)); - // Container child table.Gtk.Table+TableChild - this.saveAsName = new global::Gtk.Entry (); - this.saveAsName.CanFocus = true; - this.saveAsName.Name = "saveAsName"; - this.saveAsName.IsEditable = true; - this.saveAsName.InvisibleChar = '●'; - this.table.Add (this.saveAsName); - global::Gtk.Table.TableChild w6 = ((global::Gtk.Table.TableChild)(this.table [this.saveAsName])); - w6.LeftAttach = ((uint)(1)); - w6.RightAttach = ((uint)(2)); - w6.XOptions = ((global::Gtk.AttachOptions)(4)); - w6.YOptions = ((global::Gtk.AttachOptions)(4)); - // Container child table.Gtk.Table+TableChild - this.saveAsPath = new global::Gtk.FileChooserButton (global::Mono.Unix.Catalog.GetString ("Select A File"), ((global::Gtk.FileChooserAction)(2))); + this.saveAsPath = new global::Gtk.FileChooserWidget (((global::Gtk.FileChooserAction)(1))); this.saveAsPath.Name = "saveAsPath"; - this.saveAsPath.WidthChars = 20; + this.saveAsPath.LocalOnly = false; this.saveAsPath.DoOverwriteConfirmation = true; - this.table.Add (this.saveAsPath); - global::Gtk.Table.TableChild w7 = ((global::Gtk.Table.TableChild)(this.table [this.saveAsPath])); - w7.TopAttach = ((uint)(1)); - w7.BottomAttach = ((uint)(2)); - w7.LeftAttach = ((uint)(1)); - w7.RightAttach = ((uint)(2)); - w7.XOptions = ((global::Gtk.AttachOptions)(4)); - w7.YOptions = ((global::Gtk.AttachOptions)(4)); - // Container child table.Gtk.Table+TableChild - this.transformList = global::Gtk.ComboBox.NewText (); - this.transformList.Sensitive = false; - this.transformList.Name = "transformList"; - this.table.Add (this.transformList); - global::Gtk.Table.TableChild w8 = ((global::Gtk.Table.TableChild)(this.table [this.transformList])); - w8.TopAttach = ((uint)(3)); - w8.BottomAttach = ((uint)(4)); - w8.LeftAttach = ((uint)(1)); - w8.RightAttach = ((uint)(2)); - w8.YOptions = ((global::Gtk.AttachOptions)(4)); - w1.Add (this.table); - global::Gtk.Box.BoxChild w9 = ((global::Gtk.Box.BoxChild)(w1 [this.table])); - w9.Position = 0; - w9.Expand = false; - w9.Fill = false; + w1.Add (this.saveAsPath); + global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(w1 [this.saveAsPath])); + w2.Position = 0; // Internal child IBBoard.WarFoundry.GUI.GTK.FrmExportXml.ActionArea - global::Gtk.HButtonBox w10 = this.ActionArea; - w10.Name = "dialog1_ActionArea"; - w10.Spacing = 10; - w10.BorderWidth = ((uint)(5)); - w10.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(4)); + global::Gtk.HButtonBox w3 = this.ActionArea; + w3.Name = "dialog1_ActionArea"; + w3.Spacing = 10; + w3.BorderWidth = ((uint)(5)); + w3.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(4)); // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild this.buttonCancel = new global::Gtk.Button (); this.buttonCancel.CanDefault = true; @@ -133,9 +44,9 @@ this.buttonCancel.UseUnderline = true; this.buttonCancel.Label = "gtk-cancel"; this.AddActionWidget (this.buttonCancel, -6); - global::Gtk.ButtonBox.ButtonBoxChild w11 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w10 [this.buttonCancel])); - w11.Expand = false; - w11.Fill = false; + global::Gtk.ButtonBox.ButtonBoxChild w4 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w3 [this.buttonCancel])); + w4.Expand = false; + w4.Fill = false; // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild this.buttonOk = new global::Gtk.Button (); this.buttonOk.CanDefault = true; @@ -145,20 +56,18 @@ this.buttonOk.UseUnderline = true; this.buttonOk.Label = "gtk-ok"; this.AddActionWidget (this.buttonOk, -5); - global::Gtk.ButtonBox.ButtonBoxChild w12 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w10 [this.buttonOk])); - w12.Position = 1; - w12.Expand = false; - w12.Fill = false; + global::Gtk.ButtonBox.ButtonBoxChild w5 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w3 [this.buttonOk])); + w5.Position = 1; + w5.Expand = false; + w5.Fill = false; if ((this.Child != null)) { this.Child.ShowAll (); } - this.DefaultWidth = 397; - this.DefaultHeight = 300; + this.DefaultWidth = 634; + this.DefaultHeight = 468; this.Show (); - this.transformList.Changed += new global::System.EventHandler (this.OnTransformListChanged); + this.SizeAllocated += new global::Gtk.SizeAllocatedHandler (this.OnSizeAllocated); this.saveAsPath.SelectionChanged += new global::System.EventHandler (this.OnSaveAsPathSelectionChanged); - this.saveAsName.Changed += new global::System.EventHandler (this.OnSaveAsNameChanged); - this.doTransformWidget.Toggled += new global::System.EventHandler (this.OnDoTransformWidgetToggled); this.buttonCancel.Clicked += new global::System.EventHandler (this.OnButtonCancelClicked); this.buttonOk.Clicked += new global::System.EventHandler (this.OnButtonOkClicked); } diff -r 42d2aa87dfa7 -r d4e6bfeb1c61 gtk-gui/IBBoard.WarFoundry.GUI.GTK.TransformXmlWidget.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gtk-gui/IBBoard.WarFoundry.GUI.GTK.TransformXmlWidget.cs Sat Oct 01 16:19:48 2011 +0100 @@ -0,0 +1,68 @@ + +// This file has been generated by the GUI designer. Do not modify. +namespace IBBoard.WarFoundry.GUI.GTK +{ + public partial class TransformXmlWidget + { + private global::Gtk.Table table1; + private global::Gtk.CheckButton doTransformWidget; + private global::IBBoard.GtkSharp.Translatable.TranslatableLabel lblTransform; + private global::Gtk.ComboBox transformList; + + protected virtual void Build () + { + global::Stetic.Gui.Initialize (this); + // Widget IBBoard.WarFoundry.GUI.GTK.TransformXmlWidget + global::Stetic.BinContainer.Attach (this); + this.Name = "IBBoard.WarFoundry.GUI.GTK.TransformXmlWidget"; + // Container child IBBoard.WarFoundry.GUI.GTK.TransformXmlWidget.Gtk.Container+ContainerChild + this.table1 = new global::Gtk.Table (((uint)(2)), ((uint)(2)), false); + this.table1.Name = "table1"; + this.table1.RowSpacing = ((uint)(6)); + this.table1.ColumnSpacing = ((uint)(6)); + // Container child table1.Gtk.Table+TableChild + this.doTransformWidget = new global::Gtk.CheckButton (); + this.doTransformWidget.CanFocus = true; + this.doTransformWidget.Name = "doTransformWidget"; + this.doTransformWidget.Label = global::Mono.Unix.Catalog.GetString ("transform output"); + this.doTransformWidget.DrawIndicator = true; + this.doTransformWidget.UseUnderline = true; + this.table1.Add (this.doTransformWidget); + global::Gtk.Table.TableChild w1 = ((global::Gtk.Table.TableChild)(this.table1 [this.doTransformWidget])); + w1.LeftAttach = ((uint)(1)); + w1.RightAttach = ((uint)(2)); + w1.XOptions = ((global::Gtk.AttachOptions)(4)); + w1.YOptions = ((global::Gtk.AttachOptions)(4)); + // Container child table1.Gtk.Table+TableChild + this.lblTransform = new global::IBBoard.GtkSharp.Translatable.TranslatableLabel (); + this.lblTransform.Sensitive = false; + this.lblTransform.Name = "lblTransform"; + this.lblTransform.Xalign = 1F; + this.lblTransform.LabelProp = global::Mono.Unix.Catalog.GetString ("transformation:"); + this.table1.Add (this.lblTransform); + global::Gtk.Table.TableChild w2 = ((global::Gtk.Table.TableChild)(this.table1 [this.lblTransform])); + w2.TopAttach = ((uint)(1)); + w2.BottomAttach = ((uint)(2)); + w2.XOptions = ((global::Gtk.AttachOptions)(4)); + w2.YOptions = ((global::Gtk.AttachOptions)(4)); + // Container child table1.Gtk.Table+TableChild + this.transformList = global::Gtk.ComboBox.NewText (); + this.transformList.Sensitive = false; + this.transformList.Name = "transformList"; + this.table1.Add (this.transformList); + global::Gtk.Table.TableChild w3 = ((global::Gtk.Table.TableChild)(this.table1 [this.transformList])); + w3.TopAttach = ((uint)(1)); + w3.BottomAttach = ((uint)(2)); + w3.LeftAttach = ((uint)(1)); + w3.RightAttach = ((uint)(2)); + w3.YOptions = ((global::Gtk.AttachOptions)(4)); + this.Add (this.table1); + if ((this.Child != null)) { + this.Child.ShowAll (); + } + this.Hide (); + this.transformList.Changed += new global::System.EventHandler (this.OnTransformListChanged); + this.doTransformWidget.Toggled += new global::System.EventHandler (this.OnDoTransformWidgetToggled); + } + } +} diff -r 42d2aa87dfa7 -r d4e6bfeb1c61 gtk-gui/gui.stetic --- a/gtk-gui/gui.stetic Sat Oct 01 14:52:39 2011 +0100 +++ b/gtk-gui/gui.stetic Sat Oct 01 16:19:48 2011 +0100 @@ -2532,185 +2532,30 @@ - + Dialog CenterOnParent + True + True 2 False + 2 - + - 4 - 2 - 6 - 6 - - - - - - - True - Transform output? - True - True - True - - - - 2 - 3 - 1 - 2 - True - Fill - Fill - False - True - False - False - True - False - - - - - - 1 - save as: - - - True - Fill - Fill - False - True - False - False - True - False - - - - - - 1 - in folder - - - 1 - 2 - True - Fill - Fill - False - True - False - False - True - False - - - - - - False - transform: - - - 3 - 4 - True - Fill - Fill - False - True - False - False - True - False - - - - - - True - True - - - - - 1 - 2 - True - Fill - Fill - False - True - False - False - True - False - - - - - - SelectFolder - 20 - True - - - - 1 - 2 - 1 - 2 - True - Fill - Fill - False - True - False - False - True - False - - - - - - False - True - - - - - 3 - 4 - 1 - 2 - False - Fill - True - True - False - False - True - False - - + Save + False + True + 0 - True - False - False + False @@ -2760,4 +2605,88 @@ + + + False + + + + 2 + 2 + 6 + 6 + + + + + + + True + transform output + True + True + True + + + + 1 + 2 + True + Fill + Fill + False + True + False + False + True + False + + + + + + False + 1 + transformation: + + + 1 + 2 + True + Fill + Fill + False + True + False + False + True + False + + + + + + False + True + + + + + 1 + 2 + 1 + 2 + False + Fill + True + True + False + False + True + False + + + + + \ No newline at end of file diff -r 42d2aa87dfa7 -r d4e6bfeb1c61 gtk-gui/objects.xml --- a/gtk-gui/objects.xml Sat Oct 01 14:52:39 2011 +0100 +++ b/gtk-gui/objects.xml Sat Oct 01 16:19:48 2011 +0100 @@ -1,2 +1,10 @@ + + + + + + + + \ No newline at end of file