static IntPtr ConstructorCallback(IntPtr gtypeval, uint n_construct_properties, IntPtr construct_properties) { GType gtype = new GLib.GType(gtypeval); GObjectClass threshold_class = (GObjectClass)Marshal.PtrToStructure(gtype.GetThresholdType().GetClassPtr(), typeof(GObjectClass)); IntPtr raw = threshold_class.constructor_cb(gtypeval, n_construct_properties, construct_properties); bool construct_needed = true; for (int i = 0; i < n_construct_properties; i++) { IntPtr p = new IntPtr(construct_properties.ToInt64() + i * 2 * IntPtr.Size); string prop_name = Marshaller.Utf8PtrToString(g_param_spec_get_name(Marshal.ReadIntPtr(p))); if (prop_name != "gtk-sharp-managed-instance") { continue; } Value val = (Value)Marshal.PtrToStructure(Marshal.ReadIntPtr(p, IntPtr.Size), typeof(Value)); if ((IntPtr)val.Val != IntPtr.Zero) { GCHandle gch = (GCHandle)(IntPtr)val.Val; Object o = (GLib.Object)gch.Target; o.Raw = raw; construct_needed = false; break; } } if (construct_needed) { GetObject(raw, false); } return(raw); }
static IntPtr ConstructorCallback(IntPtr gtypeval, uint n_construct_properties, IntPtr construct_properties) { GType gtype = new GLib.GType(gtypeval); GObjectClass threshold_class = (GObjectClass)Marshal.PtrToStructure(gtype.GetThresholdType().GetClassPtr(), typeof(GObjectClass)); IntPtr raw = threshold_class.constructor_cb(gtypeval, n_construct_properties, construct_properties); Dictionary <IntPtr, GLib.Value> deferred; GLib.Object obj = null; for (int i = 0; i < n_construct_properties; i++) { IntPtr p = new IntPtr(construct_properties.ToInt64() + i * 2 * IntPtr.Size); string prop_name = Marshaller.Utf8PtrToString(g_param_spec_get_name(Marshal.ReadIntPtr(p))); if (prop_name != "gtk-sharp-managed-instance") { continue; } Value val = (Value)Marshal.PtrToStructure(Marshal.ReadIntPtr(p, IntPtr.Size), typeof(Value)); if ((IntPtr)val.Val != IntPtr.Zero) { GCHandle gch = (GCHandle)(IntPtr)val.Val; obj = (GLib.Object)gch.Target; obj.Raw = raw; break; } } if (obj == null) { obj = GetObject(raw, false); } if (PropertiesToSet.TryGetValue(raw, out deferred)) { foreach (var item in deferred) { SetDeferredProperty(obj, item.Value, item.Key); } PropertiesToSet.Remove(raw); } return(raw); }