[Monodevelop-patches-list] r2296 - trunk/MonoDevelop/Unused/Gdl
John Luke <jluke@cfl.rr.com>
jluke at mono-cvs.ximian.com
Sun Mar 6 20:50:01 EST 2005
Author: jluke
Date: 2005-03-06 20:50:01 -0500 (Sun, 06 Mar 2005)
New Revision: 2296
Modified:
trunk/MonoDevelop/Unused/Gdl/Dock.cs
trunk/MonoDevelop/Unused/Gdl/DockItem.cs
trunk/MonoDevelop/Unused/Gdl/DockLayout.cs
trunk/MonoDevelop/Unused/Gdl/DockNotebook.cs
trunk/MonoDevelop/Unused/Gdl/DockObject.cs
trunk/MonoDevelop/Unused/Gdl/DockPaned.cs
trunk/MonoDevelop/Unused/Gdl/Makefile
Log:
some serialization stuff
Modified: trunk/MonoDevelop/Unused/Gdl/Dock.cs
===================================================================
--- trunk/MonoDevelop/Unused/Gdl/Dock.cs 2005-03-07 00:00:16 UTC (rev 2295)
+++ trunk/MonoDevelop/Unused/Gdl/Dock.cs 2005-03-07 01:50:01 UTC (rev 2296)
@@ -86,6 +86,7 @@
DockObjectFlags |= DockObjectFlags.Attached;
}
+ [ExportLayout]
public bool Floating {
get {
return floating;
@@ -94,7 +95,8 @@
floating = value;
}
}
-
+
+ [ExportLayout]
public int FloatX {
get {
return floatX;
@@ -106,6 +108,7 @@
}
}
+ [ExportLayout]
public int FloatY {
get {
return floatY;
@@ -117,6 +120,7 @@
}
}
+ [ExportLayout]
public int Height {
get {
return height;
@@ -160,6 +164,7 @@
}
}
+ [ExportLayout]
public int Width {
get { return width; }
set {
Modified: trunk/MonoDevelop/Unused/Gdl/DockItem.cs
===================================================================
--- trunk/MonoDevelop/Unused/Gdl/DockItem.cs 2005-03-07 00:00:16 UTC (rev 2295)
+++ trunk/MonoDevelop/Unused/Gdl/DockItem.cs 2005-03-07 01:50:01 UTC (rev 2296)
@@ -177,6 +177,7 @@
}
}
+ [ExportLayout]
public bool Locked {
get {
return ((behavior & DockItemBehavior.Locked) != 0);
@@ -196,6 +197,7 @@
}
}
+ [ExportLayout]
public Orientation Orientation {
get {
return orientation;
Modified: trunk/MonoDevelop/Unused/Gdl/DockLayout.cs
===================================================================
--- trunk/MonoDevelop/Unused/Gdl/DockLayout.cs 2005-03-07 00:00:16 UTC (rev 2295)
+++ trunk/MonoDevelop/Unused/Gdl/DockLayout.cs 2005-03-07 01:50:01 UTC (rev 2296)
@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.IO;
+using System.Reflection;
using System.Xml;
using Gtk;
@@ -20,6 +21,7 @@
Widget itemsUI, layoutsUI;
DockMaster master = null;
ArrayList layouts;
+ Hashtable placeholders;
CheckButton locked_check;
@@ -63,6 +65,14 @@
}
}
+ private Hashtable Placeholders {
+ get {
+ if (placeholders == null)
+ placeholders = new Hashtable ();
+ return placeholders;
+ }
+ }
+
public Widget UI {
get { return ConstructUI ();}
}
@@ -200,12 +210,12 @@
this.RootNode.RemoveChild (node);
// create the new node
- XmlNode newNode = doc.CreateNode (XmlNodeType.Element, "layout", null);
- ((XmlElement) newNode).SetAttribute ("name", name);
- this.RootNode.AppendChild (newNode);
+ XmlElement element = doc.CreateElement ("layout");
+ element.SetAttribute ("name", name);
+ this.RootNode.AppendChild (element);
// save the layout
- Save (node);
+ Save (element);
dirty = true;
// notify dirty
}
@@ -240,8 +250,7 @@
{
doc = new XmlDocument ();
doc.CreateXmlDeclaration ("1.0", null, null);
- XmlNode root = doc.CreateNode (XmlNodeType.Element, "dock-layout", null);
- doc.AppendChild (root);
+ doc.AppendChild (doc.CreateElement ("dock-layout"));
}
XmlNode FindLayout (string name)
@@ -510,11 +519,49 @@
RecursiveBuild (node, null);
}
- void ForeachObjectSave (DockObject obj)
+ string GetXmlName (Type t)
{
+ switch (t.ToString ()) {
+ case "Gdl.Dock":
+ return "dock";
+ case "Gdl.DockItem":
+ return "item";
+ case "Gdl.DockNotebook":
+ return "notebook";
+ case "Gdl.DockPaned":
+ return "paned";
+ default:
+ return "object";
+ }
+ }
+
+ void ForeachObjectSave (DockObject obj, XmlNode parent)
+ {
if (obj == null)
return;
+ XmlElement element = doc.CreateElement (GetXmlName (obj.GetType ()));
+
+ // get object exported attributes
+ ArrayList exported = new ArrayList ();
+ PropertyInfo[] props = obj.GetType ().GetProperties (BindingFlags.Public | BindingFlags.Instance);
+ foreach (PropertyInfo p in props) {
+ if (p.IsDefined (typeof (ExportLayoutAttribute), true))
+ exported.Add (p);
+ }
+
+ foreach (PropertyInfo p in exported)
+ element.SetAttribute (p.Name.ToLower (), p.GetValue (obj, null).ToString ());
+
+ parent.AppendChild (element);
+
+ // save placeholders for the object
+ if (!(obj is DockPlaceholder)) {
+ //object list = this.Placeholders[obj];
+ //foreach (DockObject child in list)
+ // ForeachObjectSave (child);
+ }
+
// recurse the object if appropriate
if (obj.IsCompound) {
DockObject child;
@@ -522,7 +569,7 @@
{
child = w as DockObject;
if (child != null)
- ForeachObjectSave (child);
+ ForeachObjectSave (child, element);
}
}
}
@@ -530,12 +577,22 @@
void AddPlaceholder (DockObject obj, Hashtable placeholders)
{
if (obj is DockPlaceholder) {
- Console.WriteLine ("AddPlaceholder");
+ // FIXME:
+ // add the current placeholder to the list of placeholders for that host
}
}
void Save (XmlNode node)
{
+ // FIXME: implement this?
+ // build the placeholder's hash: the hash keeps lists of
+ // placeholders associated to each object, so that we can save the
+ // placeholders when we are saving the object (since placeholders
+ // don't show up in the normal widget hierarchy)
+
+ // save the layout recursively
+ foreach (DockObject o in master.TopLevelDocks)
+ ForeachObjectSave (o, node);
}
bool IdleSave ()
Modified: trunk/MonoDevelop/Unused/Gdl/DockNotebook.cs
===================================================================
--- trunk/MonoDevelop/Unused/Gdl/DockNotebook.cs 2005-03-07 00:00:16 UTC (rev 2295)
+++ trunk/MonoDevelop/Unused/Gdl/DockNotebook.cs 2005-03-07 01:50:01 UTC (rev 2296)
@@ -195,6 +195,7 @@
get { return true; }
}
+ [ExportLayout]
public int Page {
get { return ((Notebook)Child).CurrentPage; }
set { ((Notebook)Child).CurrentPage = value; }
Modified: trunk/MonoDevelop/Unused/Gdl/DockObject.cs
===================================================================
--- trunk/MonoDevelop/Unused/Gdl/DockObject.cs 2005-03-07 00:00:16 UTC (rev 2295)
+++ trunk/MonoDevelop/Unused/Gdl/DockObject.cs 2005-03-07 01:50:01 UTC (rev 2296)
@@ -99,6 +99,7 @@
}
}
+ [ExportLayout]
public new string Name {
get {
return name;
Modified: trunk/MonoDevelop/Unused/Gdl/DockPaned.cs
===================================================================
--- trunk/MonoDevelop/Unused/Gdl/DockPaned.cs 2005-03-07 00:00:16 UTC (rev 2295)
+++ trunk/MonoDevelop/Unused/Gdl/DockPaned.cs 2005-03-07 01:50:01 UTC (rev 2296)
@@ -34,6 +34,7 @@
}
}
+ [ExportLayout]
public int Position {
get {
if (Child != null && Child is Paned) {
Modified: trunk/MonoDevelop/Unused/Gdl/Makefile
===================================================================
--- trunk/MonoDevelop/Unused/Gdl/Makefile 2005-03-07 00:00:16 UTC (rev 2295)
+++ trunk/MonoDevelop/Unused/Gdl/Makefile 2005-03-07 01:50:01 UTC (rev 2296)
@@ -29,7 +29,8 @@
DockObject.cs \
Dock.cs \
DockPaned.cs \
- DockItemBehavior.cs
+ DockItemBehavior.cs \
+ ExportLayoutAttribute.cs
all: $(GDL) $(TEST)
More information about the Monodevelop-patches-list
mailing list