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 EditableLabelClass struct {
16 _ structs.HostLayout
17
18 ParentClass WidgetClass
19}
20
21func (x *EditableLabelClass) GoPointer() uintptr {
22 return uintptr(unsafe.Pointer(x))
23}
24
25// Allows users to edit the displayed text by switching to an “edit mode”.
26//
27// <picture>
28//
29// <source srcset="editable-label-dark.png" media="(prefers-color-scheme: dark)">
30// <img alt="An example GtkEditableLabel" src="editable-label.png">
31//
32// </picture>
33//
34// `GtkEditableLabel` does not have API of its own, but it
35// implements the [iface@Gtk.Editable] interface.
36//
37// The default bindings for activating the edit mode is
38// to click or press the Enter key. The default bindings
39// for leaving the edit mode are the Enter key (to save
40// the results) or the Escape key (to cancel the editing).
41//
42// # Shortcuts and Gestures
43//
44// `GtkEditableLabel` supports the following keyboard shortcuts:
45//
46// - <kbd>Enter</kbd> starts editing.
47// - <kbd>Escape</kbd> stops editing.
48//
49// # Actions
50//
51// `GtkEditableLabel` defines a set of built-in actions:
52//
53// - `editing.starts` switches the widget into editing mode.
54// - `editing.stop` switches the widget out of editing mode.
55//
56// # CSS nodes
57//
58// ```
59// editablelabel[.editing]
60// ╰── stack
61//
62// ├── label
63// ╰── text
64//
65// ```
66//
67// `GtkEditableLabel` has a main node with the name editablelabel.
68// When the entry is in editing mode, it gets the .editing style
69// class.
70//
71// For all the subnodes added to the text node in various situations,
72// see [class@Gtk.Text].
73type EditableLabel struct {
74 Widget
75}
76
77var xEditableLabelGLibType func() types.GType
78
79func EditableLabelGLibType() types.GType {
80 return xEditableLabelGLibType()
81}
82
83func EditableLabelNewFromInternalPtr(ptr uintptr) *EditableLabel {
84 cls := &EditableLabel{}
85 cls.Ptr = ptr
86 return cls
87}
88
89var xNewEditableLabel func(string) uintptr
90
91// Creates a new `GtkEditableLabel` widget.
92func NewEditableLabel(StrVar string) *EditableLabel {
93 var cls *EditableLabel
94
95 cret := xNewEditableLabel(StrVar)
96
97 if cret == 0 {
98 return nil
99 }
100 gobject.IncreaseRef(cret)
101 cls = &EditableLabel{}
102 cls.Ptr = cret
103 return cls
104}
105
106var xEditableLabelGetEditing func(uintptr) bool
107
108// Returns whether the label is currently in “editing mode”.
109func (x *EditableLabel) GetEditing() bool {
110
111 cret := xEditableLabelGetEditing(x.GoPointer())
112 return cret
113}
114
115var xEditableLabelStartEditing func(uintptr)
116
117// Switches the label into “editing mode”.
118func (x *EditableLabel) StartEditing() {
119
120 xEditableLabelStartEditing(x.GoPointer())
121
122}
123
124var xEditableLabelStopEditing func(uintptr, bool)
125
126// Switches the label out of “editing mode”.
127//
128// If @commit is %TRUE, the resulting text is kept as the
129// [property@Gtk.Editable:text] property value, otherwise the
130// resulting text is discarded and the label will keep its
131// previous [property@Gtk.Editable:text] property value.
132func (x *EditableLabel) StopEditing(CommitVar bool) {
133
134 xEditableLabelStopEditing(x.GoPointer(), CommitVar)
135
136}
137
138func (c *EditableLabel) GoPointer() uintptr {
139 if c == nil {
140 return 0
141 }
142 return c.Ptr
143}
144
145func (c *EditableLabel) SetGoPointer(ptr uintptr) {
146 c.Ptr = ptr
147}
148
149// SetPropertyEditing sets the "editing" property.
150// This property is %TRUE while the widget is in edit mode.
151func (x *EditableLabel) SetPropertyEditing(value bool) {
152 var v gobject.Value
153 v.Init(gobject.TypeBooleanVal)
154 v.SetBoolean(value)
155 x.SetProperty("editing", &v)
156}
157
158// GetPropertyEditing gets the "editing" property.
159// This property is %TRUE while the widget is in edit mode.
160func (x *EditableLabel) GetPropertyEditing() bool {
161 var v gobject.Value
162 x.GetProperty("editing", &v)
163 return v.GetBoolean()
164}
165
166// Requests the user's screen reader to announce the given message.
167//
168// This kind of notification is useful for messages that
169// either have only a visual representation or that are not
170// exposed visually at all, e.g. a notification about a
171// successful operation.
172//
173// Also, by using this API, you can ensure that the message
174// does not interrupts the user's current screen reader output.
175func (x *EditableLabel) Announce(MessageVar string, PriorityVar AccessibleAnnouncementPriority) {
176
177 XGtkAccessibleAnnounce(x.GoPointer(), MessageVar, PriorityVar)
178
179}
180
181// Retrieves the accessible parent for an accessible object.
182//
183// This function returns `NULL` for top level widgets.
184func (x *EditableLabel) GetAccessibleParent() *AccessibleBase {
185 var cls *AccessibleBase
186
187 cret := XGtkAccessibleGetAccessibleParent(x.GoPointer())
188
189 if cret == 0 {
190 return nil
191 }
192 cls = &AccessibleBase{}
193 cls.Ptr = cret
194 return cls
195}
196
197// Retrieves the accessible role of an accessible object.
198func (x *EditableLabel) GetAccessibleRole() AccessibleRole {
199
200 cret := XGtkAccessibleGetAccessibleRole(x.GoPointer())
201 return cret
202}
203
204// Retrieves the implementation for the given accessible object.
205func (x *EditableLabel) GetAtContext() *ATContext {
206 var cls *ATContext
207
208 cret := XGtkAccessibleGetAtContext(x.GoPointer())
209
210 if cret == 0 {
211 return nil
212 }
213 cls = &ATContext{}
214 cls.Ptr = cret
215 return cls
216}
217
218// Queries the coordinates and dimensions of this accessible
219//
220// This functionality can be overridden by `GtkAccessible`
221// implementations, e.g. to get the bounds from an ignored
222// child widget.
223func (x *EditableLabel) GetBounds(XVar *int, YVar *int, WidthVar *int, HeightVar *int) bool {
224
225 cret := XGtkAccessibleGetBounds(x.GoPointer(), XVar, YVar, WidthVar, HeightVar)
226 return cret
227}
228
229// Retrieves the first accessible child of an accessible object.
230func (x *EditableLabel) GetFirstAccessibleChild() *AccessibleBase {
231 var cls *AccessibleBase
232
233 cret := XGtkAccessibleGetFirstAccessibleChild(x.GoPointer())
234
235 if cret == 0 {
236 return nil
237 }
238 cls = &AccessibleBase{}
239 cls.Ptr = cret
240 return cls
241}
242
243// Retrieves the next accessible sibling of an accessible object
244func (x *EditableLabel) GetNextAccessibleSibling() *AccessibleBase {
245 var cls *AccessibleBase
246
247 cret := XGtkAccessibleGetNextAccessibleSibling(x.GoPointer())
248
249 if cret == 0 {
250 return nil
251 }
252 cls = &AccessibleBase{}
253 cls.Ptr = cret
254 return cls
255}
256
257// Queries a platform state, such as focus.
258//
259// This functionality can be overridden by `GtkAccessible`
260// implementations, e.g. to get platform state from an ignored
261// child widget, as is the case for `GtkText` wrappers.
262func (x *EditableLabel) GetPlatformState(StateVar AccessiblePlatformState) bool {
263
264 cret := XGtkAccessibleGetPlatformState(x.GoPointer(), StateVar)
265 return cret
266}
267
268// Resets the accessible property to its default value.
269func (x *EditableLabel) ResetProperty(PropertyVar AccessibleProperty) {
270
271 XGtkAccessibleResetProperty(x.GoPointer(), PropertyVar)
272
273}
274
275// Resets the accessible relation to its default value.
276func (x *EditableLabel) ResetRelation(RelationVar AccessibleRelation) {
277
278 XGtkAccessibleResetRelation(x.GoPointer(), RelationVar)
279
280}
281
282// Resets the accessible state to its default value.
283func (x *EditableLabel) ResetState(StateVar AccessibleState) {
284
285 XGtkAccessibleResetState(x.GoPointer(), StateVar)
286
287}
288
289// Sets the parent and sibling of an accessible object.
290//
291// This function is meant to be used by accessible implementations that are
292// not part of the widget hierarchy, and but act as a logical bridge between
293// widgets. For instance, if a widget creates an object that holds metadata
294// for each child, and you want that object to implement the `GtkAccessible`
295// interface, you will use this function to ensure that the parent of each
296// child widget is the metadata object, and the parent of each metadata
297// object is the container widget.
298func (x *EditableLabel) SetAccessibleParent(ParentVar Accessible, NextSiblingVar Accessible) {
299
300 XGtkAccessibleSetAccessibleParent(x.GoPointer(), ParentVar.GoPointer(), NextSiblingVar.GoPointer())
301
302}
303
304// Updates the next accessible sibling.
305//
306// That might be useful when a new child of a custom accessible
307// is created, and it needs to be linked to a previous child.
308func (x *EditableLabel) UpdateNextAccessibleSibling(NewSiblingVar Accessible) {
309
310 XGtkAccessibleUpdateNextAccessibleSibling(x.GoPointer(), NewSiblingVar.GoPointer())
311
312}
313
314// Informs ATs that the platform state has changed.
315//
316// This function should be used by `GtkAccessible` implementations that
317// have a platform state but are not widgets. Widgets handle platform
318// states automatically.
319func (x *EditableLabel) UpdatePlatformState(StateVar AccessiblePlatformState) {
320
321 XGtkAccessibleUpdatePlatformState(x.GoPointer(), StateVar)
322
323}
324
325// Updates a list of accessible properties.
326//
327// See the [enum@Gtk.AccessibleProperty] documentation for the
328// value types of accessible properties.
329//
330// This function should be called by `GtkWidget` types whenever
331// an accessible property change must be communicated to assistive
332// technologies.
333//
334// Example:
335// ```c
336// value = gtk_adjustment_get_value (adjustment);
337// gtk_accessible_update_property (GTK_ACCESSIBLE (spin_button),
338//
339// GTK_ACCESSIBLE_PROPERTY_VALUE_NOW, value,
340// -1);
341//
342// ```
343func (x *EditableLabel) UpdateProperty(FirstPropertyVar AccessibleProperty, varArgs ...interface{}) {
344
345 XGtkAccessibleUpdateProperty(x.GoPointer(), FirstPropertyVar, varArgs...)
346
347}
348
349// Updates an array of accessible properties.
350//
351// This function should be called by `GtkWidget` types whenever an accessible
352// property change must be communicated to assistive technologies.
353//
354// This function is meant to be used by language bindings.
355func (x *EditableLabel) UpdatePropertyValue(NPropertiesVar int, PropertiesVar []AccessibleProperty, ValuesVar []gobject.Value) {
356
357 XGtkAccessibleUpdatePropertyValue(x.GoPointer(), NPropertiesVar, PropertiesVar, ValuesVar)
358
359}
360
361// Updates a list of accessible relations.
362//
363// This function should be called by `GtkWidget` types whenever an accessible
364// relation change must be communicated to assistive technologies.
365//
366// If the [enum@Gtk.AccessibleRelation] requires a list of references,
367// you should pass each reference individually, followed by `NULL`, e.g.
368//
369// ```c
370// gtk_accessible_update_relation (accessible,
371//
372// GTK_ACCESSIBLE_RELATION_CONTROLS,
373// ref1, NULL,
374// GTK_ACCESSIBLE_RELATION_LABELLED_BY,
375// ref1, ref2, ref3, NULL,
376// -1);
377//
378// ```
379func (x *EditableLabel) UpdateRelation(FirstRelationVar AccessibleRelation, varArgs ...interface{}) {
380
381 XGtkAccessibleUpdateRelation(x.GoPointer(), FirstRelationVar, varArgs...)
382
383}
384
385// Updates an array of accessible relations.
386//
387// This function should be called by `GtkWidget` types whenever an accessible
388// relation change must be communicated to assistive technologies.
389//
390// This function is meant to be used by language bindings.
391func (x *EditableLabel) UpdateRelationValue(NRelationsVar int, RelationsVar []AccessibleRelation, ValuesVar []gobject.Value) {
392
393 XGtkAccessibleUpdateRelationValue(x.GoPointer(), NRelationsVar, RelationsVar, ValuesVar)
394
395}
396
397// Updates a list of accessible states.
398//
399// See the [enum@Gtk.AccessibleState] documentation for the
400// value types of accessible states.
401//
402// This function should be called by `GtkWidget` types whenever
403// an accessible state change must be communicated to assistive
404// technologies.
405//
406// Example:
407//
408// ```c
409// value = GTK_ACCESSIBLE_TRISTATE_MIXED;
410// gtk_accessible_update_state (GTK_ACCESSIBLE (check_button),
411//
412// GTK_ACCESSIBLE_STATE_CHECKED, value,
413// -1);
414//
415// ```
416func (x *EditableLabel) UpdateState(FirstStateVar AccessibleState, varArgs ...interface{}) {
417
418 XGtkAccessibleUpdateState(x.GoPointer(), FirstStateVar, varArgs...)
419
420}
421
422// Updates an array of accessible states.
423//
424// This function should be called by `GtkWidget` types whenever an accessible
425// state change must be communicated to assistive technologies.
426//
427// This function is meant to be used by language bindings.
428func (x *EditableLabel) UpdateStateValue(NStatesVar int, StatesVar []AccessibleState, ValuesVar []gobject.Value) {
429
430 XGtkAccessibleUpdateStateValue(x.GoPointer(), NStatesVar, StatesVar, ValuesVar)
431
432}
433
434// Gets the ID of the @buildable object.
435//
436// `GtkBuilder` sets the name based on the ID attribute
437// of the `<object>` tag used to construct the @buildable.
438func (x *EditableLabel) GetBuildableId() string {
439
440 cret := XGtkBuildableGetBuildableId(x.GoPointer())
441 return cret
442}
443
444// Retrieves the accessible platform state from the editable delegate.
445//
446// This is an helper function to retrieve the accessible state for
447// `GtkEditable` interface implementations using a delegate pattern.
448//
449// You should call this function in your editable widget implementation
450// of the [vfunc@Gtk.Accessible.get_platform_state] virtual function, for
451// instance:
452//
453// ```c
454// static void
455// accessible_interface_init (GtkAccessibleInterface *iface)
456//
457// {
458// iface->get_platform_state = your_editable_get_accessible_platform_state;
459// }
460//
461// static gboolean
462// your_editable_get_accessible_platform_state (GtkAccessible *accessible,
463//
464// GtkAccessiblePlatformState state)
465//
466// {
467// return gtk_editable_delegate_get_accessible_platform_state (GTK_EDITABLE (accessible), state);
468// }
469//
470// ```
471//
472// Note that the widget which is the delegate *must* be a direct child of
473// this widget, otherwise your implementation of [vfunc@Gtk.Accessible.get_platform_state]
474// might not even be called, as the platform change will originate from
475// the parent of the delegate, and, as a result, will not work properly.
476//
477// So, if you can't ensure the direct child condition, you should give the
478// delegate the %GTK_ACCESSIBLE_ROLE_TEXT_BOX role, or you can
479// change your tree to allow this function to work.
480func (x *EditableLabel) DelegateGetAccessiblePlatformState(StateVar AccessiblePlatformState) bool {
481
482 cret := XGtkEditableDelegateGetAccessiblePlatformState(x.GoPointer(), StateVar)
483 return cret
484}
485
486// Deletes the currently selected text of the editable.
487//
488// This call doesn’t do anything if there is no selected text.
489func (x *EditableLabel) DeleteSelection() {
490
491 XGtkEditableDeleteSelection(x.GoPointer())
492
493}
494
495// Deletes a sequence of characters.
496//
497// The characters that are deleted are those characters at positions
498// from @start_pos up to, but not including @end_pos. If @end_pos is
499// negative, then the characters deleted are those from @start_pos to
500// the end of the text.
501//
502// Note that the positions are specified in characters, not bytes.
503func (x *EditableLabel) DeleteText(StartPosVar int, EndPosVar int) {
504
505 XGtkEditableDeleteText(x.GoPointer(), StartPosVar, EndPosVar)
506
507}
508
509// Undoes the setup done by [method@Gtk.Editable.init_delegate].
510//
511// This is a helper function that should be called from dispose,
512// before removing the delegate object.
513func (x *EditableLabel) FinishDelegate() {
514
515 XGtkEditableFinishDelegate(x.GoPointer())
516
517}
518
519// Gets the alignment of the editable.
520func (x *EditableLabel) GetAlignment() float32 {
521
522 cret := XGtkEditableGetAlignment(x.GoPointer())
523 return cret
524}
525
526// Retrieves a sequence of characters.
527//
528// The characters that are retrieved are those characters at positions
529// from @start_pos up to, but not including @end_pos. If @end_pos is negative,
530// then the characters retrieved are those characters from @start_pos to
531// the end of the text.
532//
533// Note that positions are specified in characters, not bytes.
534func (x *EditableLabel) GetChars(StartPosVar int, EndPosVar int) string {
535
536 cret := XGtkEditableGetChars(x.GoPointer(), StartPosVar, EndPosVar)
537 return cret
538}
539
540// Gets the `GtkEditable` that @editable is delegating its
541// implementation to.
542//
543// Typically, the delegate is a [class@Gtk.Text] widget.
544func (x *EditableLabel) GetDelegate() *EditableBase {
545 var cls *EditableBase
546
547 cret := XGtkEditableGetDelegate(x.GoPointer())
548
549 if cret == 0 {
550 return nil
551 }
552 gobject.IncreaseRef(cret)
553 cls = &EditableBase{}
554 cls.Ptr = cret
555 return cls
556}
557
558// Retrieves whether @editable is editable.
559func (x *EditableLabel) GetEditable() bool {
560
561 cret := XGtkEditableGetEditable(x.GoPointer())
562 return cret
563}
564
565// Gets if undo/redo actions are enabled for @editable
566func (x *EditableLabel) GetEnableUndo() bool {
567
568 cret := XGtkEditableGetEnableUndo(x.GoPointer())
569 return cret
570}
571
572// Retrieves the desired maximum width of @editable, in characters.
573func (x *EditableLabel) GetMaxWidthChars() int {
574
575 cret := XGtkEditableGetMaxWidthChars(x.GoPointer())
576 return cret
577}
578
579// Retrieves the current position of the cursor relative
580// to the start of the content of the editable.
581//
582// Note that this position is in characters, not in bytes.
583func (x *EditableLabel) GetPosition() int {
584
585 cret := XGtkEditableGetPosition(x.GoPointer())
586 return cret
587}
588
589// Retrieves the selection bound of the editable.
590//
591// @start_pos will be filled with the start of the selection and
592// @end_pos with end. If no text was selected both will be identical
593// and %FALSE will be returned.
594//
595// Note that positions are specified in characters, not bytes.
596func (x *EditableLabel) GetSelectionBounds(StartPosVar *int, EndPosVar *int) bool {
597
598 cret := XGtkEditableGetSelectionBounds(x.GoPointer(), StartPosVar, EndPosVar)
599 return cret
600}
601
602// Retrieves the contents of @editable.
603//
604// The returned string is owned by GTK and must not be modified or freed.
605func (x *EditableLabel) GetText() string {
606
607 cret := XGtkEditableGetText(x.GoPointer())
608 return cret
609}
610
611// Gets the number of characters of space reserved
612// for the contents of the editable.
613func (x *EditableLabel) GetWidthChars() int {
614
615 cret := XGtkEditableGetWidthChars(x.GoPointer())
616 return cret
617}
618
619// Sets up a delegate for `GtkEditable`.
620//
621// This is assuming that the get_delegate vfunc in the `GtkEditable`
622// interface has been set up for the @editable's type.
623//
624// This is a helper function that should be called in instance init,
625// after creating the delegate object.
626func (x *EditableLabel) InitDelegate() {
627
628 XGtkEditableInitDelegate(x.GoPointer())
629
630}
631
632// Inserts @length bytes of @text into the contents of the
633// widget, at position @position.
634//
635// Note that the position is in characters, not in bytes.
636// The function updates @position to point after the newly
637// inserted text.
638func (x *EditableLabel) InsertText(TextVar string, LengthVar int, PositionVar *int) {
639
640 XGtkEditableInsertText(x.GoPointer(), TextVar, LengthVar, PositionVar)
641
642}
643
644// Selects a region of text.
645//
646// The characters that are selected are those characters at positions
647// from @start_pos up to, but not including @end_pos. If @end_pos is
648// negative, then the characters selected are those characters from
649// @start_pos to the end of the text.
650//
651// Note that positions are specified in characters, not bytes.
652func (x *EditableLabel) SelectRegion(StartPosVar int, EndPosVar int) {
653
654 XGtkEditableSelectRegion(x.GoPointer(), StartPosVar, EndPosVar)
655
656}
657
658// Sets the alignment for the contents of the editable.
659//
660// This controls the horizontal positioning of the contents when
661// the displayed text is shorter than the width of the editable.
662func (x *EditableLabel) SetAlignment(XalignVar float32) {
663
664 XGtkEditableSetAlignment(x.GoPointer(), XalignVar)
665
666}
667
668// Determines if the user can edit the text in the editable widget.
669func (x *EditableLabel) SetEditable(IsEditableVar bool) {
670
671 XGtkEditableSetEditable(x.GoPointer(), IsEditableVar)
672
673}
674
675// If enabled, changes to @editable will be saved for undo/redo
676// actions.
677//
678// This results in an additional copy of text changes and are not
679// stored in secure memory. As such, undo is forcefully disabled
680// when [property@Gtk.Text:visibility] is set to %FALSE.
681func (x *EditableLabel) SetEnableUndo(EnableUndoVar bool) {
682
683 XGtkEditableSetEnableUndo(x.GoPointer(), EnableUndoVar)
684
685}
686
687// Sets the desired maximum width in characters of @editable.
688func (x *EditableLabel) SetMaxWidthChars(NCharsVar int) {
689
690 XGtkEditableSetMaxWidthChars(x.GoPointer(), NCharsVar)
691
692}
693
694// Sets the cursor position in the editable to the given value.
695//
696// The cursor is displayed before the character with the given (base 0)
697// index in the contents of the editable. The value must be less than
698// or equal to the number of characters in the editable. A value of -1
699// indicates that the position should be set after the last character
700// of the editable. Note that @position is in characters, not in bytes.
701func (x *EditableLabel) SetPosition(PositionVar int) {
702
703 XGtkEditableSetPosition(x.GoPointer(), PositionVar)
704
705}
706
707// Sets the text in the editable to the given value.
708//
709// This is replacing the current contents.
710func (x *EditableLabel) SetText(TextVar string) {
711
712 XGtkEditableSetText(x.GoPointer(), TextVar)
713
714}
715
716// Changes the size request of the editable to be about the
717// right size for @n_chars characters.
718//
719// Note that it changes the size request, the size can still
720// be affected by how you pack the widget into containers.
721// If @n_chars is -1, the size reverts to the default size.
722func (x *EditableLabel) SetWidthChars(NCharsVar int) {
723
724 XGtkEditableSetWidthChars(x.GoPointer(), NCharsVar)
725
726}
727
728func init() {
729 core.SetPackageName("GTK", "gtk4")
730 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
731 var libs []uintptr
732 for _, libPath := range core.GetPaths("GTK") {
733 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
734 if err != nil {
735 panic(err)
736 }
737 libs = append(libs, lib)
738 }
739
740 core.PuregoSafeRegister(&xEditableLabelGLibType, libs, "gtk_editable_label_get_type")
741
742 core.PuregoSafeRegister(&xNewEditableLabel, libs, "gtk_editable_label_new")
743
744 core.PuregoSafeRegister(&xEditableLabelGetEditing, libs, "gtk_editable_label_get_editing")
745 core.PuregoSafeRegister(&xEditableLabelStartEditing, libs, "gtk_editable_label_start_editing")
746 core.PuregoSafeRegister(&xEditableLabelStopEditing, libs, "gtk_editable_label_stop_editing")
747
748}