diff --git a/generator/InterfaceGen.cs b/generator/InterfaceGen.cs index 6d1185223..c6cecdf16 100644 --- a/generator/InterfaceGen.cs +++ b/generator/InterfaceGen.cs @@ -197,12 +197,23 @@ namespace GtkSharp.Generation { m.GenerateImport (sw); sw.WriteLine ("\t\tprivate static GLib.GType _gtype = new GLib.GType ({0} ());", m.CName); sw.WriteLine (); - sw.WriteLine ("\t\tpublic override GLib.GType GType {"); + + // by convention, all GTypes generated have a static GType property + sw.WriteLine ("\t\tpublic static GLib.GType GType {"); sw.WriteLine ("\t\t\tget {"); sw.WriteLine ("\t\t\t\treturn _gtype;"); sw.WriteLine ("\t\t\t}"); sw.WriteLine ("\t\t}"); sw.WriteLine (); + + // we need same property but non-static, because it is being accessed via a GInterfaceAdapter instance + sw.WriteLine ("\t\tpublic override GLib.GType GInterfaceGType {"); + sw.WriteLine ("\t\t\tget {"); + sw.WriteLine ("\t\t\t\treturn _gtype;"); + sw.WriteLine ("\t\t\t}"); + sw.WriteLine ("\t\t}"); + + sw.WriteLine (); } void GenerateHandleProp (StreamWriter sw) diff --git a/glib/GInterfaceAdapter.cs b/glib/GInterfaceAdapter.cs index ab71f6829..f86636711 100644 --- a/glib/GInterfaceAdapter.cs +++ b/glib/GInterfaceAdapter.cs @@ -50,7 +50,7 @@ namespace GLib { } } - public abstract GType GType { get; } + public abstract GType GInterfaceGType { get; } public abstract IntPtr Handle { get; } diff --git a/glib/Object.cs b/glib/Object.cs index c1ed9642c..74994813e 100644 --- a/glib/Object.cs +++ b/glib/Object.cs @@ -225,7 +225,7 @@ namespace GLib { if (!iface.IsAssignableFrom (Type.BaseType)) { GInterfaceInfo info = adapter.Info; info.Data = gtype.Val; - g_type_add_interface_static (gtype.Val, adapter.GType.Val, ref info); + g_type_add_interface_static (gtype.Val, adapter.GInterfaceGType.Val, ref info); adapters.Add (adapter); } } @@ -341,7 +341,7 @@ namespace GLib { PropertyInfo declared_prop = Type.GetProperty (p.Name, BindingFlags.Public | BindingFlags.Instance); if (declared_prop == null) continue; - IntPtr param_spec = FindInterfaceProperty (adapter.GType, property_attr.Name); + IntPtr param_spec = FindInterfaceProperty (adapter.GInterfaceGType, property_attr.Name); Dictionary props; if (!Properties.TryGetValue (Type, out props)) { diff --git a/glib/Value.cs b/glib/Value.cs index 1c89cc37d..9b8b93745 100755 --- a/glib/Value.cs +++ b/glib/Value.cs @@ -134,7 +134,7 @@ namespace GLib { g_value_set_object (ref this, val == null ? IntPtr.Zero : val.Handle); } - public Value (GLib.GInterfaceAdapter val) : this (val == null ? GType.Object : val.GType) + public Value (GLib.GInterfaceAdapter val) : this (val == null ? GType.Object : val.GInterfaceGType) { g_value_set_object (ref this, val == null ? IntPtr.Zero : val.Handle); }