// Package gtk was automatically generated by github.com/bnema/puregotk DO NOT EDIT package gtk import ( "structs" "unsafe" "github.com/ebitengine/purego" "github.com/bnema/puregotk/pkg/core" "github.com/bnema/puregotk/v4/glib" "github.com/bnema/puregotk/v4/gobject/types" ) // A function to be used by `GtkCustomLayout` to allocate a widget. type CustomAllocateFunc func(uintptr, int, int, int) // A function to be used by `GtkCustomLayout` to measure a widget. type CustomMeasureFunc func(uintptr, Orientation, int, *int, *int, *int, *int) // Queries a widget for its preferred size request mode. type CustomRequestModeFunc func(uintptr) SizeRequestMode type CustomLayoutClass struct { _ structs.HostLayout ParentClass LayoutManagerClass } func (x *CustomLayoutClass) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // Uses closures for size negotiation. // // A `GtkCustomLayout` uses closures matching to the old `GtkWidget` // virtual functions for size negotiation, as a convenience API to // ease the porting towards the corresponding `GtkLayoutManager` // virtual functions. type CustomLayout struct { LayoutManager } var xCustomLayoutGLibType func() types.GType func CustomLayoutGLibType() types.GType { return xCustomLayoutGLibType() } func CustomLayoutNewFromInternalPtr(ptr uintptr) *CustomLayout { cls := &CustomLayout{} cls.Ptr = ptr return cls } var xNewCustomLayout func(uintptr, uintptr, uintptr) uintptr // Creates a new legacy layout manager. // // Legacy layout managers map to the old `GtkWidget` size negotiation // virtual functions, and are meant to be used during the transition // from layout containers to layout manager delegates. func NewCustomLayout(RequestModeVar *CustomRequestModeFunc, MeasureVar *CustomMeasureFunc, AllocateVar *CustomAllocateFunc) *CustomLayout { var cls *CustomLayout var RequestModeVarRef uintptr if RequestModeVar != nil { RequestModeVarPtr := uintptr(unsafe.Pointer(RequestModeVar)) if cbRefPtr, ok := glib.GetCallback(RequestModeVarPtr); ok { RequestModeVarRef = cbRefPtr } else { fcb := func(arg0 uintptr) SizeRequestMode { cbFn := *RequestModeVar return cbFn(arg0) } RequestModeVarRef = purego.NewCallback(fcb) glib.SaveCallbackWithClosure(RequestModeVarPtr, RequestModeVarRef, RequestModeVar) } } var MeasureVarRef uintptr if MeasureVar != nil { MeasureVarPtr := uintptr(unsafe.Pointer(MeasureVar)) if cbRefPtr, ok := glib.GetCallback(MeasureVarPtr); ok { MeasureVarRef = cbRefPtr } else { fcb := func(arg0 uintptr, arg1 Orientation, arg2 int, arg3 *int, arg4 *int, arg5 *int, arg6 *int) { cbFn := *MeasureVar cbFn(arg0, arg1, arg2, arg3, arg4, arg5, arg6) } MeasureVarRef = purego.NewCallback(fcb) glib.SaveCallbackWithClosure(MeasureVarPtr, MeasureVarRef, MeasureVar) } } var AllocateVarRef uintptr if AllocateVar != nil { AllocateVarPtr := uintptr(unsafe.Pointer(AllocateVar)) if cbRefPtr, ok := glib.GetCallback(AllocateVarPtr); ok { AllocateVarRef = cbRefPtr } else { fcb := func(arg0 uintptr, arg1 int, arg2 int, arg3 int) { cbFn := *AllocateVar cbFn(arg0, arg1, arg2, arg3) } AllocateVarRef = purego.NewCallback(fcb) glib.SaveCallbackWithClosure(AllocateVarPtr, AllocateVarRef, AllocateVar) } } cret := xNewCustomLayout(RequestModeVarRef, MeasureVarRef, AllocateVarRef) if cret == 0 { return nil } cls = &CustomLayout{} cls.Ptr = cret return cls } func (c *CustomLayout) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *CustomLayout) SetGoPointer(ptr uintptr) { c.Ptr = ptr } func init() { core.SetPackageName("GTK", "gtk4") core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"}) var libs []uintptr for _, libPath := range core.GetPaths("GTK") { lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL) if err != nil { panic(err) } libs = append(libs, lib) } core.PuregoSafeRegister(&xCustomLayoutGLibType, libs, "gtk_custom_layout_get_type") core.PuregoSafeRegister(&xNewCustomLayout, libs, "gtk_custom_layout_new") }