diff NotebookUtil.cs @ 30:c9e1ad81afbe

Re #26: Add GTK wrapper methods * Make notebook tabs closable with middle-click * Add extra util class with enumerations in - mouse buttons in events are just uint, not enumerated
author IBBoard <dev@ibboard.co.uk>
date Sat, 08 Jan 2011 16:37:41 +0000
parents 0a466c011016
children 50d774f164dd
line wrap: on
line diff
--- a/NotebookUtil.cs	Fri Dec 31 10:42:17 2010 +0000
+++ b/NotebookUtil.cs	Sat Jan 08 16:37:41 2011 +0000
@@ -47,7 +47,15 @@
 		/// </returns>
 		public static Widget CreateNotebookTabLabelWithClose(Notebook notebook, Widget page, String title)
 		{
+			EventBox eventBox = new EventBox();
 			HBox hbox = new HBox();
+			eventBox.Add(hbox);
+			eventBox.ButtonPressEvent += delegate(object o, ButtonPressEventArgs args) {
+				if (args.Event.Button == (uint)MouseButton.Middle)
+				{
+					notebook.Remove(page);
+				}
+			};
 			hbox.PackStart(new Label(title));
 			Button close = new Button();
 			Gtk.Rc.ParseString("style \"NotebookTab.CloseButton\" {\n GtkWidget::focus-padding = 0\n GtkWidget::focus-line-width = 0\n xthickness = 0\n ythickness = 0\n GtkButton::inner-border = {0,0,0,0}\n }\n");
@@ -62,9 +70,10 @@
 			close.Clicked += delegate {
 				notebook.Remove(page);
 			};
+
 			hbox.PackStart(close);			
 			hbox.ShowAll();	
-			return hbox;
+			return eventBox;
 		}
 	}
 }