1// Package gtk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gtk
3
4import (
5 "structs"
6 "unsafe"
7
8 "github.com/ebitengine/purego"
9
10 "github.com/bnema/puregotk/pkg/core"
11 "github.com/bnema/puregotk/v4/glib"
12 "github.com/bnema/puregotk/v4/gobject/types"
13)
14
15// A function to be used by `GtkCustomLayout` to allocate a widget.
16type CustomAllocateFunc func(uintptr, int, int, int)
17
18// A function to be used by `GtkCustomLayout` to measure a widget.
19type CustomMeasureFunc func(uintptr, Orientation, int, *int, *int, *int, *int)
20
21// Queries a widget for its preferred size request mode.
22type CustomRequestModeFunc func(uintptr) SizeRequestMode
23
24type CustomLayoutClass struct {
25 _ structs.HostLayout
26
27 ParentClass LayoutManagerClass
28}
29
30func (x *CustomLayoutClass) GoPointer() uintptr {
31 return uintptr(unsafe.Pointer(x))
32}
33
34// Uses closures for size negotiation.
35//
36// A `GtkCustomLayout` uses closures matching to the old `GtkWidget`
37// virtual functions for size negotiation, as a convenience API to
38// ease the porting towards the corresponding `GtkLayoutManager`
39// virtual functions.
40type CustomLayout struct {
41 LayoutManager
42}
43
44var xCustomLayoutGLibType func() types.GType
45
46func CustomLayoutGLibType() types.GType {
47 return xCustomLayoutGLibType()
48}
49
50func CustomLayoutNewFromInternalPtr(ptr uintptr) *CustomLayout {
51 cls := &CustomLayout{}
52 cls.Ptr = ptr
53 return cls
54}
55
56var xNewCustomLayout func(uintptr, uintptr, uintptr) uintptr
57
58// Creates a new legacy layout manager.
59//
60// Legacy layout managers map to the old `GtkWidget` size negotiation
61// virtual functions, and are meant to be used during the transition
62// from layout containers to layout manager delegates.
63func NewCustomLayout(RequestModeVar *CustomRequestModeFunc, MeasureVar *CustomMeasureFunc, AllocateVar *CustomAllocateFunc) *CustomLayout {
64 var cls *CustomLayout
65
66 var RequestModeVarRef uintptr
67 if RequestModeVar != nil {
68 RequestModeVarPtr := uintptr(unsafe.Pointer(RequestModeVar))
69 if cbRefPtr, ok := glib.GetCallback(RequestModeVarPtr); ok {
70 RequestModeVarRef = cbRefPtr
71 } else {
72 fcb := func(arg0 uintptr) SizeRequestMode {
73 cbFn := *RequestModeVar
74 return cbFn(arg0)
75 }
76 RequestModeVarRef = purego.NewCallback(fcb)
77 glib.SaveCallbackWithClosure(RequestModeVarPtr, RequestModeVarRef, RequestModeVar)
78 }
79 }
80
81 var MeasureVarRef uintptr
82 if MeasureVar != nil {
83 MeasureVarPtr := uintptr(unsafe.Pointer(MeasureVar))
84 if cbRefPtr, ok := glib.GetCallback(MeasureVarPtr); ok {
85 MeasureVarRef = cbRefPtr
86 } else {
87 fcb := func(arg0 uintptr, arg1 Orientation, arg2 int, arg3 *int, arg4 *int, arg5 *int, arg6 *int) {
88 cbFn := *MeasureVar
89 cbFn(arg0, arg1, arg2, arg3, arg4, arg5, arg6)
90 }
91 MeasureVarRef = purego.NewCallback(fcb)
92 glib.SaveCallbackWithClosure(MeasureVarPtr, MeasureVarRef, MeasureVar)
93 }
94 }
95
96 var AllocateVarRef uintptr
97 if AllocateVar != nil {
98 AllocateVarPtr := uintptr(unsafe.Pointer(AllocateVar))
99 if cbRefPtr, ok := glib.GetCallback(AllocateVarPtr); ok {
100 AllocateVarRef = cbRefPtr
101 } else {
102 fcb := func(arg0 uintptr, arg1 int, arg2 int, arg3 int) {
103 cbFn := *AllocateVar
104 cbFn(arg0, arg1, arg2, arg3)
105 }
106 AllocateVarRef = purego.NewCallback(fcb)
107 glib.SaveCallbackWithClosure(AllocateVarPtr, AllocateVarRef, AllocateVar)
108 }
109 }
110
111 cret := xNewCustomLayout(RequestModeVarRef, MeasureVarRef, AllocateVarRef)
112
113 if cret == 0 {
114 return nil
115 }
116 cls = &CustomLayout{}
117 cls.Ptr = cret
118 return cls
119}
120
121func (c *CustomLayout) GoPointer() uintptr {
122 if c == nil {
123 return 0
124 }
125 return c.Ptr
126}
127
128func (c *CustomLayout) SetGoPointer(ptr uintptr) {
129 c.Ptr = ptr
130}
131
132func init() {
133 core.SetPackageName("GTK", "gtk4")
134 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
135 var libs []uintptr
136 for _, libPath := range core.GetPaths("GTK") {
137 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
138 if err != nil {
139 panic(err)
140 }
141 libs = append(libs, lib)
142 }
143
144 core.PuregoSafeRegister(&xCustomLayoutGLibType, libs, "gtk_custom_layout_get_type")
145
146 core.PuregoSafeRegister(&xNewCustomLayout, libs, "gtk_custom_layout_new")
147
148}