Mercurial > repos > IBBoard.WarFoundry.GUI.GTK
changeset 15:85db2c9a1546
Fixes #95: Can't re-open GTK# tabs
* Make Unit for UnitDisplayWidget visible as a property
* Hook in to Destroyed event of UnitDisplayWidget to remove it from the map of tabs
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 27 Jun 2009 20:13:21 +0000 |
parents | abbf8a3ac431 |
children | eafbe69303ec |
files | FrmMainWindow.cs Widgets/UnitDisplayWidget.cs |
diffstat | 2 files changed, 16 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/FrmMainWindow.cs Sat Jun 27 19:39:41 2009 +0000 +++ b/FrmMainWindow.cs Sat Jun 27 20:13:21 2009 +0000 @@ -130,7 +130,6 @@ PointsValueChangedMethod = new DoubleValChangedDelegate(OnPointsValueChanged); FailedUnitRequirementMethod = new FailedUnitRequirementDelegate(OnFailedUnitRequirement); UnitNameChangedMethod = new StringValChangedDelegate(OnUnitNameChanged); - logger.Debug("Initialising complete - trying to load default army or system"); //FIXME: Temporary hack to add paths and factories WarFoundryLoader.GetDefault().AddLoadDirectory(new DirectoryInfo(Constants.ExecutablePath + Constants.DirectoryString + "data")); @@ -147,6 +146,8 @@ { WarFoundryLoader.GetDefault().RegisterNonNativeFactory((INonNativeWarFoundryFactory)factory); } + + logger.Debug("Initialising complete - seeing if we can load default army or system"); if (args.Length == 1) { @@ -918,6 +919,7 @@ widget = new UnitDisplayWidget(unit, CommandStack); logger.Debug("Adding page for "+unit.Name); unitToWidgetMap[unit] = widget; + widget.Destroyed+= new EventHandler(UnitWidgetDestroyed); int pageNum = NotebookUtil.AddPageToNotebookWithCloseButton(unitsNotebook, widget, unit.Name); logger.Debug("Page added at index "+pageNum); unitsNotebook.ShowAll(); @@ -925,5 +927,13 @@ } } } + + private void UnitWidgetDestroyed(object sender, EventArgs e) + { + if (sender is UnitDisplayWidget) + { + unitToWidgetMap.Remove(((UnitDisplayWidget)sender).Unit); + } + } } }
--- a/Widgets/UnitDisplayWidget.cs Sat Jun 27 19:39:41 2009 +0000 +++ b/Widgets/UnitDisplayWidget.cs Sat Jun 27 20:13:21 2009 +0000 @@ -82,6 +82,11 @@ (cell as CellRendererText).Text = u.GetStatValue(column.Title); } } + + public IBBoard.WarFoundry.API.Objects.Unit Unit + { + get { return unit; } + } private void UnitNameChanged(WarFoundryObject obj, string oldValue, string newValue) {