[Monodevelop-patches-list] r2317 - trunk/MonoDevelop/Unused/Gdl

John Luke <jluke@cfl.rr.com> jluke at mono-cvs.ximian.com
Tue Mar 8 18:12:25 EST 2005


Author: jluke
Date: 2005-03-08 18:12:25 -0500 (Tue, 08 Mar 2005)
New Revision: 2317

Modified:
   trunk/MonoDevelop/Unused/Gdl/DockBar.cs
   trunk/MonoDevelop/Unused/Gdl/DockItem.cs
   trunk/MonoDevelop/Unused/Gdl/DockMaster.cs
   trunk/MonoDevelop/Unused/Gdl/DockPaned.cs
   trunk/MonoDevelop/Unused/Gdl/GdlDockTest.cs
Log:
make the dockbar closer to the original code


Modified: trunk/MonoDevelop/Unused/Gdl/DockBar.cs
===================================================================
--- trunk/MonoDevelop/Unused/Gdl/DockBar.cs	2005-03-08 19:59:41 UTC (rev 2316)
+++ trunk/MonoDevelop/Unused/Gdl/DockBar.cs	2005-03-08 23:12:25 UTC (rev 2317)
@@ -9,70 +9,96 @@
 	public class DockBar : VBox
 	{
 		DockMaster master;
-		Tooltips tooltips = new Tooltips ();
+		ArrayList items;
+		Tooltips tooltips;
 		
-		public DockBar ()
+		public DockBar (Dock dock)
 		{
+			items = new ArrayList ();
+			tooltips = new Tooltips ();
+			Master = dock.Master;
 		}
 		
 		public DockMaster Master {
-			get {
-				return master;
-			}
-			set {
-				master = value;
-			}
+			get { return master; }
+			set { this.Attach (value); }
 		}
 		
 		public void AddItem (DockItem item)
 		{
-			DockBarButton button = new DockBarButton (item);
-			button.DockButtonClicked += OnDockButtonClicked;
 			// check if already there
-			foreach (DockBarButton dbb in this.Children) {
-				if (item == dbb.DockItem) {
-					return;
-				}
+			if (items.Contains (item)) {
+				Console.WriteLine ("WARNING: Item has already been added to the dockbar");
+				return;
 			}
+
+			items.Add (item);
+
+			// create a button for the item
+			DockBarButton button = new DockBarButton (item);
+			this.PackStart (button, false, false, 0);
 			tooltips.SetTip (button, item.Name, item.Name);
 			item.DockBar = this;
 			item.DockBarButton = button;
-			this.PackStart (button, false, false, 0);
+			button.DockButtonClicked += OnDockButtonClicked;
 			this.ShowAll ();
 		}
 		
 		public void Attach (DockMaster master)
 		{
-			if (this.master != null)
-				master.LayoutChanged -= OnLayoutChanged;
+			if (master == null)
+				return;
 
+			master.LayoutChanged -= OnLayoutChanged;
+
 			this.master = master;
 			master.LayoutChanged += OnLayoutChanged;
 		}
+
+		public override void Destroy ()
+		{
+			if (master != null) {
+				master.LayoutChanged -= OnLayoutChanged;
+				master = null;
+			}
+
+			if (tooltips != null) {
+				tooltips = null;
+			}
+
+			base.Destroy ();
+		}
 		
 		public void RemoveItem (DockItem item)
 		{
 			// we can only remove if it is there
-			foreach (DockBarButton dbb in this.Children) {
-				if (dbb == item.DockBarButton) {
-					this.Remove (item.DockBarButton);
-					return;
-				}
+			if (items.Contains (item)) {
+				items.Remove (item);
+				this.Remove (item.DockBarButton);
+				// item.DockBarButton = null;
 			}
+			else {
+				Console.WriteLine ("WARNING: Item has not been added to the dockbar");
+			}
 		}
 		
 		void UpdateDockItems ()
 		{
+			if (master == null)
+				return;
+
 			foreach (object o in master.DockObjects)
 			{
 				DockItem item = o as DockItem;
 				if (item == null)
 					continue;
 
-				if (item.Iconified)
+				// in items but shouldn't be, remove it
+				if (items.Contains (item) && !item.Iconified)
+					this.RemoveItem (item);
+				// not in items but should be, add it
+				else if (!items.Contains (item) && item.Iconified)
 					this.AddItem (item);
-				else
-					this.RemoveItem (item);
 			}
 		}
 		

Modified: trunk/MonoDevelop/Unused/Gdl/DockItem.cs
===================================================================
--- trunk/MonoDevelop/Unused/Gdl/DockItem.cs	2005-03-08 19:59:41 UTC (rev 2316)
+++ trunk/MonoDevelop/Unused/Gdl/DockItem.cs	2005-03-08 23:12:25 UTC (rev 2317)
@@ -20,7 +20,8 @@
 		private int dragoffY = 0;
 		private Menu menu = null;
 		private DockItemGrip grip;
-		private Button dockButton;
+		private DockBar dockBar;
+		private DockBarButton dockButton;
 		private uint gripSize;
 		private Widget tabLabel = null;
 		private int preferredWidth = -1;
@@ -105,17 +106,13 @@
 				child = value;
 			}
 		}
-		
+
 		public DockBar DockBar {
-			get {
-				return Master.DockBar;
-			}
-			set {
-				Master.DockBar = value;	
-			}
+			get { return dockBar; }
+			set { dockBar = value; }
 		}
 		
-		public Button DockBarButton {
+		public DockBarButton DockBarButton {
 			get {
 				return dockButton;
 			}

Modified: trunk/MonoDevelop/Unused/Gdl/DockMaster.cs
===================================================================
--- trunk/MonoDevelop/Unused/Gdl/DockMaster.cs	2005-03-08 19:59:41 UTC (rev 2316)
+++ trunk/MonoDevelop/Unused/Gdl/DockMaster.cs	2005-03-08 23:12:25 UTC (rev 2317)
@@ -11,7 +11,6 @@
 		private Hashtable dockObjects = new Hashtable ();
 		private ArrayList toplevelDocks = new ArrayList ();
 		private DockObject controller = null;
-		private DockBar dockBar;
 		private int dockNumber = 1;
 		private int number = 1;
 		private string defaultTitle;
@@ -71,19 +70,6 @@
 			}
 		}
 
-		public DockBar DockBar {
-			get {
-				if (dockBar == null) {
-					dockBar = new DockBar ();
-					dockBar.Attach (this);
-				}
-				return dockBar;
-			}
-			set {
-				dockBar = value;
-			}
-		}
-		
 		protected void ForeachLockUnlock (DockItem item, bool locked)
 		{
 			item.Locked = locked;

Modified: trunk/MonoDevelop/Unused/Gdl/DockPaned.cs
===================================================================
--- trunk/MonoDevelop/Unused/Gdl/DockPaned.cs	2005-03-08 19:59:41 UTC (rev 2316)
+++ trunk/MonoDevelop/Unused/Gdl/DockPaned.cs	2005-03-08 23:12:25 UTC (rev 2317)
@@ -279,7 +279,7 @@
 			return mayDock;
 		}
 
-		void OnNotifyPosition (object sender, EventArgs a)
+		void OnNotifyPosition (object sender, GLib.NotifyArgs a)
 		{
 			Master.EmitLayoutChangedEvent ();
 		}

Modified: trunk/MonoDevelop/Unused/Gdl/GdlDockTest.cs
===================================================================
--- trunk/MonoDevelop/Unused/Gdl/GdlDockTest.cs	2005-03-08 19:59:41 UTC (rev 2316)
+++ trunk/MonoDevelop/Unused/Gdl/GdlDockTest.cs	2005-03-08 23:12:25 UTC (rev 2317)
@@ -26,7 +26,7 @@
 		Dock dock = new Dock ();		
 		layout = new DockLayout (dock);
 		layout.LoadFromFile ("layout.xml");
-		DockBar dockbar = dock.Master.DockBar;
+		DockBar dockbar = new DockBar (dock);
 		
 		Box box = new HBox (false, 5);
 		box.PackStart (dockbar, false, false, 0);




More information about the Monodevelop-patches-list mailing list