public static T GetInstance <T> (IntPtr handle, Transfer ownership) where T : Opaque { var type = typeof(T); // special case for OpaqueInt so 0 doesn't become null if (type == typeof(OpaqueInt)) { var ret = new OpaqueInt((int)handle); return((T)(object)ret); } if (handle == IntPtr.Zero) { return(null); } if (typeof(GObject.Object).IsAssignableFrom(type)) { return((T)(object)GObject.Object.GetInstance(handle, ownership)); } if (typeof(ParamSpec).IsAssignableFrom(type)) { return((T)(object)ParamSpec.GetInstance(handle, ownership)); } if (typeof(Source).IsAssignableFrom(type)) { type = typeof(UnmanagedSource); } else if (typeof(TypeInstance).IsAssignableFrom(type)) { var gclassPtr = Marshal.ReadIntPtr(handle); var gtype = Marshal.PtrToStructure <GType>(gclassPtr); type = gtype.GetGTypeStruct(); } else if (typeof(TypeClass).IsAssignableFrom(type)) { var gtype = Marshal.PtrToStructure <GType> (handle); type = gtype.GetGTypeStruct(); } else if (typeof(TypeInterface).IsAssignableFrom(type)) { var gtype = Marshal.PtrToStructure <GType> (handle); type = gtype.GetGTypeStruct(); } return((T)Activator.CreateInstance(type, handle, ownership)); }
protected virtual void ChildNotifyHandler (object obj, Gtk.ChildNotifiedArgs args) { ParamSpec pspec = new ParamSpec (args.Pspec); EmitNotify (pspec.Name); }
public static ParamSpec LookupChildProperty (Type type, string name) { string key = type.FullName + ":" + name; if (childProps[key] != null) return (ParamSpec)childProps[key]; IntPtr klass = ParamSpecTypeHack.LookupGTypeClass (type); if (klass == IntPtr.Zero) return null; IntPtr pspec_raw = gtk_container_class_find_child_property (klass, name); if (pspec_raw == IntPtr.Zero) return null; ParamSpec pspec = new ParamSpec (pspec_raw); childProps[key] = pspec; return pspec; }