[MonoDevelop] Patch + Idea

Ben Motmans Ben Motmans <ben.motmans@gmail.com>
Fri, 4 Mar 2005 01:58:28 +0100


------=_Part_2564_29575007.1109897908646
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

hi,

First of all, the patch adds a right-click menu to all the tablabels
of the open file notebook, giving the options
   - Close
   - Close All
   - Close All but this

Now, my idea

since i think the way how scrolling in a Gtk.Notebook is handled, is
just bad, i was having some ideas how to display a list of open tabs
(so you can navigate quickly in a big project)

1) Add a "Jump to" menuitem to the same popup menu

2) Add an arrow to the notebook (see notebook_mockup.png)
but, is this possible without messing around in the Gtk+ source code ?

secondly, once you got the list of open windows, how should it be displayed

1) sorted list
SomeClass.cs
SomeClass.cs (from another project in the solution)
SomeOtherClass.cs
...

2) list sorted by project and by filename
MonoDevelop.Base
   SomeClass.cs
   SomeOtherClass.cs
MonoDevelop.Core
   SomeClass.cs

-- Ben

------=_Part_2564_29575007.1109897908646
Content-Type: text/x-patch; name="tablabel.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="tablabel.diff"

Index: Core/src/MonoDevelop.Gui.Widgets/TabLabel/TabLabel.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- Core/src/MonoDevelop.Gui.Widgets/TabLabel/TabLabel.cs=09(revision 2289)
+++ Core/src/MonoDevelop.Gui.Widgets/TabLabel/TabLabel.cs=09(working copy)
@@ -1,5 +1,7 @@
 //
-// Author: John Luke  <jluke@cfl.rr.com>
+// Authors:
+//    John Luke  <jluke@cfl.rr.com>
+//    Ben Motmans  <ben.motmans@gmail.com>
 // License: LGPL
 //
=20
@@ -10,30 +12,97 @@
=20
 namespace MonoDevelop.Gui.Widgets
 {
+=09
+=09public delegate void RightClickHandler (TabLabel tabLabel);
+=09public delegate void PopupMenuCloseHandler (TabLabel tabLabel);
+
 =09public class TabLabel : HBox
 =09{
 =09=09private static GLib.GType gtype;
 =09=09private Label title;
 =09=09private Gtk.Image icon;
 =09=09private Button btn;
+
+=09=09private ImageMenuItem popupMenuClose;
+=09=09private ImageMenuItem popupMenuCloseAll;
+=09=09private ImageMenuItem popupMenuCloseAllButThis;
+=09=09private Menu popupMenu;
+
+=09=09private HBox hbox;
+=09=09private EventBox eventBox;
+
+=09=09public event RightClickHandler RightClick;
+=09=09public event PopupMenuCloseHandler MenuClose;
+=09=09public event PopupMenuCloseHandler MenuCloseAll;
+=09=09public event PopupMenuCloseHandler MenuCloseAllButThis;
 =09=09
 =09=09public TabLabel (Label label, Gtk.Image icon) : base (false, 2)
 =09=09{
+=09=09=09popupMenu =3D new Menu ();
+
+=09=09=09popupMenuClose =3D new ImageMenuItem ("Close");
+=09=09=09popupMenuCloseAll =3D new ImageMenuItem ("Close All");
+=09=09=09popupMenuCloseAllButThis =3D new ImageMenuItem ("Close All but th=
is");
+
+=09=09=09popupMenuClose.Image =3D new Gtk.Image ("gtk-close", IconSize.Men=
u);
+=09=09=09popupMenuCloseAll.Image =3D new Gtk.Image ("gtk-close", IconSize.=
Menu);
+=09=09=09popupMenuCloseAllButThis.Image =3D new Gtk.Image ("gtk-close", Ic=
onSize.Menu);
+
+=09=09=09popupMenuClose.Activated +=3D new EventHandler (PopupMenuClose);
+=09=09=09popupMenuCloseAll.Activated +=3D new EventHandler (PopupMenuClose=
All);
+=09=09=09popupMenuCloseAllButThis.Activated +=3D new EventHandler (PopupMe=
nuCloseAllButThis);
+
+=09=09=09popupMenu.Append (popupMenuClose);
+=09=09=09popupMenu.Append (popupMenuCloseAll);
+=09=09=09popupMenu.Append (popupMenuCloseAllButThis);
+
+=09=09=09hbox =3D new HBox (false, 2);
+
 =09=09=09this.icon =3D icon;
-=09=09=09this.PackStart (icon, false, true, 2);
+=09=09=09hbox.PackStart (icon, false, true, 2);
=20
 =09=09=09title =3D label;
-=09=09=09this.PackStart (title, true, true, 0);
+=09=09=09hbox.PackStart (label, true, true, 0);
+
+=09=09=09eventBox =3D new EventBox ();
+=09=09=09eventBox.Add (hbox);
+=09=09=09eventBox.ButtonPressEvent +=3D new ButtonPressEventHandler (Butto=
nPress);
+=09=09=09this.PackStart (eventBox, true, true, 0);
 =09=09=09
 =09=09=09btn =3D new Button ();
 =09=09=09btn.Add (new Gtk.Image ("../data/resources/icons/MonoDevelop.Clos=
e.png"));
 =09=09=09btn.Relief =3D ReliefStyle.None;
 =09=09=09btn.SetSizeRequest (18, 18);
+
 =09=09=09this.PackStart (btn, false, false, 2);
 =09=09=09this.ClearFlag (WidgetFlags.CanFocus);
=20
 =09=09=09this.ShowAll ();
 =09=09}
+
+=09=09void ButtonPress (object o, ButtonPressEventArgs e) {
+=09=09=09if (e.Event.Button =3D=3D 3)
+=09=09=09=09if (RightClick !=3D null)
+=09=09=09=09=09RightClick (this);
+=09=09}
+
+=09=09void PopupMenuClose (object o, EventArgs e)
+=09=09{
+=09=09=09if (MenuClose !=3D null)
+=09=09=09=09MenuClose (this);
+=09=09}
+
+=09=09void PopupMenuCloseAll (object o, EventArgs e)
+=09=09{
+=09=09=09if (MenuCloseAll !=3D null)
+=09=09=09=09MenuCloseAll (this);
+=09=09}
+
+=09=09void PopupMenuCloseAllButThis (object o, EventArgs e)
+=09=09{
+=09=09=09if (MenuCloseAllButThis !=3D null)
+=09=09=09=09MenuCloseAllButThis (this);
+=09=09}
 =09=09
 =09=09public Label Label
 =09=09{
@@ -51,5 +120,10 @@
 =09=09{
 =09=09=09get { return btn; }
 =09=09}
+
+=09=09public Menu RightClickMenu
+=09=09{
+=09=09=09get { return popupMenu; }
+=09=09}
 =09}
 }
Index: Core/src/MonoDevelop.Gui.Widgets/ChangeLog
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- Core/src/MonoDevelop.Gui.Widgets/ChangeLog=09(revision 2289)
+++ Core/src/MonoDevelop.Gui.Widgets/ChangeLog=09(working copy)
@@ -1,3 +1,8 @@
+2005-03-04  Ben Motmans  <ben.motmans@gmail.com>
+
+=09* TabLabel/TabLabel.cs:
+=09Popup menu when right-clicking
+
 2005-01-31  John Luke  <john.luke@gmail.com>
=20
 =09* FileBrowser/FileBrowser.cs: use ToolItem
Index: Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceLayout.c=
s
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs=
=09(revision 2289)
+++ Core/src/MonoDevelop.Base/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs=
=09(working copy)
@@ -447,16 +447,53 @@
 =09=09=09TabLabel tabLabel =3D new TabLabel (new Label (), mimeimage !=3D =
null ? mimeimage : new Gtk.Image (""));
 =09=09=09tabLabel.Button.Clicked +=3D new EventHandler (closeClicked);
 =09=09=09tabLabel.Button.StateChanged +=3D new StateChangedHandler (stateC=
hanged);
+=09=09=09tabLabel.MenuClose +=3D new PopupMenuCloseHandler (PopupMenuClose=
);
+=09=09=09tabLabel.MenuCloseAll +=3D new PopupMenuCloseHandler (PopupMenuCl=
oseAll);
+=09=09=09tabLabel.MenuCloseAllButThis +=3D new PopupMenuCloseHandler (Popu=
pMenuCloseAllButThis);
+=09=09=09tabLabel.RightClick +=3D new RightClickHandler (RightClickTabLabe=
l);
 =09=09=09tabLabel.ClearFlag (WidgetFlags.CanFocus);
 =09=09=09SdiWorkspaceWindow sdiWorkspaceWindow =3D new SdiWorkspaceWindow(=
content, tabControl, tabLabel);
=20
 =09=09=09sdiWorkspaceWindow.CloseEvent +=3D new EventHandler(CloseWindowEv=
ent);
 =09=09=09tabControl.InsertPage (sdiWorkspaceWindow, tabLabel, -1);
-=09=09
+
 =09=09=09tabControl.ShowAll();
+
 =09=09=09return sdiWorkspaceWindow;
 =09=09}
=20
+=09=09void PopupMenuClose (TabLabel tabLabel)
+=09=09{
+=09=09=09foreach (Widget child in tabControl.Children) {
+=09=09=09=09if (tabControl.GetTabLabel (child) =3D=3D tabLabel) {
+=09=09=09=09=09workbench.ViewContentCollection [tabControl.PageNum (child)=
].WorkbenchWindow.CloseWindow (false, false, tabControl.PageNum (child));
+=09=09=09=09=09break;
+=09=09=09=09}
+=09=09=09}
+=09=09}
+
+=09=09void PopupMenuCloseAll (TabLabel tabLabel)
+=09=09{
+=09=09=09foreach (Widget child in tabControl.Children) {
+=09=09=09=09workbench.ViewContentCollection [tabControl.PageNum (child)].W=
orkbenchWindow.CloseWindow (false, false, tabControl.PageNum (child));
+=09=09=09}
+=09=09}
+
+=09=09void PopupMenuCloseAllButThis (TabLabel tabLabel)
+=09=09{
+=09=09=09foreach (Widget child in tabControl.Children) {
+=09=09=09=09if (tabControl.GetTabLabel (child) !=3D tabLabel) {
+=09=09=09=09=09workbench.ViewContentCollection [tabControl.PageNum (child)=
].WorkbenchWindow.CloseWindow (false, false, tabControl.PageNum (child));
+=09=09=09=09}
+=09=09=09}
+=09=09}
+
+=09=09void RightClickTabLabel (TabLabel tabLabel)
+=09=09{
+=09=09=09tabLabel.RightClickMenu.Popup (null, null, null, IntPtr.Zero, 3, =
Gtk.Global.CurrentEventTime);
+=09=09=09tabLabel.RightClickMenu.ShowAll ();
+=09=09}
+
 =09=09void stateChanged (object o, StateChangedArgs e)
 =09=09{
 =09=09=09if (((Gtk.Widget)o).State =3D=3D Gtk.StateType.Active)
Index: Core/src/MonoDevelop.Base/ChangeLog
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- Core/src/MonoDevelop.Base/ChangeLog=09(revision 2289)
+++ Core/src/MonoDevelop.Base/ChangeLog=09(working copy)
@@ -1,3 +1,8 @@
+2005-03-04  Ben Motmans  <ben.motmans@gmail.com>
+
+=09* Gui/Workbench/Layouts/SdiWorkspaceLayout.cs:
+=09Handlers for right-click menu of the TabLabels
+
 2005-02-26  Poul Andersen  <pba@mailme.dk>
 =09* Services/MessageService.cs: Added ShowMessage(string message, Gtk.Win=
dow parent )
 =09to ensure modal messagebox as window on top.

------=_Part_2564_29575007.1109897908646
Content-Type: image/png; name="notebook_mockup.png"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="notebook_mockup.png"

iVBORw0KGgoAAAANSUhEUgAAAFUAAAA8CAYAAAAXDvbIAAAABmJLR0QA/wD/AP+gvaeTAAAACXBI
WXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH1QMEACwP72u8hAAAA7NJREFUeNrt2r9LOmEcB/C3dUNk
xFFN0g9oqIQ4i4IKrA4HIaL+hhxqilvjSsiGftBWUEtLkDUENRRyTRo4WOIQTdkQDS5FmDkcVNZ9
hy+K+aNOvbTs8wbB5/S58173PM89d6dOlmUFFE0SCAQwNDSECqLQPoRKqIRKqBRCJVRCpRAqof6R
MIF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