Author: lluis
Date: 2007-03-01 18:00:18 -0500 (Thu, 01 Mar 2007)
New Revision: 73618
Modified:
trunk/stetic/ChangeLog
trunk/stetic/libstetic/GladeUtils.cs
trunk/stetic/libstetic/ObjectReader.cs
trunk/stetic/libstetic/wrapper/Container.cs
Log:
* libstetic/ObjectReader.cs, libstetic/wrapper/Container.cs: Fixed
issues with internal children when importing a glade file.
* libstetic/GladeUtils.cs: Use invariant culture to parse floats.
Modified: trunk/stetic/ChangeLog
===================================================================
--- trunk/stetic/ChangeLog 2007-03-01 21:53:20 UTC (rev 73617)
+++ trunk/stetic/ChangeLog 2007-03-01 23:00:18 UTC (rev 73618)
@@ -1,3 +1,9 @@
+2007-03-02 Lluis Sanchez Gual <[EMAIL PROTECTED]>
+
+ * libstetic/ObjectReader.cs, libstetic/wrapper/Container.cs: Fixed
+ issues with internal children when importing a glade file.
+ * libstetic/GladeUtils.cs: Use invariant culture to parse floats.
+
2007-02-20 Lluis Sanchez Gual <[EMAIL PROTECTED]>
* libsteticui/ActionGroupEditSession.cs: Added null check.
Modified: trunk/stetic/libstetic/GladeUtils.cs
===================================================================
--- trunk/stetic/libstetic/GladeUtils.cs 2007-03-01 21:53:20 UTC (rev
73617)
+++ trunk/stetic/libstetic/GladeUtils.cs 2007-03-01 23:00:18 UTC (rev
73618)
@@ -225,9 +225,9 @@
case GLib.TypeFundamentals.TypeUInt64:
return new GLib.Value (UInt64.Parse (strval));
case GLib.TypeFundamentals.TypeFloat:
- return new GLib.Value (Single.Parse (strval));
+ return new GLib.Value (Single.Parse (strval,
System.Globalization.CultureInfo.InvariantCulture));
case GLib.TypeFundamentals.TypeDouble:
- return new GLib.Value (Double.Parse (strval));
+ return new GLib.Value (Double.Parse (strval,
System.Globalization.CultureInfo.InvariantCulture));
case GLib.TypeFundamentals.TypeString:
return new GLib.Value (strval);
default:
Modified: trunk/stetic/libstetic/ObjectReader.cs
===================================================================
--- trunk/stetic/libstetic/ObjectReader.cs 2007-03-01 21:53:20 UTC (rev
73617)
+++ trunk/stetic/libstetic/ObjectReader.cs 2007-03-01 23:00:18 UTC (rev
73618)
@@ -1,5 +1,6 @@
using System;
+using System.Collections;
using System.Xml;
namespace Stetic
@@ -8,6 +9,7 @@
{
FileFormat format;
IProject proj;
+ internal ArrayList GladeChildStack = new ArrayList ();
public ObjectReader (IProject proj, FileFormat format)
{
Modified: trunk/stetic/libstetic/wrapper/Container.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Container.cs 2007-03-01 21:53:20 UTC (rev
73617)
+++ trunk/stetic/libstetic/wrapper/Container.cs 2007-03-01 23:00:18 UTC (rev
73618)
@@ -291,6 +291,8 @@
protected virtual void ReadChildren (ObjectReader reader,
XmlElement elem)
{
+ int gladeChildStackPos = reader.GladeChildStack.Count;
+
foreach (XmlElement child_elem in elem.SelectNodes
("./child")) {
try {
if (child_elem.HasAttribute
("internal-child"))
@@ -299,17 +301,29 @@
ReadPlaceholder (reader,
child_elem);
else {
ObjectWrapper cw = ReadChild
(reader, child_elem);
+
// Set a temporary id used for
the undo/redo operations
- string cid =
child_elem.GetAttribute ("undoId");
- if (cid.Length > 0)
- ChildWrapper
((Widget)cw).UndoId = cid;
- else
- child_elem.SetAttribute
("undoId", ChildWrapper ((Widget)cw).UndoId);
+ ObjectWrapper ccw =
ChildWrapper ((Widget)cw);
+ if (ccw != null) {
+ string cid =
child_elem.GetAttribute ("undoId");
+ if (cid.Length > 0)
+ ChildWrapper
((Widget)cw).UndoId = cid;
+ else
+
child_elem.SetAttribute ("undoId", ChildWrapper ((Widget)cw).UndoId);
+ }
}
} catch (GladeException ge) {
Console.Error.WriteLine (ge.Message);
}
}
+
+ if (reader.Format == FileFormat.Glade) {
+ for (int n = reader.GladeChildStack.Count - 1;
n >= gladeChildStackPos; n--) {
+ ObjectWrapper ob = ReadInternalChild
(reader, (XmlElement) reader.GladeChildStack [n]);
+ if (ob != null)
+ reader.GladeChildStack.RemoveAt
(n);
+ }
+ }
string ds = elem.GetAttribute ("design-size");
if (ds.Length > 0) {
@@ -371,8 +385,15 @@
return wrapper;
}
}
-
- throw new GladeException ("Unrecognized internal child
name", Wrapped.GetType ().FullName, false, "internal-child", childId);
+
+ // In Glade, internal children may not be direct
children of the root container. This is handled in a special way.
+ if (reader.Format == FileFormat.Glade) {
+ if (!reader.GladeChildStack.Contains
(child_elem))
+ reader.GladeChildStack.Add (child_elem);
+ return null;
+ }
+ else
+ throw new GladeException ("Unrecognized
internal child name", Wrapped.GetType ().FullName, false, "internal-child",
childId);
}
public override XmlElement Write (ObjectWriter writer)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches