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 TreeExpanderClass struct {
16 _ structs.HostLayout
17
18 ParentClass WidgetClass
19}
20
21func (x *TreeExpanderClass) GoPointer() uintptr {
22 return uintptr(unsafe.Pointer(x))
23}
24
25// Provides an expander for a tree-like list.
26//
27// It is typically placed as a bottommost child into a `GtkListView`
28// to allow users to expand and collapse children in a list with a
29// [class@Gtk.TreeListModel]. `GtkTreeExpander` provides the common UI
30// elements, gestures and keybindings for this purpose.
31//
32// On top of this, the "listitem.expand", "listitem.collapse" and
33// "listitem.toggle-expand" actions are provided to allow adding custom
34// UI for managing expanded state.
35//
36// It is important to mention that you want to set the
37// [property@Gtk.ListItem:focusable] property to FALSE when using this
38// widget, as you want the keyboard focus to be in the treexpander, and not
39// inside the list to make use of the keybindings.
40//
41// The `GtkTreeListModel` must be set to not be passthrough. Then it
42// will provide [class@Gtk.TreeListRow] items which can be set via
43// [method@Gtk.TreeExpander.set_list_row] on the expander.
44// The expander will then watch that row item automatically.
45// [method@Gtk.TreeExpander.set_child] sets the widget that displays
46// the actual row contents.
47//
48// `GtkTreeExpander` can be modified with properties such as
49// [property@Gtk.TreeExpander:indent-for-icon],
50// [property@Gtk.TreeExpander:indent-for-depth], and
51// [property@Gtk.TreeExpander:hide-expander] to achieve a different appearance.
52// This can even be done to influence individual rows, for example by binding
53// the [property@Gtk.TreeExpander:hide-expander] property to the item count of
54// the model of the treelistrow, to hide the expander for rows without children,
55// even if the row is expandable.
56//
57// ## Shortcuts and Gestures
58//
59// `GtkTreeExpander` supports the following keyboard shortcuts:
60//
61// - <kbd>+</kbd> or <kbd>*</kbd> expands the expander.
62// - <kbd>-</kbd> or <kbd>/</kbd> collapses the expander.
63// - Left and right arrow keys, when combined with <kbd>Shift</kbd> or
64// <kbd>Ctrl</kbd>+<kbd>Shift</kbd>, will expand or collapse, depending on
65// the locale's text direction.
66// - <kbd>Ctrl</kbd>+<kbd>␣</kbd> toggles the expander state.
67//
68// The row can also expand on drag gestures.
69//
70// ## Actions
71//
72// `GtkTreeExpander` defines a set of built-in actions:
73//
74// - `listitem.expand` expands the expander if it can be expanded.
75// - `listitem.collapse` collapses the expander.
76// - `listitem.toggle-expand` tries to expand the expander if it was collapsed
77// or collapses it if it was expanded.
78//
79// ## CSS nodes
80//
81// ```
82// treeexpander
83// ├── [indent]*
84// ├── [expander]
85// ╰── <child>
86// ```
87//
88// `GtkTreeExpander` has zero or one CSS nodes with the name "expander" that
89// should display the expander icon. The node will be `:checked` when it
90// is expanded. If the node is not expandable, an "indent" node will be
91// displayed instead.
92//
93// For every level of depth, another "indent" node is prepended.
94//
95// ## Accessibility
96//
97// Until GTK 4.10, `GtkTreeExpander` used the [enum@Gtk.AccessibleRole.group] role.
98//
99// Since GTK 4.12, `GtkTreeExpander` uses the [enum@Gtk.AccessibleRole.button] role.
100// Toggling it will change the `GTK_ACCESSIBLE_STATE_EXPANDED` state.
101type TreeExpander struct {
102 Widget
103}
104
105var xTreeExpanderGLibType func() types.GType
106
107func TreeExpanderGLibType() types.GType {
108 return xTreeExpanderGLibType()
109}
110
111func TreeExpanderNewFromInternalPtr(ptr uintptr) *TreeExpander {
112 cls := &TreeExpander{}
113 cls.Ptr = ptr
114 return cls
115}
116
117var xNewTreeExpander func() uintptr
118
119// Creates a new `GtkTreeExpander`
120func NewTreeExpander() *TreeExpander {
121 var cls *TreeExpander
122
123 cret := xNewTreeExpander()
124
125 if cret == 0 {
126 return nil
127 }
128 gobject.IncreaseRef(cret)
129 cls = &TreeExpander{}
130 cls.Ptr = cret
131 return cls
132}
133
134var xTreeExpanderGetChild func(uintptr) uintptr
135
136// Gets the child widget displayed by @self.
137func (x *TreeExpander) GetChild() *Widget {
138 var cls *Widget
139
140 cret := xTreeExpanderGetChild(x.GoPointer())
141
142 if cret == 0 {
143 return nil
144 }
145 gobject.IncreaseRef(cret)
146 cls = &Widget{}
147 cls.Ptr = cret
148 return cls
149}
150
151var xTreeExpanderGetHideExpander func(uintptr) bool
152
153// Gets whether the TreeExpander should be hidden in a GtkTreeListRow.
154func (x *TreeExpander) GetHideExpander() bool {
155
156 cret := xTreeExpanderGetHideExpander(x.GoPointer())
157 return cret
158}
159
160var xTreeExpanderGetIndentForDepth func(uintptr) bool
161
162// TreeExpander indents each level of depth with an additional indent.
163func (x *TreeExpander) GetIndentForDepth() bool {
164
165 cret := xTreeExpanderGetIndentForDepth(x.GoPointer())
166 return cret
167}
168
169var xTreeExpanderGetIndentForIcon func(uintptr) bool
170
171// TreeExpander indents the child by the width of an expander-icon if it is not expandable.
172func (x *TreeExpander) GetIndentForIcon() bool {
173
174 cret := xTreeExpanderGetIndentForIcon(x.GoPointer())
175 return cret
176}
177
178var xTreeExpanderGetItem func(uintptr) uintptr
179
180// Forwards the item set on the `GtkTreeListRow` that @self is managing.
181//
182// This call is essentially equivalent to calling:
183//
184// ```c
185// gtk_tree_list_row_get_item (gtk_tree_expander_get_list_row (@self));
186// ```
187func (x *TreeExpander) GetItem() *gobject.Object {
188 var cls *gobject.Object
189
190 cret := xTreeExpanderGetItem(x.GoPointer())
191
192 if cret == 0 {
193 return nil
194 }
195 cls = &gobject.Object{}
196 cls.Ptr = cret
197 return cls
198}
199
200var xTreeExpanderGetListRow func(uintptr) uintptr
201
202// Gets the list row managed by @self.
203func (x *TreeExpander) GetListRow() *TreeListRow {
204 var cls *TreeListRow
205
206 cret := xTreeExpanderGetListRow(x.GoPointer())
207
208 if cret == 0 {
209 return nil
210 }
211 gobject.IncreaseRef(cret)
212 cls = &TreeListRow{}
213 cls.Ptr = cret
214 return cls
215}
216
217var xTreeExpanderSetChild func(uintptr, uintptr)
218
219// Sets the content widget to display.
220func (x *TreeExpander) SetChild(ChildVar *Widget) {
221
222 xTreeExpanderSetChild(x.GoPointer(), ChildVar.GoPointer())
223
224}
225
226var xTreeExpanderSetHideExpander func(uintptr, bool)
227
228// Sets whether the expander icon should be visible in a GtkTreeListRow.
229func (x *TreeExpander) SetHideExpander(HideExpanderVar bool) {
230
231 xTreeExpanderSetHideExpander(x.GoPointer(), HideExpanderVar)
232
233}
234
235var xTreeExpanderSetIndentForDepth func(uintptr, bool)
236
237// Sets if the TreeExpander should indent the child according to its depth.
238func (x *TreeExpander) SetIndentForDepth(IndentForDepthVar bool) {
239
240 xTreeExpanderSetIndentForDepth(x.GoPointer(), IndentForDepthVar)
241
242}
243
244var xTreeExpanderSetIndentForIcon func(uintptr, bool)
245
246// Sets if the TreeExpander should indent the child by the width of an expander-icon when it is not expandable.
247func (x *TreeExpander) SetIndentForIcon(IndentForIconVar bool) {
248
249 xTreeExpanderSetIndentForIcon(x.GoPointer(), IndentForIconVar)
250
251}
252
253var xTreeExpanderSetListRow func(uintptr, uintptr)
254
255// Sets the tree list row that this expander should manage.
256func (x *TreeExpander) SetListRow(ListRowVar *TreeListRow) {
257
258 xTreeExpanderSetListRow(x.GoPointer(), ListRowVar.GoPointer())
259
260}
261
262func (c *TreeExpander) GoPointer() uintptr {
263 if c == nil {
264 return 0
265 }
266 return c.Ptr
267}
268
269func (c *TreeExpander) SetGoPointer(ptr uintptr) {
270 c.Ptr = ptr
271}
272
273// SetPropertyHideExpander sets the "hide-expander" property.
274// Whether the expander icon should be hidden in a GtkTreeListRow.
275// Note that this property simply hides the icon. The actions and keybinding
276// (i.e. collapse and expand) are not affected by this property.
277//
278// A common use for this property would be to bind to the number of children in a
279// GtkTreeListRow's model in order to hide the expander when a row has no children.
280func (x *TreeExpander) SetPropertyHideExpander(value bool) {
281 var v gobject.Value
282 v.Init(gobject.TypeBooleanVal)
283 v.SetBoolean(value)
284 x.SetProperty("hide-expander", &v)
285}
286
287// GetPropertyHideExpander gets the "hide-expander" property.
288// Whether the expander icon should be hidden in a GtkTreeListRow.
289// Note that this property simply hides the icon. The actions and keybinding
290// (i.e. collapse and expand) are not affected by this property.
291//
292// A common use for this property would be to bind to the number of children in a
293// GtkTreeListRow's model in order to hide the expander when a row has no children.
294func (x *TreeExpander) GetPropertyHideExpander() bool {
295 var v gobject.Value
296 x.GetProperty("hide-expander", &v)
297 return v.GetBoolean()
298}
299
300// SetPropertyIndentForDepth sets the "indent-for-depth" property.
301// TreeExpander indents the child according to its depth.
302func (x *TreeExpander) SetPropertyIndentForDepth(value bool) {
303 var v gobject.Value
304 v.Init(gobject.TypeBooleanVal)
305 v.SetBoolean(value)
306 x.SetProperty("indent-for-depth", &v)
307}
308
309// GetPropertyIndentForDepth gets the "indent-for-depth" property.
310// TreeExpander indents the child according to its depth.
311func (x *TreeExpander) GetPropertyIndentForDepth() bool {
312 var v gobject.Value
313 x.GetProperty("indent-for-depth", &v)
314 return v.GetBoolean()
315}
316
317// SetPropertyIndentForIcon sets the "indent-for-icon" property.
318// TreeExpander indents the child by the width of an expander-icon if it is not expandable.
319func (x *TreeExpander) SetPropertyIndentForIcon(value bool) {
320 var v gobject.Value
321 v.Init(gobject.TypeBooleanVal)
322 v.SetBoolean(value)
323 x.SetProperty("indent-for-icon", &v)
324}
325
326// GetPropertyIndentForIcon gets the "indent-for-icon" property.
327// TreeExpander indents the child by the width of an expander-icon if it is not expandable.
328func (x *TreeExpander) GetPropertyIndentForIcon() bool {
329 var v gobject.Value
330 x.GetProperty("indent-for-icon", &v)
331 return v.GetBoolean()
332}
333
334// Requests the user's screen reader to announce the given message.
335//
336// This kind of notification is useful for messages that
337// either have only a visual representation or that are not
338// exposed visually at all, e.g. a notification about a
339// successful operation.
340//
341// Also, by using this API, you can ensure that the message
342// does not interrupts the user's current screen reader output.
343func (x *TreeExpander) Announce(MessageVar string, PriorityVar AccessibleAnnouncementPriority) {
344
345 XGtkAccessibleAnnounce(x.GoPointer(), MessageVar, PriorityVar)
346
347}
348
349// Retrieves the accessible parent for an accessible object.
350//
351// This function returns `NULL` for top level widgets.
352func (x *TreeExpander) GetAccessibleParent() *AccessibleBase {
353 var cls *AccessibleBase
354
355 cret := XGtkAccessibleGetAccessibleParent(x.GoPointer())
356
357 if cret == 0 {
358 return nil
359 }
360 cls = &AccessibleBase{}
361 cls.Ptr = cret
362 return cls
363}
364
365// Retrieves the accessible role of an accessible object.
366func (x *TreeExpander) GetAccessibleRole() AccessibleRole {
367
368 cret := XGtkAccessibleGetAccessibleRole(x.GoPointer())
369 return cret
370}
371
372// Retrieves the implementation for the given accessible object.
373func (x *TreeExpander) GetAtContext() *ATContext {
374 var cls *ATContext
375
376 cret := XGtkAccessibleGetAtContext(x.GoPointer())
377
378 if cret == 0 {
379 return nil
380 }
381 cls = &ATContext{}
382 cls.Ptr = cret
383 return cls
384}
385
386// Queries the coordinates and dimensions of this accessible
387//
388// This functionality can be overridden by `GtkAccessible`
389// implementations, e.g. to get the bounds from an ignored
390// child widget.
391func (x *TreeExpander) GetBounds(XVar *int, YVar *int, WidthVar *int, HeightVar *int) bool {
392
393 cret := XGtkAccessibleGetBounds(x.GoPointer(), XVar, YVar, WidthVar, HeightVar)
394 return cret
395}
396
397// Retrieves the first accessible child of an accessible object.
398func (x *TreeExpander) GetFirstAccessibleChild() *AccessibleBase {
399 var cls *AccessibleBase
400
401 cret := XGtkAccessibleGetFirstAccessibleChild(x.GoPointer())
402
403 if cret == 0 {
404 return nil
405 }
406 cls = &AccessibleBase{}
407 cls.Ptr = cret
408 return cls
409}
410
411// Retrieves the next accessible sibling of an accessible object
412func (x *TreeExpander) GetNextAccessibleSibling() *AccessibleBase {
413 var cls *AccessibleBase
414
415 cret := XGtkAccessibleGetNextAccessibleSibling(x.GoPointer())
416
417 if cret == 0 {
418 return nil
419 }
420 cls = &AccessibleBase{}
421 cls.Ptr = cret
422 return cls
423}
424
425// Queries a platform state, such as focus.
426//
427// This functionality can be overridden by `GtkAccessible`
428// implementations, e.g. to get platform state from an ignored
429// child widget, as is the case for `GtkText` wrappers.
430func (x *TreeExpander) GetPlatformState(StateVar AccessiblePlatformState) bool {
431
432 cret := XGtkAccessibleGetPlatformState(x.GoPointer(), StateVar)
433 return cret
434}
435
436// Resets the accessible property to its default value.
437func (x *TreeExpander) ResetProperty(PropertyVar AccessibleProperty) {
438
439 XGtkAccessibleResetProperty(x.GoPointer(), PropertyVar)
440
441}
442
443// Resets the accessible relation to its default value.
444func (x *TreeExpander) ResetRelation(RelationVar AccessibleRelation) {
445
446 XGtkAccessibleResetRelation(x.GoPointer(), RelationVar)
447
448}
449
450// Resets the accessible state to its default value.
451func (x *TreeExpander) ResetState(StateVar AccessibleState) {
452
453 XGtkAccessibleResetState(x.GoPointer(), StateVar)
454
455}
456
457// Sets the parent and sibling of an accessible object.
458//
459// This function is meant to be used by accessible implementations that are
460// not part of the widget hierarchy, and but act as a logical bridge between
461// widgets. For instance, if a widget creates an object that holds metadata
462// for each child, and you want that object to implement the `GtkAccessible`
463// interface, you will use this function to ensure that the parent of each
464// child widget is the metadata object, and the parent of each metadata
465// object is the container widget.
466func (x *TreeExpander) SetAccessibleParent(ParentVar Accessible, NextSiblingVar Accessible) {
467
468 XGtkAccessibleSetAccessibleParent(x.GoPointer(), ParentVar.GoPointer(), NextSiblingVar.GoPointer())
469
470}
471
472// Updates the next accessible sibling.
473//
474// That might be useful when a new child of a custom accessible
475// is created, and it needs to be linked to a previous child.
476func (x *TreeExpander) UpdateNextAccessibleSibling(NewSiblingVar Accessible) {
477
478 XGtkAccessibleUpdateNextAccessibleSibling(x.GoPointer(), NewSiblingVar.GoPointer())
479
480}
481
482// Informs ATs that the platform state has changed.
483//
484// This function should be used by `GtkAccessible` implementations that
485// have a platform state but are not widgets. Widgets handle platform
486// states automatically.
487func (x *TreeExpander) UpdatePlatformState(StateVar AccessiblePlatformState) {
488
489 XGtkAccessibleUpdatePlatformState(x.GoPointer(), StateVar)
490
491}
492
493// Updates a list of accessible properties.
494//
495// See the [enum@Gtk.AccessibleProperty] documentation for the
496// value types of accessible properties.
497//
498// This function should be called by `GtkWidget` types whenever
499// an accessible property change must be communicated to assistive
500// technologies.
501//
502// Example:
503// ```c
504// value = gtk_adjustment_get_value (adjustment);
505// gtk_accessible_update_property (GTK_ACCESSIBLE (spin_button),
506//
507// GTK_ACCESSIBLE_PROPERTY_VALUE_NOW, value,
508// -1);
509//
510// ```
511func (x *TreeExpander) UpdateProperty(FirstPropertyVar AccessibleProperty, varArgs ...interface{}) {
512
513 XGtkAccessibleUpdateProperty(x.GoPointer(), FirstPropertyVar, varArgs...)
514
515}
516
517// Updates an array of accessible properties.
518//
519// This function should be called by `GtkWidget` types whenever an accessible
520// property change must be communicated to assistive technologies.
521//
522// This function is meant to be used by language bindings.
523func (x *TreeExpander) UpdatePropertyValue(NPropertiesVar int, PropertiesVar []AccessibleProperty, ValuesVar []gobject.Value) {
524
525 XGtkAccessibleUpdatePropertyValue(x.GoPointer(), NPropertiesVar, PropertiesVar, ValuesVar)
526
527}
528
529// Updates a list of accessible relations.
530//
531// This function should be called by `GtkWidget` types whenever an accessible
532// relation change must be communicated to assistive technologies.
533//
534// If the [enum@Gtk.AccessibleRelation] requires a list of references,
535// you should pass each reference individually, followed by `NULL`, e.g.
536//
537// ```c
538// gtk_accessible_update_relation (accessible,
539//
540// GTK_ACCESSIBLE_RELATION_CONTROLS,
541// ref1, NULL,
542// GTK_ACCESSIBLE_RELATION_LABELLED_BY,
543// ref1, ref2, ref3, NULL,
544// -1);
545//
546// ```
547func (x *TreeExpander) UpdateRelation(FirstRelationVar AccessibleRelation, varArgs ...interface{}) {
548
549 XGtkAccessibleUpdateRelation(x.GoPointer(), FirstRelationVar, varArgs...)
550
551}
552
553// Updates an array of accessible relations.
554//
555// This function should be called by `GtkWidget` types whenever an accessible
556// relation change must be communicated to assistive technologies.
557//
558// This function is meant to be used by language bindings.
559func (x *TreeExpander) UpdateRelationValue(NRelationsVar int, RelationsVar []AccessibleRelation, ValuesVar []gobject.Value) {
560
561 XGtkAccessibleUpdateRelationValue(x.GoPointer(), NRelationsVar, RelationsVar, ValuesVar)
562
563}
564
565// Updates a list of accessible states.
566//
567// See the [enum@Gtk.AccessibleState] documentation for the
568// value types of accessible states.
569//
570// This function should be called by `GtkWidget` types whenever
571// an accessible state change must be communicated to assistive
572// technologies.
573//
574// Example:
575//
576// ```c
577// value = GTK_ACCESSIBLE_TRISTATE_MIXED;
578// gtk_accessible_update_state (GTK_ACCESSIBLE (check_button),
579//
580// GTK_ACCESSIBLE_STATE_CHECKED, value,
581// -1);
582//
583// ```
584func (x *TreeExpander) UpdateState(FirstStateVar AccessibleState, varArgs ...interface{}) {
585
586 XGtkAccessibleUpdateState(x.GoPointer(), FirstStateVar, varArgs...)
587
588}
589
590// Updates an array of accessible states.
591//
592// This function should be called by `GtkWidget` types whenever an accessible
593// state change must be communicated to assistive technologies.
594//
595// This function is meant to be used by language bindings.
596func (x *TreeExpander) UpdateStateValue(NStatesVar int, StatesVar []AccessibleState, ValuesVar []gobject.Value) {
597
598 XGtkAccessibleUpdateStateValue(x.GoPointer(), NStatesVar, StatesVar, ValuesVar)
599
600}
601
602// Gets the ID of the @buildable object.
603//
604// `GtkBuilder` sets the name based on the ID attribute
605// of the `<object>` tag used to construct the @buildable.
606func (x *TreeExpander) GetBuildableId() string {
607
608 cret := XGtkBuildableGetBuildableId(x.GoPointer())
609 return cret
610}
611
612func init() {
613 core.SetPackageName("GTK", "gtk4")
614 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
615 var libs []uintptr
616 for _, libPath := range core.GetPaths("GTK") {
617 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
618 if err != nil {
619 panic(err)
620 }
621 libs = append(libs, lib)
622 }
623
624 core.PuregoSafeRegister(&xTreeExpanderGLibType, libs, "gtk_tree_expander_get_type")
625
626 core.PuregoSafeRegister(&xNewTreeExpander, libs, "gtk_tree_expander_new")
627
628 core.PuregoSafeRegister(&xTreeExpanderGetChild, libs, "gtk_tree_expander_get_child")
629 core.PuregoSafeRegister(&xTreeExpanderGetHideExpander, libs, "gtk_tree_expander_get_hide_expander")
630 core.PuregoSafeRegister(&xTreeExpanderGetIndentForDepth, libs, "gtk_tree_expander_get_indent_for_depth")
631 core.PuregoSafeRegister(&xTreeExpanderGetIndentForIcon, libs, "gtk_tree_expander_get_indent_for_icon")
632 core.PuregoSafeRegister(&xTreeExpanderGetItem, libs, "gtk_tree_expander_get_item")
633 core.PuregoSafeRegister(&xTreeExpanderGetListRow, libs, "gtk_tree_expander_get_list_row")
634 core.PuregoSafeRegister(&xTreeExpanderSetChild, libs, "gtk_tree_expander_set_child")
635 core.PuregoSafeRegister(&xTreeExpanderSetHideExpander, libs, "gtk_tree_expander_set_hide_expander")
636 core.PuregoSafeRegister(&xTreeExpanderSetIndentForDepth, libs, "gtk_tree_expander_set_indent_for_depth")
637 core.PuregoSafeRegister(&xTreeExpanderSetIndentForIcon, libs, "gtk_tree_expander_set_indent_for_icon")
638 core.PuregoSafeRegister(&xTreeExpanderSetListRow, libs, "gtk_tree_expander_set_list_row")
639
640}