changeset 7:d92d11bd4808

* Refactor out "label with close button" creation to new method (useful for warfoundry:ticket:125) * Change close from deleting to removing page (fixes warfoundry:ticket:96) no-open-ticket
author IBBoard <dev@ibboard.co.uk>
date Fri, 28 Aug 2009 18:45:06 +0000
parents 49307b998555
children 14ce41d2f9bd
files NotebookUtil.cs
diffstat 1 files changed, 23 insertions(+), 4 deletions(-) [+]
line diff
     1.1 --- a/NotebookUtil.cs	Wed Jul 22 20:58:19 2009 +0000
     1.2 +++ b/NotebookUtil.cs	Fri Aug 28 18:45:06 2009 +0000
     1.3 @@ -27,6 +27,26 @@
     1.4  		/// </returns>
     1.5  		public static int AddPageToNotebookWithCloseButton(Notebook notebook, Widget page, string title)
     1.6  		{
     1.7 +			return notebook.AppendPage(page, CreateNotebookTabLabelWithClose(notebook, page, title)); 
     1.8 +		}
     1.9 +		
    1.10 +		/// <summary>
    1.11 +		/// Creates a widget to be used as the label for a notebook tab with text and a close button
    1.12 +		/// </summary>
    1.13 +		/// <param name="notebook">
    1.14 +		/// The <see cref="Notebook"/> the page is on
    1.15 +		/// </param>
    1.16 +		/// <param name="page">
    1.17 +		/// The <see cref="Widget"/> that is the content of the page
    1.18 +		/// </param>
    1.19 +		/// <param name="title">
    1.20 +		/// The text to display on the tab
    1.21 +		/// </param>
    1.22 +		/// <returns>
    1.23 +		/// A <see cref="Widget"/> that can be used as a tab label that contains the label with the title text and a close button
    1.24 +		/// </returns>
    1.25 +		public static Widget CreateNotebookTabLabelWithClose(Notebook notebook, Widget page,String title)
    1.26 +		{
    1.27  			HBox hbox = new HBox();
    1.28  			hbox.PackStart(new Label(title));			
    1.29  			Button close = new Button();
    1.30 @@ -40,12 +60,11 @@
    1.31  			close.BorderWidth = 0;
    1.32  			close.Name = "NotebookTab.CloseButton";			
    1.33  			close.Clicked += delegate {
    1.34 -			    hbox.Destroy();
    1.35 -			    page.Destroy();
    1.36 +				notebook.Remove(page);
    1.37  			};
    1.38  			hbox.PackStart(close);			
    1.39 -			hbox.ShowAll();			
    1.40 -			return notebook.AppendPage(page, hbox); 
    1.41 +			hbox.ShowAll();	
    1.42 +			return hbox;
    1.43  		}
    1.44  	}
    1.45  }