# HG changeset patch # User IBBoard # Date 1294504661 0 # Node ID c9e1ad81afbe9d926988a22e30ef8e67b46d0427 # Parent bcb437c046854b19e07611f3d2425fbafecd3372 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 diff -r bcb437c04685 -r c9e1ad81afbe GtkSharp.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GtkSharp.cs Sat Jan 08 16:37:41 2011 +0000 @@ -0,0 +1,17 @@ +// This file (GtkSharp.cs) is a part of the IBBoard.GtkSharp project and is copyright 2011 IBBoard +// +// // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. + +using System; + +namespace IBBoard.GtkSharp +{ + //Define mouse buttons as constants according to documentation + public enum MouseButton + { + Left = 1, + Middle = 2, + Right = 3 + } +} + diff -r bcb437c04685 -r c9e1ad81afbe IBBoard.GtkSharp.csproj --- a/IBBoard.GtkSharp.csproj Fri Dec 31 10:42:17 2010 +0000 +++ b/IBBoard.GtkSharp.csproj Sat Jan 08 16:37:41 2011 +0000 @@ -40,6 +40,7 @@ + diff -r bcb437c04685 -r c9e1ad81afbe NotebookUtil.cs --- 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 @@ /// 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; } } }