Mercurial > repos > IBBoard.GtkSharp
changeset 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 | bcb437c04685 |
children | 50d774f164dd |
files | GtkSharp.cs IBBoard.GtkSharp.csproj NotebookUtil.cs |
diffstat | 3 files changed, 28 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- /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 + } +} +
--- 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 @@ <Compile Include="Translatable\TranslatableWindowWithActions.cs" /> <Compile Include="Translatable\TranslatableLabel.cs" /> <Compile Include="Translatable\TranslatableButton.cs" /> + <Compile Include="GtkSharp.cs" /> </ItemGroup> <ItemGroup> <None Include="COPYING.GPL" />
--- 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; } } }