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/gobject"
12 "github.com/bnema/puregotk/v4/gobject/types"
13)
14
15type StringSorterClass struct {
16 _ structs.HostLayout
17
18 ParentClass SorterClass
19}
20
21func (x *StringSorterClass) GoPointer() uintptr {
22 return uintptr(unsafe.Pointer(x))
23}
24
25// Describes how a [class@Gtk.StringSorter] turns strings into sort keys to
26// compare them.
27//
28// Note that the result of sorting will in general depend on the current locale
29// unless the mode is @GTK_COLLATION_NONE.
30type Collation int
31
32var xCollationGLibType func() types.GType
33
34func CollationGLibType() types.GType {
35 return xCollationGLibType()
36}
37
38const (
39
40 // Don't do any collation
41 CollationNoneValue Collation = 0
42 // Use [func@GLib.utf8_collate_key]
43 CollationUnicodeValue Collation = 1
44 // Use [func@GLib.utf8_collate_key_for_filename]
45 CollationFilenameValue Collation = 2
46)
47
48// Sorts items by comparing strings.
49//
50// To obtain the strings to compare, this sorter evaluates a
51// [class@Gtk.Expression].
52//
53// It does the comparison in a linguistically correct way using the
54// current locale by normalizing Unicode strings and possibly case-folding
55// them before performing the comparison.
56type StringSorter struct {
57 Sorter
58}
59
60var xStringSorterGLibType func() types.GType
61
62func StringSorterGLibType() types.GType {
63 return xStringSorterGLibType()
64}
65
66func StringSorterNewFromInternalPtr(ptr uintptr) *StringSorter {
67 cls := &StringSorter{}
68 cls.Ptr = ptr
69 return cls
70}
71
72var xNewStringSorter func(uintptr) uintptr
73
74// Creates a new string sorter that compares items using the given
75// @expression.
76//
77// Unless an expression is set on it, this sorter will always
78// compare items as invalid.
79func NewStringSorter(ExpressionVar *Expression) *StringSorter {
80 var cls *StringSorter
81
82 cret := xNewStringSorter(ExpressionVar.GoPointer())
83
84 if cret == 0 {
85 return nil
86 }
87 cls = &StringSorter{}
88 cls.Ptr = cret
89 return cls
90}
91
92var xStringSorterGetCollation func(uintptr) Collation
93
94// Gets which collation method the sorter uses.
95func (x *StringSorter) GetCollation() Collation {
96
97 cret := xStringSorterGetCollation(x.GoPointer())
98 return cret
99}
100
101var xStringSorterGetExpression func(uintptr) uintptr
102
103// Gets the expression that is evaluated to obtain strings from items.
104func (x *StringSorter) GetExpression() *Expression {
105 var cls *Expression
106
107 cret := xStringSorterGetExpression(x.GoPointer())
108
109 if cret == 0 {
110 return nil
111 }
112 gobject.IncreaseRef(cret)
113 cls = &Expression{}
114 cls.Ptr = cret
115 return cls
116}
117
118var xStringSorterGetIgnoreCase func(uintptr) bool
119
120// Gets whether the sorter ignores case differences.
121func (x *StringSorter) GetIgnoreCase() bool {
122
123 cret := xStringSorterGetIgnoreCase(x.GoPointer())
124 return cret
125}
126
127var xStringSorterSetCollation func(uintptr, Collation)
128
129// Sets the collation method to use for sorting.
130func (x *StringSorter) SetCollation(CollationVar Collation) {
131
132 xStringSorterSetCollation(x.GoPointer(), CollationVar)
133
134}
135
136var xStringSorterSetExpression func(uintptr, uintptr)
137
138// Sets the expression that is evaluated to obtain strings from items.
139//
140// The expression must have the type %G_TYPE_STRING.
141func (x *StringSorter) SetExpression(ExpressionVar *Expression) {
142
143 xStringSorterSetExpression(x.GoPointer(), ExpressionVar.GoPointer())
144
145}
146
147var xStringSorterSetIgnoreCase func(uintptr, bool)
148
149// Sets whether the sorter will ignore case differences.
150func (x *StringSorter) SetIgnoreCase(IgnoreCaseVar bool) {
151
152 xStringSorterSetIgnoreCase(x.GoPointer(), IgnoreCaseVar)
153
154}
155
156func (c *StringSorter) GoPointer() uintptr {
157 if c == nil {
158 return 0
159 }
160 return c.Ptr
161}
162
163func (c *StringSorter) SetGoPointer(ptr uintptr) {
164 c.Ptr = ptr
165}
166
167// SetPropertyIgnoreCase sets the "ignore-case" property.
168// If sorting is case sensitive.
169func (x *StringSorter) SetPropertyIgnoreCase(value bool) {
170 var v gobject.Value
171 v.Init(gobject.TypeBooleanVal)
172 v.SetBoolean(value)
173 x.SetProperty("ignore-case", &v)
174}
175
176// GetPropertyIgnoreCase gets the "ignore-case" property.
177// If sorting is case sensitive.
178func (x *StringSorter) GetPropertyIgnoreCase() bool {
179 var v gobject.Value
180 x.GetProperty("ignore-case", &v)
181 return v.GetBoolean()
182}
183
184func init() {
185 core.SetPackageName("GTK", "gtk4")
186 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
187 var libs []uintptr
188 for _, libPath := range core.GetPaths("GTK") {
189 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
190 if err != nil {
191 panic(err)
192 }
193 libs = append(libs, lib)
194 }
195
196 core.PuregoSafeRegister(&xCollationGLibType, libs, "gtk_collation_get_type")
197
198 core.PuregoSafeRegister(&xStringSorterGLibType, libs, "gtk_string_sorter_get_type")
199
200 core.PuregoSafeRegister(&xNewStringSorter, libs, "gtk_string_sorter_new")
201
202 core.PuregoSafeRegister(&xStringSorterGetCollation, libs, "gtk_string_sorter_get_collation")
203 core.PuregoSafeRegister(&xStringSorterGetExpression, libs, "gtk_string_sorter_get_expression")
204 core.PuregoSafeRegister(&xStringSorterGetIgnoreCase, libs, "gtk_string_sorter_get_ignore_case")
205 core.PuregoSafeRegister(&xStringSorterSetCollation, libs, "gtk_string_sorter_set_collation")
206 core.PuregoSafeRegister(&xStringSorterSetExpression, libs, "gtk_string_sorter_set_expression")
207 core.PuregoSafeRegister(&xStringSorterSetIgnoreCase, libs, "gtk_string_sorter_set_ignore_case")
208
209}