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

John Luke <jluke@cfl.rr.com> jluke at mono-cvs.ximian.com
Tue Mar 1 19:24:55 EST 2005


Author: jluke
Date: 2005-03-01 19:24:55 -0500 (Tue, 01 Mar 2005)
New Revision: 2283

Modified:
   trunk/MonoDevelop/Unused/Gdl/DockLayout.cs
   trunk/MonoDevelop/Unused/Gdl/DockObjectFlags.cs
   trunk/MonoDevelop/Unused/Gdl/DockParamFlags.cs
   trunk/MonoDevelop/Unused/Gdl/GdlDockTest.cs
   trunk/MonoDevelop/Unused/Gdl/Makefile
Log:
small stuff


Modified: trunk/MonoDevelop/Unused/Gdl/DockLayout.cs
===================================================================
--- trunk/MonoDevelop/Unused/Gdl/DockLayout.cs	2005-03-01 23:58:20 UTC (rev 2282)
+++ trunk/MonoDevelop/Unused/Gdl/DockLayout.cs	2005-03-02 00:24:55 UTC (rev 2283)
@@ -1,34 +1,31 @@
-// created on 6/24/2004 at 7:39 PM
-
 using System;
 using System.Collections;
+using System.Xml;
+using System.Xml.Serialization;
 using Gtk;
 
 namespace Gdl
 {
-	// stub so I can compile in MD
 	public class DockLayout
 	{
 		DockMaster master;
 		Widget itemsui;
 		Widget layoutsui;
-		string[] layouts;
+		ArrayList layouts;
 		bool dirty;
-	
+		XmlDocument doc;
+
 		public DockLayout (Dock dock)
 		{
+			layouts = new ArrayList ();
+			this.Attach (dock.Master);
 		}
 		
 		public DockMaster Master {
-			get {
-				return master;
-			}
-			set {
-				master = value;
-			}
+			get { return master; }
+			set { master = value; }
 		}
 		
-		// generated had Dirty and IsDirty
 		public bool IsDirty {
 			get {
 				return dirty;
@@ -46,28 +43,87 @@
 				return layoutsui;
 			}
 		}
+
+		public string[] Layouts {
+			get {
+				return layouts.ToArray (typeof (string)) as string[];
+			}
+		}
 		
 		public void Attach (DockMaster master)
 		{
+			if (this.master != null)
+				master.LayoutChanged -= OnLayoutChanged;
+
 			this.master = master;
+			master.LayoutChanged += OnLayoutChanged;
 		}
 		
 		public void DeleteLayout (string name)
 		{
 		}
 	
-		public string[] GetLayouts (bool includeDefault)
-		{
-			return layouts;
-		}
-		
 		public void LoadLayout (string newLayout)
 		{
 		}
 		
 		public void LoadFromFile (string configFile)
 		{
+			doc = new XmlDocument ();
+			doc.Load (configFile);
+			XmlNodeList nodes = doc.SelectNodes ("/dock-layout/layout");
+			foreach (XmlNode n in nodes)
+				LoadLayout (n);
 		}
+
+		void LoadLayout (XmlNode node)
+		{
+			layouts.Add (node.Attributes["name"].Value);
+			LoadDock (node["dock"]);
+		}
+
+		void LoadDock (XmlNode node)
+		{
+			Dock dock = new Dock ();
+			foreach (XmlNode child in node.ChildNodes)
+			{
+				switch (child.Name) {
+					case "notebook":
+						LoadNotebook (child);
+						break;
+					default:
+						Console.WriteLine (child.Name);
+						break;
+				}
+			}	
+		}
+
+		void LoadNotebook (XmlNode node)
+		{
+			DockNotebook notebook = new DockNotebook ();
+			notebook.Orientation = node.Attributes ["orientation"].Value == "vertical" ? Orientation.Vertical : Orientation.Horizontal;
+			notebook.Page = int.Parse (node.Attributes ["page"].Value);
+
+			foreach (XmlNode child in node.ChildNodes)
+			{
+				switch (child.Name) {
+					case "item":
+						LoadItem (child);
+						break;
+					default:
+						Console.WriteLine (child.Name);
+						break;
+				}
+			}	
+		}
+
+		void LoadItem (XmlNode node)
+		{
+			string name = node.Attributes ["name"].Value;
+			string locked = node.Attributes ["locked"].Value;
+			DockItem item = new DockItem (name, name, DockItemBehavior.Normal);
+			item.Orientation = node.Attributes ["orientation"].Value == "vertical" ? Orientation.Vertical : Orientation.Horizontal;
+		}
 		
 		public void RunManager ()
 		{
@@ -79,6 +135,22 @@
 		
 		public void SaveToFile (string file)
 		{
+			XmlTextWriter writer = new XmlTextWriter (file, System.Text.Encoding.UTF8);
+			writer.Formatting = Formatting.Indented;
+			doc.WriteTo (writer);
 		}
+
+		public void Dump ()
+		{
+			XmlTextWriter writer = new XmlTextWriter (Console.Out);
+			writer.Formatting = Formatting.Indented;
+			doc.WriteTo (writer);
+		}
+
+		void OnLayoutChanged (object sender, EventArgs a)
+		{
+			Console.WriteLine ("layout changed");
+		}
 	}
-}
\ No newline at end of file
+}
+

Modified: trunk/MonoDevelop/Unused/Gdl/DockObjectFlags.cs
===================================================================
--- trunk/MonoDevelop/Unused/Gdl/DockObjectFlags.cs	2005-03-01 23:58:20 UTC (rev 2282)
+++ trunk/MonoDevelop/Unused/Gdl/DockObjectFlags.cs	2005-03-02 00:24:55 UTC (rev 2283)
@@ -2,6 +2,7 @@
 
 namespace Gdl
 {
+	[Serializable]
 	[Flags]
 	public enum DockObjectFlags
 	{

Modified: trunk/MonoDevelop/Unused/Gdl/DockParamFlags.cs
===================================================================
--- trunk/MonoDevelop/Unused/Gdl/DockParamFlags.cs	2005-03-01 23:58:20 UTC (rev 2282)
+++ trunk/MonoDevelop/Unused/Gdl/DockParamFlags.cs	2005-03-02 00:24:55 UTC (rev 2283)
@@ -2,6 +2,8 @@
 
 namespace Gdl
 {
+	[Serializable]
+	[Flags]
 	public enum DockParamFlags
 	{
 		Export = 1,

Modified: trunk/MonoDevelop/Unused/Gdl/GdlDockTest.cs
===================================================================
--- trunk/MonoDevelop/Unused/Gdl/GdlDockTest.cs	2005-03-01 23:58:20 UTC (rev 2282)
+++ trunk/MonoDevelop/Unused/Gdl/GdlDockTest.cs	2005-03-02 00:24:55 UTC (rev 2283)
@@ -4,6 +4,8 @@
 
 class T
 {
+	DockLayout layout;
+
 	static void Main (string[] args)
 	{
 		new T (args);
@@ -14,6 +16,7 @@
 		Application.Init ();
 		Window app = new Window ("test");
 		app.SetDefaultSize (400, 400);
+		app.WindowPosition = WindowPosition.Center;
 		app.DeleteEvent += new DeleteEventHandler (OnAppDelete);
 		
 		Box table = new VBox (false, 5);
@@ -21,7 +24,8 @@
 		app.Add (table);
 		
 		Dock dock = new Dock ();		
-		DockLayout layout = new DockLayout (dock);
+		layout = new DockLayout (dock);
+		layout.LoadFromFile ("layout.xml");
 		DockBar dockbar = dock.Master.DockBar;
 		
 		Box box = new HBox (false, 5);
@@ -38,9 +42,8 @@
 		di2.Add (new Button ("Button 2"));
 		dock.AddItem (di2, DockPlacement.Right);
 
-		DockItem di3 = new DockItem ("item3", "Item #3 has accented characters",/* (áéíóúñ)",*/
-					     Gtk.Stock.Convert, DockItemBehavior.Normal |
-					     DockItemBehavior.CantClose);
+		DockItem di3 = new DockItem ("item3", "Item #3 has accented characters (áéíóúñ)",
+					     Gtk.Stock.Convert, DockItemBehavior.Normal | DockItemBehavior.CantClose);
 		di3.Add (new Button ("Button 3"));
 		dock.AddItem (di3, DockPlacement.Bottom);
 
@@ -99,14 +102,17 @@
 	
 	private void OnSaveLayout (object o, EventArgs args)
 	{
+		layout.SaveToFile ("layout.xml");
 	}
 	
 	private void OnRunLayoutManager (object o, EventArgs args)
 	{
+		layout.RunManager ();
 	}
 	
 	private void OnDumpXML (object o, EventArgs args)
 	{
+		layout.Dump ();
 	}
 	
 	private void OnAppDelete (object o, DeleteEventArgs args)

Modified: trunk/MonoDevelop/Unused/Gdl/Makefile
===================================================================
--- trunk/MonoDevelop/Unused/Gdl/Makefile	2005-03-01 23:58:20 UTC (rev 2282)
+++ trunk/MonoDevelop/Unused/Gdl/Makefile	2005-03-02 00:24:55 UTC (rev 2283)
@@ -33,7 +33,7 @@
 	$(CSC) -out:$@ -target:library $(FILES) -pkg:gtk-sharp-2.0
 
 $(TEST) : GdlDockTest.cs $(GDL)
-	$(CSC) -out:$@ -r:$(GDL) -pkg:gtk-sharp-2.0 GdlDockTest.cs
+	$(CSC) -out:$@ -r:$(GDL) -pkg:gtk-sharp-2.0 GdlDockTest.cs -codepage:utf8
 
 run-test: $(TEST)
 	mono $(TEST)




More information about the Monodevelop-patches-list mailing list