Author: danw
Date: 2005-04-19 16:29:04 -0400 (Tue, 19 Apr 2005)
New Revision: 43290

Removed:
   trunk/stetic/glue/value.c
Modified:
   trunk/stetic/ChangeLog
   trunk/stetic/glue/Makefile.am
   trunk/stetic/libstetic/GladeUtils.cs
   trunk/stetic/libstetic/wrapper/Container.cs
Log:
        * libstetic/GladeUtils.cs (ParseProperty, PropToString): do the
        value<->string conversion here rather than calling out to C glue.
        Later on, this will let us get rid of some per-widget hacks, but
        for now it just does exactly what the C code did.

        * libstetic/wrapper/Container.cs (GladeExportChild): fix the
        tagging of internal-children, which has apparently been broken for
        a while.

        * glue/value.c: gone


Modified: trunk/stetic/ChangeLog
===================================================================
--- trunk/stetic/ChangeLog      2005-04-19 20:27:43 UTC (rev 43289)
+++ trunk/stetic/ChangeLog      2005-04-19 20:29:04 UTC (rev 43290)
@@ -1,3 +1,16 @@
+2005-04-19  Dan Winship  <[EMAIL PROTECTED]>
+
+       * libstetic/GladeUtils.cs (ParseProperty, PropToString): do the
+       value<->string conversion here rather than calling out to C glue.
+       Later on, this will let us get rid of some per-widget hacks, but
+       for now it just does exactly what the C code did.
+
+       * libstetic/wrapper/Container.cs (GladeExportChild): fix the
+       tagging of internal-children, which has apparently been broken for
+       a while.
+
+       * glue/value.c: gone
+
 2005-04-13  Dan Winship  <[EMAIL PROTECTED]>
 
        * libstetic/wrapper/*.cs: change a bunch of fields that are only

Modified: trunk/stetic/glue/Makefile.am
===================================================================
--- trunk/stetic/glue/Makefile.am       2005-04-19 20:27:43 UTC (rev 43289)
+++ trunk/stetic/glue/Makefile.am       2005-04-19 20:29:04 UTC (rev 43290)
@@ -7,5 +7,4 @@
 
 libsteticglue_la_SOURCES =     \
        custom.c                \
-       paramspec.c             \
-       value.c
+       paramspec.c

Deleted: trunk/stetic/glue/value.c
===================================================================
--- trunk/stetic/glue/value.c   2005-04-19 20:27:43 UTC (rev 43289)
+++ trunk/stetic/glue/value.c   2005-04-19 20:29:04 UTC (rev 43290)
@@ -1,197 +0,0 @@
-/* Copyright (c) 2005 Novell, Inc. */
-
-#include <stdlib.h>
-#include <string.h>
-#include <glib-object.h>
-#include <gtk/gtkcontainer.h>
-
-gboolean stetic_g_value_parse_property (GValue *value, GObjectClass *klass, 
const char *property_name, const char *data);
-gboolean stetic_g_value_parse_child_property (GValue *value, GObjectClass 
*klass, const char *property_name, const char *data);
-gboolean stetic_g_value_parse (GValue *value, const char *data);
-
-char *stetic_g_value_child_property_to_string (GtkContainer *parent, GtkWidget 
*child, const char *property_name);
-char *stetic_g_value_property_to_string (GtkWidget *widget, const char 
*property_name);
-char *stetic_g_value_to_string (GValue *value);
-
-gboolean
-stetic_g_value_parse_property (GValue *value, GObjectClass *klass, const char 
*property_name, const char *data)
-{
-       GParamSpec *spec = g_object_class_find_property (klass, property_name);
-       if (!spec)
-               return FALSE;
-
-       g_value_init (value, spec->value_type);
-       return stetic_g_value_parse (value, data);
-}
-
-gboolean
-stetic_g_value_parse_child_property (GValue *value, GObjectClass *klass, const 
char *property_name, const char *data)
-{
-       GParamSpec *spec = gtk_container_class_find_child_property 
(G_OBJECT_CLASS (klass), property_name);
-       if (!spec)
-               return FALSE;
-
-       g_value_init (value, spec->value_type);
-       return stetic_g_value_parse (value, data);
-}
-
-gboolean
-stetic_g_value_parse (GValue *value, const char *data)
-{
-       switch (G_VALUE_TYPE (value)) {
-       case G_TYPE_CHAR:
-               g_value_set_char (value, strtol (data, NULL, 10));
-               break;
-       case G_TYPE_UCHAR:
-               g_value_set_uchar (value, strtol (data, NULL, 10));
-               break;
-       case G_TYPE_BOOLEAN:
-               g_value_set_boolean (value, !strcmp (data, "True"));
-               break;
-       case G_TYPE_INT:
-               g_value_set_int (value, strtol (data, NULL, 10));
-               break;
-       case G_TYPE_UINT:
-               g_value_set_uint (value, strtoul (data, NULL, 10));
-               break;
-       case G_TYPE_LONG:
-               g_value_set_long (value, strtol (data, NULL, 10));
-               break;
-       case G_TYPE_ULONG:
-               g_value_set_ulong (value, strtoul (data, NULL, 10));
-               break;
-       case G_TYPE_INT64:
-               g_value_set_int64 (value, strtoll (data, NULL, 10));
-               break;
-       case G_TYPE_UINT64:
-               g_value_set_uint64 (value, strtoull (data, NULL, 10));
-               break;
-       case G_TYPE_FLOAT:
-               g_value_set_float (value, strtof (data, NULL));
-               break;
-       case G_TYPE_DOUBLE:
-               g_value_set_double (value, strtod (data, NULL));
-               break;
-       case G_TYPE_STRING:
-               g_value_set_string (value, data);
-               break;
-       default:
-               if (G_TYPE_IS_ENUM (G_VALUE_TYPE (value))) {
-                       GEnumClass *enum_class = g_type_class_ref (G_VALUE_TYPE 
(value));
-                       GEnumValue *enum_value = g_enum_get_value_by_name 
(enum_class, data);
-                       g_type_class_unref (enum_class);
-                       if (enum_value) {
-                               g_value_set_enum (value, enum_value->value);
-                               return TRUE;
-                       }
-               } else if (G_TYPE_IS_FLAGS (G_VALUE_TYPE (value))) {
-                       GFlagsClass *flags_class = g_type_class_ref 
(G_VALUE_TYPE (value));
-                       char **flags;
-                       guint i, fval = 0;
-
-                       flags = g_strsplit (data, "|", 0);
-                       for (i = 0; flags[i]; i++) {
-                               GFlagsValue *flags_value = 
g_flags_get_value_by_nick (flags_class, flags[i]);
-                               if (flags_value)
-                                       fval |= flags_value->value;
-                       }
-                       g_strfreev (flags);
-
-                       g_value_set_flags (value, fval);
-                       g_type_class_unref (flags_class);
-                       return TRUE;
-               }
-
-               return FALSE;
-       }
-
-       return TRUE;
-}
-
-char *
-stetic_g_value_child_property_to_string (GtkContainer *container, GtkWidget 
*child,
-                                        const char *property_name)
-{
-       GParamSpec *pspec = gtk_container_class_find_child_property 
(G_OBJECT_GET_CLASS (container), property_name);
-       GValue value;
-       char *strval;
-
-       memset (&value, 0, sizeof (GValue));
-       g_value_init (&value, pspec->value_type);
-       gtk_container_child_get_property (container, child, property_name, 
&value);
-       strval = stetic_g_value_to_string (&value);
-       g_value_unset (&value);
-
-       return strval;
-}
-
-char *
-stetic_g_value_property_to_string (GtkWidget *widget, const char 
*property_name)
-{
-       GParamSpec *pspec = g_object_class_find_property (G_OBJECT_GET_CLASS 
(widget), property_name);
-       GValue value;
-       char *strval;
-
-       memset (&value, 0, sizeof (GValue));
-       g_value_init (&value, pspec->value_type);
-       g_object_get_property (widget, property_name, &value);
-       strval = stetic_g_value_to_string (&value);
-       g_value_unset (&value);
-
-       return strval;
-}
-
-char *
-stetic_g_value_to_string (GValue *value)
-{
-       switch (G_VALUE_TYPE (value)) {
-       case G_TYPE_CHAR:
-               return g_strdup_printf ("%d", g_value_get_char (value));
-       case G_TYPE_UCHAR:
-               return g_strdup_printf ("%u", g_value_get_uchar (value));
-       case G_TYPE_BOOLEAN:
-               return g_strdup (g_value_get_boolean (value) ? "True" : 
"False");
-       case G_TYPE_INT:
-               return g_strdup_printf ("%d", g_value_get_int (value));
-       case G_TYPE_UINT:
-               return g_strdup_printf ("%u", g_value_get_uint (value));
-       case G_TYPE_LONG:
-               return g_strdup_printf ("%ld", g_value_get_long (value));
-       case G_TYPE_ULONG:
-               return g_strdup_printf ("%lu", g_value_get_ulong (value));
-       case G_TYPE_INT64:
-               return g_strdup_printf ("%lld", g_value_get_int64 (value));
-       case G_TYPE_UINT64:
-               return g_strdup_printf ("%llu", g_value_get_uint64 (value));
-       case G_TYPE_FLOAT:
-               return g_strdup_printf ("%g", g_value_get_float (value));
-       case G_TYPE_DOUBLE:
-               return g_strdup_printf ("%g", g_value_get_double (value));
-       case G_TYPE_STRING:
-               return g_value_dup_string (value);
-       default:
-               if (G_TYPE_IS_ENUM (G_VALUE_TYPE (value))) {
-                       GEnumClass *enum_class = g_type_class_ref (G_VALUE_TYPE 
(value));
-                       GEnumValue *enum_value = g_enum_get_value (enum_class, 
g_value_get_enum (value));
-                       g_type_class_unref (enum_class);
-                       if (enum_value)
-                               return g_strdup (enum_value->value_name);
-               } else if (G_TYPE_IS_FLAGS (G_VALUE_TYPE (value))) {
-                       GFlagsClass *flags_class = g_type_class_ref 
(G_VALUE_TYPE (value));
-                       GString *flags = g_string_new (NULL);
-                       guint i, val = g_value_get_flags (value);
-
-                       for (i = 0; i < flags_class->n_values; i++) {
-                               if ((val & flags_class->values[i].value) == 
flags_class->values[i].value) {
-                                       if (flags->len != 0)
-                                               g_string_append_c (flags, '|');
-                                       g_string_append (flags, 
flags_class->values[i].value_nick);
-                               }
-                       }
-                       return g_string_free (flags, FALSE);
-               }
-               break;
-       }
-
-       return NULL;
-}

Modified: trunk/stetic/libstetic/GladeUtils.cs
===================================================================
--- trunk/stetic/libstetic/GladeUtils.cs        2005-04-19 20:27:43 UTC (rev 
43289)
+++ trunk/stetic/libstetic/GladeUtils.cs        2005-04-19 20:29:04 UTC (rev 
43290)
@@ -38,7 +38,7 @@
                        }
                }
 
-               static void ParseProperty (IntPtr klass, bool childprop, string 
name, string strval, out GLib.Value value)
+               static void ParseProperty (Type type, bool childprop, string 
name, string strval, out GLib.Value value)
                {
                        if (name == "adjustment") {
                                try {
@@ -59,23 +59,88 @@
                                }
                        }
 
-                       value = new GLib.Value ();
-                       bool parsed;
+                       ParamSpec pspec;
 
                        if (childprop)
-                               parsed = stetic_g_value_parse_child_property 
(ref value, klass, name, strval);
+                               pspec = ParamSpec.LookupChildProperty (type, 
name);
                        else
-                               parsed = stetic_g_value_parse_property (ref 
value, klass, name, strval);
+                               pspec = ParamSpec.LookupObjectProperty (type, 
name);
+                       if (pspec == null)
+                               throw new GladeException ("Unknown property", 
type.ToString (), childprop, name, strval);
 
-                       if (!parsed)
-                               throw new GladeException ("Could not parse 
property", GTypeNameFromClass (klass), childprop, name, strval);
+                       GLib.GType gtype = new GLib.GType (g_type_fundamental 
(pspec.ValueType));
+                       switch ((GLib.TypeFundamentals)(int)gtype.Val) {
+                       case GLib.TypeFundamentals.TypeChar:
+                               value = new GLib.Value (SByte.Parse (strval));
+                               break;
+                       case GLib.TypeFundamentals.TypeUChar:
+                               value = new GLib.Value (Byte.Parse (strval));
+                               break;
+                       case GLib.TypeFundamentals.TypeBoolean:
+                               value = new GLib.Value (strval == "True");
+                               break;
+                       case GLib.TypeFundamentals.TypeInt:
+                               value = new GLib.Value (Int32.Parse (strval));
+                               break;
+                       case GLib.TypeFundamentals.TypeUInt:
+                               value = new GLib.Value (UInt32.Parse (strval));
+                               break;
+                       case GLib.TypeFundamentals.TypeInt64:
+                               value = new GLib.Value (Int64.Parse (strval));
+                               break;
+                       case GLib.TypeFundamentals.TypeUInt64:
+                               value = new GLib.Value (UInt64.Parse (strval));
+                               break;
+                       case GLib.TypeFundamentals.TypeFloat:
+                               value = new GLib.Value (Single.Parse (strval));
+                               break;
+                       case GLib.TypeFundamentals.TypeDouble:
+                               value = new GLib.Value (Double.Parse (strval));
+                               break;
+                       case GLib.TypeFundamentals.TypeString:
+                               value = new GLib.Value (strval);
+                               break;
+
+                       case GLib.TypeFundamentals.TypeEnum:
+                               IntPtr enum_class = g_type_class_ref 
(pspec.ValueType);
+                               IntPtr enum_value = g_enum_get_value_by_name 
(enum_class, strval);
+                               if (enum_value == IntPtr.Zero)
+                                       goto default;
+
+                               IntPtr eval = Marshal.ReadIntPtr (enum_value);
+                               string ename = GLib.Marshaller.Utf8PtrToString 
(g_type_name_from_class (enum_class));
+                               value = new GLib.Value (new GLib.EnumWrapper 
((int)eval, false), ename);
+                               g_type_class_unref (enum_class);
+                               break;
+
+                       case GLib.TypeFundamentals.TypeFlags:
+                               IntPtr flags_class = g_type_class_ref 
(pspec.ValueType);
+                               uint fval = 0;
+
+                               foreach (string flag in strval.Split ('|')) {
+                                       if (flag == "")
+                                               continue;
+                                       IntPtr flags_value = 
g_flags_get_value_by_nick (flags_class, flag);
+                                       if (flags_value == IntPtr.Zero)
+                                               goto default;
+
+                                       IntPtr bits = Marshal.ReadIntPtr 
(flags_value);
+                                       fval |= (uint)bits;
+                               }
+
+                               string fname = GLib.Marshaller.Utf8PtrToString 
(g_type_name_from_class (flags_class));
+                               value = new GLib.Value (new GLib.EnumWrapper 
((int)fval, true), fname);
+                               g_type_class_unref (flags_class);
+                               break;
+
+                       default:
+                               throw new GladeException ("Could not parse 
property", type.ToString (), childprop, name, strval);
+                       }
                }
 
-               static void ParseProperties (IntPtr gtype, bool childprops, 
Hashtable props,
+               static void ParseProperties (Type type, 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 ();
 
@@ -84,7 +149,7 @@
 
                                GLib.Value value;
                                try {
-                                       ParseProperty (klass, childprops, name, 
strval, out value);
+                                       ParseProperty (type, childprops, name, 
strval, out value);
                                        names.Add (name);
                                        values.Add (value);
                                } catch (GladeException ge) {
@@ -94,8 +159,6 @@
 
                        propNames = (string[])names.ToArray (typeof (string));
                        propVals = (GLib.Value[])values.ToArray (typeof 
(GLib.Value));
-
-                       g_type_class_unref (klass);
                }
 
                static public void ImportWidget (IStetic stetic, ObjectWrapper 
wrapper,
@@ -108,7 +171,7 @@
 
                        string[] propNames;
                        GLib.Value[] propVals;
-                       ParseProperties (gtype, false, props, out propNames, 
out propVals);
+                       ParseProperties (ObjectWrapper.WrappedType 
(wrapper.GetType ()), false, props, out propNames, out propVals);
 
                        IntPtr raw = gtksharp_object_newv (gtype, 
propNames.Length, propNames, propVals);
                        if (raw == IntPtr.Zero)
@@ -131,8 +194,8 @@
 
                        string[] propNames;
                        GLib.Value[] propVals;
-                       ParseProperties (gtksharp_get_type_id (widget.Handle), 
false, props,
-                                          out propNames, out propVals);
+                       ParseProperties (widget.GetType (), false, props,
+                                        out propNames, out propVals);
 
                        for (int i = 0; i < propNames.Length; i++)
                                g_object_set_property (widget.Handle, 
propNames[i], ref propVals[i]);
@@ -149,50 +212,42 @@
                        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);
+                                               helper = new LateImportHelper 
(stetic, wrapper, false);
                                                stetic.GladeImportComplete += 
helper.LateImport;
                                        }
                                        helper.Props[prop] = wProps[prop];
                                } else
-                                       ParseGladeProperty (wrapper, klass, 
false, prop, wProps[prop] as string);
+                                       ParseGladeProperty (wrapper, 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) {
+                       public LateImportHelper (IStetic stetic, ObjectWrapper 
wrapper, 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) 
{
-                                       ParseGladeProperty (wrapper, klass, 
childprop,
+                                       ParseGladeProperty (wrapper, childprop,
                                                            prop, Props[prop] 
as string);
                                }
-                               g_type_class_unref (klass);
                                stetic.GladeImportComplete -= LateImport;
                        }
                }
 
-               static void ParseGladeProperty (ObjectWrapper wrapper, IntPtr 
klass, bool childprop,
+               static void ParseGladeProperty (ObjectWrapper wrapper, bool 
childprop,
                                                PropertyDescriptor prop, string 
strval)
                {
                        if (((prop.GladeFlags & GladeProperty.Proxied) != 0) ||
@@ -200,7 +255,8 @@
                                prop.GladeSetValue (wrapper, strval);
                        else {
                                GLib.Value value;
-                               ParseProperty (klass, childprop, 
prop.GladeName, strval, out value);
+                               ParseProperty (ObjectWrapper.WrappedType 
(wrapper.GetType ()),
+                                              childprop, prop.GladeName, 
strval, out value);
                                if (prop.PropertyType.IsEnum) {
                                        GLib.EnumWrapper wrap = 
(GLib.EnumWrapper)value;
                                        prop.GladeSetValue (wrapper, 
Enum.ToObject (prop.PropertyType, (int)wrap));
@@ -213,7 +269,7 @@
                {
                        string[] propNames;
                        GLib.Value[] propVals;
-                       ParseProperties (gtksharp_get_type_id (parent.Handle), 
true, childprops,
+                       ParseProperties (parent.GetType (), true, childprops,
                                         out propNames, out propVals);
 
                        for (int i = 0; i < propNames.Length; i++)
@@ -222,65 +278,82 @@
 
                static string PropToString (ObjectWrapper wrapper, 
PropertyDescriptor prop)
                {
-                       GLib.Value gvalue;
-                       IntPtr raw;
+                       // If this is a stetic-only property, skip it
+                       if (prop.GladeName == null && prop.GladeFlags == 0)
+                               return null;
 
-                       // If we're supposed to use the underlying property, 
just use that
+                       // Get the value, either from the underlying property 
or from
+                       // the wrapper
+                       object value;
+
                        if ((prop.GladeFlags & GladeProperty.UseUnderlying) != 
0) {
                                Stetic.Wrapper.Container.ContainerChild ccwrap 
= wrapper as Stetic.Wrapper.Container.ContainerChild;
+                               GLib.Value gval;
+
                                if (ccwrap != null) {
                                        Gtk.Container.ContainerChild cc = 
(Gtk.Container.ContainerChild)ccwrap.Wrapped;
-                                       raw = 
stetic_g_value_child_property_to_string (cc.Parent.Handle, cc.Child.Handle, 
prop.GladeName);
+                                       gval = new GLib.Value ();
+                                       gtk_container_child_get_property 
(cc.Parent.Handle, cc.Child.Handle, prop.GladeName, ref gval);
                                } else {
                                        Gtk.Widget widget = wrapper.Wrapped as 
Gtk.Widget;
-                                       raw = stetic_g_value_property_to_string 
(widget.Handle, prop.GladeName);
+                                       gval = new GLib.Value (widget, 
prop.GladeName);
+                                       g_object_get_property (widget.Handle, 
prop.GladeName, ref gval);
                                }
-                               if (raw == IntPtr.Zero)
-                                       return null;
-                               return GLib.Marshaller.PtrToStringGFree (raw);
-                       }
-
-                       // Otherwise, if this is a stetic-only property, skip it
-                       if (prop.GladeName == null && prop.GladeFlags == 0)
-                               return null;
-
-                       object value = prop.GladeGetValue (wrapper);
+                               value = gval.Val;
+                       } else
+                               value = prop.GladeGetValue (wrapper);
                        if (value == null)
                                return null;
 
                        if (prop.GladeProperty != null)
                                prop = prop.GladeProperty;
 
-                       // If there's no underlying property, just return the 
property
-                       // as a string. (This only works for some data types...)
-                       if (prop.ParamSpec == null)
-                               return value.ToString ();
-
                        // If the property has its default value, we don't need 
to write it
-                       if (value.Equals (prop.ParamSpec.Default))
+                       if (prop.ParamSpec != null && value.Equals 
(prop.ParamSpec.Default))
                                return null;
 
-                       // Special handling for Adjustments
                        if (value is Gtk.Adjustment) {
                                Gtk.Adjustment adj = value as Gtk.Adjustment;
                                return String.Format ("{0:G} {1:G} {2:G} {3:G} 
{4:G} {5:G}",
                                                      adj.Value, adj.Lower, 
adj.Upper,
                                                      adj.StepIncrement, 
adj.PageIncrement,
                                                      adj.PageSize);
-                       }
+                       } else if (prop.PropertyType.IsEnum && prop.ParamSpec 
!= null) {
+                               IntPtr klass = g_type_class_ref 
(prop.ParamSpec.ValueType);
 
-                       if (prop.PropertyType.IsEnum) {
-                               string nativeEnumName = GTypeName 
(prop.ParamSpec.ValueType);
-                               GLib.EnumWrapper wrap = new GLib.EnumWrapper 
((int)value, prop.PropertyType.IsDefined (typeof (FlagsAttribute), false));
-                               gvalue = new GLib.Value (wrap, nativeEnumName);
-                       } else
-                               gvalue = new GLib.Value (value);
+                               if (prop.PropertyType.IsDefined (typeof 
(FlagsAttribute), false)) {
+                                       System.Text.StringBuilder sb = new 
System.Text.StringBuilder ();
+                                       uint val = 
(uint)System.Convert.ChangeType (value, typeof (uint));
 
-                       raw = stetic_g_value_to_string (ref gvalue);
-                       if (raw == IntPtr.Zero)
-                               throw new GladeException ("Could not convert 
property to string", ObjectWrapper.NativeTypeName (wrapper.GetType ()), false, 
prop.GladeName);
+                                       while (val != 0) {
+                                               IntPtr flags_value = 
g_flags_get_first_value (klass, val);
+                                               if (flags_value == IntPtr.Zero)
+                                                       break;
+                                               IntPtr fval = 
Marshal.ReadIntPtr (flags_value);
+                                               val &= ~(uint)fval;
 
-                       return GLib.Marshaller.PtrToStringGFree (raw);
+                                               IntPtr nick = 
Marshal.ReadIntPtr (flags_value, 2 * Marshal.SizeOf (typeof (IntPtr)));
+                                               if (nick != IntPtr.Zero) {
+                                                       if (sb.Length != 0)
+                                                               sb.Append ('|');
+                                                       sb.Append 
(GLib.Marshaller.Utf8PtrToString (nick));
+                                               }
+                                       }
+
+                                       g_type_class_unref (klass);
+                                       return sb.ToString ();
+                               } else {
+                                       int val = 
(int)System.Convert.ChangeType (value, typeof (int));
+                                       IntPtr enum_value = g_enum_get_value 
(klass, val);
+                                       g_type_class_unref (klass);
+
+                                       IntPtr name = Marshal.ReadIntPtr 
(enum_value, Marshal.SizeOf (typeof (IntPtr)));
+                                       return GLib.Marshaller.Utf8PtrToString 
(name);
+                               }
+                       } else if (prop.PropertyType == typeof (bool))
+                               return (bool)value ? "True" : "False";
+                       else
+                               return value.ToString ();
                }
 
                static public void ExportWidget (IStetic stetic, ObjectWrapper 
wrapper,
@@ -313,33 +386,8 @@
                        }
                }
 
-               static string GTypeName (IntPtr gtype)
-               {
-                       return Marshal.PtrToStringAnsi (g_type_name (gtype));
-               }
-
-               static string GTypeNameFromClass (IntPtr klass)
-               {
-                       return Marshal.PtrToStringAnsi (g_type_name_from_class 
(klass));
-               }
-
-               [DllImport("libsteticglue")]
-               static extern bool stetic_g_value_parse_property (ref 
GLib.Value value, IntPtr klass, string propertyName, string data);
-
-               [DllImport("libsteticglue")]
-               static extern bool stetic_g_value_parse_child_property (ref 
GLib.Value value, IntPtr klass, string propertyName, string data);
-
-               [DllImport("libsteticglue")]
-               static extern IntPtr stetic_g_value_child_property_to_string 
(IntPtr parent, IntPtr child, string property_name);
-
-               [DllImport("libsteticglue")]
-               static extern IntPtr stetic_g_value_property_to_string (IntPtr 
widget, string property_name);
-
-               [DllImport("libsteticglue")]
-               static extern IntPtr stetic_g_value_to_string (ref GLib.Value 
value);
-
                [DllImport("libgobject-2.0-0.dll")]
-               static extern IntPtr g_type_name (IntPtr gtype);
+               static extern IntPtr g_type_fundamental (IntPtr gtype);
 
                [DllImport("libgobject-2.0-0.dll")]
                static extern IntPtr g_type_name_from_class (IntPtr klass);
@@ -351,7 +399,7 @@
                static extern IntPtr g_type_class_ref (IntPtr gtype);
 
                [DllImport("libgobject-2.0-0.dll")]
-               static extern void g_type_class_unref (IntPtr gtype);
+               static extern IntPtr g_type_class_unref (IntPtr klass);
 
                [DllImport("glibsharpglue-2")]
                static extern IntPtr gtksharp_object_newv (IntPtr gtype, int 
n_params, string[] names, GLib.Value[] vals);
@@ -359,10 +407,25 @@
                [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_get_property (IntPtr obj, string 
name, ref GLib.Value val);
 
                [DllImport("libgobject-2.0-0.dll")]
                static extern void g_object_set_property (IntPtr obj, string 
name, ref GLib.Value val);
+
+               [DllImport("libgtk-win32-2.0-0.dll")]
+               static extern void gtk_container_child_get_property (IntPtr 
parent, IntPtr child, string name, ref GLib.Value val);
+
+               [DllImport("libgobject-2.0-0.dll")]
+               static extern IntPtr g_enum_get_value_by_name (IntPtr 
enum_class, string name);
+
+               [DllImport("libgobject-2.0-0.dll")]
+               static extern IntPtr g_enum_get_value (IntPtr enum_class, int 
val);
+
+               [DllImport("libgobject-2.0-0.dll")]
+               static extern IntPtr g_flags_get_value_by_nick (IntPtr 
flags_class, string nick);
+
+               [DllImport("libgobject-2.0-0.dll")]
+               static extern IntPtr g_flags_get_first_value (IntPtr 
flags_class, uint val);
        }
 }

Modified: trunk/stetic/libstetic/wrapper/Container.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Container.cs 2005-04-19 20:27:43 UTC (rev 
43289)
+++ trunk/stetic/libstetic/wrapper/Container.cs 2005-04-19 20:29:04 UTC (rev 
43290)
@@ -90,8 +90,8 @@
                        childprops = null;
                        wrapper.GladeExport (out className, out id, out props);
 
-                       if (InternalChildId != null)
-                               internalId = InternalChildId;
+                       if (wrapper.InternalChildId != null)
+                               internalId = wrapper.InternalChildId;
                        else {
                                ObjectWrapper childwrapper = ChildWrapper 
(wrapper);
                                if (childwrapper != null)

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

Reply via email to