# HG changeset patch # User IBBoard # Date 1251485106 0 # Node ID d92d11bd48085816405bb7f9e74d066d24c94ece # Parent 49307b998555ac114840f3d91bf91c470853ee38 * 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 diff -r 49307b998555 -r d92d11bd4808 NotebookUtil.cs --- a/NotebookUtil.cs Wed Jul 22 20:58:19 2009 +0000 +++ b/NotebookUtil.cs Fri Aug 28 18:45:06 2009 +0000 @@ -27,6 +27,26 @@ /// public static int AddPageToNotebookWithCloseButton(Notebook notebook, Widget page, string title) { + return notebook.AppendPage(page, CreateNotebookTabLabelWithClose(notebook, page, title)); + } + + /// + /// Creates a widget to be used as the label for a notebook tab with text and a close button + /// + /// + /// The the page is on + /// + /// + /// The that is the content of the page + /// + /// + /// The text to display on the tab + /// + /// + /// A that can be used as a tab label that contains the label with the title text and a close button + /// + public static Widget CreateNotebookTabLabelWithClose(Notebook notebook, Widget page,String title) + { HBox hbox = new HBox(); hbox.PackStart(new Label(title)); Button close = new Button(); @@ -40,12 +60,11 @@ close.BorderWidth = 0; close.Name = "NotebookTab.CloseButton"; close.Clicked += delegate { - hbox.Destroy(); - page.Destroy(); + notebook.Remove(page); }; hbox.PackStart(close); - hbox.ShowAll(); - return notebook.AppendPage(page, hbox); + hbox.ShowAll(); + return hbox; } } }