Author: danw
Date: 2005-03-08 15:08:45 -0500 (Tue, 08 Mar 2005)
New Revision: 41578

Added:
   trunk/stetic/libstetic/GladePropertyAttribute.cs
Modified:
   trunk/stetic/ChangeLog
   trunk/stetic/libstetic/GladeUtils.cs
   trunk/stetic/libstetic/Makefile.am
   trunk/stetic/libstetic/ObjectWrapper.cs
   trunk/stetic/libstetic/PropertyDescriptor.cs
   trunk/stetic/libstetic/wrapper/ComboBox.cs
   trunk/stetic/libstetic/wrapper/Container.cs
   trunk/stetic/libstetic/wrapper/Entry.cs
   trunk/stetic/libstetic/wrapper/Label.cs
   trunk/stetic/libstetic/wrapper/TextView.cs
   trunk/stetic/libstetic/wrapper/Widget.cs
   trunk/stetic/libstetic/wrapper/Window.cs
Log:
        * libstetic/GladePropertyAttribute.cs: new attribute to mark
        properties that need special treatment for glade import/export (to
        allow us to do the special treatment automatically rather than
        needing custom GladeImport/GladeExport routines).
        (GladeProperty): flags type for GladePropertyAttribute. Currently
        defines Proxied (meaning that an alternate property is actually
        used for glade import/export) and LateImport (meaning that on
        import, the property shouldn't be set until the import has
        completed).

        * libstetic/PropertyDescriptor.cs: track glade-related info
        (GladeFlags, GladeName): new accessors
        (GladeProxyGetValue, GladeProxySetValue): getter/setter for glade
        proxy properties

        * libstetic/GladeUtils.cs (ImportWidget): replace CreateWidget and
        SetProps with two new ImportWidget methods that also handle
        [GladeProperty] properties.

        * libstetic/ObjectWrapper.cs (GladeImport): if the GladeImport
        invocation throws a TargetInvocationException, throw its
        InnerException (presumably a GladeException) up to the caller.

        * libstetic/wrapper/ComboBox.cs (Items): add
        GladePropertyAttribute noting that this is glade's "items"
        property.
        (GladeImport): simplify

        * libstetic/wrapper/Container.cs (GladeSetInternalChild): update.

        * libstetic/wrapper/Entry.cs (InvisibleChar): add this, with a
        GladePropertyAttribute marking GladeInvisibleChar as its proxy
        (GladeInvisibleChar): get/set InvisibleChar as a string
        (GladeImport): gone

        * libstetic/wrapper/Label.cs (MnemonicWidget): add this, with a
        GladePropertyAttribute marking GladeMnemonicWidget as its
        LateImport proxy
        (GladeMnemonicWidget): get/set MnemonicWidget as a string
        (GladeImport): gone

        * libstetic/wrapper/TextView.cs (Text): add a
        GladePropertyAttribute noting that this is glade's "text"
        property.
        (GladeImport): gone

        * libstetic/wrapper/Widget.cs (Visible, HasDefault): add
        GladePropertyAttributes. (HasDefault is LateImport)
        (GladeImport): simplified
        
        * libstetic/wrapper/Window.cs (Modal, TypeHint, Type): add
        GladePropertyAttributes
        (GladeImport): gone


Modified: trunk/stetic/ChangeLog
===================================================================
--- trunk/stetic/ChangeLog      2005-03-08 19:36:46 UTC (rev 41577)
+++ trunk/stetic/ChangeLog      2005-03-08 20:08:45 UTC (rev 41578)
@@ -1,5 +1,61 @@
 2005-03-08  Dan Winship  <[EMAIL PROTECTED]>
 
+       * libstetic/GladePropertyAttribute.cs: new attribute to mark
+       properties that need special treatment for glade import/export (to
+       allow us to do the special treatment automatically rather than
+       needing custom GladeImport/GladeExport routines).
+       (GladeProperty): flags type for GladePropertyAttribute. Currently
+       defines Proxied (meaning that an alternate property is actually
+       used for glade import/export) and LateImport (meaning that on
+       import, the property shouldn't be set until the import has
+       completed).
+
+       * libstetic/PropertyDescriptor.cs: track glade-related info
+       (GladeFlags, GladeName): new accessors
+       (GladeProxyGetValue, GladeProxySetValue): getter/setter for glade
+       proxy properties
+
+       * libstetic/GladeUtils.cs (ImportWidget): replace CreateWidget and
+       SetProps with two new ImportWidget methods that also handle
+       [GladeProperty] properties.
+
+       * libstetic/ObjectWrapper.cs (GladeImport): if the GladeImport
+       invocation throws a TargetInvocationException, throw its
+       InnerException (presumably a GladeException) up to the caller.
+
+       * libstetic/wrapper/ComboBox.cs (Items): add
+       GladePropertyAttribute noting that this is glade's "items"
+       property.
+       (GladeImport): simplify
+
+       * libstetic/wrapper/Container.cs (GladeSetInternalChild): update.
+
+       * libstetic/wrapper/Entry.cs (InvisibleChar): add this, with a
+       GladePropertyAttribute marking GladeInvisibleChar as its proxy
+       (GladeInvisibleChar): get/set InvisibleChar as a string
+       (GladeImport): gone
+
+       * libstetic/wrapper/Label.cs (MnemonicWidget): add this, with a
+       GladePropertyAttribute marking GladeMnemonicWidget as its
+       LateImport proxy
+       (GladeMnemonicWidget): get/set MnemonicWidget as a string
+       (GladeImport): gone
+
+       * libstetic/wrapper/TextView.cs (Text): add a
+       GladePropertyAttribute noting that this is glade's "text"
+       property.
+       (GladeImport): gone
+
+       * libstetic/wrapper/Widget.cs (Visible, HasDefault): add
+       GladePropertyAttributes. (HasDefault is LateImport)
+       (GladeImport): simplified
+       
+       * libstetic/wrapper/Window.cs (Modal, TypeHint, Type): add
+       GladePropertyAttributes
+       (GladeImport): gone
+
+2005-03-08  Dan Winship  <[EMAIL PROTECTED]>
+
        * libstetic/WidgetSite.cs (SetupFaults): Pass "false" to DND.DestSet,
        not true, so that the whole widget isn't drop-on-able.
        (AddHFault, AddVFault): don't create windows if we're not realized.

Added: trunk/stetic/libstetic/GladePropertyAttribute.cs
===================================================================
--- trunk/stetic/libstetic/GladePropertyAttribute.cs    2005-03-08 19:36:46 UTC 
(rev 41577)
+++ trunk/stetic/libstetic/GladePropertyAttribute.cs    2005-03-08 20:08:45 UTC 
(rev 41578)
@@ -0,0 +1,44 @@
+using System;
+
+namespace Stetic {
+
+       [Flags]
+       public enum GladeProperty {
+               Wrapped    = (1 << 0),
+               Proxied    = (1 << 1),
+               LateImport = (1 << 2)
+       }
+
+       [AttributeUsage (AttributeTargets.Property)]
+       public sealed class GladePropertyAttribute : Attribute {
+
+               public GladePropertyAttribute () : this (0) { }
+               public GladePropertyAttribute (GladeProperty flags) 
+               {
+                       this.flags = flags | GladeProperty.Wrapped;
+               }
+
+               GladeProperty flags;
+               public GladeProperty Flags {
+                       get { return flags; }
+               }
+
+               string name;
+               public string Name {
+                       get { return name; }
+                       set { name = value; }
+               }
+
+               string proxy;
+               public string Proxy {
+                       get { return proxy; }
+                       set {
+                               proxy = value;
+                               if (proxy != null)
+                                       flags |= GladeProperty.Proxied;
+                               else
+                                       flags &= ~GladeProperty.Proxied;
+                       }
+               }
+       }
+}

Modified: trunk/stetic/libstetic/GladeUtils.cs
===================================================================
--- trunk/stetic/libstetic/GladeUtils.cs        2005-03-08 19:36:46 UTC (rev 
41577)
+++ trunk/stetic/libstetic/GladeUtils.cs        2005-03-08 20:08:45 UTC (rev 
41578)
@@ -14,6 +14,27 @@
                        return value;
                }
 
+               static void ExtractWrapperProperties (ObjectWrapper wrapper, 
Hashtable props, 
+                                                     out Hashtable wProps)
+               {
+                       wProps = null;
+
+                       foreach (ItemGroup group in wrapper.ItemGroups) {
+                               foreach (ItemDescriptor item in group.Items) {
+                                       PropertyDescriptor prop = item as 
PropertyDescriptor;
+                                       if (prop == null || prop.GladeName == 
null)
+                                               continue;
+
+                                       string val = ExtractProperty 
(prop.GladeName, props);
+                                       if (val != null) {
+                                               if (wProps == null)
+                                                       wProps = new Hashtable 
();
+                                               wProps[prop] = val;
+                                       }
+                               }
+                       }
+               }
+
                static void Hydrate (IntPtr klass, bool childprop, string name, 
string strval, out GLib.Value value)
                {
                        value = new GLib.Value ();
@@ -78,8 +99,12 @@
                        g_type_class_unref (klass);
                }
 
-               static public Gtk.Widget CreateWidget (string className, 
Hashtable props)
+               static public void ImportWidget (IStetic stetic, ObjectWrapper 
wrapper,
+                                                string className, string id, 
Hashtable props)
                {
+                       Hashtable wProps;
+                       ExtractWrapperProperties (wrapper, props, out wProps);
+
                        IntPtr gtype = g_type_from_name (className);
 
                        string[] propNames;
@@ -96,11 +121,15 @@
                                throw new GladeException ("Could not create 
gtk# wrapper", className);
                        }
 
-                       return widget;
+                       Wrap (stetic, wrapper, widget, id, wProps);
                }
 
-               static public void SetProps (Gtk.Widget widget, Hashtable props)
+               static public void ImportWidget (IStetic stetic, ObjectWrapper 
wrapper,
+                                                Gtk.Widget widget, string id, 
Hashtable props)
                {
+                       Hashtable wProps;
+                       ExtractWrapperProperties (wrapper, props, out wProps);
+
                        string[] propNames;
                        GLib.Value[] propVals;
                        HydrateProperties (gtksharp_get_type_id 
(widget.Handle), false, props,
@@ -108,8 +137,80 @@
 
                        for (int i = 0; i < propNames.Length; i++)
                                g_object_set_property (widget.Handle, 
propNames[i], ref propVals[i]);
+
+                       Wrap (stetic, wrapper, widget, id, wProps);
                }
 
+               static void Wrap (IStetic stetic, ObjectWrapper wrapper,
+                                 Gtk.Widget widget, string id, Hashtable 
wProps)
+               {
+                       widget.Name = id;
+                       wrapper.Wrap (widget, true);
+
+                       if (wProps == null)
+                               return;
+
+                       IntPtr klass = g_type_class_ref (gtksharp_get_type_id 
(widget.Handle));
+                       LateImportHelper helper = null;
+
+                       foreach (PropertyDescriptor prop in wProps.Keys) {
+                               if ((prop.GladeFlags & 
GladeProperty.LateImport) != 0) {
+                                       if (helper == null) {
+                                               helper = new LateImportHelper 
(stetic, wrapper, klass, false);
+                                               stetic.GladeImportComplete += 
helper.LateImport;
+                                       }
+                                       helper.Props[prop] = wProps[prop];
+                               } else
+                                       HydrateGladeProp (wrapper, klass, 
false, prop, wProps[prop] as string);
+                       }
+
+                       if (helper == null)
+                               g_type_class_unref (klass);
+               }
+
+               private class LateImportHelper {
+                       public LateImportHelper (IStetic stetic, ObjectWrapper 
wrapper, IntPtr klass, bool childprop) {
+                               this.stetic = stetic;
+                               this.wrapper = wrapper;
+                               this.klass = klass;
+                               this.childprop = childprop;
+                               Props = new Hashtable ();
+                       }
+
+                       IStetic stetic;
+                       ObjectWrapper wrapper;
+                       IntPtr klass;
+                       bool childprop;
+                       public Hashtable Props;
+
+                       public void LateImport () {
+                               foreach (PropertyDescriptor prop in Props.Keys) 
{
+                                       HydrateGladeProp (wrapper, klass, 
childprop,
+                                                         prop, Props[prop] as 
string);
+                               }
+                               g_type_class_unref (klass);
+                               stetic.GladeImportComplete -= LateImport;
+                       }
+               }
+
+               static void HydrateGladeProp (ObjectWrapper wrapper, IntPtr 
klass, bool childprop,
+                                             PropertyDescriptor prop, string 
strval)
+               {
+                       if ((prop.GladeFlags & GladeProperty.Proxied) != 0)
+                               prop.GladeProxySetValue (wrapper, strval);
+                       else if (prop.ParamSpec == null && prop.PropertyType == 
typeof (string))
+                               prop.SetValue (wrapper, strval);
+                       else {
+                               GLib.Value value;
+                               Hydrate (klass, childprop, prop.GladeName, 
strval, out value);
+                               if (prop.PropertyType.IsEnum) {
+                                       GLib.EnumWrapper wrap = 
(GLib.EnumWrapper)value;
+                                       prop.SetValue (wrapper, Enum.ToObject 
(prop.PropertyType, (int)wrap));
+                               } else
+                                       prop.SetValue (wrapper, value.Val);
+                       }
+               }
+
                static public void SetPacking (Gtk.Container parent, Gtk.Widget 
child, Hashtable childprops)
                {
                        string[] propNames;

Modified: trunk/stetic/libstetic/Makefile.am
===================================================================
--- trunk/stetic/libstetic/Makefile.am  2005-03-08 19:36:46 UTC (rev 41577)
+++ trunk/stetic/libstetic/Makefile.am  2005-03-08 20:08:45 UTC (rev 41578)
@@ -7,6 +7,7 @@
        DND.cs                          \
        EditorAttribute.cs              \
        GladeException.cs               \
+       GladePropertyAttribute.cs       \
        GladeUtils.cs                   \
        ItemDescriptor.cs               \
        ItemGroup.cs                    \

Modified: trunk/stetic/libstetic/ObjectWrapper.cs
===================================================================
--- trunk/stetic/libstetic/ObjectWrapper.cs     2005-03-08 19:36:46 UTC (rev 
41577)
+++ trunk/stetic/libstetic/ObjectWrapper.cs     2005-03-08 20:08:45 UTC (rev 
41578)
@@ -97,12 +97,17 @@
                        return wrapper;
                }
 
-               public static ObjectWrapper Create (IStetic stetic, string 
className, object wrapped)
+               public static ObjectWrapper Create (IStetic stetic, string 
className)
                {
                        Type type = wrapperTypes[className] as Type;
                        if (type == null)
                                return null;
-                       return Create (stetic, type, wrapped);
+
+                       ObjectWrapper wrapper = Activator.CreateInstance (type) 
as ObjectWrapper;
+                       if (wrapper == null)
+                               return null;
+                       wrapper.stetic = stetic;
+                       return wrapper;
                }
 
                public static ObjectWrapper GladeImport (IStetic stetic, string 
className, string id, Hashtable props)
@@ -119,7 +124,11 @@
                        if (wrapper == null)
                                throw new GladeException ("Can't create wrapper 
for type " + type.FullName, className);
                        wrapper.stetic = stetic;
-                       info.Invoke (wrapper, new object[] { className, id, 
props });
+                       try {
+                               info.Invoke (wrapper, new object[] { className, 
id, props });
+                       } catch (TargetInvocationException tie) {
+                               throw tie.InnerException;
+                       }
                        return wrapper;
                }
 

Modified: trunk/stetic/libstetic/PropertyDescriptor.cs
===================================================================
--- trunk/stetic/libstetic/PropertyDescriptor.cs        2005-03-08 19:36:46 UTC 
(rev 41577)
+++ trunk/stetic/libstetic/PropertyDescriptor.cs        2005-03-08 20:08:45 UTC 
(rev 41578)
@@ -8,12 +8,13 @@
 
        public class PropertyDescriptor : ItemDescriptor {
 
-               PropertyInfo memberInfo, propertyInfo;
+               PropertyInfo memberInfo, propertyInfo, gladeProxyInfo;
                bool isWrapperProperty;
                ParamSpec pspec;
                Type editorType;
                string label, description;
                object minimum, maximum;
+               GladePropertyAttribute gladeProperty;
 
                public PropertyDescriptor (Type objectType, string 
propertyName) : this (null, objectType, propertyName) {}
 
@@ -87,6 +88,12 @@
                                        ChildPropertyAttribute cpattr = 
(ChildPropertyAttribute)attr;
                                        pspec = ParamSpec.LookupChildProperty 
(trueObjectType.DeclaringType, cpattr.Name);
                                }
+
+                               if (attr is Stetic.GladePropertyAttribute) {
+                                       gladeProperty = 
(GladePropertyAttribute)attr;
+                                       if (gladeProperty.Proxy != null)
+                                               gladeProxyInfo = 
wrapperType.GetProperty (gladeProperty.Proxy, flags | BindingFlags.NonPublic);
+                               }
                        }
 
                        if (label == null) {
@@ -174,5 +181,34 @@
                                obj = memberInfo.GetValue (obj, null);
                        propertyInfo.SetValue (obj, value, null);
                }
+
+               public GladeProperty GladeFlags {
+                       get {
+                               return gladeProperty != null ? 
gladeProperty.Flags : 0;
+                       }
+               }
+
+               public string GladeName {
+                       get {
+                               if (gladeProperty == null)
+                                       return null;
+                               if (gladeProperty.Name != null)
+                                       return gladeProperty.Name;
+                               else if (pspec != null)
+                                       return pspec.Name.Replace ('-', '_');
+                               else
+                                       return null;
+                       }
+               }
+
+               public string GladeProxyGetValue (ObjectWrapper wrapper)
+               {
+                       return (string)gladeProxyInfo.GetValue (wrapper, null);
+               }
+
+               public void GladeProxySetValue (ObjectWrapper wrapper, string 
value)
+               {
+                       gladeProxyInfo.SetValue (wrapper, value, null);
+               }
        }
 }

Modified: trunk/stetic/libstetic/wrapper/ComboBox.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/ComboBox.cs  2005-03-08 19:36:46 UTC (rev 
41577)
+++ trunk/stetic/libstetic/wrapper/ComboBox.cs  2005-03-08 20:08:45 UTC (rev 
41578)
@@ -26,12 +26,7 @@
 
                protected override void GladeImport (string className, string 
id, Hashtable props)
                {
-                       Gtk.ComboBox combobox = CreateInstance ();
-                       string items = GladeUtils.ExtractProperty ("items", 
props);
-                       GladeUtils.SetProps (combobox, props);
-                       combobox.Name = id;
-                       Wrap (combobox, true);
-                       Items = items;
+                       GladeUtils.ImportWidget (stetic, this, CreateInstance 
(), id, props);
                }
 
                string items = "";
@@ -39,6 +34,7 @@
 
                [Editor (typeof (Stetic.Editor.Text))]
                [Description ("Items", "The items to display in the Combo Box, 
one per line")]
+               [GladeProperty]
                public string Items {
                        get {
                                return items;

Modified: trunk/stetic/libstetic/wrapper/Container.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Container.cs 2005-03-08 19:36:46 UTC (rev 
41577)
+++ trunk/stetic/libstetic/wrapper/Container.cs 2005-03-08 20:08:45 UTC (rev 
41578)
@@ -103,10 +103,10 @@
                        if (widget == null)
                                throw new GladeException ("Unrecognized 
internal child name", className, false, "internal-child", childName);
 
-                       widget.Name = id;
-                       GladeUtils.SetProps (widget, props);
+                       ObjectWrapper wrapper = Stetic.ObjectWrapper.Create 
(stetic, className);
+                       GladeUtils.ImportWidget (stetic, wrapper, widget, id, 
props);
 
-                       return (Widget) Stetic.ObjectWrapper.Create (stetic, 
className, widget);
+                       return (Widget) wrapper;
                }
 
                public static new Container Lookup (GLib.Object obj)

Modified: trunk/stetic/libstetic/wrapper/Entry.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Entry.cs     2005-03-08 19:36:46 UTC (rev 
41577)
+++ trunk/stetic/libstetic/wrapper/Entry.cs     2005-03-08 20:08:45 UTC (rev 
41578)
@@ -23,17 +23,23 @@
                                      "Xalign");
                }
 
-               protected override void GladeImport (string className, string 
id, Hashtable props)
-               {
-                       string invisible_char = props["invisible_char"] as 
string;
-                       if (invisible_char != null) {
-                               // invisible_char is a guint, but glade
-                               // serializes it as a string, so we have
-                               // to translate it
-                               props["invisible_char"] = 
((int)invisible_char[0]).ToString ();
+               [GladeProperty (Proxy = "GladeInvisibleChar")]
+               public char InvisibleChar {
+                       get {
+                               return ((Gtk.Entry)Wrapped).InvisibleChar;
                        }
+                       set {
+                               ((Gtk.Entry)Wrapped).InvisibleChar = value;
+                       }
+               }
 
-                       base.GladeImport (className, id, props);
+               private string GladeInvisibleChar {
+                       get {
+                               return InvisibleChar.ToString ();
+                       }
+                       set {
+                               InvisibleChar = Char.Parse (value);
+                       }
                }
        }
 }

Modified: trunk/stetic/libstetic/wrapper/Label.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Label.cs     2005-03-08 19:36:46 UTC (rev 
41577)
+++ trunk/stetic/libstetic/wrapper/Label.cs     2005-03-08 20:08:45 UTC (rev 
41578)
@@ -36,22 +36,28 @@
                        }
                }
 
-               string mnemonic_widget;
-
-               protected override void GladeImport (string className, string 
id, Hashtable props)
-               {
-                       mnemonic_widget = GladeUtils.ExtractProperty 
("mnemonic_widget", props);
-                       if (mnemonic_widget != null)
-                               stetic.GladeImportComplete += SetMnemonicWidget;
-                       base.GladeImport (className, id, props);
+               [GladeProperty (GladeProperty.LateImport, Proxy = 
"GladeMnemonicWidget")]
+               public Gtk.Widget MnemonicWidget {
+                       get {
+                               return ((Gtk.Label)Wrapped).MnemonicWidget;
+                       }
+                       set {
+                               ((Gtk.Label)Wrapped).MnemonicWidget = value;
+                       }
                }
 
-               void SetMnemonicWidget ()
-               {
-                       Gtk.Widget mnem = stetic.LookupWidgetById 
(mnemonic_widget);
-                       if (mnem != null)
-                               ((Gtk.Label)Wrapped).MnemonicWidget = mnem;
-                       stetic.GladeImportComplete -= SetMnemonicWidget;
+               private string GladeMnemonicWidget {
+                       get {
+                               Gtk.Widget mnem = MnemonicWidget;
+                               if (mnem == null)
+                                       return null;
+                               else
+                                       return mnem.Name;
+                       }
+                       set {
+                               Gtk.Widget mnem = stetic.LookupWidgetById 
(value);
+                               MnemonicWidget = mnem;
+                       }
                }
        }
 }

Modified: trunk/stetic/libstetic/wrapper/TextView.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/TextView.cs  2005-03-08 19:36:46 UTC (rev 
41577)
+++ trunk/stetic/libstetic/wrapper/TextView.cs  2005-03-08 20:08:45 UTC (rev 
41578)
@@ -33,15 +33,9 @@
                        ((Gtk.TextView)Wrapped).Buffer.Changed += 
Buffer_Changed;
                }
 
-               protected override void GladeImport (string className, string 
id, Hashtable props)
-               {
-                       string text = GladeUtils.ExtractProperty ("text", 
props);
-                       base.GladeImport (className, id, props);
-                       Text = text;
-               }
-
                [Editor (typeof (Stetic.Editor.Text))]
                [Description ("Text", "The initial text to display in the Text 
View")]
+               [GladeProperty (Name = "text")]
                public string Text {
                        get {
                                return ((Gtk.TextView)Wrapped).Buffer.Text;

Modified: trunk/stetic/libstetic/wrapper/Widget.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Widget.cs    2005-03-08 19:36:46 UTC (rev 
41577)
+++ trunk/stetic/libstetic/wrapper/Widget.cs    2005-03-08 20:08:45 UTC (rev 
41578)
@@ -44,23 +44,9 @@
 
                protected virtual void GladeImport (string className, string 
id, Hashtable props)
                {
-                       string visible = GladeUtils.ExtractProperty ("visible", 
props);
-                       string has_default = GladeUtils.ExtractProperty 
("has_default", props);
-                       Gtk.Widget widget = GladeUtils.CreateWidget (className, 
props);
-                       widget.Name = id;
-                       Wrap (widget, true);
-
-                       Visible = (visible == "True");
-                       if (has_default == "True")
-                               stetic.GladeImportComplete += SetDefault;
+                       GladeUtils.ImportWidget (stetic, this, className, id, 
props);
                }
 
-               void SetDefault ()
-               {
-                       ((Gtk.Widget)Wrapped).HasDefault = true;
-                       stetic.GladeImportComplete -= SetDefault;
-               }
-
                public static new Widget Lookup (GLib.Object obj)
                {
                        return Stetic.ObjectWrapper.Lookup (obj) as 
Stetic.Wrapper.Widget;
@@ -77,6 +63,7 @@
                public virtual bool VExpandable { get { return false; } }
 
                bool window_visible;
+               [GladeProperty]
                public bool Visible {
                        get {
                                if (Wrapped is Gtk.Window)
@@ -91,5 +78,15 @@
                                        ((Gtk.Widget)Wrapped).Visible = value;
                        }
                }
+
+               [GladeProperty (GladeProperty.LateImport)]
+               public bool HasDefault {
+                       get {
+                               return ((Gtk.Widget)Wrapped).HasDefault;
+                       }
+                       set {
+                               ((Gtk.Widget)Wrapped).HasDefault = value;
+                       }
+               }
        }
 }

Modified: trunk/stetic/libstetic/wrapper/Window.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Window.cs    2005-03-08 19:36:46 UTC (rev 
41577)
+++ trunk/stetic/libstetic/wrapper/Window.cs    2005-03-08 20:08:45 UTC (rev 
41578)
@@ -61,20 +61,6 @@
                        window.DeleteEvent += DeleteEvent;
                }
 
-               protected override void GladeImport (string className, string 
id, Hashtable props)
-               {
-                       string modal = GladeUtils.ExtractProperty ("modal", 
props);
-                       string type_hint = GladeUtils.ExtractProperty 
("type_hint", props);
-                       string type = GladeUtils.ExtractProperty ("type", 
props);
-                       base.GladeImport (className, id, props);
-                       Modal = (modal == "True");
-
-                       if (type_hint != null && type_hint.StartsWith 
("GDK_WINDOW_TYPE_HINT_"))
-                               TypeHint = (Gdk.WindowTypeHint) Enum.Parse 
(typeof (Gdk.WindowTypeHint), type_hint.Substring (21), true);
-                       if (type != null && type.StartsWith ("GTK_WINDOW_"))
-                               Type = (Gtk.WindowType) Enum.Parse (typeof 
(Gtk.WindowType), type.Substring (11), true);
-               }
-
                [ConnectBefore]
                void DeleteEvent (object obj, Gtk.DeleteEventArgs args)
                {
@@ -88,6 +74,7 @@
                // We don't want to actually set the underlying properties for 
these;
                // that would be annoying to interact with.
                bool modal;
+               [GladeProperty]
                public bool Modal {
                        get {
                                return modal;
@@ -98,6 +85,7 @@
                }
 
                Gdk.WindowTypeHint typeHint;
+               [GladeProperty]
                public Gdk.WindowTypeHint TypeHint {
                        get {
                                return typeHint;
@@ -108,6 +96,7 @@
                }
 
                Gtk.WindowType type;
+               [GladeProperty]
                public Gtk.WindowType Type {
                        get {
                                return type;

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

Reply via email to