* glib/Value.cs: add new constructors for enum and boxed values
that take the name of the type rather than an object/property name pair; this way they work for both GObject properties and GtkContainer child properties. * glib/glue/value.c (gtksharp_value_create_from_type_name): glue for that * glib/Opaque.cs (GetOpaque): Fix this. * generator/Property.cs (Generate): Use the new GLib.Value constructors. (Fixes setting of enum-valued child properties.) svn path=/trunk/gtk-sharp/; revision=36174
This commit is contained in:
parent
acdb2f73da
commit
598f8e28e5
5 changed files with 46 additions and 14 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
2004-11-16 Dan Winship <danw@novell.com>
|
||||
|
||||
* glib/Value.cs: add new constructors for enum and boxed values
|
||||
that take the name of the type rather than an object/property
|
||||
name pair; this way they work for both GObject properties and
|
||||
GtkContainer child properties.
|
||||
|
||||
* glib/glue/value.c (gtksharp_value_create_from_type_name): glue
|
||||
for that
|
||||
|
||||
* glib/Opaque.cs (GetOpaque): Fix this.
|
||||
|
||||
* generator/Property.cs (Generate): Use the new GLib.Value
|
||||
constructors. (Fixes setting of enum-valued child properties.)
|
||||
|
||||
2004-11-15 Dan Winship <danw@novell.com>
|
||||
|
||||
* gtk/glue/container.c (gtksharp_container_get_focus_child): New
|
||||
|
|
|
@ -211,11 +211,11 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine(indent + SetterHeader (modifiers, cs_type, name) + " {");
|
||||
sw.Write(indent + "\tGLib.Value val = ");
|
||||
if (table.IsEnum(c_type)) {
|
||||
sw.WriteLine("new GLib.Value(this, " + qpname + ", new GLib.EnumWrapper ((int) value, {0}));", table.IsEnumFlags (c_type) ? "true" : "false");
|
||||
sw.WriteLine("new GLib.Value(new GLib.EnumWrapper ((int) value, {0}), \"{1}\");", table.IsEnumFlags (c_type) ? "true" : "false", c_type);
|
||||
} else if (table.IsBoxed (c_type)) {
|
||||
sw.WriteLine("(GLib.Value) value;");
|
||||
} else if (table.IsOpaque (c_type)) {
|
||||
sw.WriteLine("new GLib.Value(Handle, " + qpname + ", value);");
|
||||
sw.WriteLine("new GLib.Value(value, \"{0}\");", c_type);
|
||||
} else {
|
||||
sw.Write("new GLib.Value(");
|
||||
if (v_type != "" && !(table.IsObject (c_type) || table.IsOpaque (c_type))) {
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace GLib {
|
|||
|
||||
public static Opaque GetOpaque(IntPtr o)
|
||||
{
|
||||
Opaque obj = (Opaque)Opaques[(int)o];
|
||||
Opaque obj = (Opaque)Opaques[o];
|
||||
if (obj != null) return obj;
|
||||
return null; //FIXME: Call TypeParser here eventually.
|
||||
}
|
||||
|
|
|
@ -47,6 +47,9 @@ namespace GLib {
|
|||
[DllImport("glibsharpglue-2.0")]
|
||||
static extern IntPtr gtksharp_value_create_from_type_and_property(ref GLib.Value val, IntPtr gtype, string name);
|
||||
|
||||
[DllImport("glibsharpglue-2.0")]
|
||||
static extern IntPtr gtksharp_value_create_from_type_name(ref GLib.Value val, string type_name);
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
g_value_unset (ref this);
|
||||
|
@ -82,20 +85,15 @@ namespace GLib {
|
|||
[DllImport("libgobject-2.0-0.dll")]
|
||||
static extern void g_value_set_boxed (ref Value val, IntPtr data);
|
||||
|
||||
/*
|
||||
public Value (GLib.Boxed val)
|
||||
public Value (Opaque val, string type_name)
|
||||
{
|
||||
_val = gtksharp_value_create(GType.Boxed);
|
||||
//g_value_set_boxed (_val, val.Handle);
|
||||
type = IntPtr.Zero;
|
||||
pad_1 = pad_2 = 0;
|
||||
gtksharp_value_create_from_type_name (ref this, type_name);
|
||||
g_value_set_boxed (ref this, val.Handle);
|
||||
}
|
||||
|
||||
public Value (IntPtr obj, string prop_name, Boxed val)
|
||||
{
|
||||
_val = gtksharp_value_create_from_property (obj, prop_name);
|
||||
//g_value_set_boxed (_val, val.Handle);
|
||||
}
|
||||
*/
|
||||
|
||||
[Obsolete]
|
||||
public Value (IntPtr obj, string prop_name, Opaque val)
|
||||
{
|
||||
type = IntPtr.Zero;
|
||||
|
@ -172,6 +170,18 @@ namespace GLib {
|
|||
[DllImport("libgobject-2.0-0.dll")]
|
||||
static extern void g_value_set_char (ref Value val, char data);
|
||||
|
||||
public Value (EnumWrapper wrap, string type_name)
|
||||
{
|
||||
type = IntPtr.Zero;
|
||||
pad_1 = pad_2 = 0;
|
||||
gtksharp_value_create_from_type_name (ref this, type_name);
|
||||
if (wrap.flags)
|
||||
g_value_set_flags (ref this, (uint) (int) wrap);
|
||||
else
|
||||
g_value_set_enum (ref this, (int) wrap);
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public Value (GLib.Object obj, string prop_name, EnumWrapper wrap)
|
||||
{
|
||||
type = IntPtr.Zero;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
/* Forward declarations */
|
||||
void gtksharp_value_create_from_property (GValue *value, GObject *obj, const gchar* name);
|
||||
void gtksharp_value_create_from_type_and_property (GValue *value, GType gtype, const gchar* name);
|
||||
void gtksharp_value_create_from_type_name (GValue *value, const gchar *type_name);
|
||||
GType gtksharp_value_get_value_type (GValue *value);
|
||||
gboolean glibsharp_value_holds_flags (GValue *value);
|
||||
/* */
|
||||
|
@ -42,6 +43,12 @@ gtksharp_value_create_from_type_and_property (GValue *value, GType gtype, const
|
|||
g_value_init (value, spec->value_type);
|
||||
}
|
||||
|
||||
void
|
||||
gtksharp_value_create_from_type_name (GValue *value, const gchar *type_name)
|
||||
{
|
||||
g_value_init (value, g_type_from_name (type_name));
|
||||
}
|
||||
|
||||
GType
|
||||
gtksharp_value_get_value_type (GValue *value)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue