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/gio"
12 "github.com/bnema/puregotk/v4/gobject"
13 "github.com/bnema/puregotk/v4/gobject/types"
14)
15
16type MultiSorterClass struct {
17 _ structs.HostLayout
18
19 ParentClass SorterClass
20}
21
22func (x *MultiSorterClass) GoPointer() uintptr {
23 return uintptr(unsafe.Pointer(x))
24}
25
26// Combines multiple sorters by trying them in turn.
27//
28// If the first sorter compares two items as equal,
29// the second is tried next, and so on.
30type MultiSorter struct {
31 Sorter
32}
33
34var xMultiSorterGLibType func() types.GType
35
36func MultiSorterGLibType() types.GType {
37 return xMultiSorterGLibType()
38}
39
40func MultiSorterNewFromInternalPtr(ptr uintptr) *MultiSorter {
41 cls := &MultiSorter{}
42 cls.Ptr = ptr
43 return cls
44}
45
46var xNewMultiSorter func() uintptr
47
48// Creates a new multi sorter.
49//
50// This sorter compares items by trying each of the sorters
51// in turn, until one returns non-zero. In particular, if
52// no sorter has been added to it, it will always compare
53// items as equal.
54func NewMultiSorter() *MultiSorter {
55 var cls *MultiSorter
56
57 cret := xNewMultiSorter()
58
59 if cret == 0 {
60 return nil
61 }
62 cls = &MultiSorter{}
63 cls.Ptr = cret
64 return cls
65}
66
67var xMultiSorterAppend func(uintptr, uintptr)
68
69// Add @sorter to @self to use for sorting at the end.
70//
71// @self will consult all existing sorters before it will
72// sort with the given @sorter.
73func (x *MultiSorter) Append(SorterVar *Sorter) {
74
75 xMultiSorterAppend(x.GoPointer(), SorterVar.GoPointer())
76
77}
78
79var xMultiSorterRemove func(uintptr, uint)
80
81// Removes the sorter at the given @position from the list of sorter
82// used by @self.
83//
84// If @position is larger than the number of sorters, nothing happens.
85func (x *MultiSorter) Remove(PositionVar uint) {
86
87 xMultiSorterRemove(x.GoPointer(), PositionVar)
88
89}
90
91func (c *MultiSorter) GoPointer() uintptr {
92 if c == nil {
93 return 0
94 }
95 return c.Ptr
96}
97
98func (c *MultiSorter) SetGoPointer(ptr uintptr) {
99 c.Ptr = ptr
100}
101
102// GetPropertyNItems gets the "n-items" property.
103// The number of items. See [method@Gio.ListModel.get_n_items].
104func (x *MultiSorter) GetPropertyNItems() uint {
105 var v gobject.Value
106 x.GetProperty("n-items", &v)
107 return v.GetUint()
108}
109
110// Get the item at @position.
111//
112// If @position is greater than the number of items in @list, %NULL is
113// returned.
114//
115// %NULL is never returned for an index that is smaller than the length
116// of the list.
117//
118// See also: g_list_model_get_n_items()
119func (x *MultiSorter) GetItem(PositionVar uint) uintptr {
120
121 cret := gio.XGListModelGetItem(x.GoPointer(), PositionVar)
122 return cret
123}
124
125// Gets the type of the items in @list.
126//
127// All items returned from g_list_model_get_item() are of the type
128// returned by this function, or a subtype, or if the type is an
129// interface, they are an implementation of that interface.
130//
131// The item type of a #GListModel can not change during the life of the
132// model.
133func (x *MultiSorter) GetItemType() types.GType {
134
135 cret := gio.XGListModelGetItemType(x.GoPointer())
136 return cret
137}
138
139// Gets the number of items in @list.
140//
141// Depending on the model implementation, calling this function may be
142// less efficient than iterating the list with increasing values for
143// @position until g_list_model_get_item() returns %NULL.
144func (x *MultiSorter) GetNItems() uint {
145
146 cret := gio.XGListModelGetNItems(x.GoPointer())
147 return cret
148}
149
150// Get the item at @position.
151//
152// If @position is greater than the number of items in @list, %NULL is
153// returned.
154//
155// %NULL is never returned for an index that is smaller than the length
156// of the list.
157//
158// This function is meant to be used by language bindings in place
159// of g_list_model_get_item().
160//
161// See also: g_list_model_get_n_items()
162func (x *MultiSorter) GetObject(PositionVar uint) *gobject.Object {
163 var cls *gobject.Object
164
165 cret := gio.XGListModelGetObject(x.GoPointer(), PositionVar)
166
167 if cret == 0 {
168 return nil
169 }
170 cls = &gobject.Object{}
171 cls.Ptr = cret
172 return cls
173}
174
175// Emits the #GListModel::items-changed signal on @list.
176//
177// This function should only be called by classes implementing
178// #GListModel. It has to be called after the internal representation
179// of @list has been updated, because handlers connected to this signal
180// might query the new state of the list.
181//
182// Implementations must only make changes to the model (as visible to
183// its consumer) in places that will not cause problems for that
184// consumer. For models that are driven directly by a write API (such
185// as #GListStore), changes can be reported in response to uses of that
186// API. For models that represent remote data, changes should only be
187// made from a fresh mainloop dispatch. It is particularly not
188// permitted to make changes in response to a call to the #GListModel
189// consumer API.
190//
191// Stated another way: in general, it is assumed that code making a
192// series of accesses to the model via the API, without returning to the
193// mainloop, and without calling other code, will continue to view the
194// same contents of the model.
195func (x *MultiSorter) ItemsChanged(PositionVar uint, RemovedVar uint, AddedVar uint) {
196
197 gio.XGListModelItemsChanged(x.GoPointer(), PositionVar, RemovedVar, AddedVar)
198
199}
200
201// Gets the ID of the @buildable object.
202//
203// `GtkBuilder` sets the name based on the ID attribute
204// of the `<object>` tag used to construct the @buildable.
205func (x *MultiSorter) GetBuildableId() string {
206
207 cret := XGtkBuildableGetBuildableId(x.GoPointer())
208 return cret
209}
210
211func init() {
212 core.SetPackageName("GTK", "gtk4")
213 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
214 var libs []uintptr
215 for _, libPath := range core.GetPaths("GTK") {
216 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
217 if err != nil {
218 panic(err)
219 }
220 libs = append(libs, lib)
221 }
222
223 core.PuregoSafeRegister(&xMultiSorterGLibType, libs, "gtk_multi_sorter_get_type")
224
225 core.PuregoSafeRegister(&xNewMultiSorter, libs, "gtk_multi_sorter_new")
226
227 core.PuregoSafeRegister(&xMultiSorterAppend, libs, "gtk_multi_sorter_append")
228 core.PuregoSafeRegister(&xMultiSorterRemove, libs, "gtk_multi_sorter_remove")
229
230}