Author: danw
Date: 2005-03-08 10:32:21 -0500 (Tue, 08 Mar 2005)
New Revision: 41571

Added:
   trunk/stetic/libstetic/GladeException.cs
   trunk/stetic/stetic/Glade.cs
Removed:
   trunk/stetic/stetic/GladeImport.cs
Modified:
   trunk/stetic/ChangeLog
   trunk/stetic/glue/value.c
   trunk/stetic/libstetic/GladeUtils.cs
   trunk/stetic/libstetic/Makefile.am
   trunk/stetic/libstetic/ObjectWrapper.cs
   trunk/stetic/libstetic/wrapper/Box.cs
   trunk/stetic/libstetic/wrapper/Container.cs
   trunk/stetic/stetic/Makefile.am
   trunk/stetic/stetic/Stetic.cs
Log:
        * libstetic/GladeException.cs: exception class for Glade import problems

        * libstetic/GladeUtils.cs:
        * libstetic/ObjectWrapper.cs:
        * libstetic/wrapper/Container.cs: use GladeException

        * libstetic/GladeUtils.cs (Hydrate): Call g_type_class_ref() and
        pass the GObjectClass* to the glue methods rather than the GType*
        (to save a bunch of lookups).

        * glue/value.c (stetic_g_value_init_for_property,
        stetic_g_value_init_for_child_property): Update for that

        * stetic/Glade.cs: renamed from GladeImport.cs
        (Import): renamed from Load. Use GladeException.

        * libstetic/wrapper/Box.cs (Sync): Fix to not crash on empty boxes


Modified: trunk/stetic/ChangeLog
===================================================================
--- trunk/stetic/ChangeLog      2005-03-08 14:22:15 UTC (rev 41570)
+++ trunk/stetic/ChangeLog      2005-03-08 15:32:21 UTC (rev 41571)
@@ -1,5 +1,25 @@
 2005-03-08  Dan Winship  <[EMAIL PROTECTED]>
 
+       * libstetic/GladeException.cs: exception class for Glade import problems
+
+       * libstetic/GladeUtils.cs:
+       * libstetic/ObjectWrapper.cs:
+       * libstetic/wrapper/Container.cs: use GladeException
+
+       * libstetic/GladeUtils.cs (Hydrate): Call g_type_class_ref() and
+       pass the GObjectClass* to the glue methods rather than the GType*
+       (to save a bunch of lookups).
+
+       * glue/value.c (stetic_g_value_init_for_property,
+       stetic_g_value_init_for_child_property): Update for that
+
+       * stetic/Glade.cs: renamed from GladeImport.cs
+       (Import): renamed from Load. Use GladeException.
+
+       * libstetic/wrapper/Box.cs (Sync): Fix to not crash on empty boxes
+
+2005-03-08  Dan Winship  <[EMAIL PROTECTED]>
+
        * libstetic/GladeUtils.cs (ExtractProperty, CreateWidget,
        SetProps, SetPacking): Make these all take a Hashtable of
        propname->value rather than a pair of ArrayLists.

Modified: trunk/stetic/glue/value.c
===================================================================
--- trunk/stetic/glue/value.c   2005-03-08 14:22:15 UTC (rev 41570)
+++ trunk/stetic/glue/value.c   2005-03-08 15:32:21 UTC (rev 41571)
@@ -5,34 +5,26 @@
 #include <glib-object.h>
 #include <gtk/gtkcontainer.h>
 
-gboolean stetic_g_value_init_for_property (GValue *value, GType gtype, const 
char *property_name);
-gboolean stetic_g_value_init_for_child_property (GValue *value, GType gtype, 
const char *property_name);
+gboolean stetic_g_value_init_for_property (GValue *value, GObjectClass *klass, 
const char *property_name);
+gboolean stetic_g_value_init_for_child_property (GValue *value, GObjectClass 
*klass, const char *property_name);
 gboolean stetic_g_value_hydrate (GValue *value, const char *data);
 
 gboolean
-stetic_g_value_init_for_property (GValue *value, GType gtype, const char 
*property_name)
+stetic_g_value_init_for_property (GValue *value, GObjectClass *klass, const 
char *property_name)
 {
-       GObjectClass *klass = g_type_class_ref (gtype);
        GParamSpec *spec = g_object_class_find_property (klass, property_name);
-       g_type_class_unref (klass);
-       if (!spec)
-               return FALSE;
-
-       g_value_init (value, spec->value_type);
-       return TRUE;
+       if (spec)
+               g_value_init (value, spec->value_type);
+       return spec != NULL;
 }
 
 gboolean
-stetic_g_value_init_for_child_property (GValue *value, GType gtype, const char 
*property_name)
+stetic_g_value_init_for_child_property (GValue *value, GObjectClass *klass, 
const char *property_name)
 {
-       GtkContainerClass *klass = g_type_class_ref (gtype);
-       GParamSpec *spec = gtk_container_class_find_child_property 
(G_OBJECT_CLASS(klass), property_name);
-       g_type_class_unref (klass);
-       if (!spec)
-               return FALSE;
-
-       g_value_init (value, spec->value_type);
-       return TRUE;
+       GParamSpec *spec = gtk_container_class_find_child_property 
(G_OBJECT_CLASS (klass), property_name);
+       if (spec)
+               g_value_init (value, spec->value_type);
+       return spec != NULL;
 }
 
 gboolean

Added: trunk/stetic/libstetic/GladeException.cs
===================================================================
--- trunk/stetic/libstetic/GladeException.cs    2005-03-08 14:22:15 UTC (rev 
41570)
+++ trunk/stetic/libstetic/GladeException.cs    2005-03-08 15:32:21 UTC (rev 
41571)
@@ -0,0 +1,73 @@
+using System;
+
+namespace Stetic {
+
+       public class GladeException : ApplicationException {
+
+               public GladeException (string message) : base (message) { }
+
+               public GladeException (string message, string className) : this 
(message)
+               {
+                       this.className = className;
+               }
+
+               public GladeException (string message, string className,
+                                      bool childprop, string propName, string 
propVal) : this (message, className)
+               {
+                       this.childprop = childprop;
+                       this.propName = propName;
+                       this.propVal = propVal;
+               }
+
+               string className, propName, propVal;
+               bool childprop;
+
+               public string ClassName {
+                       get {
+                               return className;
+                       }
+                       set {
+                               className = value;
+                       }
+               }
+
+               public bool ChildProp {
+                       get {
+                               return childprop;
+                       }
+                       set {
+                               childprop = value;
+                       }
+               }
+
+               public string PropName {
+                       get {
+                               return propName;
+                       }
+                       set {
+                               propName = value;
+                       }
+               }
+
+               public string PropVal {
+                       get {
+                               return propVal;
+                       }
+                       set {
+                               propVal = value;
+                       }
+               }
+
+               public override string ToString ()
+               {
+                       if (className == null)
+                               return Message;
+                       else if (propName == null)
+                               return Message + " (class " + className + ")";
+                       else if (propVal == null)
+                               return Message + " (class " + className + ", " 
+ (childprop ? "child " : "") + "property " + propName + ")";
+                       else
+                               return Message + " (class " + className + ", " 
+ (childprop ? "child " : "") + "property " + propName + ", value " + propVal + 
")";
+               }
+       }
+}

Modified: trunk/stetic/libstetic/GladeUtils.cs
===================================================================
--- trunk/stetic/libstetic/GladeUtils.cs        2005-03-08 14:22:15 UTC (rev 
41570)
+++ trunk/stetic/libstetic/GladeUtils.cs        2005-03-08 15:32:21 UTC (rev 
41571)
@@ -14,30 +14,18 @@
                        return value;
                }
 
-               [DllImport("libsteticglue")]
-               static extern bool stetic_g_value_init_for_property (ref 
GLib.Value value, IntPtr gtype, string propertyName);
-
-               [DllImport("libsteticglue")]
-               static extern bool stetic_g_value_init_for_child_property (ref 
GLib.Value value, IntPtr gtype, string propertyName);
-
-               [DllImport("libsteticglue")]
-               static extern bool stetic_g_value_hydrate (ref GLib.Value 
value, string data);
-
-               static bool Hydrate (IntPtr gtype, bool childprop, string name, 
string strval, out GLib.Value value)
+               static void Hydrate (IntPtr klass, bool childprop, string name, 
string strval, out GLib.Value value)
                {
                        value = new GLib.Value ();
-                       bool inited = false;
+                       bool inited;
 
                        if (childprop)
-                               inited = stetic_g_value_init_for_child_property 
(ref value, gtype, name);
+                               inited = stetic_g_value_init_for_child_property 
(ref value, klass, name);
                        else
-                               inited = stetic_g_value_init_for_property (ref 
value, gtype, name);
+                               inited = stetic_g_value_init_for_property (ref 
value, klass, name);
 
-                       if (!inited) {
-                               Console.WriteLine ("Unrecognized {0}property 
name '{1}'",
-                                                  childprop ? "child " : "", 
name);
-                               return false;
-                       }
+                       if (!inited)
+                               throw new GladeException ("Unrecognized 
property name", null, childprop, name, strval);
 
                        if (name == "adjustment") {
                                try {
@@ -52,24 +40,21 @@
                                        page_size = Double.Parse (vals[5]);
 
                                        value.Val = new Gtk.Adjustment (deflt, 
min, max, step, page_inc, page_size);
-                                       return true;
+                                       return;
                                } catch {
                                        ;
                                }
                        }
 
-                       if (!stetic_g_value_hydrate (ref value, strval)) {
-                               Console.WriteLine ("Could not hydrate 
{0}property '{1}' with value '{2}'",
-                                                  childprop ? "child " : "", 
name, strval);
-                               return false;
-                       }
-
-                       return true;
+                       if (!stetic_g_value_hydrate (ref value, strval))
+                               throw new GladeException ("Could not hydrate 
property", null, childprop, name, strval);
                }
 
                static void HydrateProperties (IntPtr gtype, bool childprops, 
Hashtable props,
                                               out string[] propNames, out 
GLib.Value[] propVals)
                {
+                       IntPtr klass = g_type_class_ref (gtype);
+
                        ArrayList names = new ArrayList ();
                        ArrayList values = new ArrayList ();
 
@@ -77,25 +62,22 @@
                                string strval = props[name] as string;
 
                                GLib.Value value;
-                               if (Hydrate (gtype, childprops, name, strval, 
out value)) {
+                               try {
+                                       Hydrate (klass, childprops, name, 
strval, out value);
                                        names.Add (name);
                                        values.Add (value);
+                               } catch (GladeException ge) {
+                                       ge.ClassName = Marshal.PtrToStringAnsi 
(g_type_name (gtype));
+                                       Console.Error.WriteLine (ge);
                                }
                        }
 
                        propNames = (string[])names.ToArray (typeof (string));
                        propVals = (GLib.Value[])values.ToArray (typeof 
(GLib.Value));
+
+                       g_type_class_unref (klass);
                }
 
-               [DllImport("libgobject-2.0-0.dll")]
-               static extern IntPtr g_type_from_name (string name);
-
-               [DllImport("glibsharpglue-2")]
-               static extern IntPtr gtksharp_object_newv (IntPtr gtype, int 
n_params, string[] names, GLib.Value[] vals);
-
-               [DllImport("libgtk-win32-2.0-0.dll")]
-               static extern void gtk_object_sink (IntPtr raw);
-
                static public Gtk.Widget CreateWidget (string className, 
Hashtable props)
                {
                        IntPtr gtype = g_type_from_name (className);
@@ -105,26 +87,18 @@
                        HydrateProperties (gtype, false, props, out propNames, 
out propVals);
 
                        IntPtr raw = gtksharp_object_newv (gtype, 
propNames.Length, propNames, propVals);
-                       if (raw == IntPtr.Zero) {
-                               Console.WriteLine ("Could not create widget of 
type {0}", className);
-                               return null;
-                       }
+                       if (raw == IntPtr.Zero)
+                               throw new GladeException ("Could not create 
widget", className);
 
                        Gtk.Widget widget = (Gtk.Widget)GLib.Object.GetObject 
(raw, true);
                        if (widget == null) {
-                               Console.WriteLine ("Could not create gtk# 
wrapper for type {0}", className);
                                gtk_object_sink (raw);
+                               throw new GladeException ("Could not create 
gtk# wrapper", className);
                        }
 
                        return widget;
                }
 
-               [DllImport("glibsharpglue-2")]
-               static extern IntPtr gtksharp_get_type_id (IntPtr obj);
-
-               [DllImport("libgobject-2.0-0.dll")]
-               static extern void g_object_set_property (IntPtr obj, string 
name, ref GLib.Value val);
-
                static public void SetProps (Gtk.Widget widget, Hashtable props)
                {
                        string[] propNames;
@@ -146,5 +120,38 @@
                        for (int i = 0; i < propNames.Length; i++)
                                parent.ChildSetProperty (child, propNames[i], 
propVals[i]);
                }
+
+               [DllImport("libsteticglue")]
+               static extern bool stetic_g_value_init_for_property (ref 
GLib.Value value, IntPtr klass, string propertyName);
+
+               [DllImport("libsteticglue")]
+               static extern bool stetic_g_value_init_for_child_property (ref 
GLib.Value value, IntPtr klass, string propertyName);
+
+               [DllImport("libsteticglue")]
+               static extern bool stetic_g_value_hydrate (ref GLib.Value 
value, string data);
+
+               [DllImport("libgobject-2.0-0.dll")]
+               static extern IntPtr g_type_name (IntPtr gtype);
+
+               [DllImport("libgobject-2.0-0.dll")]
+               static extern IntPtr g_type_from_name (string name);
+
+               [DllImport("libgobject-2.0-0.dll")]
+               static extern IntPtr g_type_class_ref (IntPtr gtype);
+
+               [DllImport("libgobject-2.0-0.dll")]
+               static extern void g_type_class_unref (IntPtr gtype);
+
+               [DllImport("glibsharpglue-2")]
+               static extern IntPtr gtksharp_object_newv (IntPtr gtype, int 
n_params, string[] names, GLib.Value[] vals);
+
+               [DllImport("libgtk-win32-2.0-0.dll")]
+               static extern void gtk_object_sink (IntPtr raw);
+
+               [DllImport("glibsharpglue-2")]
+               static extern IntPtr gtksharp_get_type_id (IntPtr obj);
+
+               [DllImport("libgobject-2.0-0.dll")]
+               static extern void g_object_set_property (IntPtr obj, string 
name, ref GLib.Value val);
        }
 }

Modified: trunk/stetic/libstetic/Makefile.am
===================================================================
--- trunk/stetic/libstetic/Makefile.am  2005-03-08 14:22:15 UTC (rev 41570)
+++ trunk/stetic/libstetic/Makefile.am  2005-03-08 15:32:21 UTC (rev 41571)
@@ -6,6 +6,7 @@
        DescriptionAttribute.cs         \
        DND.cs                          \
        EditorAttribute.cs              \
+       GladeException.cs               \
        GladeUtils.cs                   \
        ItemDescriptor.cs               \
        ItemGroup.cs                    \

Modified: trunk/stetic/libstetic/ObjectWrapper.cs
===================================================================
--- trunk/stetic/libstetic/ObjectWrapper.cs     2005-03-08 14:22:15 UTC (rev 
41570)
+++ trunk/stetic/libstetic/ObjectWrapper.cs     2005-03-08 15:32:21 UTC (rev 
41571)
@@ -109,15 +109,15 @@
                {
                        Type type = (Type)wrapperTypes[className];
                        if (type == null)
-                               return null;
+                               throw new GladeException ("No Stetic wrapper 
for type", className);
 
                        MethodInfo info = type.GetMethod ("GladeImport", 
BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                        if (info == null)
-                               return null;
+                               throw new GladeException ("No Import method for 
type " + type.FullName, className);
 
                        ObjectWrapper wrapper = Activator.CreateInstance (type) 
as ObjectWrapper;
                        if (wrapper == null)
-                               return null;
+                               throw new GladeException ("Can't create wrapper 
for type " + type.FullName, className);
                        wrapper.stetic = stetic;
                        info.Invoke (wrapper, new object[] { className, id, 
props });
                        return wrapper;

Modified: trunk/stetic/libstetic/wrapper/Box.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Box.cs       2005-03-08 14:22:15 UTC (rev 
41570)
+++ trunk/stetic/libstetic/wrapper/Box.cs       2005-03-08 15:32:21 UTC (rev 
41571)
@@ -56,6 +56,8 @@
                        Gdk.Rectangle alloc = box.Allocation;
 
                        site.ClearFaults ();
+                       if (sorted.Length == 0)
+                               return;
 
                        if (this is HBox) {
                                if (sorted[0] != null)

Modified: trunk/stetic/libstetic/wrapper/Container.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Container.cs 2005-03-08 14:22:15 UTC (rev 
41570)
+++ trunk/stetic/libstetic/wrapper/Container.cs 2005-03-08 15:32:21 UTC (rev 
41571)
@@ -50,9 +50,6 @@
                                                        Hashtable props, 
Hashtable childprops)
                {
                        ObjectWrapper wrapper = 
Stetic.ObjectWrapper.GladeImport (stetic, className, id, props);
-                       if (wrapper == null)
-                               return null;
-
                        Gtk.Widget child = (Gtk.Widget)wrapper.Wrapped;
 
                        if (container.ChildType () == Gtk.Widget.GType) {
@@ -97,9 +94,6 @@
                                        return child;
                                ancestor = ancestor.Parent as Gtk.Container;
                        }
-
-                       Console.WriteLine ("Could not find internal child {0} 
of {1}",
-                                          childName, container);
                        return null;
                }
 
@@ -108,7 +102,7 @@
                {
                        Gtk.Widget widget = FindInternalChild (childName);
                        if (widget == null)
-                               return null;
+                               throw new GladeException ("Unrecognized 
internal child name", className, false, "internal-child", childName);
 
                        widget.Name = id;
                        GladeUtils.SetProps (widget, props);

Copied: trunk/stetic/stetic/Glade.cs (from rev 41568, 
trunk/stetic/stetic/GladeImport.cs)
===================================================================
--- trunk/stetic/stetic/GladeImport.cs  2005-03-08 13:53:41 UTC (rev 41568)
+++ trunk/stetic/stetic/Glade.cs        2005-03-08 15:32:21 UTC (rev 41571)
@@ -0,0 +1,110 @@
+using System;
+using System.Xml;
+using System.Collections;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+using Gtk;
+
+namespace Stetic {
+
+       public static class Glade {
+
+               public const string Glade20SystemId = 
"http://glade.gnome.org/glade-2.0.dtd";;
+
+               public static void Import (string filename, Project project)
+               {
+                       XmlDocument doc = new XmlDocument ();
+                       doc.PreserveWhitespace = true;
+
+                       XmlTextReader reader = null;
+                       try {
+                               reader = new XmlTextReader (filename);
+                               doc.Load (reader);
+                       } catch {
+                               return;
+                       } finally {
+                               if (reader != null)
+                                       reader.Close ();
+                       }
+
+                       XmlDocumentType doctype = doc.DocumentType;
+                       if (doctype == null ||
+                           doctype.Name != "glade-interface" ||
+                           doctype.SystemId != Glade20SystemId)
+                               throw new ApplicationException ("Not a glade 
file according to doctype");
+
+                       XmlNode node;
+
+                       node = doc.SelectSingleNode ("/glade-interface");
+                       if (node == null)
+                               throw new ApplicationException ("Not a glade 
file according to node name");
+
+                       project.BeginGladeImport ();
+                       foreach (XmlNode toplevel in node.SelectNodes 
("widget")) {
+                               Widget w = CreateWidget (project, null, null, 
toplevel);
+                               if (w == null)
+                                       continue;
+                               project.AddWindow (w);
+                               WindowSite site = new WindowSite 
((Gtk.Window)w);
+                               site.FocusChanged += delegate (WindowSite site, 
IWidgetSite focus) {
+                                       if (focus == null)
+                                               SteticMain.NoSelection ();
+                                       else
+                                               SteticMain.Select (focus);
+                               };
+                       }
+                       project.EndGladeImport ();
+               }
+
+               [DllImport("libsteticglue")]
+               static extern bool stetic_g_value_init_for_child_property (ref 
GLib.Value value, string className, string propertyName);
+
+               static Widget CreateWidget (Project project, 
Stetic.Wrapper.Container parent, XmlNode thischild, XmlNode widget)
+               {
+                       string className = widget.Attributes["class"].Value;
+                       string id = widget.Attributes["id"].Value;
+
+                       Hashtable props;
+                       ExtractProperties (widget.SelectNodes ("property"), out 
props);
+
+                       ObjectWrapper wrapper;
+                       try {
+                               if (thischild == null) {
+                                       wrapper = 
Stetic.ObjectWrapper.GladeImport (project, className, id, props);
+                               } else if 
(thischild.Attributes["internal-child"] != null) {
+                                       wrapper = parent.GladeSetInternalChild 
(thischild.Attributes["internal-child"].Value,
+                                                                               
className, id, props);
+                               } else {
+                                       Hashtable childprops;
+                                       ExtractProperties 
(thischild.SelectNodes ("packing/property"), out childprops);
+                                       wrapper = parent.GladeImportChild 
(className, id, props, childprops);
+                               }
+                       } catch (GladeException ge) {
+                               Console.Error.WriteLine ("Could not import 
widget: {0}", ge);
+                               return null;
+                       }
+
+                       Stetic.Wrapper.Container container = wrapper as 
Stetic.Wrapper.Container;
+                       if (container != null) {
+                               foreach (XmlNode child in widget.SelectNodes 
("child")) {
+                                       widget = child.SelectSingleNode 
("widget");
+
+                                       if (widget == null)
+                                               container.AddPlaceholder ();
+                                       else
+                                               CreateWidget (project, 
container, child, widget);
+                               }
+                       }
+
+                       return (Gtk.Widget)wrapper.Wrapped;
+               }
+
+               static void ExtractProperties (XmlNodeList nodes, out Hashtable 
props)
+               {
+                       props = new Hashtable ();
+                       foreach (XmlNode prop in nodes)
+                               props[prop.Attributes["name"].Value] = 
prop.InnerText;
+               }
+       }
+}

Deleted: trunk/stetic/stetic/GladeImport.cs
===================================================================
--- trunk/stetic/stetic/GladeImport.cs  2005-03-08 14:22:15 UTC (rev 41570)
+++ trunk/stetic/stetic/GladeImport.cs  2005-03-08 15:32:21 UTC (rev 41571)
@@ -1,114 +0,0 @@
-using System;
-using System.Xml;
-using System.Collections;
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-using Gtk;
-
-namespace Stetic {
-
-       public class GladeImport {
-
-               static WidgetFactory empty_istetic;
-
-               public const string Glade20SystemId = 
"http://glade.gnome.org/glade-2.0.dtd";;
-
-               static MethodInfo setProperty = typeof (GLib.Object).GetMethod 
("SetProperty", BindingFlags.NonPublic | BindingFlags.Instance);
-               
-               public static void Load (string filename, Project project)
-               {
-                       XmlDocument doc = new XmlDocument ();
-                       doc.PreserveWhitespace = true;
-
-                       XmlTextReader reader = null;
-                       try {
-                               reader = new XmlTextReader (filename);
-                               doc.Load (reader);
-                       } catch {
-                               return;
-                       } finally {
-                               if (reader != null)
-                                       reader.Close ();
-                       }
-
-                       XmlDocumentType doctype = doc.DocumentType;
-                       if (doctype == null ||
-                           doctype.Name != "glade-interface" ||
-                           doctype.SystemId != Glade20SystemId)
-                               throw new ApplicationException ("Not a glade 
file according to doctype");
-
-                       XmlNode node;
-
-                       node = doc.SelectSingleNode ("/glade-interface");
-                       if (node == null)
-                               throw new ApplicationException ("Not a glade 
file according to node name");
-
-                       project.BeginGladeImport ();
-                       foreach (XmlNode toplevel in node.SelectNodes 
("widget")) {
-                               Widget w = CreateWidget (project, null, null, 
toplevel);
-                               if (w == null)
-                                       continue;
-                               project.AddWindow (w);
-                               WindowSite site = new WindowSite 
((Gtk.Window)w);
-                               site.FocusChanged += delegate (WindowSite site, 
IWidgetSite focus) {
-                                       if (focus == null)
-                                               SteticMain.NoSelection ();
-                                       else
-                                               SteticMain.Select (focus);
-                               };
-                       }
-                       project.EndGladeImport ();
-               }
-
-               [DllImport("libsteticglue")]
-               static extern bool stetic_g_value_init_for_child_property (ref 
GLib.Value value, string className, string propertyName);
-
-               static Widget CreateWidget (Project project, 
Stetic.Wrapper.Container parent, XmlNode thischild, XmlNode widget)
-               {
-                       string className = widget.Attributes["class"].Value;
-                       string id = widget.Attributes["id"].Value;
-
-                       Hashtable props;
-                       ExtractProperties (widget.SelectNodes ("property"), out 
props);
-
-                       ObjectWrapper wrapper;
-                       if (thischild == null) {
-                               wrapper = Stetic.ObjectWrapper.GladeImport 
(project, className, id, props);
-                       } else if (thischild.Attributes["internal-child"] != 
null) {
-                               wrapper = parent.GladeSetInternalChild 
(thischild.Attributes["internal-child"].Value,
-                                                                       
className, id, props);
-                       } else {
-                               Hashtable childprops;
-                               ExtractProperties (thischild.SelectNodes 
("packing/property"), out childprops);
-                               wrapper = parent.GladeImportChild (className, 
id, props, childprops);
-                       }
-
-                       if (wrapper == null) {
-                               Console.WriteLine ("Could not create stetic 
wrapper for type {0}", className);
-                               return null;
-                       }
-
-                       Stetic.Wrapper.Container container = wrapper as 
Stetic.Wrapper.Container;
-                       if (container != null) {
-                               foreach (XmlNode child in widget.SelectNodes 
("child")) {
-                                       widget = child.SelectSingleNode 
("widget");
-
-                                       if (widget == null)
-                                               container.AddPlaceholder ();
-                                       else
-                                               CreateWidget (project, 
container, child, widget);
-                               }
-                       }
-
-                       return (Gtk.Widget)wrapper.Wrapped;
-               }
-
-               static void ExtractProperties (XmlNodeList nodes, out Hashtable 
props)
-               {
-                       props = new Hashtable ();
-                       foreach (XmlNode prop in nodes)
-                               props[prop.Attributes["name"].Value] = 
prop.InnerText;
-               }
-       }
-}

Modified: trunk/stetic/stetic/Makefile.am
===================================================================
--- trunk/stetic/stetic/Makefile.am     2005-03-08 14:22:15 UTC (rev 41570)
+++ trunk/stetic/stetic/Makefile.am     2005-03-08 15:32:21 UTC (rev 41571)
@@ -3,7 +3,7 @@
 
 stetic_exe_SOURCES =                   \
        ContextMenu.cs                  \
-       GladeImport.cs                  \
+       Glade.cs                        \
        Grid.cs                         \
        Palette.cs                      \
        Project.cs                      \

Modified: trunk/stetic/stetic/Stetic.cs
===================================================================
--- trunk/stetic/stetic/Stetic.cs       2005-03-08 14:22:15 UTC (rev 41570)
+++ trunk/stetic/stetic/Stetic.cs       2005-03-08 15:32:21 UTC (rev 41571)
@@ -75,7 +75,7 @@
                        FileChooserDialog dialog = new FileChooserDialog ("Load 
glade file", null, FileChooserAction.Open, Gtk.Stock.Cancel, 
Gtk.ResponseType.Cancel, Gtk.Stock.Open, Gtk.ResponseType.Ok);
                        int response = dialog.Run ();
                        if (response == (int)Gtk.ResponseType.Ok) {
-                               GladeImport.Load (dialog.Filename, Project);
+                               Glade.Import (dialog.Filename, Project);
                        }
                        dialog.Hide ();
                }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to