1// Package gio was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gio
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"
13 "github.com/bnema/puregotk/v4/gobject/types"
14)
15
16type ListStoreClass struct {
17 _ structs.HostLayout
18
19 ParentClass gobject.ObjectClass
20}
21
22func (x *ListStoreClass) GoPointer() uintptr {
23 return uintptr(unsafe.Pointer(x))
24}
25
26// `GListStore` is a simple implementation of [iface@Gio.ListModel] that stores
27// all items in memory.
28//
29// It provides insertions, deletions, and lookups in logarithmic time
30// with a fast path for the common case of iterating the list linearly.
31type ListStore struct {
32 gobject.Object
33}
34
35var xListStoreGLibType func() types.GType
36
37func ListStoreGLibType() types.GType {
38 return xListStoreGLibType()
39}
40
41func ListStoreNewFromInternalPtr(ptr uintptr) *ListStore {
42 cls := &ListStore{}
43 cls.Ptr = ptr
44 return cls
45}
46
47var xNewListStore func(types.GType) uintptr
48
49// Creates a new #GListStore with items of type @item_type. @item_type
50// must be a subclass of #GObject.
51func NewListStore(ItemTypeVar types.GType) *ListStore {
52 var cls *ListStore
53
54 cret := xNewListStore(ItemTypeVar)
55
56 if cret == 0 {
57 return nil
58 }
59 cls = &ListStore{}
60 cls.Ptr = cret
61 return cls
62}
63
64var xListStoreAppend func(uintptr, uintptr)
65
66// Appends @item to @store. @item must be of type #GListStore:item-type.
67//
68// This function takes a ref on @item.
69//
70// Use g_list_store_splice() to append multiple items at the same time
71// efficiently.
72func (x *ListStore) Append(ItemVar *gobject.Object) {
73
74 xListStoreAppend(x.GoPointer(), ItemVar.GoPointer())
75
76}
77
78var xListStoreFind func(uintptr, uintptr, *uint) bool
79
80// Looks up the given @item in the list store by looping over the items until
81// the first occurrence of @item. If @item was not found, then @position will
82// not be set, and this method will return %FALSE.
83//
84// If you need to compare the two items with a custom comparison function, use
85// g_list_store_find_with_equal_func() with a custom #GEqualFunc instead.
86func (x *ListStore) Find(ItemVar *gobject.Object, PositionVar *uint) bool {
87
88 cret := xListStoreFind(x.GoPointer(), ItemVar.GoPointer(), PositionVar)
89 return cret
90}
91
92var xListStoreFindWithEqualFunc func(uintptr, uintptr, uintptr, *uint) bool
93
94// Looks up the given @item in the list store by looping over the items and
95// comparing them with @equal_func until the first occurrence of @item which
96// matches. If @item was not found, then @position will not be set, and this
97// method will return %FALSE.
98//
99// @item is always passed as second parameter to @equal_func.
100//
101// Since GLib 2.76 it is possible to pass `NULL` for @item.
102func (x *ListStore) FindWithEqualFunc(ItemVar *gobject.Object, EqualFuncVar *glib.EqualFunc, PositionVar *uint) bool {
103
104 var EqualFuncVarRef uintptr
105 if EqualFuncVar != nil {
106 EqualFuncVarPtr := uintptr(unsafe.Pointer(EqualFuncVar))
107 if cbRefPtr, ok := glib.GetCallback(EqualFuncVarPtr); ok {
108 EqualFuncVarRef = cbRefPtr
109 } else {
110 fcb := func(arg0 uintptr, arg1 uintptr) bool {
111 cbFn := *EqualFuncVar
112 return cbFn(arg0, arg1)
113 }
114 EqualFuncVarRef = purego.NewCallback(fcb)
115 glib.SaveCallbackWithClosure(EqualFuncVarPtr, EqualFuncVarRef, EqualFuncVar)
116 }
117 }
118
119 cret := xListStoreFindWithEqualFunc(x.GoPointer(), ItemVar.GoPointer(), EqualFuncVarRef, PositionVar)
120 return cret
121}
122
123var xListStoreFindWithEqualFuncFull func(uintptr, uintptr, uintptr, uintptr, *uint) bool
124
125// Like g_list_store_find_with_equal_func() but with an additional @user_data
126// that is passed to @equal_func.
127//
128// @item is always passed as second parameter to @equal_func.
129//
130// Since GLib 2.76 it is possible to pass `NULL` for @item.
131func (x *ListStore) FindWithEqualFuncFull(ItemVar *gobject.Object, EqualFuncVar *glib.EqualFuncFull, UserDataVar uintptr, PositionVar *uint) bool {
132
133 var EqualFuncVarRef uintptr
134 if EqualFuncVar != nil {
135 EqualFuncVarPtr := uintptr(unsafe.Pointer(EqualFuncVar))
136 if cbRefPtr, ok := glib.GetCallback(EqualFuncVarPtr); ok {
137 EqualFuncVarRef = cbRefPtr
138 } else {
139 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) bool {
140 cbFn := *EqualFuncVar
141 return cbFn(arg0, arg1, arg2)
142 }
143 EqualFuncVarRef = purego.NewCallback(fcb)
144 glib.SaveCallbackWithClosure(EqualFuncVarPtr, EqualFuncVarRef, EqualFuncVar)
145 }
146 }
147
148 cret := xListStoreFindWithEqualFuncFull(x.GoPointer(), ItemVar.GoPointer(), EqualFuncVarRef, UserDataVar, PositionVar)
149 return cret
150}
151
152var xListStoreInsert func(uintptr, uint, uintptr)
153
154// Inserts @item into @store at @position. @item must be of type
155// #GListStore:item-type or derived from it. @position must be smaller
156// than the length of the list, or equal to it to append.
157//
158// This function takes a ref on @item.
159//
160// Use g_list_store_splice() to insert multiple items at the same time
161// efficiently.
162func (x *ListStore) Insert(PositionVar uint, ItemVar *gobject.Object) {
163
164 xListStoreInsert(x.GoPointer(), PositionVar, ItemVar.GoPointer())
165
166}
167
168var xListStoreInsertSorted func(uintptr, uintptr, uintptr, uintptr) uint
169
170// Inserts @item into @store at a position to be determined by the
171// @compare_func.
172//
173// The list must already be sorted before calling this function or the
174// result is undefined. Usually you would approach this by only ever
175// inserting items by way of this function.
176//
177// This function takes a ref on @item.
178func (x *ListStore) InsertSorted(ItemVar *gobject.Object, CompareFuncVar *glib.CompareDataFunc, UserDataVar uintptr) uint {
179
180 var CompareFuncVarRef uintptr
181 if CompareFuncVar != nil {
182 CompareFuncVarPtr := uintptr(unsafe.Pointer(CompareFuncVar))
183 if cbRefPtr, ok := glib.GetCallback(CompareFuncVarPtr); ok {
184 CompareFuncVarRef = cbRefPtr
185 } else {
186 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) int {
187 cbFn := *CompareFuncVar
188 return cbFn(arg0, arg1, arg2)
189 }
190 CompareFuncVarRef = purego.NewCallback(fcb)
191 glib.SaveCallbackWithClosure(CompareFuncVarPtr, CompareFuncVarRef, CompareFuncVar)
192 }
193 }
194
195 cret := xListStoreInsertSorted(x.GoPointer(), ItemVar.GoPointer(), CompareFuncVarRef, UserDataVar)
196 return cret
197}
198
199var xListStoreRemove func(uintptr, uint)
200
201// Removes the item from @store that is at @position. @position must be
202// smaller than the current length of the list.
203//
204// Use g_list_store_splice() to remove multiple items at the same time
205// efficiently.
206func (x *ListStore) Remove(PositionVar uint) {
207
208 xListStoreRemove(x.GoPointer(), PositionVar)
209
210}
211
212var xListStoreRemoveAll func(uintptr)
213
214// Removes all items from @store.
215func (x *ListStore) RemoveAll() {
216
217 xListStoreRemoveAll(x.GoPointer())
218
219}
220
221var xListStoreSort func(uintptr, uintptr, uintptr)
222
223// Sort the items in @store according to @compare_func.
224func (x *ListStore) Sort(CompareFuncVar *glib.CompareDataFunc, UserDataVar uintptr) {
225
226 var CompareFuncVarRef uintptr
227 if CompareFuncVar != nil {
228 CompareFuncVarPtr := uintptr(unsafe.Pointer(CompareFuncVar))
229 if cbRefPtr, ok := glib.GetCallback(CompareFuncVarPtr); ok {
230 CompareFuncVarRef = cbRefPtr
231 } else {
232 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) int {
233 cbFn := *CompareFuncVar
234 return cbFn(arg0, arg1, arg2)
235 }
236 CompareFuncVarRef = purego.NewCallback(fcb)
237 glib.SaveCallbackWithClosure(CompareFuncVarPtr, CompareFuncVarRef, CompareFuncVar)
238 }
239 }
240
241 xListStoreSort(x.GoPointer(), CompareFuncVarRef, UserDataVar)
242
243}
244
245var xListStoreSplice func(uintptr, uint, uint, []gobject.Object, uint)
246
247// Changes @store by removing @n_removals items and adding @n_additions
248// items to it. @additions must contain @n_additions items of type
249// #GListStore:item-type. %NULL is not permitted.
250//
251// This function is more efficient than g_list_store_insert() and
252// g_list_store_remove(), because it only emits
253// #GListModel::items-changed once for the change.
254//
255// This function takes a ref on each item in @additions.
256//
257// The parameters @position and @n_removals must be correct (ie:
258// @position + @n_removals must be less than or equal to the length of
259// the list at the time this function is called).
260func (x *ListStore) Splice(PositionVar uint, NRemovalsVar uint, AdditionsVar []gobject.Object, NAdditionsVar uint) {
261
262 xListStoreSplice(x.GoPointer(), PositionVar, NRemovalsVar, AdditionsVar, NAdditionsVar)
263
264}
265
266func (c *ListStore) GoPointer() uintptr {
267 if c == nil {
268 return 0
269 }
270 return c.Ptr
271}
272
273func (c *ListStore) SetGoPointer(ptr uintptr) {
274 c.Ptr = ptr
275}
276
277// GetPropertyNItems gets the "n-items" property.
278// The number of items contained in this list store.
279func (x *ListStore) GetPropertyNItems() uint {
280 var v gobject.Value
281 x.GetProperty("n-items", &v)
282 return v.GetUint()
283}
284
285// Get the item at @position.
286//
287// If @position is greater than the number of items in @list, %NULL is
288// returned.
289//
290// %NULL is never returned for an index that is smaller than the length
291// of the list.
292//
293// See also: g_list_model_get_n_items()
294func (x *ListStore) GetItem(PositionVar uint) uintptr {
295
296 cret := XGListModelGetItem(x.GoPointer(), PositionVar)
297 return cret
298}
299
300// Gets the type of the items in @list.
301//
302// All items returned from g_list_model_get_item() are of the type
303// returned by this function, or a subtype, or if the type is an
304// interface, they are an implementation of that interface.
305//
306// The item type of a #GListModel can not change during the life of the
307// model.
308func (x *ListStore) GetItemType() types.GType {
309
310 cret := XGListModelGetItemType(x.GoPointer())
311 return cret
312}
313
314// Gets the number of items in @list.
315//
316// Depending on the model implementation, calling this function may be
317// less efficient than iterating the list with increasing values for
318// @position until g_list_model_get_item() returns %NULL.
319func (x *ListStore) GetNItems() uint {
320
321 cret := XGListModelGetNItems(x.GoPointer())
322 return cret
323}
324
325// Get the item at @position.
326//
327// If @position is greater than the number of items in @list, %NULL is
328// returned.
329//
330// %NULL is never returned for an index that is smaller than the length
331// of the list.
332//
333// This function is meant to be used by language bindings in place
334// of g_list_model_get_item().
335//
336// See also: g_list_model_get_n_items()
337func (x *ListStore) GetObject(PositionVar uint) *gobject.Object {
338 var cls *gobject.Object
339
340 cret := XGListModelGetObject(x.GoPointer(), PositionVar)
341
342 if cret == 0 {
343 return nil
344 }
345 cls = &gobject.Object{}
346 cls.Ptr = cret
347 return cls
348}
349
350// Emits the #GListModel::items-changed signal on @list.
351//
352// This function should only be called by classes implementing
353// #GListModel. It has to be called after the internal representation
354// of @list has been updated, because handlers connected to this signal
355// might query the new state of the list.
356//
357// Implementations must only make changes to the model (as visible to
358// its consumer) in places that will not cause problems for that
359// consumer. For models that are driven directly by a write API (such
360// as #GListStore), changes can be reported in response to uses of that
361// API. For models that represent remote data, changes should only be
362// made from a fresh mainloop dispatch. It is particularly not
363// permitted to make changes in response to a call to the #GListModel
364// consumer API.
365//
366// Stated another way: in general, it is assumed that code making a
367// series of accesses to the model via the API, without returning to the
368// mainloop, and without calling other code, will continue to view the
369// same contents of the model.
370func (x *ListStore) ItemsChanged(PositionVar uint, RemovedVar uint, AddedVar uint) {
371
372 XGListModelItemsChanged(x.GoPointer(), PositionVar, RemovedVar, AddedVar)
373
374}
375
376func init() {
377 core.SetPackageName("GIO", "gio-2.0")
378 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
379 var libs []uintptr
380 for _, libPath := range core.GetPaths("GIO") {
381 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
382 if err != nil {
383 panic(err)
384 }
385 libs = append(libs, lib)
386 }
387
388 core.PuregoSafeRegister(&xListStoreGLibType, libs, "g_list_store_get_type")
389
390 core.PuregoSafeRegister(&xNewListStore, libs, "g_list_store_new")
391
392 core.PuregoSafeRegister(&xListStoreAppend, libs, "g_list_store_append")
393 core.PuregoSafeRegister(&xListStoreFind, libs, "g_list_store_find")
394 core.PuregoSafeRegister(&xListStoreFindWithEqualFunc, libs, "g_list_store_find_with_equal_func")
395 core.PuregoSafeRegister(&xListStoreFindWithEqualFuncFull, libs, "g_list_store_find_with_equal_func_full")
396 core.PuregoSafeRegister(&xListStoreInsert, libs, "g_list_store_insert")
397 core.PuregoSafeRegister(&xListStoreInsertSorted, libs, "g_list_store_insert_sorted")
398 core.PuregoSafeRegister(&xListStoreRemove, libs, "g_list_store_remove")
399 core.PuregoSafeRegister(&xListStoreRemoveAll, libs, "g_list_store_remove_all")
400 core.PuregoSafeRegister(&xListStoreSort, libs, "g_list_store_sort")
401 core.PuregoSafeRegister(&xListStoreSplice, libs, "g_list_store_splice")
402
403}