1// Package gtk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gtk
3
4import (
5 "unsafe"
6
7 "github.com/ebitengine/purego"
8
9 "github.com/bnema/puregotk/pkg/core"
10 "github.com/bnema/puregotk/v4/gio"
11 "github.com/bnema/puregotk/v4/glib"
12 "github.com/bnema/puregotk/v4/gobject"
13 "github.com/bnema/puregotk/v4/gobject/types"
14 "github.com/bnema/puregotk/v4/pango"
15)
16
17// Displays a small amount of text.
18//
19// Most labels are used to label another widget (such as an [class@Entry]).
20//
21// <picture>
22//
23// <source srcset="label-dark.png" media="(prefers-color-scheme: dark)">
24// <img alt="An example GtkLabel" src="label.png">
25//
26// </picture>
27//
28// ## Shortcuts and Gestures
29//
30// `GtkLabel` supports the following keyboard shortcuts, when the cursor is
31// visible:
32//
33// - <kbd>Shift</kbd>+<kbd>F10</kbd> or <kbd>Menu</kbd> opens the context menu.
34// - <kbd>Ctrl</kbd>+<kbd>A</kbd> or <kbd>Ctrl</kbd>+<kbd>&sol;</kbd>
35// selects all.
36// - <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>A</kbd> or
37// <kbd>Ctrl</kbd>+<kbd>&bsol;</kbd> unselects all.
38//
39// Additionally, the following signals have default keybindings:
40//
41// - [signal@Gtk.Label::activate-current-link]
42// - [signal@Gtk.Label::copy-clipboard]
43// - [signal@Gtk.Label::move-cursor]
44//
45// ## Actions
46//
47// `GtkLabel` defines a set of built-in actions:
48//
49// - `clipboard.copy` copies the text to the clipboard.
50// - `clipboard.cut` doesn't do anything, since text in labels can't be deleted.
51// - `clipboard.paste` doesn't do anything, since text in labels can't be
52// edited.
53// - `link.open` opens the link, when activated on a link inside the label.
54// - `link.copy` copies the link to the clipboard, when activated on a link
55// inside the label.
56// - `menu.popup` opens the context menu.
57// - `selection.delete` doesn't do anything, since text in labels can't be
58// deleted.
59// - `selection.select-all` selects all of the text, if the label allows
60// selection.
61//
62// ## CSS nodes
63//
64// ```
65// label
66// ├── [selection]
67// ├── [link]
68// ┊
69// ╰── [link]
70// ```
71//
72// `GtkLabel` has a single CSS node with the name label. A wide variety
73// of style classes may be applied to labels, such as .title, .subtitle,
74// .dim-label, etc. In the `GtkShortcutsWindow`, labels are used with the
75// .keycap style class.
76//
77// If the label has a selection, it gets a subnode with name selection.
78//
79// If the label has links, there is one subnode per link. These subnodes
80// carry the link or visited state depending on whether they have been
81// visited. In this case, label node also gets a .link style class.
82//
83// ## GtkLabel as GtkBuildable
84//
85// The GtkLabel implementation of the GtkBuildable interface supports a
86// custom `<attributes>` element, which supports any number of `<attribute>`
87// elements. The `<attribute>` element has attributes named “name“, “value“,
88// “start“ and “end“ and allows you to specify [struct@Pango.Attribute]
89// values for this label.
90//
91// An example of a UI definition fragment specifying Pango attributes:
92//
93// ```xml
94// <object class="GtkLabel">
95//
96// <attributes>
97// <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
98// <attribute name="background" value="red" start="5" end="10"/>
99// </attributes>
100//
101// </object>
102// ```
103//
104// The start and end attributes specify the range of characters to which the
105// Pango attribute applies. If start and end are not specified, the attribute is
106// applied to the whole text. Note that specifying ranges does not make much
107// sense with translatable attributes. Use markup embedded in the translatable
108// content instead.
109//
110// ## Accessibility
111//
112// `GtkLabel` uses the [enum@Gtk.AccessibleRole.label] role.
113//
114// ## Mnemonics
115//
116// Labels may contain “mnemonics”. Mnemonics are underlined characters in the
117// label, used for keyboard navigation. Mnemonics are created by providing a
118// string with an underscore before the mnemonic character, such as `"_File"`,
119// to the functions [ctor@Gtk.Label.new_with_mnemonic] or
120// [method@Gtk.Label.set_text_with_mnemonic].
121//
122// Mnemonics automatically activate any activatable widget the label is
123// inside, such as a [class@Gtk.Button]; if the label is not inside the
124// mnemonic’s target widget, you have to tell the label about the target
125// using [method@Gtk.Label.set_mnemonic_widget].
126//
127// Here’s a simple example where the label is inside a button:
128//
129// ```c
130// // Pressing Alt+H will activate this button
131// GtkWidget *button = gtk_button_new ();
132// GtkWidget *label = gtk_label_new_with_mnemonic ("_Hello");
133// gtk_button_set_child (GTK_BUTTON (button), label);
134// ```
135//
136// There’s a convenience function to create buttons with a mnemonic label
137// already inside:
138//
139// ```c
140// // Pressing Alt+H will activate this button
141// GtkWidget *button = gtk_button_new_with_mnemonic ("_Hello");
142// ```
143//
144// To create a mnemonic for a widget alongside the label, such as a
145// [class@Gtk.Entry], you have to point the label at the entry with
146// [method@Gtk.Label.set_mnemonic_widget]:
147//
148// ```c
149// // Pressing Alt+H will focus the entry
150// GtkWidget *entry = gtk_entry_new ();
151// GtkWidget *label = gtk_label_new_with_mnemonic ("_Hello");
152// gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
153// ```
154//
155// ## Markup (styled text)
156//
157// To make it easy to format text in a label (changing colors, fonts, etc.),
158// label text can be provided in a simple markup format:
159//
160// Here’s how to create a label with a small font:
161// ```c
162// GtkWidget *label = gtk_label_new (NULL);
163// gtk_label_set_markup (GTK_LABEL (label), "<small>Small text</small>");
164// ```
165//
166// (See the Pango manual for complete documentation] of available
167// tags, [func@Pango.parse_markup])
168//
169// The markup passed to [method@Gtk.Label.set_markup] must be valid XML; for example,
170// literal `<`, `>` and `&` characters must be escaped as `&lt;`, `&gt;`, and `&amp;`.
171// If you pass text obtained from the user, file, or a network to
172// [method@Gtk.Label.set_markup], you’ll want to escape it with
173// [func@GLib.markup_escape_text] or [func@GLib.markup_printf_escaped].
174//
175// Markup strings are just a convenient way to set the [struct@Pango.AttrList]
176// on a label; [method@Gtk.Label.set_attributes] may be a simpler way to set
177// attributes in some cases. Be careful though; [struct@Pango.AttrList] tends
178// to cause internationalization problems, unless you’re applying attributes
179// to the entire string (i.e. unless you set the range of each attribute
180// to [0, `G_MAXINT`)). The reason is that specifying the `start_index` and
181// `end_index` for a [struct@Pango.Attribute] requires knowledge of the exact
182// string being displayed, so translations will cause problems.
183//
184// ## Selectable labels
185//
186// Labels can be made selectable with [method@Gtk.Label.set_selectable].
187// Selectable labels allow the user to copy the label contents to the
188// clipboard. Only labels that contain useful-to-copy information — such
189// as error messages — should be made selectable.
190//
191// ## Text layout
192//
193// A label can contain any number of paragraphs, but will have
194// performance problems if it contains more than a small number.
195// Paragraphs are separated by newlines or other paragraph separators
196// understood by Pango.
197//
198// Labels can automatically wrap text if you call [method@Gtk.Label.set_wrap].
199//
200// [method@Gtk.Label.set_justify] sets how the lines in a label align
201// with one another. If you want to set how the label as a whole aligns
202// in its available space, see the [property@Gtk.Widget:halign] and
203// [property@Gtk.Widget:valign] properties.
204//
205// The [property@Gtk.Label:width-chars] and [property@Gtk.Label:max-width-chars]
206// properties can be used to control the size allocation of ellipsized or
207// wrapped labels. For ellipsizing labels, if either is specified (and less
208// than the actual text size), it is used as the minimum width, and the actual
209// text size is used as the natural width of the label. For wrapping labels,
210// width-chars is used as the minimum width, if specified, and max-width-chars
211// is used as the natural width. Even if max-width-chars specified, wrapping
212// labels will be rewrapped to use all of the available width.
213//
214// ## Links
215//
216// GTK supports markup for clickable hyperlinks in addition to regular Pango
217// markup. The markup for links is borrowed from HTML, using the `<a>` tag
218// with “href“, “title“ and “class“ attributes. GTK renders links similar to
219// the way they appear in web browsers, with colored, underlined text. The
220// “title“ attribute is displayed as a tooltip on the link. The “class“
221// attribute is used as style class on the CSS node for the link.
222//
223// An example of inline links looks like this:
224//
225// ```c
226// const char *text =
227// "Go to the "
228// "<a href=\"https://www.gtk.org\" title=\"&lt;i&gt;Our&lt;/i&gt; website\">"
229// "GTK website</a> for more...";
230// GtkWidget *label = gtk_label_new (NULL);
231// gtk_label_set_markup (GTK_LABEL (label), text);
232// ```
233//
234// It is possible to implement custom handling for links and their tooltips
235// with the [signal@Gtk.Label::activate-link] signal and the
236// [method@Gtk.Label.get_current_uri] function.
237type Label struct {
238 Widget
239}
240
241var xLabelGLibType func() types.GType
242
243func LabelGLibType() types.GType {
244 return xLabelGLibType()
245}
246
247func LabelNewFromInternalPtr(ptr uintptr) *Label {
248 cls := &Label{}
249 cls.Ptr = ptr
250 return cls
251}
252
253var xNewLabel func(uintptr) uintptr
254
255// Creates a new label with the given text inside it.
256//
257// You can pass `NULL` to get an empty label widget.
258func NewLabel(StrVar *string) *Label {
259 var cls *Label
260
261 StrVarPtr := core.GStrdupNullable(StrVar)
262 defer core.GFreeNullable(StrVarPtr)
263
264 cret := xNewLabel(StrVarPtr)
265
266 if cret == 0 {
267 return nil
268 }
269 gobject.IncreaseRef(cret)
270 cls = &Label{}
271 cls.Ptr = cret
272 return cls
273}
274
275var xNewLabelWithMnemonic func(uintptr) uintptr
276
277// Creates a new label with the given text inside it, and a mnemonic.
278//
279// If characters in @str are preceded by an underscore, they are
280// underlined. If you need a literal underscore character in a label, use
281// '__' (two underscores). The first underlined character represents a
282// keyboard accelerator called a mnemonic. The mnemonic key can be used
283// to activate another widget, chosen automatically, or explicitly using
284// [method@Gtk.Label.set_mnemonic_widget].
285//
286// If [method@Gtk.Label.set_mnemonic_widget] is not called, then the first
287// activatable ancestor of the label will be chosen as the mnemonic
288// widget. For instance, if the label is inside a button or menu item,
289// the button or menu item will automatically become the mnemonic widget
290// and be activated by the mnemonic.
291func NewLabelWithMnemonic(StrVar *string) *Label {
292 var cls *Label
293
294 StrVarPtr := core.GStrdupNullable(StrVar)
295 defer core.GFreeNullable(StrVarPtr)
296
297 cret := xNewLabelWithMnemonic(StrVarPtr)
298
299 if cret == 0 {
300 return nil
301 }
302 gobject.IncreaseRef(cret)
303 cls = &Label{}
304 cls.Ptr = cret
305 return cls
306}
307
308var xLabelGetAttributes func(uintptr) *pango.AttrList
309
310// Gets the label's attribute list.
311//
312// This is the [struct@Pango.AttrList] that was set on the label using
313// [method@Gtk.Label.set_attributes], if any. This function does not
314// reflect attributes that come from the label's markup (see
315// [method@Gtk.Label.set_markup]). If you want to get the effective
316// attributes for the label, use
317// `pango_layout_get_attributes (gtk_label_get_layout (self))`.
318func (x *Label) GetAttributes() *pango.AttrList {
319
320 cret := xLabelGetAttributes(x.GoPointer())
321 return cret
322}
323
324var xLabelGetCurrentUri func(uintptr) string
325
326// Returns the URI for the active link in the label.
327//
328// The active link is the one under the mouse pointer or, in a
329// selectable label, the link in which the text cursor is currently
330// positioned.
331//
332// This function is intended for use in a [signal@Gtk.Label::activate-link]
333// handler or for use in a [signal@Gtk.Widget::query-tooltip] handler.
334func (x *Label) GetCurrentUri() string {
335
336 cret := xLabelGetCurrentUri(x.GoPointer())
337 return cret
338}
339
340var xLabelGetEllipsize func(uintptr) pango.EllipsizeMode
341
342// Returns the ellipsization mode of the label.
343//
344// See [method@Gtk.Label.set_ellipsize].
345func (x *Label) GetEllipsize() pango.EllipsizeMode {
346
347 cret := xLabelGetEllipsize(x.GoPointer())
348 return cret
349}
350
351var xLabelGetExtraMenu func(uintptr) uintptr
352
353// Gets the extra menu model of the label.
354//
355// See [method@Gtk.Label.set_extra_menu].
356func (x *Label) GetExtraMenu() *gio.MenuModel {
357 var cls *gio.MenuModel
358
359 cret := xLabelGetExtraMenu(x.GoPointer())
360
361 if cret == 0 {
362 return nil
363 }
364 gobject.IncreaseRef(cret)
365 cls = &gio.MenuModel{}
366 cls.Ptr = cret
367 return cls
368}
369
370var xLabelGetJustify func(uintptr) Justification
371
372// Returns the justification of the label.
373//
374// See [method@Gtk.Label.set_justify].
375func (x *Label) GetJustify() Justification {
376
377 cret := xLabelGetJustify(x.GoPointer())
378 return cret
379}
380
381var xLabelGetLabel func(uintptr) string
382
383// Fetches the text from a label.
384//
385// The returned text includes any embedded underlines indicating
386// mnemonics and Pango markup. (See [method@Gtk.Label.get_text]).
387func (x *Label) GetLabel() string {
388
389 cret := xLabelGetLabel(x.GoPointer())
390 return cret
391}
392
393var xLabelGetLayout func(uintptr) uintptr
394
395// Gets the Pango layout used to display the label.
396//
397// The layout is useful to e.g. convert text positions to pixel
398// positions, in combination with [method@Gtk.Label.get_layout_offsets].
399// The returned layout is owned by the @label so need not be
400// freed by the caller. The @label is free to recreate its layout
401// at any time, so it should be considered read-only.
402func (x *Label) GetLayout() *pango.Layout {
403 var cls *pango.Layout
404
405 cret := xLabelGetLayout(x.GoPointer())
406
407 if cret == 0 {
408 return nil
409 }
410 gobject.IncreaseRef(cret)
411 cls = &pango.Layout{}
412 cls.Ptr = cret
413 return cls
414}
415
416var xLabelGetLayoutOffsets func(uintptr, *int, *int)
417
418// Obtains the coordinates where the label will draw its Pango layout.
419//
420// The coordinates are useful to convert mouse events into coordinates
421// inside the [class@Pango.Layout], e.g. to take some action if some part
422// of the label is clicked. Remember when using the [class@Pango.Layout]
423// functions you need to convert to and from pixels using `PANGO_PIXELS()`
424// or [const@Pango.SCALE].
425func (x *Label) GetLayoutOffsets(XVar *int, YVar *int) {
426
427 xLabelGetLayoutOffsets(x.GoPointer(), XVar, YVar)
428
429}
430
431var xLabelGetLines func(uintptr) int
432
433// Gets the number of lines to which an ellipsized, wrapping
434// label should be limited.
435//
436// See [method@Gtk.Label.set_lines].
437func (x *Label) GetLines() int {
438
439 cret := xLabelGetLines(x.GoPointer())
440 return cret
441}
442
443var xLabelGetMaxWidthChars func(uintptr) int
444
445// Retrieves the maximum width of the label in characters.
446//
447// See [method@Gtk.Label.set_width_chars].
448func (x *Label) GetMaxWidthChars() int {
449
450 cret := xLabelGetMaxWidthChars(x.GoPointer())
451 return cret
452}
453
454var xLabelGetMnemonicKeyval func(uintptr) uint
455
456// Return the mnemonic accelerator.
457//
458// If the label has been set so that it has a mnemonic key this function
459// returns the keyval used for the mnemonic accelerator. If there is no
460// mnemonic set up it returns `GDK_KEY_VoidSymbol`.
461func (x *Label) GetMnemonicKeyval() uint {
462
463 cret := xLabelGetMnemonicKeyval(x.GoPointer())
464 return cret
465}
466
467var xLabelGetMnemonicWidget func(uintptr) uintptr
468
469// Retrieves the mnemonic target of this label.
470//
471// See [method@Gtk.Label.set_mnemonic_widget].
472func (x *Label) GetMnemonicWidget() *Widget {
473 var cls *Widget
474
475 cret := xLabelGetMnemonicWidget(x.GoPointer())
476
477 if cret == 0 {
478 return nil
479 }
480 gobject.IncreaseRef(cret)
481 cls = &Widget{}
482 cls.Ptr = cret
483 return cls
484}
485
486var xLabelGetNaturalWrapMode func(uintptr) NaturalWrapMode
487
488// Returns natural line wrap mode used by the label.
489//
490// See [method@Gtk.Label.set_natural_wrap_mode].
491func (x *Label) GetNaturalWrapMode() NaturalWrapMode {
492
493 cret := xLabelGetNaturalWrapMode(x.GoPointer())
494 return cret
495}
496
497var xLabelGetSelectable func(uintptr) bool
498
499// Returns whether the label is selectable.
500func (x *Label) GetSelectable() bool {
501
502 cret := xLabelGetSelectable(x.GoPointer())
503 return cret
504}
505
506var xLabelGetSelectionBounds func(uintptr, *int, *int) bool
507
508// Gets the selected range of characters in the label.
509//
510// The returned @start and @end positions are in characters.
511func (x *Label) GetSelectionBounds(StartVar *int, EndVar *int) bool {
512
513 cret := xLabelGetSelectionBounds(x.GoPointer(), StartVar, EndVar)
514 return cret
515}
516
517var xLabelGetSingleLineMode func(uintptr) bool
518
519// Returns whether the label is in single line mode.
520func (x *Label) GetSingleLineMode() bool {
521
522 cret := xLabelGetSingleLineMode(x.GoPointer())
523 return cret
524}
525
526var xLabelGetTabs func(uintptr) *pango.TabArray
527
528// Gets the tab stops for the label.
529//
530// The returned array will be `NULL` if “standard” (8-space) tabs are used.
531func (x *Label) GetTabs() *pango.TabArray {
532
533 cret := xLabelGetTabs(x.GoPointer())
534 return cret
535}
536
537var xLabelGetText func(uintptr) string
538
539// Gets the text of the label.
540//
541// The returned text is as it appears on screen. This does not include
542// any embedded underlines indicating mnemonics or Pango markup. (See
543// [method@Gtk.Label.get_label])
544func (x *Label) GetText() string {
545
546 cret := xLabelGetText(x.GoPointer())
547 return cret
548}
549
550var xLabelGetUseMarkup func(uintptr) bool
551
552// Returns whether the label’s text is interpreted as Pango markup.
553//
554// See [method@Gtk.Label.set_use_markup].
555func (x *Label) GetUseMarkup() bool {
556
557 cret := xLabelGetUseMarkup(x.GoPointer())
558 return cret
559}
560
561var xLabelGetUseUnderline func(uintptr) bool
562
563// Returns whether underlines in the label indicate mnemonics.
564//
565// See [method@Gtk.Label.set_use_underline].
566func (x *Label) GetUseUnderline() bool {
567
568 cret := xLabelGetUseUnderline(x.GoPointer())
569 return cret
570}
571
572var xLabelGetWidthChars func(uintptr) int
573
574// Retrieves the desired width of the label in characters.
575//
576// See [method@Gtk.Label.set_width_chars].
577func (x *Label) GetWidthChars() int {
578
579 cret := xLabelGetWidthChars(x.GoPointer())
580 return cret
581}
582
583var xLabelGetWrap func(uintptr) bool
584
585// Returns whether lines in the label are automatically wrapped.
586//
587// See [method@Gtk.Label.set_wrap].
588func (x *Label) GetWrap() bool {
589
590 cret := xLabelGetWrap(x.GoPointer())
591 return cret
592}
593
594var xLabelGetWrapMode func(uintptr) pango.WrapMode
595
596// Returns line wrap mode used by the label.
597//
598// See [method@Gtk.Label.set_wrap_mode].
599func (x *Label) GetWrapMode() pango.WrapMode {
600
601 cret := xLabelGetWrapMode(x.GoPointer())
602 return cret
603}
604
605var xLabelGetXalign func(uintptr) float32
606
607// Gets the `xalign` of the label.
608//
609// See the [property@Gtk.Label:xalign] property.
610func (x *Label) GetXalign() float32 {
611
612 cret := xLabelGetXalign(x.GoPointer())
613 return cret
614}
615
616var xLabelGetYalign func(uintptr) float32
617
618// Gets the `yalign` of the label.
619//
620// See the [property@Gtk.Label:yalign] property.
621func (x *Label) GetYalign() float32 {
622
623 cret := xLabelGetYalign(x.GoPointer())
624 return cret
625}
626
627var xLabelSelectRegion func(uintptr, int, int)
628
629// Selects a range of characters in the label, if the label is selectable.
630//
631// See [method@Gtk.Label.set_selectable]. If the label is not selectable,
632// this function has no effect. If @start_offset or
633// @end_offset are -1, then the end of the label will be substituted.
634func (x *Label) SelectRegion(StartOffsetVar int, EndOffsetVar int) {
635
636 xLabelSelectRegion(x.GoPointer(), StartOffsetVar, EndOffsetVar)
637
638}
639
640var xLabelSetAttributes func(uintptr, *pango.AttrList)
641
642// Apply attributes to the label text.
643//
644// The attributes set with this function will be applied and merged with
645// any other attributes previously effected by way of the
646// [property@Gtk.Label:use-underline] or [property@Gtk.Label:use-markup]
647// properties
648//
649// While it is not recommended to mix markup strings with manually set
650// attributes, if you must; know that the attributes will be applied
651// to the label after the markup string is parsed.
652func (x *Label) SetAttributes(AttrsVar *pango.AttrList) {
653
654 xLabelSetAttributes(x.GoPointer(), AttrsVar)
655
656}
657
658var xLabelSetEllipsize func(uintptr, pango.EllipsizeMode)
659
660// Sets the mode used to ellipsize the text.
661//
662// The text will be ellipsized if there is not
663// enough space to render the entire string.
664func (x *Label) SetEllipsize(ModeVar pango.EllipsizeMode) {
665
666 xLabelSetEllipsize(x.GoPointer(), ModeVar)
667
668}
669
670var xLabelSetExtraMenu func(uintptr, uintptr)
671
672// Sets a menu model to add to the context menu of the label.
673func (x *Label) SetExtraMenu(ModelVar *gio.MenuModel) {
674
675 xLabelSetExtraMenu(x.GoPointer(), ModelVar.GoPointer())
676
677}
678
679var xLabelSetJustify func(uintptr, Justification)
680
681// Sets the alignment of lines in the label relative to each other.
682//
683// This function has no effect on labels containing only a single line.
684//
685// [enum@Gtk.Justification.left] is the default value when the widget
686// is first created with [ctor@Gtk.Label.new].
687//
688// If you instead want to set the alignment of the label as a whole,
689// use [method@Gtk.Widget.set_halign] instead.
690func (x *Label) SetJustify(JtypeVar Justification) {
691
692 xLabelSetJustify(x.GoPointer(), JtypeVar)
693
694}
695
696var xLabelSetLabel func(uintptr, string)
697
698// Sets the text of the label.
699//
700// The label is interpreted as including embedded underlines and/or Pango
701// markup depending on the values of the [property@Gtk.Label:use-underline]
702// and [property@Gtk.Label:use-markup] properties.
703func (x *Label) SetLabel(StrVar string) {
704
705 xLabelSetLabel(x.GoPointer(), StrVar)
706
707}
708
709var xLabelSetLines func(uintptr, int)
710
711// Sets the number of lines to which an ellipsized, wrapping label
712// should be limited.
713//
714// This has no effect if the label is not wrapping or ellipsized.
715// Set this to -1 if you don’t want to limit the number of lines.
716func (x *Label) SetLines(LinesVar int) {
717
718 xLabelSetLines(x.GoPointer(), LinesVar)
719
720}
721
722var xLabelSetMarkup func(uintptr, string)
723
724// Sets the labels text and attributes from markup.
725//
726// The string must be marked up with Pango markup
727// (see [func@Pango.parse_markup]).
728//
729// If @str is external data, you may need to escape it
730// with [func@GLib.markup_escape_text] or [func@GLib.markup_printf_escaped]:
731//
732// ```c
733// GtkWidget *self = gtk_label_new (NULL);
734// const char *str = "...";
735// const char *format = "<span style=\"italic\">\%s</span>";
736// char *markup;
737//
738// markup = g_markup_printf_escaped (format, str);
739// gtk_label_set_markup (GTK_LABEL (self), markup);
740// g_free (markup);
741// ```
742//
743// This function sets the [property@Gtk.Label:use-markup] property
744// to true.
745//
746// Also see [method@Gtk.Label.set_text].
747func (x *Label) SetMarkup(StrVar string) {
748
749 xLabelSetMarkup(x.GoPointer(), StrVar)
750
751}
752
753var xLabelSetMarkupWithMnemonic func(uintptr, string)
754
755// Sets the labels text, attributes and mnemonic from markup.
756//
757// Parses @str which is marked up with Pango markup (see [func@Pango.parse_markup]),
758// setting the label’s text and attribute list based on the parse results.
759// If characters in @str are preceded by an underscore, they are underlined
760// indicating that they represent a keyboard accelerator called a mnemonic.
761//
762// The mnemonic key can be used to activate another widget, chosen
763// automatically, or explicitly using [method@Gtk.Label.set_mnemonic_widget].
764func (x *Label) SetMarkupWithMnemonic(StrVar string) {
765
766 xLabelSetMarkupWithMnemonic(x.GoPointer(), StrVar)
767
768}
769
770var xLabelSetMaxWidthChars func(uintptr, int)
771
772// Sets the maximum width of the label in characters.
773func (x *Label) SetMaxWidthChars(NCharsVar int) {
774
775 xLabelSetMaxWidthChars(x.GoPointer(), NCharsVar)
776
777}
778
779var xLabelSetMnemonicWidget func(uintptr, uintptr)
780
781// Associate the label with its mnemonic target.
782//
783// If the label has been set so that it has a mnemonic key (using
784// i.e. [method@Gtk.Label.set_markup_with_mnemonic],
785// [method@Gtk.Label.set_text_with_mnemonic],
786// [ctor@Gtk.Label.new_with_mnemonic]
787// or the [property@Gtk.Label:use_underline] property) the label can
788// be associated with a widget that is the target of the mnemonic.
789// When the label is inside a widget (like a [class@Gtk.Button] or a
790// [class@Gtk.Notebook] tab) it is automatically associated with the
791// correct widget, but sometimes (i.e. when the target is a [class@Gtk.Entry]
792// next to the label) you need to set it explicitly using this function.
793//
794// The target widget will be accelerated by emitting the
795// [signal@Gtk.Widget::mnemonic-activate] signal on it. The default handler
796// for this signal will activate the widget if there are no mnemonic
797// collisions and toggle focus between the colliding widgets otherwise.
798func (x *Label) SetMnemonicWidget(WidgetVar *Widget) {
799
800 xLabelSetMnemonicWidget(x.GoPointer(), WidgetVar.GoPointer())
801
802}
803
804var xLabelSetNaturalWrapMode func(uintptr, NaturalWrapMode)
805
806// Selects the line wrapping for the natural size request.
807//
808// This only affects the natural size requested, for the actual wrapping used,
809// see the [property@Gtk.Label:wrap-mode] property.
810func (x *Label) SetNaturalWrapMode(WrapModeVar NaturalWrapMode) {
811
812 xLabelSetNaturalWrapMode(x.GoPointer(), WrapModeVar)
813
814}
815
816var xLabelSetSelectable func(uintptr, bool)
817
818// Makes text in the label selectable.
819//
820// Selectable labels allow the user to select text from the label,
821// for copy-and-paste.
822func (x *Label) SetSelectable(SettingVar bool) {
823
824 xLabelSetSelectable(x.GoPointer(), SettingVar)
825
826}
827
828var xLabelSetSingleLineMode func(uintptr, bool)
829
830// Sets whether the label is in single line mode.
831func (x *Label) SetSingleLineMode(SingleLineModeVar bool) {
832
833 xLabelSetSingleLineMode(x.GoPointer(), SingleLineModeVar)
834
835}
836
837var xLabelSetTabs func(uintptr, *pango.TabArray)
838
839// Sets tab stops for the label.
840func (x *Label) SetTabs(TabsVar *pango.TabArray) {
841
842 xLabelSetTabs(x.GoPointer(), TabsVar)
843
844}
845
846var xLabelSetText func(uintptr, string)
847
848// Sets the text for the label.
849//
850// It overwrites any text that was there before and clears any
851// previously set mnemonic accelerators, and sets the
852// [property@Gtk.Label:use-underline] and
853// [property@Gtk.Label:use-markup] properties to false.
854//
855// Also see [method@Gtk.Label.set_markup].
856func (x *Label) SetText(StrVar string) {
857
858 xLabelSetText(x.GoPointer(), StrVar)
859
860}
861
862var xLabelSetTextWithMnemonic func(uintptr, string)
863
864// Sets the text for the label, with mnemonics.
865//
866// If characters in @str are preceded by an underscore, they are underlined
867// indicating that they represent a keyboard accelerator called a mnemonic.
868// The mnemonic key can be used to activate another widget, chosen
869// automatically, or explicitly using [method@Gtk.Label.set_mnemonic_widget].
870func (x *Label) SetTextWithMnemonic(StrVar string) {
871
872 xLabelSetTextWithMnemonic(x.GoPointer(), StrVar)
873
874}
875
876var xLabelSetUseMarkup func(uintptr, bool)
877
878// Sets whether the text of the label contains markup.
879//
880// See [method@Gtk.Label.set_markup].
881func (x *Label) SetUseMarkup(SettingVar bool) {
882
883 xLabelSetUseMarkup(x.GoPointer(), SettingVar)
884
885}
886
887var xLabelSetUseUnderline func(uintptr, bool)
888
889// Sets whether underlines in the text indicate mnemonics.
890func (x *Label) SetUseUnderline(SettingVar bool) {
891
892 xLabelSetUseUnderline(x.GoPointer(), SettingVar)
893
894}
895
896var xLabelSetWidthChars func(uintptr, int)
897
898// Sets the desired width in characters of the label.
899func (x *Label) SetWidthChars(NCharsVar int) {
900
901 xLabelSetWidthChars(x.GoPointer(), NCharsVar)
902
903}
904
905var xLabelSetWrap func(uintptr, bool)
906
907// Toggles line wrapping within the label.
908//
909// True makes it break lines if text exceeds the widget’s size.
910// false lets the text get cut off by the edge of the widget if
911// it exceeds the widget size.
912//
913// Note that setting line wrapping to true does not make the label
914// wrap at its parent widget’s width, because GTK widgets conceptually
915// can’t make their requisition depend on the parent widget’s size.
916// For a label that wraps at a specific position, set the label’s width
917// using [method@Gtk.Widget.set_size_request].
918func (x *Label) SetWrap(WrapVar bool) {
919
920 xLabelSetWrap(x.GoPointer(), WrapVar)
921
922}
923
924var xLabelSetWrapMode func(uintptr, pango.WrapMode)
925
926// Controls how line wrapping is done.
927//
928// This only affects the label if line wrapping is on. (See
929// [method@Gtk.Label.set_wrap])
930//
931// The default is [enum@Pango.WrapMode.word], which means
932// wrap on word boundaries.
933//
934// For sizing behavior, also consider the
935// [property@Gtk.Label:natural-wrap-mode] property.
936func (x *Label) SetWrapMode(WrapModeVar pango.WrapMode) {
937
938 xLabelSetWrapMode(x.GoPointer(), WrapModeVar)
939
940}
941
942var xLabelSetXalign func(uintptr, float32)
943
944// Sets the `xalign` of the label.
945//
946// See the [property@Gtk.Label:xalign] property.
947func (x *Label) SetXalign(XalignVar float32) {
948
949 xLabelSetXalign(x.GoPointer(), XalignVar)
950
951}
952
953var xLabelSetYalign func(uintptr, float32)
954
955// Sets the `yalign` of the label.
956//
957// See the [property@Gtk.Label:yalign] property.
958func (x *Label) SetYalign(YalignVar float32) {
959
960 xLabelSetYalign(x.GoPointer(), YalignVar)
961
962}
963
964func (c *Label) GoPointer() uintptr {
965 if c == nil {
966 return 0
967 }
968 return c.Ptr
969}
970
971func (c *Label) SetGoPointer(ptr uintptr) {
972 c.Ptr = ptr
973}
974
975// SetPropertyAttributes sets the "attributes" property.
976// A list of style attributes to apply to the text of the label.
977func (x *Label) SetPropertyAttributes(value uintptr) {
978 var v gobject.Value
979 v.Init(gobject.TypePointerVal)
980 v.SetPointer(value)
981 x.SetProperty("attributes", &v)
982}
983
984// GetPropertyAttributes gets the "attributes" property.
985// A list of style attributes to apply to the text of the label.
986func (x *Label) GetPropertyAttributes() uintptr {
987 var v gobject.Value
988 x.GetProperty("attributes", &v)
989 return v.GetPointer()
990}
991
992// SetPropertyLabel sets the "label" property.
993// The contents of the label.
994//
995// If the string contains Pango markup (see [func@Pango.parse_markup]),
996// you will have to set the [property@Gtk.Label:use-markup] property to
997// true in order for the label to display the markup attributes. See also
998// [method@Gtk.Label.set_markup] for a convenience function that sets both
999// this property and the [property@Gtk.Label:use-markup] property at the
1000// same time.
1001//
1002// If the string contains underlines acting as mnemonics, you will have to
1003// set the [property@Gtk.Label:use-underline] property to true in order
1004// for the label to display them.
1005func (x *Label) SetPropertyLabel(value string) {
1006 var v gobject.Value
1007 v.Init(gobject.TypeStringVal)
1008 v.SetString(&value)
1009 x.SetProperty("label", &v)
1010}
1011
1012// GetPropertyLabel gets the "label" property.
1013// The contents of the label.
1014//
1015// If the string contains Pango markup (see [func@Pango.parse_markup]),
1016// you will have to set the [property@Gtk.Label:use-markup] property to
1017// true in order for the label to display the markup attributes. See also
1018// [method@Gtk.Label.set_markup] for a convenience function that sets both
1019// this property and the [property@Gtk.Label:use-markup] property at the
1020// same time.
1021//
1022// If the string contains underlines acting as mnemonics, you will have to
1023// set the [property@Gtk.Label:use-underline] property to true in order
1024// for the label to display them.
1025func (x *Label) GetPropertyLabel() string {
1026 var v gobject.Value
1027 x.GetProperty("label", &v)
1028 return v.GetString()
1029}
1030
1031// SetPropertyLines sets the "lines" property.
1032// The number of lines to which an ellipsized, wrapping label
1033// should display before it gets ellipsized. This both prevents the label
1034// from ellipsizing before this many lines are displayed, and limits the
1035// height request of the label to this many lines.
1036//
1037// ::: warning
1038//
1039// Setting this property has unintuitive and unfortunate consequences
1040// for the minimum _width_ of the label. Specifically, if the height
1041// of the label is such that it fits a smaller number of lines than
1042// the value of this property, the label can not be ellipsized at all,
1043// which means it must be wide enough to fit all the text fully.
1044//
1045// This property has no effect if the label is not wrapping or ellipsized.
1046//
1047// Set this property to -1 if you don't want to limit the number of lines.
1048func (x *Label) SetPropertyLines(value int) {
1049 var v gobject.Value
1050 v.Init(gobject.TypeIntVal)
1051 v.SetInt(value)
1052 x.SetProperty("lines", &v)
1053}
1054
1055// GetPropertyLines gets the "lines" property.
1056// The number of lines to which an ellipsized, wrapping label
1057// should display before it gets ellipsized. This both prevents the label
1058// from ellipsizing before this many lines are displayed, and limits the
1059// height request of the label to this many lines.
1060//
1061// ::: warning
1062//
1063// Setting this property has unintuitive and unfortunate consequences
1064// for the minimum _width_ of the label. Specifically, if the height
1065// of the label is such that it fits a smaller number of lines than
1066// the value of this property, the label can not be ellipsized at all,
1067// which means it must be wide enough to fit all the text fully.
1068//
1069// This property has no effect if the label is not wrapping or ellipsized.
1070//
1071// Set this property to -1 if you don't want to limit the number of lines.
1072func (x *Label) GetPropertyLines() int {
1073 var v gobject.Value
1074 x.GetProperty("lines", &v)
1075 return v.GetInt()
1076}
1077
1078// SetPropertyMaxWidthChars sets the "max-width-chars" property.
1079// The desired maximum width of the label, in characters.
1080//
1081// If this property is set to -1, the width will be calculated automatically.
1082//
1083// See the section on [text layout](class.Label.html#text-layout) for details
1084// of how [property@Gtk.Label:width-chars] and [property@Gtk.Label:max-width-chars]
1085// determine the width of ellipsized and wrapped labels.
1086func (x *Label) SetPropertyMaxWidthChars(value int) {
1087 var v gobject.Value
1088 v.Init(gobject.TypeIntVal)
1089 v.SetInt(value)
1090 x.SetProperty("max-width-chars", &v)
1091}
1092
1093// GetPropertyMaxWidthChars gets the "max-width-chars" property.
1094// The desired maximum width of the label, in characters.
1095//
1096// If this property is set to -1, the width will be calculated automatically.
1097//
1098// See the section on [text layout](class.Label.html#text-layout) for details
1099// of how [property@Gtk.Label:width-chars] and [property@Gtk.Label:max-width-chars]
1100// determine the width of ellipsized and wrapped labels.
1101func (x *Label) GetPropertyMaxWidthChars() int {
1102 var v gobject.Value
1103 x.GetProperty("max-width-chars", &v)
1104 return v.GetInt()
1105}
1106
1107// GetPropertyMnemonicKeyval gets the "mnemonic-keyval" property.
1108// The mnemonic accelerator key for the label.
1109func (x *Label) GetPropertyMnemonicKeyval() uint {
1110 var v gobject.Value
1111 x.GetProperty("mnemonic-keyval", &v)
1112 return v.GetUint()
1113}
1114
1115// SetPropertySelectable sets the "selectable" property.
1116// Whether the label text can be selected with the mouse.
1117func (x *Label) SetPropertySelectable(value bool) {
1118 var v gobject.Value
1119 v.Init(gobject.TypeBooleanVal)
1120 v.SetBoolean(value)
1121 x.SetProperty("selectable", &v)
1122}
1123
1124// GetPropertySelectable gets the "selectable" property.
1125// Whether the label text can be selected with the mouse.
1126func (x *Label) GetPropertySelectable() bool {
1127 var v gobject.Value
1128 x.GetProperty("selectable", &v)
1129 return v.GetBoolean()
1130}
1131
1132// SetPropertySingleLineMode sets the "single-line-mode" property.
1133// Whether the label is in single line mode.
1134//
1135// In single line mode, the height of the label does not depend on the
1136// actual text, it is always set to ascent + descent of the font. This
1137// can be an advantage in situations where resizing the label because
1138// of text changes would be distracting, e.g. in a statusbar.
1139func (x *Label) SetPropertySingleLineMode(value bool) {
1140 var v gobject.Value
1141 v.Init(gobject.TypeBooleanVal)
1142 v.SetBoolean(value)
1143 x.SetProperty("single-line-mode", &v)
1144}
1145
1146// GetPropertySingleLineMode gets the "single-line-mode" property.
1147// Whether the label is in single line mode.
1148//
1149// In single line mode, the height of the label does not depend on the
1150// actual text, it is always set to ascent + descent of the font. This
1151// can be an advantage in situations where resizing the label because
1152// of text changes would be distracting, e.g. in a statusbar.
1153func (x *Label) GetPropertySingleLineMode() bool {
1154 var v gobject.Value
1155 x.GetProperty("single-line-mode", &v)
1156 return v.GetBoolean()
1157}
1158
1159// SetPropertyTabs sets the "tabs" property.
1160// Custom tabs for this label.
1161func (x *Label) SetPropertyTabs(value uintptr) {
1162 var v gobject.Value
1163 v.Init(gobject.TypePointerVal)
1164 v.SetPointer(value)
1165 x.SetProperty("tabs", &v)
1166}
1167
1168// GetPropertyTabs gets the "tabs" property.
1169// Custom tabs for this label.
1170func (x *Label) GetPropertyTabs() uintptr {
1171 var v gobject.Value
1172 x.GetProperty("tabs", &v)
1173 return v.GetPointer()
1174}
1175
1176// SetPropertyUseMarkup sets the "use-markup" property.
1177// True if the text of the label includes Pango markup.
1178//
1179// See [func@Pango.parse_markup].
1180func (x *Label) SetPropertyUseMarkup(value bool) {
1181 var v gobject.Value
1182 v.Init(gobject.TypeBooleanVal)
1183 v.SetBoolean(value)
1184 x.SetProperty("use-markup", &v)
1185}
1186
1187// GetPropertyUseMarkup gets the "use-markup" property.
1188// True if the text of the label includes Pango markup.
1189//
1190// See [func@Pango.parse_markup].
1191func (x *Label) GetPropertyUseMarkup() bool {
1192 var v gobject.Value
1193 x.GetProperty("use-markup", &v)
1194 return v.GetBoolean()
1195}
1196
1197// SetPropertyUseUnderline sets the "use-underline" property.
1198// True if the text of the label indicates a mnemonic with an `_`
1199// before the mnemonic character.
1200func (x *Label) SetPropertyUseUnderline(value bool) {
1201 var v gobject.Value
1202 v.Init(gobject.TypeBooleanVal)
1203 v.SetBoolean(value)
1204 x.SetProperty("use-underline", &v)
1205}
1206
1207// GetPropertyUseUnderline gets the "use-underline" property.
1208// True if the text of the label indicates a mnemonic with an `_`
1209// before the mnemonic character.
1210func (x *Label) GetPropertyUseUnderline() bool {
1211 var v gobject.Value
1212 x.GetProperty("use-underline", &v)
1213 return v.GetBoolean()
1214}
1215
1216// SetPropertyWidthChars sets the "width-chars" property.
1217// The desired width of the label, in characters.
1218//
1219// If this property is set to -1, the width will be calculated automatically.
1220//
1221// See the section on [text layout](class.Label.html#text-layout) for details
1222// of how [property@Gtk.Label:width-chars] and [property@Gtk.Label:max-width-chars]
1223// determine the width of ellipsized and wrapped labels.
1224func (x *Label) SetPropertyWidthChars(value int) {
1225 var v gobject.Value
1226 v.Init(gobject.TypeIntVal)
1227 v.SetInt(value)
1228 x.SetProperty("width-chars", &v)
1229}
1230
1231// GetPropertyWidthChars gets the "width-chars" property.
1232// The desired width of the label, in characters.
1233//
1234// If this property is set to -1, the width will be calculated automatically.
1235//
1236// See the section on [text layout](class.Label.html#text-layout) for details
1237// of how [property@Gtk.Label:width-chars] and [property@Gtk.Label:max-width-chars]
1238// determine the width of ellipsized and wrapped labels.
1239func (x *Label) GetPropertyWidthChars() int {
1240 var v gobject.Value
1241 x.GetProperty("width-chars", &v)
1242 return v.GetInt()
1243}
1244
1245// SetPropertyWrap sets the "wrap" property.
1246// True if the label text will wrap if it gets too wide.
1247func (x *Label) SetPropertyWrap(value bool) {
1248 var v gobject.Value
1249 v.Init(gobject.TypeBooleanVal)
1250 v.SetBoolean(value)
1251 x.SetProperty("wrap", &v)
1252}
1253
1254// GetPropertyWrap gets the "wrap" property.
1255// True if the label text will wrap if it gets too wide.
1256func (x *Label) GetPropertyWrap() bool {
1257 var v gobject.Value
1258 x.GetProperty("wrap", &v)
1259 return v.GetBoolean()
1260}
1261
1262// SetPropertyXalign sets the "xalign" property.
1263// The horizontal alignment of the label text inside its size allocation.
1264//
1265// Compare this to [property@Gtk.Widget:halign], which determines how the
1266// labels size allocation is positioned in the space available for the label.
1267func (x *Label) SetPropertyXalign(value float32) {
1268 var v gobject.Value
1269 v.Init(gobject.TypeFloatVal)
1270 v.SetFloat(value)
1271 x.SetProperty("xalign", &v)
1272}
1273
1274// GetPropertyXalign gets the "xalign" property.
1275// The horizontal alignment of the label text inside its size allocation.
1276//
1277// Compare this to [property@Gtk.Widget:halign], which determines how the
1278// labels size allocation is positioned in the space available for the label.
1279func (x *Label) GetPropertyXalign() float32 {
1280 var v gobject.Value
1281 x.GetProperty("xalign", &v)
1282 return v.GetFloat()
1283}
1284
1285// SetPropertyYalign sets the "yalign" property.
1286// The vertical alignment of the label text inside its size allocation.
1287//
1288// Compare this to [property@Gtk.Widget:valign], which determines how the
1289// labels size allocation is positioned in the space available for the label.
1290func (x *Label) SetPropertyYalign(value float32) {
1291 var v gobject.Value
1292 v.Init(gobject.TypeFloatVal)
1293 v.SetFloat(value)
1294 x.SetProperty("yalign", &v)
1295}
1296
1297// GetPropertyYalign gets the "yalign" property.
1298// The vertical alignment of the label text inside its size allocation.
1299//
1300// Compare this to [property@Gtk.Widget:valign], which determines how the
1301// labels size allocation is positioned in the space available for the label.
1302func (x *Label) GetPropertyYalign() float32 {
1303 var v gobject.Value
1304 x.GetProperty("yalign", &v)
1305 return v.GetFloat()
1306}
1307
1308// Gets emitted when the user activates a link in the label.
1309//
1310// The `::activate-current-link` is a [keybinding signal](class.SignalAction.html).
1311//
1312// Applications may also emit the signal with g_signal_emit_by_name()
1313// if they need to control activation of URIs programmatically.
1314//
1315// The default bindings for this signal are all forms of the <kbd>Enter</kbd> key.
1316func (x *Label) ConnectActivateCurrentLink(cb *func(Label)) uint {
1317 cbPtr := uintptr(unsafe.Pointer(cb))
1318 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
1319 handlerID := gobject.SignalConnect(x.GoPointer(), "activate-current-link", cbRefPtr)
1320 glib.SaveHandlerMapping(handlerID, cbPtr)
1321 return handlerID
1322 }
1323
1324 fcb := func(clsPtr uintptr) {
1325 fa := Label{}
1326 fa.Ptr = clsPtr
1327 cbFn := *cb
1328
1329 cbFn(fa)
1330
1331 }
1332 cbRefPtr := purego.NewCallback(fcb)
1333 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
1334 handlerID := gobject.SignalConnect(x.GoPointer(), "activate-current-link", cbRefPtr)
1335 glib.SaveHandlerMapping(handlerID, cbPtr)
1336 return handlerID
1337}
1338
1339// Gets emitted to activate a URI.
1340//
1341// Applications may connect to it to override the default behaviour,
1342// which is to call [method@Gtk.FileLauncher.launch].
1343func (x *Label) ConnectActivateLink(cb *func(Label, string) bool) uint {
1344 cbPtr := uintptr(unsafe.Pointer(cb))
1345 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
1346 handlerID := gobject.SignalConnect(x.GoPointer(), "activate-link", cbRefPtr)
1347 glib.SaveHandlerMapping(handlerID, cbPtr)
1348 return handlerID
1349 }
1350
1351 fcb := func(clsPtr uintptr, UriVarp uintptr) bool {
1352 fa := Label{}
1353 fa.Ptr = clsPtr
1354 cbFn := *cb
1355
1356 return cbFn(fa, core.GoString(UriVarp))
1357
1358 }
1359 cbRefPtr := purego.NewCallback(fcb)
1360 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
1361 handlerID := gobject.SignalConnect(x.GoPointer(), "activate-link", cbRefPtr)
1362 glib.SaveHandlerMapping(handlerID, cbPtr)
1363 return handlerID
1364}
1365
1366// Gets emitted to copy the selection to the clipboard.
1367//
1368// The `::copy-clipboard` signal is a [keybinding signal](class.SignalAction.html).
1369//
1370// The default binding for this signal is <kbd>Ctrl</kbd>+<kbd>c</kbd>.
1371func (x *Label) ConnectCopyClipboard(cb *func(Label)) uint {
1372 cbPtr := uintptr(unsafe.Pointer(cb))
1373 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
1374 handlerID := gobject.SignalConnect(x.GoPointer(), "copy-clipboard", cbRefPtr)
1375 glib.SaveHandlerMapping(handlerID, cbPtr)
1376 return handlerID
1377 }
1378
1379 fcb := func(clsPtr uintptr) {
1380 fa := Label{}
1381 fa.Ptr = clsPtr
1382 cbFn := *cb
1383
1384 cbFn(fa)
1385
1386 }
1387 cbRefPtr := purego.NewCallback(fcb)
1388 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
1389 handlerID := gobject.SignalConnect(x.GoPointer(), "copy-clipboard", cbRefPtr)
1390 glib.SaveHandlerMapping(handlerID, cbPtr)
1391 return handlerID
1392}
1393
1394// Gets emitted when the user initiates a cursor movement.
1395//
1396// The `::move-cursor` signal is a [keybinding signal](class.SignalAction.html).
1397// If the cursor is not visible in @entry, this signal causes the viewport to
1398// be moved instead.
1399//
1400// Applications should not connect to it, but may emit it with
1401// [func@GObject.signal_emit_by_name] if they need to control
1402// the cursor programmatically.
1403//
1404// The default bindings for this signal come in two variants, the
1405// variant with the <kbd>Shift</kbd> modifier extends the selection,
1406// the variant without the <kbd>Shift</kbd> modifier does not.
1407// There are too many key combinations to list them all here.
1408//
1409// - <kbd>←</kbd>, <kbd>→</kbd>, <kbd>↑</kbd>, <kbd>↓</kbd>
1410// move by individual characters/lines
1411// - <kbd>Ctrl</kbd>+<kbd>←</kbd>, etc. move by words/paragraphs
1412// - <kbd>Home</kbd> and <kbd>End</kbd> move to the ends of the buffer
1413func (x *Label) ConnectMoveCursor(cb *func(Label, MovementStep, int, bool)) uint {
1414 cbPtr := uintptr(unsafe.Pointer(cb))
1415 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
1416 handlerID := gobject.SignalConnect(x.GoPointer(), "move-cursor", cbRefPtr)
1417 glib.SaveHandlerMapping(handlerID, cbPtr)
1418 return handlerID
1419 }
1420
1421 fcb := func(clsPtr uintptr, StepVarp MovementStep, CountVarp int, ExtendSelectionVarp bool) {
1422 fa := Label{}
1423 fa.Ptr = clsPtr
1424 cbFn := *cb
1425
1426 cbFn(fa, StepVarp, CountVarp, ExtendSelectionVarp)
1427
1428 }
1429 cbRefPtr := purego.NewCallback(fcb)
1430 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
1431 handlerID := gobject.SignalConnect(x.GoPointer(), "move-cursor", cbRefPtr)
1432 glib.SaveHandlerMapping(handlerID, cbPtr)
1433 return handlerID
1434}
1435
1436// Requests the user's screen reader to announce the given message.
1437//
1438// This kind of notification is useful for messages that
1439// either have only a visual representation or that are not
1440// exposed visually at all, e.g. a notification about a
1441// successful operation.
1442//
1443// Also, by using this API, you can ensure that the message
1444// does not interrupts the user's current screen reader output.
1445func (x *Label) Announce(MessageVar string, PriorityVar AccessibleAnnouncementPriority) {
1446
1447 XGtkAccessibleAnnounce(x.GoPointer(), MessageVar, PriorityVar)
1448
1449}
1450
1451// Retrieves the accessible parent for an accessible object.
1452//
1453// This function returns `NULL` for top level widgets.
1454func (x *Label) GetAccessibleParent() *AccessibleBase {
1455 var cls *AccessibleBase
1456
1457 cret := XGtkAccessibleGetAccessibleParent(x.GoPointer())
1458
1459 if cret == 0 {
1460 return nil
1461 }
1462 cls = &AccessibleBase{}
1463 cls.Ptr = cret
1464 return cls
1465}
1466
1467// Retrieves the accessible role of an accessible object.
1468func (x *Label) GetAccessibleRole() AccessibleRole {
1469
1470 cret := XGtkAccessibleGetAccessibleRole(x.GoPointer())
1471 return cret
1472}
1473
1474// Retrieves the implementation for the given accessible object.
1475func (x *Label) GetAtContext() *ATContext {
1476 var cls *ATContext
1477
1478 cret := XGtkAccessibleGetAtContext(x.GoPointer())
1479
1480 if cret == 0 {
1481 return nil
1482 }
1483 cls = &ATContext{}
1484 cls.Ptr = cret
1485 return cls
1486}
1487
1488// Queries the coordinates and dimensions of this accessible
1489//
1490// This functionality can be overridden by `GtkAccessible`
1491// implementations, e.g. to get the bounds from an ignored
1492// child widget.
1493func (x *Label) GetBounds(XVar *int, YVar *int, WidthVar *int, HeightVar *int) bool {
1494
1495 cret := XGtkAccessibleGetBounds(x.GoPointer(), XVar, YVar, WidthVar, HeightVar)
1496 return cret
1497}
1498
1499// Retrieves the first accessible child of an accessible object.
1500func (x *Label) GetFirstAccessibleChild() *AccessibleBase {
1501 var cls *AccessibleBase
1502
1503 cret := XGtkAccessibleGetFirstAccessibleChild(x.GoPointer())
1504
1505 if cret == 0 {
1506 return nil
1507 }
1508 cls = &AccessibleBase{}
1509 cls.Ptr = cret
1510 return cls
1511}
1512
1513// Retrieves the next accessible sibling of an accessible object
1514func (x *Label) GetNextAccessibleSibling() *AccessibleBase {
1515 var cls *AccessibleBase
1516
1517 cret := XGtkAccessibleGetNextAccessibleSibling(x.GoPointer())
1518
1519 if cret == 0 {
1520 return nil
1521 }
1522 cls = &AccessibleBase{}
1523 cls.Ptr = cret
1524 return cls
1525}
1526
1527// Queries a platform state, such as focus.
1528//
1529// This functionality can be overridden by `GtkAccessible`
1530// implementations, e.g. to get platform state from an ignored
1531// child widget, as is the case for `GtkText` wrappers.
1532func (x *Label) GetPlatformState(StateVar AccessiblePlatformState) bool {
1533
1534 cret := XGtkAccessibleGetPlatformState(x.GoPointer(), StateVar)
1535 return cret
1536}
1537
1538// Resets the accessible property to its default value.
1539func (x *Label) ResetProperty(PropertyVar AccessibleProperty) {
1540
1541 XGtkAccessibleResetProperty(x.GoPointer(), PropertyVar)
1542
1543}
1544
1545// Resets the accessible relation to its default value.
1546func (x *Label) ResetRelation(RelationVar AccessibleRelation) {
1547
1548 XGtkAccessibleResetRelation(x.GoPointer(), RelationVar)
1549
1550}
1551
1552// Resets the accessible state to its default value.
1553func (x *Label) ResetState(StateVar AccessibleState) {
1554
1555 XGtkAccessibleResetState(x.GoPointer(), StateVar)
1556
1557}
1558
1559// Sets the parent and sibling of an accessible object.
1560//
1561// This function is meant to be used by accessible implementations that are
1562// not part of the widget hierarchy, and but act as a logical bridge between
1563// widgets. For instance, if a widget creates an object that holds metadata
1564// for each child, and you want that object to implement the `GtkAccessible`
1565// interface, you will use this function to ensure that the parent of each
1566// child widget is the metadata object, and the parent of each metadata
1567// object is the container widget.
1568func (x *Label) SetAccessibleParent(ParentVar Accessible, NextSiblingVar Accessible) {
1569
1570 XGtkAccessibleSetAccessibleParent(x.GoPointer(), ParentVar.GoPointer(), NextSiblingVar.GoPointer())
1571
1572}
1573
1574// Updates the next accessible sibling.
1575//
1576// That might be useful when a new child of a custom accessible
1577// is created, and it needs to be linked to a previous child.
1578func (x *Label) UpdateNextAccessibleSibling(NewSiblingVar Accessible) {
1579
1580 XGtkAccessibleUpdateNextAccessibleSibling(x.GoPointer(), NewSiblingVar.GoPointer())
1581
1582}
1583
1584// Informs ATs that the platform state has changed.
1585//
1586// This function should be used by `GtkAccessible` implementations that
1587// have a platform state but are not widgets. Widgets handle platform
1588// states automatically.
1589func (x *Label) UpdatePlatformState(StateVar AccessiblePlatformState) {
1590
1591 XGtkAccessibleUpdatePlatformState(x.GoPointer(), StateVar)
1592
1593}
1594
1595// Updates a list of accessible properties.
1596//
1597// See the [enum@Gtk.AccessibleProperty] documentation for the
1598// value types of accessible properties.
1599//
1600// This function should be called by `GtkWidget` types whenever
1601// an accessible property change must be communicated to assistive
1602// technologies.
1603//
1604// Example:
1605// ```c
1606// value = gtk_adjustment_get_value (adjustment);
1607// gtk_accessible_update_property (GTK_ACCESSIBLE (spin_button),
1608//
1609// GTK_ACCESSIBLE_PROPERTY_VALUE_NOW, value,
1610// -1);
1611//
1612// ```
1613func (x *Label) UpdateProperty(FirstPropertyVar AccessibleProperty, varArgs ...interface{}) {
1614
1615 XGtkAccessibleUpdateProperty(x.GoPointer(), FirstPropertyVar, varArgs...)
1616
1617}
1618
1619// Updates an array of accessible properties.
1620//
1621// This function should be called by `GtkWidget` types whenever an accessible
1622// property change must be communicated to assistive technologies.
1623//
1624// This function is meant to be used by language bindings.
1625func (x *Label) UpdatePropertyValue(NPropertiesVar int, PropertiesVar []AccessibleProperty, ValuesVar []gobject.Value) {
1626
1627 XGtkAccessibleUpdatePropertyValue(x.GoPointer(), NPropertiesVar, PropertiesVar, ValuesVar)
1628
1629}
1630
1631// Updates a list of accessible relations.
1632//
1633// This function should be called by `GtkWidget` types whenever an accessible
1634// relation change must be communicated to assistive technologies.
1635//
1636// If the [enum@Gtk.AccessibleRelation] requires a list of references,
1637// you should pass each reference individually, followed by `NULL`, e.g.
1638//
1639// ```c
1640// gtk_accessible_update_relation (accessible,
1641//
1642// GTK_ACCESSIBLE_RELATION_CONTROLS,
1643// ref1, NULL,
1644// GTK_ACCESSIBLE_RELATION_LABELLED_BY,
1645// ref1, ref2, ref3, NULL,
1646// -1);
1647//
1648// ```
1649func (x *Label) UpdateRelation(FirstRelationVar AccessibleRelation, varArgs ...interface{}) {
1650
1651 XGtkAccessibleUpdateRelation(x.GoPointer(), FirstRelationVar, varArgs...)
1652
1653}
1654
1655// Updates an array of accessible relations.
1656//
1657// This function should be called by `GtkWidget` types whenever an accessible
1658// relation change must be communicated to assistive technologies.
1659//
1660// This function is meant to be used by language bindings.
1661func (x *Label) UpdateRelationValue(NRelationsVar int, RelationsVar []AccessibleRelation, ValuesVar []gobject.Value) {
1662
1663 XGtkAccessibleUpdateRelationValue(x.GoPointer(), NRelationsVar, RelationsVar, ValuesVar)
1664
1665}
1666
1667// Updates a list of accessible states.
1668//
1669// See the [enum@Gtk.AccessibleState] documentation for the
1670// value types of accessible states.
1671//
1672// This function should be called by `GtkWidget` types whenever
1673// an accessible state change must be communicated to assistive
1674// technologies.
1675//
1676// Example:
1677//
1678// ```c
1679// value = GTK_ACCESSIBLE_TRISTATE_MIXED;
1680// gtk_accessible_update_state (GTK_ACCESSIBLE (check_button),
1681//
1682// GTK_ACCESSIBLE_STATE_CHECKED, value,
1683// -1);
1684//
1685// ```
1686func (x *Label) UpdateState(FirstStateVar AccessibleState, varArgs ...interface{}) {
1687
1688 XGtkAccessibleUpdateState(x.GoPointer(), FirstStateVar, varArgs...)
1689
1690}
1691
1692// Updates an array of accessible states.
1693//
1694// This function should be called by `GtkWidget` types whenever an accessible
1695// state change must be communicated to assistive technologies.
1696//
1697// This function is meant to be used by language bindings.
1698func (x *Label) UpdateStateValue(NStatesVar int, StatesVar []AccessibleState, ValuesVar []gobject.Value) {
1699
1700 XGtkAccessibleUpdateStateValue(x.GoPointer(), NStatesVar, StatesVar, ValuesVar)
1701
1702}
1703
1704// Updates the position of the caret.
1705//
1706// Implementations of the `GtkAccessibleText` interface should call this
1707// function every time the caret has moved, in order to notify assistive
1708// technologies.
1709func (x *Label) UpdateCaretPosition() {
1710
1711 XGtkAccessibleTextUpdateCaretPosition(x.GoPointer())
1712
1713}
1714
1715// Notifies assistive technologies of a change in contents.
1716//
1717// Implementations of the `GtkAccessibleText` interface should call this
1718// function every time their contents change as the result of an operation,
1719// like an insertion or a removal.
1720//
1721// Note: If the change is a deletion, this function must be called *before*
1722// removing the contents, if it is an insertion, it must be called *after*
1723// inserting the new contents.
1724func (x *Label) UpdateContents(ChangeVar AccessibleTextContentChange, StartVar uint, EndVar uint) {
1725
1726 XGtkAccessibleTextUpdateContents(x.GoPointer(), ChangeVar, StartVar, EndVar)
1727
1728}
1729
1730// Updates the boundary of the selection.
1731//
1732// Implementations of the `GtkAccessibleText` interface should call this
1733// function every time the selection has moved, in order to notify assistive
1734// technologies.
1735func (x *Label) UpdateSelectionBound() {
1736
1737 XGtkAccessibleTextUpdateSelectionBound(x.GoPointer())
1738
1739}
1740
1741// Gets the ID of the @buildable object.
1742//
1743// `GtkBuilder` sets the name based on the ID attribute
1744// of the `<object>` tag used to construct the @buildable.
1745func (x *Label) GetBuildableId() string {
1746
1747 cret := XGtkBuildableGetBuildableId(x.GoPointer())
1748 return cret
1749}
1750
1751func init() {
1752 core.SetPackageName("GTK", "gtk4")
1753 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
1754 var libs []uintptr
1755 for _, libPath := range core.GetPaths("GTK") {
1756 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
1757 if err != nil {
1758 panic(err)
1759 }
1760 libs = append(libs, lib)
1761 }
1762
1763 core.PuregoSafeRegister(&xLabelGLibType, libs, "gtk_label_get_type")
1764
1765 core.PuregoSafeRegister(&xNewLabel, libs, "gtk_label_new")
1766 core.PuregoSafeRegister(&xNewLabelWithMnemonic, libs, "gtk_label_new_with_mnemonic")
1767
1768 core.PuregoSafeRegister(&xLabelGetAttributes, libs, "gtk_label_get_attributes")
1769 core.PuregoSafeRegister(&xLabelGetCurrentUri, libs, "gtk_label_get_current_uri")
1770 core.PuregoSafeRegister(&xLabelGetEllipsize, libs, "gtk_label_get_ellipsize")
1771 core.PuregoSafeRegister(&xLabelGetExtraMenu, libs, "gtk_label_get_extra_menu")
1772 core.PuregoSafeRegister(&xLabelGetJustify, libs, "gtk_label_get_justify")
1773 core.PuregoSafeRegister(&xLabelGetLabel, libs, "gtk_label_get_label")
1774 core.PuregoSafeRegister(&xLabelGetLayout, libs, "gtk_label_get_layout")
1775 core.PuregoSafeRegister(&xLabelGetLayoutOffsets, libs, "gtk_label_get_layout_offsets")
1776 core.PuregoSafeRegister(&xLabelGetLines, libs, "gtk_label_get_lines")
1777 core.PuregoSafeRegister(&xLabelGetMaxWidthChars, libs, "gtk_label_get_max_width_chars")
1778 core.PuregoSafeRegister(&xLabelGetMnemonicKeyval, libs, "gtk_label_get_mnemonic_keyval")
1779 core.PuregoSafeRegister(&xLabelGetMnemonicWidget, libs, "gtk_label_get_mnemonic_widget")
1780 core.PuregoSafeRegister(&xLabelGetNaturalWrapMode, libs, "gtk_label_get_natural_wrap_mode")
1781 core.PuregoSafeRegister(&xLabelGetSelectable, libs, "gtk_label_get_selectable")
1782 core.PuregoSafeRegister(&xLabelGetSelectionBounds, libs, "gtk_label_get_selection_bounds")
1783 core.PuregoSafeRegister(&xLabelGetSingleLineMode, libs, "gtk_label_get_single_line_mode")
1784 core.PuregoSafeRegister(&xLabelGetTabs, libs, "gtk_label_get_tabs")
1785 core.PuregoSafeRegister(&xLabelGetText, libs, "gtk_label_get_text")
1786 core.PuregoSafeRegister(&xLabelGetUseMarkup, libs, "gtk_label_get_use_markup")
1787 core.PuregoSafeRegister(&xLabelGetUseUnderline, libs, "gtk_label_get_use_underline")
1788 core.PuregoSafeRegister(&xLabelGetWidthChars, libs, "gtk_label_get_width_chars")
1789 core.PuregoSafeRegister(&xLabelGetWrap, libs, "gtk_label_get_wrap")
1790 core.PuregoSafeRegister(&xLabelGetWrapMode, libs, "gtk_label_get_wrap_mode")
1791 core.PuregoSafeRegister(&xLabelGetXalign, libs, "gtk_label_get_xalign")
1792 core.PuregoSafeRegister(&xLabelGetYalign, libs, "gtk_label_get_yalign")
1793 core.PuregoSafeRegister(&xLabelSelectRegion, libs, "gtk_label_select_region")
1794 core.PuregoSafeRegister(&xLabelSetAttributes, libs, "gtk_label_set_attributes")
1795 core.PuregoSafeRegister(&xLabelSetEllipsize, libs, "gtk_label_set_ellipsize")
1796 core.PuregoSafeRegister(&xLabelSetExtraMenu, libs, "gtk_label_set_extra_menu")
1797 core.PuregoSafeRegister(&xLabelSetJustify, libs, "gtk_label_set_justify")
1798 core.PuregoSafeRegister(&xLabelSetLabel, libs, "gtk_label_set_label")
1799 core.PuregoSafeRegister(&xLabelSetLines, libs, "gtk_label_set_lines")
1800 core.PuregoSafeRegister(&xLabelSetMarkup, libs, "gtk_label_set_markup")
1801 core.PuregoSafeRegister(&xLabelSetMarkupWithMnemonic, libs, "gtk_label_set_markup_with_mnemonic")
1802 core.PuregoSafeRegister(&xLabelSetMaxWidthChars, libs, "gtk_label_set_max_width_chars")
1803 core.PuregoSafeRegister(&xLabelSetMnemonicWidget, libs, "gtk_label_set_mnemonic_widget")
1804 core.PuregoSafeRegister(&xLabelSetNaturalWrapMode, libs, "gtk_label_set_natural_wrap_mode")
1805 core.PuregoSafeRegister(&xLabelSetSelectable, libs, "gtk_label_set_selectable")
1806 core.PuregoSafeRegister(&xLabelSetSingleLineMode, libs, "gtk_label_set_single_line_mode")
1807 core.PuregoSafeRegister(&xLabelSetTabs, libs, "gtk_label_set_tabs")
1808 core.PuregoSafeRegister(&xLabelSetText, libs, "gtk_label_set_text")
1809 core.PuregoSafeRegister(&xLabelSetTextWithMnemonic, libs, "gtk_label_set_text_with_mnemonic")
1810 core.PuregoSafeRegister(&xLabelSetUseMarkup, libs, "gtk_label_set_use_markup")
1811 core.PuregoSafeRegister(&xLabelSetUseUnderline, libs, "gtk_label_set_use_underline")
1812 core.PuregoSafeRegister(&xLabelSetWidthChars, libs, "gtk_label_set_width_chars")
1813 core.PuregoSafeRegister(&xLabelSetWrap, libs, "gtk_label_set_wrap")
1814 core.PuregoSafeRegister(&xLabelSetWrapMode, libs, "gtk_label_set_wrap_mode")
1815 core.PuregoSafeRegister(&xLabelSetXalign, libs, "gtk_label_set_xalign")
1816 core.PuregoSafeRegister(&xLabelSetYalign, libs, "gtk_label_set_yalign")
1817
1818}