Author: jacobilsoe
Date: 2007-06-22 10:24:17 -0400 (Fri, 22 Jun 2007)
New Revision: 80556

Modified:
   trunk/monodevelop/Core/src/MonoDevelop.Components/ChangeLog
   
trunk/monodevelop/Core/src/MonoDevelop.Components/MonoDevelop.Components/TabLabel.cs
Log:
* MonoDevelop.Components/TabLabel.cs: Added a CloseClicked event to
  encapsulate middle clicks on the tab and clicking the close button.
  Fixes bug #81890.

Modified: trunk/monodevelop/Core/src/MonoDevelop.Components/ChangeLog
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Components/ChangeLog 2007-06-22 
14:23:42 UTC (rev 80555)
+++ trunk/monodevelop/Core/src/MonoDevelop.Components/ChangeLog 2007-06-22 
14:24:17 UTC (rev 80556)
@@ -1,3 +1,9 @@
+2007-06-22  Jacob Ilsø Christensen <[EMAIL PROTECTED]> 
+
+       * MonoDevelop.Components/TabLabel.cs: Added a CloseClicked event to
+         encapsulate middle clicks on the tab and clicking the close button.
+         Fixes bug #81890.
+
 2007-06-11  Lluis Sanchez Gual <[EMAIL PROTECTED]> 
 
        * MonoDevelop.Components.Commands/CommandManager.cs: Setting the accel

Modified: 
trunk/monodevelop/Core/src/MonoDevelop.Components/MonoDevelop.Components/TabLabel.cs
===================================================================
--- 
trunk/monodevelop/Core/src/MonoDevelop.Components/MonoDevelop.Components/TabLabel.cs
        2007-06-22 14:23:42 UTC (rev 80555)
+++ 
trunk/monodevelop/Core/src/MonoDevelop.Components/MonoDevelop.Components/TabLabel.cs
        2007-06-22 14:24:17 UTC (rev 80556)
@@ -1,5 +1,6 @@
 //
-// Author: John Luke  <[EMAIL PROTECTED]>
+// Authors: John Luke  <[EMAIL PROTECTED]>
+//          Jacob Ilsø Christensen <[EMAIL PROTECTED]>
 // License: LGPL
 //
 
@@ -14,30 +15,34 @@
        {
                private Label title;
                private Gtk.Image icon;
-               private Button btn;
                private EventBox titleBox;
-               Tooltips tips;
+               private Tooltips tips;
                
                protected TabLabel (IntPtr p): base (p)
                {
                }
 
                public TabLabel (Label label, Gtk.Image icon) : base (false, 2)
-               {
-                       this.titleBox = new EventBox ();
-                       titleBox.VisibleWindow = false;
+               {       
+                       this.title = label;
                        this.icon = icon;
-                       this.PackStart (icon, false, true, 2);
+                       
+                       EventBox eventBox = new EventBox ();
+                       eventBox.VisibleWindow = false;                 
+                       eventBox.Add (icon);
+                       this.PackStart (eventBox, false, true, 2);
 
-                       title = label;
+                       titleBox = new EventBox ();
+                       titleBox.VisibleWindow = false;                 
                        titleBox.Add (title);
                        this.PackStart (titleBox, true, true, 0);
                        
-                       btn = new Button ();
-                       btn.Add (new Gtk.Image (GetType().Assembly, 
"MonoDevelop.Close.png"));
-                       btn.Relief = ReliefStyle.None;
-                       btn.SetSizeRequest (18, 18);
-                       this.PackStart (btn, false, false, 2);
+                       Button button = new Button ();
+                       button.Add (new Gtk.Image (GetType().Assembly, 
"MonoDevelop.Close.png"));
+                       button.Relief = ReliefStyle.None;
+                       button.SetSizeRequest (18, 18);
+                       button.Clicked += new EventHandler(ButtonClicked);
+                       this.PackStart (button, false, false, 2);
                        this.ClearFlag (WidgetFlags.CanFocus);
 
                        this.ShowAll ();
@@ -54,16 +59,32 @@
                        get { return icon; }
                        set { icon = value; }
                }
-
-               public Button Button
-               {
-                       get { return btn; }
-               }
                
+               public event EventHandler CloseClicked;
+                               
                public void SetTooltip (string tip, string desc)
                {
                        if (tips == null) tips = new Tooltips ();
                        tips.SetTip (titleBox, tip, desc);
                }
+               
+               protected override bool OnButtonReleaseEvent (EventButton evnt)
+               {
+                       if (evnt.Button == 2 && CloseClicked != null)
+                       {
+                               CloseClicked(this, null);
+                               return true;
+                       }
+                                                       
+                       return false;
+               }
+                                                       
+               private void ButtonClicked(object o, EventArgs eventArgs)
+               {
+                       if (CloseClicked != null)
+                       {
+                               CloseClicked(this, null);                       
        
+                       }
+               }
        }
 }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to