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/glib"
13 "github.com/bnema/puregotk/v4/gobject"
14 "github.com/bnema/puregotk/v4/gobject/types"
15)
16
17// Prototype of the function called to create new child models when
18// gtk_tree_list_row_set_expanded() is called.
19//
20// This function can return %NULL to indicate that @item is guaranteed to be
21// a leaf node and will never have children. If it does not have children but
22// may get children later, it should return an empty model that is filled once
23// children arrive.
24type TreeListModelCreateModelFunc func(uintptr, uintptr) uintptr
25
26type TreeListModelClass struct {
27 _ structs.HostLayout
28
29 ParentClass gobject.ObjectClass
30}
31
32func (x *TreeListModelClass) GoPointer() uintptr {
33 return uintptr(unsafe.Pointer(x))
34}
35
36type TreeListRowClass struct {
37 _ structs.HostLayout
38
39 ParentClass gobject.ObjectClass
40}
41
42func (x *TreeListRowClass) GoPointer() uintptr {
43 return uintptr(unsafe.Pointer(x))
44}
45
46// A list model that can create child models on demand.
47type TreeListModel struct {
48 gobject.Object
49}
50
51var xTreeListModelGLibType func() types.GType
52
53func TreeListModelGLibType() types.GType {
54 return xTreeListModelGLibType()
55}
56
57func TreeListModelNewFromInternalPtr(ptr uintptr) *TreeListModel {
58 cls := &TreeListModel{}
59 cls.Ptr = ptr
60 return cls
61}
62
63var xNewTreeListModel func(uintptr, bool, bool, uintptr, uintptr, uintptr) uintptr
64
65// Creates a new empty `GtkTreeListModel` displaying @root
66// with all rows collapsed.
67func NewTreeListModel(RootVar gio.ListModel, PassthroughVar bool, AutoexpandVar bool, CreateFuncVar *TreeListModelCreateModelFunc, UserDataVar uintptr, UserDestroyVar *glib.DestroyNotify) *TreeListModel {
68 var cls *TreeListModel
69
70 var CreateFuncVarRef uintptr
71 if CreateFuncVar != nil {
72 CreateFuncVarPtr := uintptr(unsafe.Pointer(CreateFuncVar))
73 if cbRefPtr, ok := glib.GetCallback(CreateFuncVarPtr); ok {
74 CreateFuncVarRef = cbRefPtr
75 } else {
76 fcb := func(arg0 uintptr, arg1 uintptr) uintptr {
77 cbFn := *CreateFuncVar
78 return cbFn(arg0, arg1)
79 }
80 CreateFuncVarRef = purego.NewCallback(fcb)
81 glib.SaveCallbackWithClosure(CreateFuncVarPtr, CreateFuncVarRef, CreateFuncVar)
82 }
83 }
84
85 var UserDestroyVarRef uintptr
86 if UserDestroyVar != nil {
87 UserDestroyVarPtr := uintptr(unsafe.Pointer(UserDestroyVar))
88 if cbRefPtr, ok := glib.GetCallback(UserDestroyVarPtr); ok {
89 UserDestroyVarRef = cbRefPtr
90 } else {
91 fcb := func(arg0 uintptr) {
92 cbFn := *UserDestroyVar
93 cbFn(arg0)
94 }
95 UserDestroyVarRef = purego.NewCallback(fcb)
96 glib.SaveCallbackWithClosure(UserDestroyVarPtr, UserDestroyVarRef, UserDestroyVar)
97 }
98 }
99
100 cret := xNewTreeListModel(RootVar.GoPointer(), PassthroughVar, AutoexpandVar, CreateFuncVarRef, UserDataVar, UserDestroyVarRef)
101
102 if cret == 0 {
103 return nil
104 }
105 cls = &TreeListModel{}
106 cls.Ptr = cret
107 return cls
108}
109
110var xTreeListModelGetAutoexpand func(uintptr) bool
111
112// Gets whether the model is set to automatically expand new rows
113// that get added.
114//
115// This can be either rows added by changes to the underlying
116// models or via [method@Gtk.TreeListRow.set_expanded].
117func (x *TreeListModel) GetAutoexpand() bool {
118
119 cret := xTreeListModelGetAutoexpand(x.GoPointer())
120 return cret
121}
122
123var xTreeListModelGetChildRow func(uintptr, uint) uintptr
124
125// Gets the row item corresponding to the child at index @position for
126// @self's root model.
127//
128// If @position is greater than the number of children in the root model,
129// %NULL is returned.
130//
131// Do not confuse this function with [method@Gtk.TreeListModel.get_row].
132func (x *TreeListModel) GetChildRow(PositionVar uint) *TreeListRow {
133 var cls *TreeListRow
134
135 cret := xTreeListModelGetChildRow(x.GoPointer(), PositionVar)
136
137 if cret == 0 {
138 return nil
139 }
140 cls = &TreeListRow{}
141 cls.Ptr = cret
142 return cls
143}
144
145var xTreeListModelGetModel func(uintptr) uintptr
146
147// Gets the root model that @self was created with.
148func (x *TreeListModel) GetModel() *gio.ListModelBase {
149 var cls *gio.ListModelBase
150
151 cret := xTreeListModelGetModel(x.GoPointer())
152
153 if cret == 0 {
154 return nil
155 }
156 gobject.IncreaseRef(cret)
157 cls = &gio.ListModelBase{}
158 cls.Ptr = cret
159 return cls
160}
161
162var xTreeListModelGetPassthrough func(uintptr) bool
163
164// Gets whether the model is passing through original row items.
165//
166// If this function returns %FALSE, the `GListModel` functions for @self
167// return custom `GtkTreeListRow` objects. You need to call
168// [method@Gtk.TreeListRow.get_item] on these objects to get the original
169// item.
170//
171// If %TRUE, the values of the child models are passed through in their
172// original state. You then need to call [method@Gtk.TreeListModel.get_row]
173// to get the custom `GtkTreeListRow`s.
174func (x *TreeListModel) GetPassthrough() bool {
175
176 cret := xTreeListModelGetPassthrough(x.GoPointer())
177 return cret
178}
179
180var xTreeListModelGetRow func(uintptr, uint) uintptr
181
182// Gets the row object for the given row.
183//
184// If @position is greater than the number of items in @self,
185// %NULL is returned.
186//
187// The row object can be used to expand and collapse rows as
188// well as to inspect its position in the tree. See its
189// documentation for details.
190//
191// This row object is persistent and will refer to the current
192// item as long as the row is present in @self, independent of
193// other rows being added or removed.
194//
195// If @self is set to not be passthrough, this function is
196// equivalent to calling g_list_model_get_item().
197//
198// Do not confuse this function with [method@Gtk.TreeListModel.get_child_row].
199func (x *TreeListModel) GetRow(PositionVar uint) *TreeListRow {
200 var cls *TreeListRow
201
202 cret := xTreeListModelGetRow(x.GoPointer(), PositionVar)
203
204 if cret == 0 {
205 return nil
206 }
207 cls = &TreeListRow{}
208 cls.Ptr = cret
209 return cls
210}
211
212var xTreeListModelSetAutoexpand func(uintptr, bool)
213
214// Sets whether the model should autoexpand.
215//
216// If set to %TRUE, the model will recursively expand all rows that
217// get added to the model. This can be either rows added by changes
218// to the underlying models or via [method@Gtk.TreeListRow.set_expanded].
219func (x *TreeListModel) SetAutoexpand(AutoexpandVar bool) {
220
221 xTreeListModelSetAutoexpand(x.GoPointer(), AutoexpandVar)
222
223}
224
225func (c *TreeListModel) GoPointer() uintptr {
226 if c == nil {
227 return 0
228 }
229 return c.Ptr
230}
231
232func (c *TreeListModel) SetGoPointer(ptr uintptr) {
233 c.Ptr = ptr
234}
235
236// SetPropertyAutoexpand sets the "autoexpand" property.
237// If all rows should be expanded by default.
238func (x *TreeListModel) SetPropertyAutoexpand(value bool) {
239 var v gobject.Value
240 v.Init(gobject.TypeBooleanVal)
241 v.SetBoolean(value)
242 x.SetProperty("autoexpand", &v)
243}
244
245// GetPropertyAutoexpand gets the "autoexpand" property.
246// If all rows should be expanded by default.
247func (x *TreeListModel) GetPropertyAutoexpand() bool {
248 var v gobject.Value
249 x.GetProperty("autoexpand", &v)
250 return v.GetBoolean()
251}
252
253// GetPropertyNItems gets the "n-items" property.
254// The number of items. See [method@Gio.ListModel.get_n_items].
255func (x *TreeListModel) GetPropertyNItems() uint {
256 var v gobject.Value
257 x.GetProperty("n-items", &v)
258 return v.GetUint()
259}
260
261// SetPropertyPassthrough sets the "passthrough" property.
262// Gets whether the model is in passthrough mode.
263//
264// If %FALSE, the `GListModel` functions for this object return custom
265// [class@Gtk.TreeListRow] objects. If %TRUE, the values of the child
266// models are pass through unmodified.
267func (x *TreeListModel) SetPropertyPassthrough(value bool) {
268 var v gobject.Value
269 v.Init(gobject.TypeBooleanVal)
270 v.SetBoolean(value)
271 x.SetProperty("passthrough", &v)
272}
273
274// GetPropertyPassthrough gets the "passthrough" property.
275// Gets whether the model is in passthrough mode.
276//
277// If %FALSE, the `GListModel` functions for this object return custom
278// [class@Gtk.TreeListRow] objects. If %TRUE, the values of the child
279// models are pass through unmodified.
280func (x *TreeListModel) GetPropertyPassthrough() bool {
281 var v gobject.Value
282 x.GetProperty("passthrough", &v)
283 return v.GetBoolean()
284}
285
286// Get the item at @position.
287//
288// If @position is greater than the number of items in @list, %NULL is
289// returned.
290//
291// %NULL is never returned for an index that is smaller than the length
292// of the list.
293//
294// See also: g_list_model_get_n_items()
295func (x *TreeListModel) GetItem(PositionVar uint) uintptr {
296
297 cret := gio.XGListModelGetItem(x.GoPointer(), PositionVar)
298 return cret
299}
300
301// Gets the type of the items in @list.
302//
303// All items returned from g_list_model_get_item() are of the type
304// returned by this function, or a subtype, or if the type is an
305// interface, they are an implementation of that interface.
306//
307// The item type of a #GListModel can not change during the life of the
308// model.
309func (x *TreeListModel) GetItemType() types.GType {
310
311 cret := gio.XGListModelGetItemType(x.GoPointer())
312 return cret
313}
314
315// Gets the number of items in @list.
316//
317// Depending on the model implementation, calling this function may be
318// less efficient than iterating the list with increasing values for
319// @position until g_list_model_get_item() returns %NULL.
320func (x *TreeListModel) GetNItems() uint {
321
322 cret := gio.XGListModelGetNItems(x.GoPointer())
323 return cret
324}
325
326// Get the item at @position.
327//
328// If @position is greater than the number of items in @list, %NULL is
329// returned.
330//
331// %NULL is never returned for an index that is smaller than the length
332// of the list.
333//
334// This function is meant to be used by language bindings in place
335// of g_list_model_get_item().
336//
337// See also: g_list_model_get_n_items()
338func (x *TreeListModel) GetObject(PositionVar uint) *gobject.Object {
339 var cls *gobject.Object
340
341 cret := gio.XGListModelGetObject(x.GoPointer(), PositionVar)
342
343 if cret == 0 {
344 return nil
345 }
346 cls = &gobject.Object{}
347 cls.Ptr = cret
348 return cls
349}
350
351// Emits the #GListModel::items-changed signal on @list.
352//
353// This function should only be called by classes implementing
354// #GListModel. It has to be called after the internal representation
355// of @list has been updated, because handlers connected to this signal
356// might query the new state of the list.
357//
358// Implementations must only make changes to the model (as visible to
359// its consumer) in places that will not cause problems for that
360// consumer. For models that are driven directly by a write API (such
361// as #GListStore), changes can be reported in response to uses of that
362// API. For models that represent remote data, changes should only be
363// made from a fresh mainloop dispatch. It is particularly not
364// permitted to make changes in response to a call to the #GListModel
365// consumer API.
366//
367// Stated another way: in general, it is assumed that code making a
368// series of accesses to the model via the API, without returning to the
369// mainloop, and without calling other code, will continue to view the
370// same contents of the model.
371func (x *TreeListModel) ItemsChanged(PositionVar uint, RemovedVar uint, AddedVar uint) {
372
373 gio.XGListModelItemsChanged(x.GoPointer(), PositionVar, RemovedVar, AddedVar)
374
375}
376
377// The type of item used by `GtkTreeListModel`.
378//
379// It allows navigating the model as a tree and modify the state of rows.
380//
381// `GtkTreeListRow` instances are created by a `GtkTreeListModel` only
382// when the [property@Gtk.TreeListModel:passthrough] property is not set.
383//
384// There are various support objects that can make use of `GtkTreeListRow`
385// objects, such as the [class@Gtk.TreeExpander] widget that allows displaying
386// an icon to expand or collapse a row or [class@Gtk.TreeListRowSorter] that
387// makes it possible to sort trees properly.
388type TreeListRow struct {
389 gobject.Object
390}
391
392var xTreeListRowGLibType func() types.GType
393
394func TreeListRowGLibType() types.GType {
395 return xTreeListRowGLibType()
396}
397
398func TreeListRowNewFromInternalPtr(ptr uintptr) *TreeListRow {
399 cls := &TreeListRow{}
400 cls.Ptr = ptr
401 return cls
402}
403
404var xTreeListRowGetChildRow func(uintptr, uint) uintptr
405
406// If @self is not expanded or @position is greater than the
407// number of children, %NULL is returned.
408func (x *TreeListRow) GetChildRow(PositionVar uint) *TreeListRow {
409 var cls *TreeListRow
410
411 cret := xTreeListRowGetChildRow(x.GoPointer(), PositionVar)
412
413 if cret == 0 {
414 return nil
415 }
416 cls = &TreeListRow{}
417 cls.Ptr = cret
418 return cls
419}
420
421var xTreeListRowGetChildren func(uintptr) uintptr
422
423// If the row is expanded, gets the model holding the children of @self.
424//
425// This model is the model created by the
426// [callback@Gtk.TreeListModelCreateModelFunc]
427// and contains the original items, no matter what value
428// [property@Gtk.TreeListModel:passthrough] is set to.
429func (x *TreeListRow) GetChildren() *gio.ListModelBase {
430 var cls *gio.ListModelBase
431
432 cret := xTreeListRowGetChildren(x.GoPointer())
433
434 if cret == 0 {
435 return nil
436 }
437 gobject.IncreaseRef(cret)
438 cls = &gio.ListModelBase{}
439 cls.Ptr = cret
440 return cls
441}
442
443var xTreeListRowGetDepth func(uintptr) uint
444
445// Gets the depth of this row.
446//
447// Rows that correspond to items in the root model have a depth
448// of zero, rows corresponding to items of models of direct children
449// of the root model have a depth of 1 and so on.
450//
451// The depth of a row never changes until the row is removed from its model
452// at which point it will forever return 0.
453func (x *TreeListRow) GetDepth() uint {
454
455 cret := xTreeListRowGetDepth(x.GoPointer())
456 return cret
457}
458
459var xTreeListRowGetExpanded func(uintptr) bool
460
461// Gets if a row is currently expanded.
462func (x *TreeListRow) GetExpanded() bool {
463
464 cret := xTreeListRowGetExpanded(x.GoPointer())
465 return cret
466}
467
468var xTreeListRowGetItem func(uintptr) uintptr
469
470// Gets the item corresponding to this row,
471func (x *TreeListRow) GetItem() *gobject.Object {
472 var cls *gobject.Object
473
474 cret := xTreeListRowGetItem(x.GoPointer())
475
476 if cret == 0 {
477 return nil
478 }
479 cls = &gobject.Object{}
480 cls.Ptr = cret
481 return cls
482}
483
484var xTreeListRowGetParent func(uintptr) uintptr
485
486// Gets the row representing the parent for @self.
487//
488// That is the row that would need to be collapsed
489// to make this row disappear.
490//
491// If @self is a row corresponding to the root model,
492// %NULL is returned.
493//
494// The value returned by this function never changes
495// until the row is removed from its model at which point
496// it will forever return %NULL.
497func (x *TreeListRow) GetParent() *TreeListRow {
498 var cls *TreeListRow
499
500 cret := xTreeListRowGetParent(x.GoPointer())
501
502 if cret == 0 {
503 return nil
504 }
505 cls = &TreeListRow{}
506 cls.Ptr = cret
507 return cls
508}
509
510var xTreeListRowGetPosition func(uintptr) uint
511
512// Returns the position in the `GtkTreeListModel` that @self occupies
513// at the moment.
514func (x *TreeListRow) GetPosition() uint {
515
516 cret := xTreeListRowGetPosition(x.GoPointer())
517 return cret
518}
519
520var xTreeListRowIsExpandable func(uintptr) bool
521
522// Checks if a row can be expanded.
523//
524// This does not mean that the row is actually expanded,
525// this can be checked with [method@Gtk.TreeListRow.get_expanded].
526//
527// If a row is expandable never changes until the row is removed
528// from its model at which point it will forever return %FALSE.
529func (x *TreeListRow) IsExpandable() bool {
530
531 cret := xTreeListRowIsExpandable(x.GoPointer())
532 return cret
533}
534
535var xTreeListRowSetExpanded func(uintptr, bool)
536
537// Expands or collapses a row.
538//
539// If a row is expanded, the model of calling the
540// [callback@Gtk.TreeListModelCreateModelFunc] for the row's
541// item will be inserted after this row. If a row is collapsed,
542// those items will be removed from the model.
543//
544// If the row is not expandable, this function does nothing.
545func (x *TreeListRow) SetExpanded(ExpandedVar bool) {
546
547 xTreeListRowSetExpanded(x.GoPointer(), ExpandedVar)
548
549}
550
551func (c *TreeListRow) GoPointer() uintptr {
552 if c == nil {
553 return 0
554 }
555 return c.Ptr
556}
557
558func (c *TreeListRow) SetGoPointer(ptr uintptr) {
559 c.Ptr = ptr
560}
561
562// GetPropertyDepth gets the "depth" property.
563// The depth in the tree of this row.
564func (x *TreeListRow) GetPropertyDepth() uint {
565 var v gobject.Value
566 x.GetProperty("depth", &v)
567 return v.GetUint()
568}
569
570// GetPropertyExpandable gets the "expandable" property.
571// If this row can ever be expanded.
572func (x *TreeListRow) GetPropertyExpandable() bool {
573 var v gobject.Value
574 x.GetProperty("expandable", &v)
575 return v.GetBoolean()
576}
577
578// SetPropertyExpanded sets the "expanded" property.
579// If this row is currently expanded.
580func (x *TreeListRow) SetPropertyExpanded(value bool) {
581 var v gobject.Value
582 v.Init(gobject.TypeBooleanVal)
583 v.SetBoolean(value)
584 x.SetProperty("expanded", &v)
585}
586
587// GetPropertyExpanded gets the "expanded" property.
588// If this row is currently expanded.
589func (x *TreeListRow) GetPropertyExpanded() bool {
590 var v gobject.Value
591 x.GetProperty("expanded", &v)
592 return v.GetBoolean()
593}
594
595func init() {
596 core.SetPackageName("GTK", "gtk4")
597 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
598 var libs []uintptr
599 for _, libPath := range core.GetPaths("GTK") {
600 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
601 if err != nil {
602 panic(err)
603 }
604 libs = append(libs, lib)
605 }
606
607 core.PuregoSafeRegister(&xTreeListModelGLibType, libs, "gtk_tree_list_model_get_type")
608
609 core.PuregoSafeRegister(&xNewTreeListModel, libs, "gtk_tree_list_model_new")
610
611 core.PuregoSafeRegister(&xTreeListModelGetAutoexpand, libs, "gtk_tree_list_model_get_autoexpand")
612 core.PuregoSafeRegister(&xTreeListModelGetChildRow, libs, "gtk_tree_list_model_get_child_row")
613 core.PuregoSafeRegister(&xTreeListModelGetModel, libs, "gtk_tree_list_model_get_model")
614 core.PuregoSafeRegister(&xTreeListModelGetPassthrough, libs, "gtk_tree_list_model_get_passthrough")
615 core.PuregoSafeRegister(&xTreeListModelGetRow, libs, "gtk_tree_list_model_get_row")
616 core.PuregoSafeRegister(&xTreeListModelSetAutoexpand, libs, "gtk_tree_list_model_set_autoexpand")
617
618 core.PuregoSafeRegister(&xTreeListRowGLibType, libs, "gtk_tree_list_row_get_type")
619
620 core.PuregoSafeRegister(&xTreeListRowGetChildRow, libs, "gtk_tree_list_row_get_child_row")
621 core.PuregoSafeRegister(&xTreeListRowGetChildren, libs, "gtk_tree_list_row_get_children")
622 core.PuregoSafeRegister(&xTreeListRowGetDepth, libs, "gtk_tree_list_row_get_depth")
623 core.PuregoSafeRegister(&xTreeListRowGetExpanded, libs, "gtk_tree_list_row_get_expanded")
624 core.PuregoSafeRegister(&xTreeListRowGetItem, libs, "gtk_tree_list_row_get_item")
625 core.PuregoSafeRegister(&xTreeListRowGetParent, libs, "gtk_tree_list_row_get_parent")
626 core.PuregoSafeRegister(&xTreeListRowGetPosition, libs, "gtk_tree_list_row_get_position")
627 core.PuregoSafeRegister(&xTreeListRowIsExpandable, libs, "gtk_tree_list_row_is_expandable")
628 core.PuregoSafeRegister(&xTreeListRowSetExpanded, libs, "gtk_tree_list_row_set_expanded")
629
630}