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
15type CustomSorterClass struct {
16 _ structs.HostLayout
17
18 ParentClass SorterClass
19}
20
21func (x *CustomSorterClass) GoPointer() uintptr {
22 return uintptr(unsafe.Pointer(x))
23}
24
25// Sorts items via a callback function.
26type CustomSorter struct {
27 Sorter
28}
29
30var xCustomSorterGLibType func() types.GType
31
32func CustomSorterGLibType() types.GType {
33 return xCustomSorterGLibType()
34}
35
36func CustomSorterNewFromInternalPtr(ptr uintptr) *CustomSorter {
37 cls := &CustomSorter{}
38 cls.Ptr = ptr
39 return cls
40}
41
42var xNewCustomSorter func(uintptr, uintptr, uintptr) uintptr
43
44// Creates a new `GtkSorter` that works by calling
45// @sort_func to compare items.
46//
47// If @sort_func is %NULL, all items are considered equal.
48func NewCustomSorter(SortFuncVar *glib.CompareDataFunc, UserDataVar uintptr, UserDestroyVar *glib.DestroyNotify) *CustomSorter {
49 var cls *CustomSorter
50
51 var SortFuncVarRef uintptr
52 if SortFuncVar != nil {
53 SortFuncVarPtr := uintptr(unsafe.Pointer(SortFuncVar))
54 if cbRefPtr, ok := glib.GetCallback(SortFuncVarPtr); ok {
55 SortFuncVarRef = cbRefPtr
56 } else {
57 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) int {
58 cbFn := *SortFuncVar
59 return cbFn(arg0, arg1, arg2)
60 }
61 SortFuncVarRef = purego.NewCallback(fcb)
62 glib.SaveCallbackWithClosure(SortFuncVarPtr, SortFuncVarRef, SortFuncVar)
63 }
64 }
65
66 var UserDestroyVarRef uintptr
67 if UserDestroyVar != nil {
68 UserDestroyVarPtr := uintptr(unsafe.Pointer(UserDestroyVar))
69 if cbRefPtr, ok := glib.GetCallback(UserDestroyVarPtr); ok {
70 UserDestroyVarRef = cbRefPtr
71 } else {
72 fcb := func(arg0 uintptr) {
73 cbFn := *UserDestroyVar
74 cbFn(arg0)
75 }
76 UserDestroyVarRef = purego.NewCallback(fcb)
77 glib.SaveCallbackWithClosure(UserDestroyVarPtr, UserDestroyVarRef, UserDestroyVar)
78 }
79 }
80
81 cret := xNewCustomSorter(SortFuncVarRef, UserDataVar, UserDestroyVarRef)
82
83 if cret == 0 {
84 return nil
85 }
86 cls = &CustomSorter{}
87 cls.Ptr = cret
88 return cls
89}
90
91var xCustomSorterSetSortFunc func(uintptr, uintptr, uintptr, uintptr)
92
93// Sets (or unsets) the function used for sorting items.
94//
95// If @sort_func is %NULL, all items are considered equal.
96//
97// If the sort func changes its sorting behavior,
98// gtk_sorter_changed() needs to be called.
99//
100// If a previous function was set, its @user_destroy will be
101// called now.
102func (x *CustomSorter) SetSortFunc(SortFuncVar *glib.CompareDataFunc, UserDataVar uintptr, UserDestroyVar *glib.DestroyNotify) {
103
104 var SortFuncVarRef uintptr
105 if SortFuncVar != nil {
106 SortFuncVarPtr := uintptr(unsafe.Pointer(SortFuncVar))
107 if cbRefPtr, ok := glib.GetCallback(SortFuncVarPtr); ok {
108 SortFuncVarRef = cbRefPtr
109 } else {
110 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) int {
111 cbFn := *SortFuncVar
112 return cbFn(arg0, arg1, arg2)
113 }
114 SortFuncVarRef = purego.NewCallback(fcb)
115 glib.SaveCallbackWithClosure(SortFuncVarPtr, SortFuncVarRef, SortFuncVar)
116 }
117 }
118
119 var UserDestroyVarRef uintptr
120 if UserDestroyVar != nil {
121 UserDestroyVarPtr := uintptr(unsafe.Pointer(UserDestroyVar))
122 if cbRefPtr, ok := glib.GetCallback(UserDestroyVarPtr); ok {
123 UserDestroyVarRef = cbRefPtr
124 } else {
125 fcb := func(arg0 uintptr) {
126 cbFn := *UserDestroyVar
127 cbFn(arg0)
128 }
129 UserDestroyVarRef = purego.NewCallback(fcb)
130 glib.SaveCallbackWithClosure(UserDestroyVarPtr, UserDestroyVarRef, UserDestroyVar)
131 }
132 }
133
134 xCustomSorterSetSortFunc(x.GoPointer(), SortFuncVarRef, UserDataVar, UserDestroyVarRef)
135
136}
137
138func (c *CustomSorter) GoPointer() uintptr {
139 if c == nil {
140 return 0
141 }
142 return c.Ptr
143}
144
145func (c *CustomSorter) SetGoPointer(ptr uintptr) {
146 c.Ptr = ptr
147}
148
149func init() {
150 core.SetPackageName("GTK", "gtk4")
151 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
152 var libs []uintptr
153 for _, libPath := range core.GetPaths("GTK") {
154 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
155 if err != nil {
156 panic(err)
157 }
158 libs = append(libs, lib)
159 }
160
161 core.PuregoSafeRegister(&xCustomSorterGLibType, libs, "gtk_custom_sorter_get_type")
162
163 core.PuregoSafeRegister(&xNewCustomSorter, libs, "gtk_custom_sorter_new")
164
165 core.PuregoSafeRegister(&xCustomSorterSetSortFunc, libs, "gtk_custom_sorter_set_sort_func")
166
167}