changeset 33:441cfc410987

Re #86: Complete GTK# UI * Make save buttons enable when a change has been made, whether the file was saved or not * Make the Save button default to "Save As" behaviour if the file hasn't been saved before * Make sure that loaded file path is kept and that it is wiped on file load
author IBBoard <dev@ibboard.co.uk>
date Sat, 26 Sep 2009 11:06:34 +0000
parents eab45344cd56
children a35c8be46006
files FrmMainWindow.cs
diffstat 1 files changed, 8 insertions(+), 12 deletions(-) [+]
line diff
     1.1 --- a/FrmMainWindow.cs	Mon Sep 21 19:17:27 2009 +0000
     1.2 +++ b/FrmMainWindow.cs	Sat Sep 26 11:06:34 2009 +0000
     1.3 @@ -391,7 +391,7 @@
     1.4  
     1.5  		protected virtual void OnSaveArmyActivated(object sender, System.EventArgs e)
     1.6  		{
     1.7 -			SaveCurrentArmy();
     1.8 +			SaveCurrentArmyOrSaveAs();
     1.9  		}
    1.10  
    1.11  		protected virtual void OnAddUnitActivated(object sender, System.EventArgs e)
    1.12 @@ -498,6 +498,7 @@
    1.13  			miCloseArmy.Sensitive = newArmy!=null;
    1.14  			miSaveArmyAs.Sensitive = newArmy!=null;
    1.15  			miExportArmy.Sensitive = newArmy!=null;
    1.16 +			loadedArmyPath = null;
    1.17  			//New army has no changes, so we can't save it
    1.18  			miSaveArmy.Sensitive = false;
    1.19  			saveArmyButton.Sensitive = false;
    1.20 @@ -677,18 +678,13 @@
    1.21  				//undoMenuButton.Tooltip = CommandStack.PeekUndoCommand().UndoDescription;
    1.22  			}
    1.23  
    1.24 -			saveArmyButton.Sensitive = commandStack.IsDirty() && WarFoundryCore.CurrentArmy!=null && CanSave();
    1.25 -			miSaveArmy.Sensitive = commandStack.IsDirty() && WarFoundryCore.CurrentArmy!=null && CanSave();
    1.26 -		}
    1.27 -
    1.28 -		private bool CanSave()
    1.29 -		{
    1.30 -			return loadedArmyPath!=null && WarFoundryCore.CurrentArmy!=null && WarFoundrySaver.GetSaver()!=null;
    1.31 +			saveArmyButton.Sensitive = commandStack.IsDirty() && WarFoundryCore.CurrentArmy!=null;
    1.32 +			miSaveArmy.Sensitive = commandStack.IsDirty() && WarFoundryCore.CurrentArmy!=null;
    1.33  		}
    1.34  
    1.35  		private bool SaveCurrentArmyOrSaveAs()
    1.36  		{
    1.37 -			if (CanSave())
    1.38 +			if (loadedArmyPath != null)
    1.39  			{
    1.40  				return SaveCurrentArmy();
    1.41  			}
    1.42 @@ -727,8 +723,8 @@
    1.43  				{
    1.44  					logger.Debug("Loaded army " + army.ID);
    1.45  					success = true;
    1.46 +					WarFoundryCore.CurrentArmy = army;
    1.47  					loadedArmyPath = filePath;
    1.48 -					WarFoundryCore.CurrentArmy = army;
    1.49  					logger.Debug("Army loading complete");
    1.50  				}
    1.51  				else
    1.52 @@ -753,7 +749,7 @@
    1.53  		{
    1.54  			bool success = false;
    1.55  
    1.56 -			if (CanSave())
    1.57 +			if (loadedArmyPath!=null)
    1.58  			{
    1.59  				success = SaveArmyToPath(WarFoundryCore.CurrentArmy, loadedArmyPath);
    1.60  			}
    1.61 @@ -917,7 +913,7 @@
    1.62  
    1.63  		protected virtual void saveTBButtonActivated (object sender, System.EventArgs e)
    1.64  		{
    1.65 -			SaveCurrentArmy();
    1.66 +			SaveCurrentArmyOrSaveAs();
    1.67  		}
    1.68  
    1.69  		protected virtual void openTBButtonActivated (object sender, System.EventArgs e)