gtknumericsorter.go RawHistoryFolder
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 NumericSorterClass struct {
16 _ structs.HostLayout
17
18 ParentClass SorterClass
19}
20
21func (x *NumericSorterClass) GoPointer() uintptr {
22 return uintptr(unsafe.Pointer(x))
23}
24
25// Sorts items numerically.
26//
27// To obtain the numbers to compare, this sorter evaluates a
28// [class@Gtk.Expression].
29type NumericSorter struct {
30 Sorter
31}
32
33var xNumericSorterGLibType func() types.GType
34
35func NumericSorterGLibType() types.GType {
36 return xNumericSorterGLibType()
37}
38
39func NumericSorterNewFromInternalPtr(ptr uintptr) *NumericSorter {
40 cls := &NumericSorter{}
41 cls.Ptr = ptr
42 return cls
43}
44
45var xNewNumericSorter func(uintptr) uintptr
46
47// Creates a new numeric sorter using the given @expression.
48//
49// Smaller numbers will be sorted first. You can call
50// [method@Gtk.NumericSorter.set_sort_order] to change this.
51func NewNumericSorter(ExpressionVar *Expression) *NumericSorter {
52 var cls *NumericSorter
53
54 cret := xNewNumericSorter(ExpressionVar.GoPointer())
55
56 if cret == 0 {
57 return nil
58 }
59 cls = &NumericSorter{}
60 cls.Ptr = cret
61 return cls
62}
63
64var xNumericSorterGetExpression func(uintptr) uintptr
65
66// Gets the expression that is evaluated to obtain numbers from items.
67func (x *NumericSorter) GetExpression() *Expression {
68 var cls *Expression
69
70 cret := xNumericSorterGetExpression(x.GoPointer())
71
72 if cret == 0 {
73 return nil
74 }
75 gobject.IncreaseRef(cret)
76 cls = &Expression{}
77 cls.Ptr = cret
78 return cls
79}
80
81var xNumericSorterGetSortOrder func(uintptr) SortType
82
83// Gets whether this sorter will sort smaller numbers first.
84func (x *NumericSorter) GetSortOrder() SortType {
85
86 cret := xNumericSorterGetSortOrder(x.GoPointer())
87 return cret
88}
89
90var xNumericSorterSetExpression func(uintptr, uintptr)
91
92// Sets the expression that is evaluated to obtain numbers from items.
93//
94// Unless an expression is set on @self, the sorter will always
95// compare items as invalid.
96//
97// The expression must have a return type that can be compared
98// numerically, such as %G_TYPE_INT or %G_TYPE_DOUBLE.
99func (x *NumericSorter) SetExpression(ExpressionVar *Expression) {
100
101 xNumericSorterSetExpression(x.GoPointer(), ExpressionVar.GoPointer())
102
103}
104
105var xNumericSorterSetSortOrder func(uintptr, SortType)
106
107// Sets whether to sort smaller numbers before larger ones.
108func (x *NumericSorter) SetSortOrder(SortOrderVar SortType) {
109
110 xNumericSorterSetSortOrder(x.GoPointer(), SortOrderVar)
111
112}
113
114func (c *NumericSorter) GoPointer() uintptr {
115 if c == nil {
116 return 0
117 }
118 return c.Ptr
119}
120
121func (c *NumericSorter) SetGoPointer(ptr uintptr) {
122 c.Ptr = ptr
123}
124
125func init() {
126 core.SetPackageName("GTK", "gtk4")
127 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
128 var libs []uintptr
129 for _, libPath := range core.GetPaths("GTK") {
130 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
131 if err != nil {
132 panic(err)
133 }
134 libs = append(libs, lib)
135 }
136
137 core.PuregoSafeRegister(&xNumericSorterGLibType, libs, "gtk_numeric_sorter_get_type")
138
139 core.PuregoSafeRegister(&xNewNumericSorter, libs, "gtk_numeric_sorter_new")
140
141 core.PuregoSafeRegister(&xNumericSorterGetExpression, libs, "gtk_numeric_sorter_get_expression")
142 core.PuregoSafeRegister(&xNumericSorterGetSortOrder, libs, "gtk_numeric_sorter_get_sort_order")
143 core.PuregoSafeRegister(&xNumericSorterSetExpression, libs, "gtk_numeric_sorter_set_expression")
144 core.PuregoSafeRegister(&xNumericSorterSetSortOrder, libs, "gtk_numeric_sorter_set_sort_order")
145
146}