gtk4/auto/
label.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5#[cfg(feature = "v4_14")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
7use crate::AccessibleText;
8#[cfg(feature = "v4_6")]
9#[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
10use crate::NaturalWrapMode;
11use crate::{
12    ffi, Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, Justification,
13    LayoutManager, MovementStep, Overflow, Widget,
14};
15use glib::{
16    object::ObjectType as _,
17    prelude::*,
18    signal::{connect_raw, SignalHandlerId},
19    translate::*,
20};
21use std::boxed::Box as Box_;
22
23#[cfg(feature = "v4_14")]
24#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
25glib::wrapper! {
26    /// Displays a small amount of text.
27    ///
28    /// Most labels are used to label another widget (such as an [`Entry`][crate::Entry]).
29    ///
30    /// <picture>
31    ///   <source srcset="label-dark.png" media="(prefers-color-scheme: dark)">
32    ///   <img alt="An example GtkLabel" src="label.png">
33    /// </picture>
34    ///
35    /// ## Shortcuts and Gestures
36    ///
37    /// [`Label`][crate::Label] supports the following keyboard shortcuts, when the cursor is
38    /// visible:
39    ///
40    /// - <kbd>Shift</kbd>+<kbd>F10</kbd> or <kbd>Menu</kbd> opens the context menu.
41    /// - <kbd>Ctrl</kbd>+<kbd>A</kbd> or <kbd>Ctrl</kbd>+<kbd>&sol;</kbd>
42    ///   selects all.
43    /// - <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>A</kbd> or
44    ///   <kbd>Ctrl</kbd>+<kbd>&bsol;</kbd> unselects all.
45    ///
46    /// Additionally, the following signals have default keybindings:
47    ///
48    /// - [`activate-current-link`][struct@crate::Label#activate-current-link]
49    /// - [`copy-clipboard`][struct@crate::Label#copy-clipboard]
50    /// - [`move-cursor`][struct@crate::Label#move-cursor]
51    ///
52    /// ## Actions
53    ///
54    /// [`Label`][crate::Label] defines a set of built-in actions:
55    ///
56    /// - `clipboard.copy` copies the text to the clipboard.
57    /// - `clipboard.cut` doesn't do anything, since text in labels can't be deleted.
58    /// - `clipboard.paste` doesn't do anything, since text in labels can't be
59    ///   edited.
60    /// - `link.open` opens the link, when activated on a link inside the label.
61    /// - `link.copy` copies the link to the clipboard, when activated on a link
62    ///   inside the label.
63    /// - `menu.popup` opens the context menu.
64    /// - `selection.delete` doesn't do anything, since text in labels can't be
65    ///   deleted.
66    /// - `selection.select-all` selects all of the text, if the label allows
67    ///   selection.
68    ///
69    /// ## CSS nodes
70    ///
71    /// ```text
72    /// label
73    /// ├── [selection]
74    /// ├── [link]
75    /// ┊
76    /// ╰── [link]
77    /// ```
78    ///
79    /// [`Label`][crate::Label] has a single CSS node with the name label. A wide variety
80    /// of style classes may be applied to labels, such as .title, .subtitle,
81    /// .dim-label, etc. In the [`ShortcutsWindow`][crate::ShortcutsWindow], labels are used with the
82    /// .keycap style class.
83    ///
84    /// If the label has a selection, it gets a subnode with name selection.
85    ///
86    /// If the label has links, there is one subnode per link. These subnodes
87    /// carry the link or visited state depending on whether they have been
88    /// visited. In this case, label node also gets a .link style class.
89    ///
90    /// ## GtkLabel as GtkBuildable
91    ///
92    /// The GtkLabel implementation of the GtkBuildable interface supports a
93    /// custom `<attributes>` element, which supports any number of `<attribute>`
94    /// elements. The `<attribute>` element has attributes named “name“, “value“,
95    /// “start“ and “end“ and allows you to specify `Pango::Attribute`
96    /// values for this label.
97    ///
98    /// An example of a UI definition fragment specifying Pango attributes:
99    ///
100    /// ```xml
101    /// <object class="GtkLabel">
102    ///   <attributes>
103    ///     <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
104    ///     <attribute name="background" value="red" start="5" end="10"/>
105    ///   </attributes>
106    /// </object>
107    /// ```
108    ///
109    /// The start and end attributes specify the range of characters to which the
110    /// Pango attribute applies. If start and end are not specified, the attribute is
111    /// applied to the whole text. Note that specifying ranges does not make much
112    /// sense with translatable attributes. Use markup embedded in the translatable
113    /// content instead.
114    ///
115    /// ## Accessibility
116    ///
117    /// [`Label`][crate::Label] uses the [enum@Gtk.AccessibleRole.label] role.
118    ///
119    /// ## Mnemonics
120    ///
121    /// Labels may contain “mnemonics”. Mnemonics are underlined characters in the
122    /// label, used for keyboard navigation. Mnemonics are created by providing a
123    /// string with an underscore before the mnemonic character, such as `"_File"`,
124    /// to the functions [`with_mnemonic()`][Self::with_mnemonic()] or
125    /// [`set_text_with_mnemonic()`][Self::set_text_with_mnemonic()].
126    ///
127    /// Mnemonics automatically activate any activatable widget the label is
128    /// inside, such as a [`Button`][crate::Button]; if the label is not inside the
129    /// mnemonic’s target widget, you have to tell the label about the target
130    /// using [`set_mnemonic_widget()`][Self::set_mnemonic_widget()].
131    ///
132    /// Here’s a simple example where the label is inside a button:
133    ///
134    /// **⚠️ The following code is in c ⚠️**
135    ///
136    /// ```c
137    /// // Pressing Alt+H will activate this button
138    /// GtkWidget *button = gtk_button_new ();
139    /// GtkWidget *label = gtk_label_new_with_mnemonic ("_Hello");
140    /// gtk_button_set_child (GTK_BUTTON (button), label);
141    /// ```
142    ///
143    /// There’s a convenience function to create buttons with a mnemonic label
144    /// already inside:
145    ///
146    /// **⚠️ The following code is in c ⚠️**
147    ///
148    /// ```c
149    /// // Pressing Alt+H will activate this button
150    /// GtkWidget *button = gtk_button_new_with_mnemonic ("_Hello");
151    /// ```
152    ///
153    /// To create a mnemonic for a widget alongside the label, such as a
154    /// [`Entry`][crate::Entry], you have to point the label at the entry with
155    /// [`set_mnemonic_widget()`][Self::set_mnemonic_widget()]:
156    ///
157    /// **⚠️ The following code is in c ⚠️**
158    ///
159    /// ```c
160    /// // Pressing Alt+H will focus the entry
161    /// GtkWidget *entry = gtk_entry_new ();
162    /// GtkWidget *label = gtk_label_new_with_mnemonic ("_Hello");
163    /// gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
164    /// ```
165    ///
166    /// ## Markup (styled text)
167    ///
168    /// To make it easy to format text in a label (changing colors, fonts, etc.),
169    /// label text can be provided in a simple markup format:
170    ///
171    /// Here’s how to create a label with a small font:
172    /// **⚠️ The following code is in c ⚠️**
173    ///
174    /// ```c
175    /// GtkWidget *label = gtk_label_new (NULL);
176    /// gtk_label_set_markup (GTK_LABEL (label), "<small>Small text</small>");
177    /// ```
178    ///
179    /// (See the Pango manual for complete documentation] of available
180    /// tags, `parse_markup()`)
181    ///
182    /// The markup passed to [`set_markup()`][Self::set_markup()] must be valid XML; for example,
183    /// literal `<`, `>` and `&` characters must be escaped as `&lt;`, `&gt;`, and `&amp;`.
184    /// If you pass text obtained from the user, file, or a network to
185    /// [`set_markup()`][Self::set_markup()], you’ll want to escape it with
186    /// `markup_escape_text()` or `markup_printf_escaped()`.
187    ///
188    /// Markup strings are just a convenient way to set the [`pango::AttrList`][crate::pango::AttrList]
189    /// on a label; [`set_attributes()`][Self::set_attributes()] may be a simpler way to set
190    /// attributes in some cases. Be careful though; [`pango::AttrList`][crate::pango::AttrList] tends
191    /// to cause internationalization problems, unless you’re applying attributes
192    /// to the entire string (i.e. unless you set the range of each attribute
193    /// to [0, `G_MAXINT`)). The reason is that specifying the `start_index` and
194    /// `end_index` for a `Pango::Attribute` requires knowledge of the exact
195    /// string being displayed, so translations will cause problems.
196    ///
197    /// ## Selectable labels
198    ///
199    /// Labels can be made selectable with [`set_selectable()`][Self::set_selectable()].
200    /// Selectable labels allow the user to copy the label contents to the
201    /// clipboard. Only labels that contain useful-to-copy information — such
202    /// as error messages — should be made selectable.
203    ///
204    /// ## Text layout
205    ///
206    /// A label can contain any number of paragraphs, but will have
207    /// performance problems if it contains more than a small number.
208    /// Paragraphs are separated by newlines or other paragraph separators
209    /// understood by Pango.
210    ///
211    /// Labels can automatically wrap text if you call [`set_wrap()`][Self::set_wrap()].
212    ///
213    /// [`set_justify()`][Self::set_justify()] sets how the lines in a label align
214    /// with one another. If you want to set how the label as a whole aligns
215    /// in its available space, see the [`halign`][struct@crate::Widget#halign] and
216    /// [`valign`][struct@crate::Widget#valign] properties.
217    ///
218    /// The [`width-chars`][struct@crate::Label#width-chars] and [`max-width-chars`][struct@crate::Label#max-width-chars]
219    /// properties can be used to control the size allocation of ellipsized or
220    /// wrapped labels. For ellipsizing labels, if either is specified (and less
221    /// than the actual text size), it is used as the minimum width, and the actual
222    /// text size is used as the natural width of the label. For wrapping labels,
223    /// width-chars is used as the minimum width, if specified, and max-width-chars
224    /// is used as the natural width. Even if max-width-chars specified, wrapping
225    /// labels will be rewrapped to use all of the available width.
226    ///
227    /// ## Links
228    ///
229    /// GTK supports markup for clickable hyperlinks in addition to regular Pango
230    /// markup. The markup for links is borrowed from HTML, using the `<a>` tag
231    /// with “href“, “title“ and “class“ attributes. GTK renders links similar to
232    /// the way they appear in web browsers, with colored, underlined text. The
233    /// “title“ attribute is displayed as a tooltip on the link. The “class“
234    /// attribute is used as style class on the CSS node for the link.
235    ///
236    /// An example of inline links looks like this:
237    ///
238    /// **⚠️ The following code is in c ⚠️**
239    ///
240    /// ```c
241    /// const char *text =
242    /// "Go to the "
243    /// "<a href=\"https://www.gtk.org\" title=\"&lt;i&gt;Our&lt;/i&gt; website\">"
244    /// "GTK website</a> for more...";
245    /// GtkWidget *label = gtk_label_new (NULL);
246    /// gtk_label_set_markup (GTK_LABEL (label), text);
247    /// ```
248    ///
249    /// It is possible to implement custom handling for links and their tooltips
250    /// with the [`activate-link`][struct@crate::Label#activate-link] signal and the
251    /// [`current_uri()`][Self::current_uri()] function.
252    ///
253    /// ## Properties
254    ///
255    ///
256    /// #### `attributes`
257    ///  A list of style attributes to apply to the text of the label.
258    ///
259    /// Readable | Writeable
260    ///
261    ///
262    /// #### `ellipsize`
263    ///  The preferred place to ellipsize the string, if the label does
264    /// not have enough room to display the entire string.
265    ///
266    /// Note that setting this property to a value other than
267    /// [enum.Pango.EllipsizeMode.none] has the side-effect that the label requests
268    /// only enough space to display the ellipsis "...". In particular, this
269    /// means that ellipsizing labels do not work well in notebook tabs, unless
270    /// the [`tab-expand`][struct@crate::NotebookPage#tab-expand] child property is set to true.
271    ///
272    /// Other ways to set a label's width are [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()]
273    /// and [`Label::set_width_chars()`][crate::Label::set_width_chars()].
274    ///
275    /// Readable | Writeable
276    ///
277    ///
278    /// #### `extra-menu`
279    ///  A menu model whose contents will be appended to the context menu.
280    ///
281    /// Readable | Writeable
282    ///
283    ///
284    /// #### `justify`
285    ///  The alignment of the lines in the text of the label, relative to each other.
286    ///
287    /// This does *not* affect the alignment of the label within its allocation.
288    /// See [`xalign`][struct@crate::Label#xalign] for that.
289    ///
290    /// Readable | Writeable
291    ///
292    ///
293    /// #### `label`
294    ///  The contents of the label.
295    ///
296    /// If the string contains Pango markup (see `parse_markup()`),
297    /// you will have to set the [`use-markup`][struct@crate::Label#use-markup] property to
298    /// true in order for the label to display the markup attributes. See also
299    /// [`Label::set_markup()`][crate::Label::set_markup()] for a convenience function that sets both
300    /// this property and the [`use-markup`][struct@crate::Label#use-markup] property at the
301    /// same time.
302    ///
303    /// If the string contains underlines acting as mnemonics, you will have to
304    /// set the [`use-underline`][struct@crate::Label#use-underline] property to true in order
305    /// for the label to display them.
306    ///
307    /// Readable | Writeable
308    ///
309    ///
310    /// #### `lines`
311    ///  The number of lines to which an ellipsized, wrapping label
312    /// should display before it gets ellipsized. This both prevents the label
313    /// from ellipsizing before this many lines are displayed, and limits the
314    /// height request of the label to this many lines.
315    ///
316    /// ::: warning
317    ///     Setting this property has unintuitive and unfortunate consequences
318    ///     for the minimum _width_ of the label. Specifically, if the height
319    ///     of the label is such that it fits a smaller number of lines than
320    ///     the value of this property, the label can not be ellipsized at all,
321    ///     which means it must be wide enough to fit all the text fully.
322    ///
323    /// This property has no effect if the label is not wrapping or ellipsized.
324    ///
325    /// Set this property to -1 if you don't want to limit the number of lines.
326    ///
327    /// Readable | Writeable
328    ///
329    ///
330    /// #### `max-width-chars`
331    ///  The desired maximum width of the label, in characters.
332    ///
333    /// If this property is set to -1, the width will be calculated automatically.
334    ///
335    /// See the section on [text layout](class.Label.html#text-layout) for details
336    /// of how [`width-chars`][struct@crate::Label#width-chars] and [`max-width-chars`][struct@crate::Label#max-width-chars]
337    /// determine the width of ellipsized and wrapped labels.
338    ///
339    /// Readable | Writeable
340    ///
341    ///
342    /// #### `mnemonic-keyval`
343    ///  The mnemonic accelerator key for the label.
344    ///
345    /// Readable
346    ///
347    ///
348    /// #### `mnemonic-widget`
349    ///  The widget to be activated when the labels mnemonic key is pressed.
350    ///
351    /// Readable | Writeable
352    ///
353    ///
354    /// #### `natural-wrap-mode`
355    ///  Select the line wrapping for the natural size request.
356    ///
357    /// This only affects the natural size requested. For the actual wrapping
358    /// used, see the [`wrap-mode`][struct@crate::Label#wrap-mode] property.
359    ///
360    /// The default is [enum@Gtk.NaturalWrapMode.inherit], which inherits
361    /// the behavior of the [`wrap-mode`][struct@crate::Label#wrap-mode] property.
362    ///
363    /// Readable | Writeable
364    ///
365    ///
366    /// #### `selectable`
367    ///  Whether the label text can be selected with the mouse.
368    ///
369    /// Readable | Writeable
370    ///
371    ///
372    /// #### `single-line-mode`
373    ///  Whether the label is in single line mode.
374    ///
375    /// In single line mode, the height of the label does not depend on the
376    /// actual text, it is always set to ascent + descent of the font. This
377    /// can be an advantage in situations where resizing the label because
378    /// of text changes would be distracting, e.g. in a statusbar.
379    ///
380    /// Readable | Writeable
381    ///
382    ///
383    /// #### `tabs`
384    ///  Custom tabs for this label.
385    ///
386    /// Readable | Writeable
387    ///
388    ///
389    /// #### `use-markup`
390    ///  True if the text of the label includes Pango markup.
391    ///
392    /// See `parse_markup()`.
393    ///
394    /// Readable | Writeable
395    ///
396    ///
397    /// #### `use-underline`
398    ///  True if the text of the label indicates a mnemonic with an `_`
399    /// before the mnemonic character.
400    ///
401    /// Readable | Writeable
402    ///
403    ///
404    /// #### `width-chars`
405    ///  The desired width of the label, in characters.
406    ///
407    /// If this property is set to -1, the width will be calculated automatically.
408    ///
409    /// See the section on [text layout](class.Label.html#text-layout) for details
410    /// of how [`width-chars`][struct@crate::Label#width-chars] and [`max-width-chars`][struct@crate::Label#max-width-chars]
411    /// determine the width of ellipsized and wrapped labels.
412    ///
413    /// Readable | Writeable
414    ///
415    ///
416    /// #### `wrap`
417    ///  True if the label text will wrap if it gets too wide.
418    ///
419    /// Readable | Writeable
420    ///
421    ///
422    /// #### `wrap-mode`
423    ///  Controls how the line wrapping is done.
424    ///
425    /// This only affects the formatting if line wrapping is on (see the
426    /// [`wrap`][struct@crate::Label#wrap] property). The default is [enum@Pango.WrapMode.word],
427    /// which means wrap on word boundaries.
428    ///
429    /// For sizing behavior, also consider the [`natural-wrap-mode`][struct@crate::Label#natural-wrap-mode]
430    /// property.
431    ///
432    /// Readable | Writeable
433    ///
434    ///
435    /// #### `xalign`
436    ///  The horizontal alignment of the label text inside its size allocation.
437    ///
438    /// Compare this to [`halign`][struct@crate::Widget#halign], which determines how the
439    /// labels size allocation is positioned in the space available for the label.
440    ///
441    /// Readable | Writeable
442    ///
443    ///
444    /// #### `yalign`
445    ///  The vertical alignment of the label text inside its size allocation.
446    ///
447    /// Compare this to [`valign`][struct@crate::Widget#valign], which determines how the
448    /// labels size allocation is positioned in the space available for the label.
449    ///
450    /// Readable | Writeable
451    /// <details><summary><h4>Widget</h4></summary>
452    ///
453    ///
454    /// #### `can-focus`
455    ///  Whether the widget or any of its descendents can accept
456    /// the input focus.
457    ///
458    /// This property is meant to be set by widget implementations,
459    /// typically in their instance init function.
460    ///
461    /// Readable | Writeable
462    ///
463    ///
464    /// #### `can-target`
465    ///  Whether the widget can receive pointer events.
466    ///
467    /// Readable | Writeable
468    ///
469    ///
470    /// #### `css-classes`
471    ///  A list of css classes applied to this widget.
472    ///
473    /// Readable | Writeable
474    ///
475    ///
476    /// #### `css-name`
477    ///  The name of this widget in the CSS tree.
478    ///
479    /// This property is meant to be set by widget implementations,
480    /// typically in their instance init function.
481    ///
482    /// Readable | Writeable | Construct Only
483    ///
484    ///
485    /// #### `cursor`
486    ///  The cursor used by @widget.
487    ///
488    /// Readable | Writeable
489    ///
490    ///
491    /// #### `focus-on-click`
492    ///  Whether the widget should grab focus when it is clicked with the mouse.
493    ///
494    /// This property is only relevant for widgets that can take focus.
495    ///
496    /// Readable | Writeable
497    ///
498    ///
499    /// #### `focusable`
500    ///  Whether this widget itself will accept the input focus.
501    ///
502    /// Readable | Writeable
503    ///
504    ///
505    /// #### `halign`
506    ///  How to distribute horizontal space if widget gets extra space.
507    ///
508    /// Readable | Writeable
509    ///
510    ///
511    /// #### `has-default`
512    ///  Whether the widget is the default widget.
513    ///
514    /// Readable
515    ///
516    ///
517    /// #### `has-focus`
518    ///  Whether the widget has the input focus.
519    ///
520    /// Readable
521    ///
522    ///
523    /// #### `has-tooltip`
524    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
525    /// signal on @widget.
526    ///
527    /// A true value indicates that @widget can have a tooltip, in this case
528    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
529    /// determine whether it will provide a tooltip or not.
530    ///
531    /// Readable | Writeable
532    ///
533    ///
534    /// #### `height-request`
535    ///  Overrides for height request of the widget.
536    ///
537    /// If this is -1, the natural request will be used.
538    ///
539    /// Readable | Writeable
540    ///
541    ///
542    /// #### `hexpand`
543    ///  Whether to expand horizontally.
544    ///
545    /// Readable | Writeable
546    ///
547    ///
548    /// #### `hexpand-set`
549    ///  Whether to use the `hexpand` property.
550    ///
551    /// Readable | Writeable
552    ///
553    ///
554    /// #### `layout-manager`
555    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
556    /// the preferred size of the widget, and allocate its children.
557    ///
558    /// This property is meant to be set by widget implementations,
559    /// typically in their instance init function.
560    ///
561    /// Readable | Writeable
562    ///
563    ///
564    /// #### `limit-events`
565    ///  Makes this widget act like a modal dialog, with respect to
566    /// event delivery.
567    ///
568    /// Global event controllers will not handle events with targets
569    /// inside the widget, unless they are set up to ignore propagation
570    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
571    ///
572    /// Readable | Writeable
573    ///
574    ///
575    /// #### `margin-bottom`
576    ///  Margin on bottom side of widget.
577    ///
578    /// This property adds margin outside of the widget's normal size
579    /// request, the margin will be added in addition to the size from
580    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
581    ///
582    /// Readable | Writeable
583    ///
584    ///
585    /// #### `margin-end`
586    ///  Margin on end of widget, horizontally.
587    ///
588    /// This property supports left-to-right and right-to-left text
589    /// directions.
590    ///
591    /// This property adds margin outside of the widget's normal size
592    /// request, the margin will be added in addition to the size from
593    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
594    ///
595    /// Readable | Writeable
596    ///
597    ///
598    /// #### `margin-start`
599    ///  Margin on start of widget, horizontally.
600    ///
601    /// This property supports left-to-right and right-to-left text
602    /// directions.
603    ///
604    /// This property adds margin outside of the widget's normal size
605    /// request, the margin will be added in addition to the size from
606    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
607    ///
608    /// Readable | Writeable
609    ///
610    ///
611    /// #### `margin-top`
612    ///  Margin on top side of widget.
613    ///
614    /// This property adds margin outside of the widget's normal size
615    /// request, the margin will be added in addition to the size from
616    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
617    ///
618    /// Readable | Writeable
619    ///
620    ///
621    /// #### `name`
622    ///  The name of the widget.
623    ///
624    /// Readable | Writeable
625    ///
626    ///
627    /// #### `opacity`
628    ///  The requested opacity of the widget.
629    ///
630    /// Readable | Writeable
631    ///
632    ///
633    /// #### `overflow`
634    ///  How content outside the widget's content area is treated.
635    ///
636    /// This property is meant to be set by widget implementations,
637    /// typically in their instance init function.
638    ///
639    /// Readable | Writeable
640    ///
641    ///
642    /// #### `parent`
643    ///  The parent widget of this widget.
644    ///
645    /// Readable
646    ///
647    ///
648    /// #### `receives-default`
649    ///  Whether the widget will receive the default action when it is focused.
650    ///
651    /// Readable | Writeable
652    ///
653    ///
654    /// #### `root`
655    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
656    ///
657    /// This will be `NULL` if the widget is not contained in a root widget.
658    ///
659    /// Readable
660    ///
661    ///
662    /// #### `scale-factor`
663    ///  The scale factor of the widget.
664    ///
665    /// Readable
666    ///
667    ///
668    /// #### `sensitive`
669    ///  Whether the widget responds to input.
670    ///
671    /// Readable | Writeable
672    ///
673    ///
674    /// #### `tooltip-markup`
675    ///  Sets the text of tooltip to be the given string, which is marked up
676    /// with Pango markup.
677    ///
678    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
679    ///
680    /// This is a convenience property which will take care of getting the
681    /// tooltip shown if the given string is not `NULL`:
682    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
683    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
684    /// the default signal handler.
685    ///
686    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
687    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
688    ///
689    /// Readable | Writeable
690    ///
691    ///
692    /// #### `tooltip-text`
693    ///  Sets the text of tooltip to be the given string.
694    ///
695    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
696    ///
697    /// This is a convenience property which will take care of getting the
698    /// tooltip shown if the given string is not `NULL`:
699    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
700    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
701    /// the default signal handler.
702    ///
703    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
704    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
705    ///
706    /// Readable | Writeable
707    ///
708    ///
709    /// #### `valign`
710    ///  How to distribute vertical space if widget gets extra space.
711    ///
712    /// Readable | Writeable
713    ///
714    ///
715    /// #### `vexpand`
716    ///  Whether to expand vertically.
717    ///
718    /// Readable | Writeable
719    ///
720    ///
721    /// #### `vexpand-set`
722    ///  Whether to use the `vexpand` property.
723    ///
724    /// Readable | Writeable
725    ///
726    ///
727    /// #### `visible`
728    ///  Whether the widget is visible.
729    ///
730    /// Readable | Writeable
731    ///
732    ///
733    /// #### `width-request`
734    ///  Overrides for width request of the widget.
735    ///
736    /// If this is -1, the natural request will be used.
737    ///
738    /// Readable | Writeable
739    /// </details>
740    /// <details><summary><h4>Accessible</h4></summary>
741    ///
742    ///
743    /// #### `accessible-role`
744    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
745    ///
746    /// The accessible role cannot be changed once set.
747    ///
748    /// Readable | Writeable
749    /// </details>
750    ///
751    /// ## Signals
752    ///
753    ///
754    /// #### `activate-current-link`
755    ///  Gets emitted when the user activates a link in the label.
756    ///
757    /// The `::activate-current-link` is a [keybinding signal](class.SignalAction.html).
758    ///
759    /// Applications may also emit the signal with g_signal_emit_by_name()
760    /// if they need to control activation of URIs programmatically.
761    ///
762    /// The default bindings for this signal are all forms of the <kbd>Enter</kbd> key.
763    ///
764    /// Action
765    ///
766    ///
767    /// #### `activate-link`
768    ///  Gets emitted to activate a URI.
769    ///
770    /// Applications may connect to it to override the default behaviour,
771    /// which is to call [`FileLauncher::launch()`][crate::FileLauncher::launch()].
772    ///
773    ///
774    ///
775    ///
776    /// #### `copy-clipboard`
777    ///  Gets emitted to copy the selection to the clipboard.
778    ///
779    /// The `::copy-clipboard` signal is a [keybinding signal](class.SignalAction.html).
780    ///
781    /// The default binding for this signal is <kbd>Ctrl</kbd>+<kbd>c</kbd>.
782    ///
783    /// Action
784    ///
785    ///
786    /// #### `move-cursor`
787    ///  Gets emitted when the user initiates a cursor movement.
788    ///
789    /// The `::move-cursor` signal is a [keybinding signal](class.SignalAction.html).
790    /// If the cursor is not visible in @entry, this signal causes the viewport to
791    /// be moved instead.
792    ///
793    /// Applications should not connect to it, but may emit it with
794    /// `signal_emit_by_name()` if they need to control
795    /// the cursor programmatically.
796    ///
797    /// The default bindings for this signal come in two variants, the
798    /// variant with the <kbd>Shift</kbd> modifier extends the selection,
799    /// the variant without the <kbd>Shift</kbd> modifier does not.
800    /// There are too many key combinations to list them all here.
801    ///
802    /// - <kbd>←</kbd>, <kbd>→</kbd>, <kbd>↑</kbd>, <kbd>↓</kbd>
803    ///   move by individual characters/lines
804    /// - <kbd>Ctrl</kbd>+<kbd>←</kbd>, etc. move by words/paragraphs
805    /// - <kbd>Home</kbd> and <kbd>End</kbd> move to the ends of the buffer
806    ///
807    /// Action
808    /// <details><summary><h4>Widget</h4></summary>
809    ///
810    ///
811    /// #### `destroy`
812    ///  Signals that all holders of a reference to the widget should release
813    /// the reference that they hold.
814    ///
815    /// May result in finalization of the widget if all references are released.
816    ///
817    /// This signal is not suitable for saving widget state.
818    ///
819    ///
820    ///
821    ///
822    /// #### `direction-changed`
823    ///  Emitted when the text direction of a widget changes.
824    ///
825    ///
826    ///
827    ///
828    /// #### `hide`
829    ///  Emitted when @widget is hidden.
830    ///
831    ///
832    ///
833    ///
834    /// #### `keynav-failed`
835    ///  Emitted if keyboard navigation fails.
836    ///
837    /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
838    ///
839    ///
840    ///
841    ///
842    /// #### `map`
843    ///  Emitted when @widget is going to be mapped.
844    ///
845    /// A widget is mapped when the widget is visible (which is controlled with
846    /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
847    /// are also visible.
848    ///
849    /// The `::map` signal can be used to determine whether a widget will be drawn,
850    /// for instance it can resume an animation that was stopped during the
851    /// emission of [`unmap`][struct@crate::Widget#unmap].
852    ///
853    ///
854    ///
855    ///
856    /// #### `mnemonic-activate`
857    ///  Emitted when a widget is activated via a mnemonic.
858    ///
859    /// The default handler for this signal activates @widget if @group_cycling
860    /// is false, or just makes @widget grab focus if @group_cycling is true.
861    ///
862    ///
863    ///
864    ///
865    /// #### `move-focus`
866    ///  Emitted when the focus is moved.
867    ///
868    /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
869    ///
870    /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
871    /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
872    ///
873    /// Action
874    ///
875    ///
876    /// #### `query-tooltip`
877    ///  Emitted when the widget’s tooltip is about to be shown.
878    ///
879    /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
880    /// is true and the hover timeout has expired with the cursor hovering
881    /// above @widget; or emitted when @widget got focus in keyboard mode.
882    ///
883    /// Using the given coordinates, the signal handler should determine
884    /// whether a tooltip should be shown for @widget. If this is the case
885    /// true should be returned, false otherwise. Note that if @keyboard_mode
886    /// is true, the values of @x and @y are undefined and should not be used.
887    ///
888    /// The signal handler is free to manipulate @tooltip with the therefore
889    /// destined function calls.
890    ///
891    ///
892    ///
893    ///
894    /// #### `realize`
895    ///  Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
896    ///
897    /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
898    /// or the widget has been mapped (that is, it is going to be drawn).
899    ///
900    ///
901    ///
902    ///
903    /// #### `show`
904    ///  Emitted when @widget is shown.
905    ///
906    ///
907    ///
908    ///
909    /// #### `state-flags-changed`
910    ///  Emitted when the widget state changes.
911    ///
912    /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
913    ///
914    ///
915    ///
916    ///
917    /// #### `unmap`
918    ///  Emitted when @widget is going to be unmapped.
919    ///
920    /// A widget is unmapped when either it or any of its parents up to the
921    /// toplevel widget have been set as hidden.
922    ///
923    /// As `::unmap` indicates that a widget will not be shown any longer,
924    /// it can be used to, for example, stop an animation on the widget.
925    ///
926    ///
927    ///
928    ///
929    /// #### `unrealize`
930    ///  Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
931    ///
932    /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
933    /// or the widget has been unmapped (that is, it is going to be hidden).
934    ///
935    ///
936    /// </details>
937    ///
938    /// # Implements
939    ///
940    /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`AccessibleTextExt`][trait@crate::prelude::AccessibleTextExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
941    #[doc(alias = "GtkLabel")]
942    pub struct Label(Object<ffi::GtkLabel>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, AccessibleText;
943
944    match fn {
945        type_ => || ffi::gtk_label_get_type(),
946    }
947}
948
949#[cfg(not(any(feature = "v4_14")))]
950glib::wrapper! {
951    #[doc(alias = "GtkLabel")]
952    pub struct Label(Object<ffi::GtkLabel>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
953
954    match fn {
955        type_ => || ffi::gtk_label_get_type(),
956    }
957}
958
959impl Label {
960    /// Creates a new label with the given text inside it.
961    ///
962    /// You can pass `NULL` to get an empty label widget.
963    /// ## `str`
964    /// the text of the label
965    ///
966    /// # Returns
967    ///
968    /// the new label
969    #[doc(alias = "gtk_label_new")]
970    pub fn new(str: Option<&str>) -> Label {
971        assert_initialized_main_thread!();
972        unsafe { Widget::from_glib_none(ffi::gtk_label_new(str.to_glib_none().0)).unsafe_cast() }
973    }
974
975    /// Creates a new label with the given text inside it, and a mnemonic.
976    ///
977    /// If characters in @str are preceded by an underscore, they are
978    /// underlined. If you need a literal underscore character in a label, use
979    /// '__' (two underscores). The first underlined character represents a
980    /// keyboard accelerator called a mnemonic. The mnemonic key can be used
981    /// to activate another widget, chosen automatically, or explicitly using
982    /// [`set_mnemonic_widget()`][Self::set_mnemonic_widget()].
983    ///
984    /// If [`set_mnemonic_widget()`][Self::set_mnemonic_widget()] is not called, then the first
985    /// activatable ancestor of the label will be chosen as the mnemonic
986    /// widget. For instance, if the label is inside a button or menu item,
987    /// the button or menu item will automatically become the mnemonic widget
988    /// and be activated by the mnemonic.
989    /// ## `str`
990    /// the text of the label, with an underscore in front of the
991    ///   mnemonic character
992    ///
993    /// # Returns
994    ///
995    /// the new label
996    #[doc(alias = "gtk_label_new_with_mnemonic")]
997    #[doc(alias = "new_with_mnemonic")]
998    pub fn with_mnemonic(str: &str) -> Label {
999        assert_initialized_main_thread!();
1000        unsafe {
1001            Widget::from_glib_none(ffi::gtk_label_new_with_mnemonic(str.to_glib_none().0))
1002                .unsafe_cast()
1003        }
1004    }
1005
1006    // rustdoc-stripper-ignore-next
1007    /// Creates a new builder-pattern struct instance to construct [`Label`] objects.
1008    ///
1009    /// This method returns an instance of [`LabelBuilder`](crate::builders::LabelBuilder) which can be used to create [`Label`] objects.
1010    pub fn builder() -> LabelBuilder {
1011        LabelBuilder::new()
1012    }
1013
1014    /// Gets the label's attribute list.
1015    ///
1016    /// This is the [`pango::AttrList`][crate::pango::AttrList] that was set on the label using
1017    /// [`set_attributes()`][Self::set_attributes()], if any. This function does not
1018    /// reflect attributes that come from the label's markup (see
1019    /// [`set_markup()`][Self::set_markup()]). If you want to get the effective
1020    /// attributes for the label, use
1021    /// `pango_layout_get_attributes (gtk_label_get_layout (self))`.
1022    ///
1023    /// # Returns
1024    ///
1025    /// the attribute list
1026    #[doc(alias = "gtk_label_get_attributes")]
1027    #[doc(alias = "get_attributes")]
1028    pub fn attributes(&self) -> Option<pango::AttrList> {
1029        unsafe { from_glib_none(ffi::gtk_label_get_attributes(self.to_glib_none().0)) }
1030    }
1031
1032    /// Returns the URI for the active link in the label.
1033    ///
1034    /// The active link is the one under the mouse pointer or, in a
1035    /// selectable label, the link in which the text cursor is currently
1036    /// positioned.
1037    ///
1038    /// This function is intended for use in a [`activate-link`][struct@crate::Label#activate-link]
1039    /// handler or for use in a [`query-tooltip`][struct@crate::Widget#query-tooltip] handler.
1040    ///
1041    /// # Returns
1042    ///
1043    /// the active URI
1044    #[doc(alias = "gtk_label_get_current_uri")]
1045    #[doc(alias = "get_current_uri")]
1046    pub fn current_uri(&self) -> Option<glib::GString> {
1047        unsafe { from_glib_none(ffi::gtk_label_get_current_uri(self.to_glib_none().0)) }
1048    }
1049
1050    /// Returns the ellipsization mode of the label.
1051    ///
1052    /// See [`set_ellipsize()`][Self::set_ellipsize()].
1053    ///
1054    /// # Returns
1055    ///
1056    /// the ellipsization mode
1057    #[doc(alias = "gtk_label_get_ellipsize")]
1058    #[doc(alias = "get_ellipsize")]
1059    pub fn ellipsize(&self) -> pango::EllipsizeMode {
1060        unsafe { from_glib(ffi::gtk_label_get_ellipsize(self.to_glib_none().0)) }
1061    }
1062
1063    /// Gets the extra menu model of the label.
1064    ///
1065    /// See [`set_extra_menu()`][Self::set_extra_menu()].
1066    ///
1067    /// # Returns
1068    ///
1069    /// the menu model
1070    #[doc(alias = "gtk_label_get_extra_menu")]
1071    #[doc(alias = "get_extra_menu")]
1072    #[doc(alias = "extra-menu")]
1073    pub fn extra_menu(&self) -> Option<gio::MenuModel> {
1074        unsafe { from_glib_none(ffi::gtk_label_get_extra_menu(self.to_glib_none().0)) }
1075    }
1076
1077    /// Returns the justification of the label.
1078    ///
1079    /// See [`set_justify()`][Self::set_justify()].
1080    ///
1081    /// # Returns
1082    ///
1083    /// the justification value
1084    #[doc(alias = "gtk_label_get_justify")]
1085    #[doc(alias = "get_justify")]
1086    pub fn justify(&self) -> Justification {
1087        unsafe { from_glib(ffi::gtk_label_get_justify(self.to_glib_none().0)) }
1088    }
1089
1090    /// Fetches the text from a label.
1091    ///
1092    /// The returned text includes any embedded underlines indicating
1093    /// mnemonics and Pango markup. (See [`text()`][Self::text()]).
1094    ///
1095    /// # Returns
1096    ///
1097    /// the text of the label widget
1098    #[doc(alias = "gtk_label_get_label")]
1099    #[doc(alias = "get_label")]
1100    pub fn label(&self) -> glib::GString {
1101        unsafe { from_glib_none(ffi::gtk_label_get_label(self.to_glib_none().0)) }
1102    }
1103
1104    /// Gets the Pango layout used to display the label.
1105    ///
1106    /// The layout is useful to e.g. convert text positions to pixel
1107    /// positions, in combination with [`layout_offsets()`][Self::layout_offsets()].
1108    /// The returned layout is owned by the @label so need not be
1109    /// freed by the caller. The @label is free to recreate its layout
1110    /// at any time, so it should be considered read-only.
1111    ///
1112    /// # Returns
1113    ///
1114    /// the [`pango::Layout`][crate::pango::Layout] for this label
1115    #[doc(alias = "gtk_label_get_layout")]
1116    #[doc(alias = "get_layout")]
1117    pub fn layout(&self) -> pango::Layout {
1118        unsafe { from_glib_none(ffi::gtk_label_get_layout(self.to_glib_none().0)) }
1119    }
1120
1121    /// Obtains the coordinates where the label will draw its Pango layout.
1122    ///
1123    /// The coordinates are useful to convert mouse events into coordinates
1124    /// inside the [`pango::Layout`][crate::pango::Layout], e.g. to take some action if some part
1125    /// of the label is clicked. Remember when using the [`pango::Layout`][crate::pango::Layout]
1126    /// functions you need to convert to and from pixels using `PANGO_PIXELS()`
1127    /// or `Pango::SCALE`.
1128    ///
1129    /// # Returns
1130    ///
1131    ///
1132    /// ## `x`
1133    /// location to store X offset of layout
1134    ///
1135    /// ## `y`
1136    /// location to store Y offset of layout
1137    #[doc(alias = "gtk_label_get_layout_offsets")]
1138    #[doc(alias = "get_layout_offsets")]
1139    pub fn layout_offsets(&self) -> (i32, i32) {
1140        unsafe {
1141            let mut x = std::mem::MaybeUninit::uninit();
1142            let mut y = std::mem::MaybeUninit::uninit();
1143            ffi::gtk_label_get_layout_offsets(
1144                self.to_glib_none().0,
1145                x.as_mut_ptr(),
1146                y.as_mut_ptr(),
1147            );
1148            (x.assume_init(), y.assume_init())
1149        }
1150    }
1151
1152    /// Gets the number of lines to which an ellipsized, wrapping
1153    /// label should be limited.
1154    ///
1155    /// See [`set_lines()`][Self::set_lines()].
1156    ///
1157    /// # Returns
1158    ///
1159    /// the number of lines
1160    #[doc(alias = "gtk_label_get_lines")]
1161    #[doc(alias = "get_lines")]
1162    pub fn lines(&self) -> i32 {
1163        unsafe { ffi::gtk_label_get_lines(self.to_glib_none().0) }
1164    }
1165
1166    /// Retrieves the maximum width of the label in characters.
1167    ///
1168    /// See [`set_width_chars()`][Self::set_width_chars()].
1169    ///
1170    /// # Returns
1171    ///
1172    /// the maximum width of the label, in characters
1173    #[doc(alias = "gtk_label_get_max_width_chars")]
1174    #[doc(alias = "get_max_width_chars")]
1175    #[doc(alias = "max-width-chars")]
1176    pub fn max_width_chars(&self) -> i32 {
1177        unsafe { ffi::gtk_label_get_max_width_chars(self.to_glib_none().0) }
1178    }
1179
1180    /// Retrieves the mnemonic target of this label.
1181    ///
1182    /// See [`set_mnemonic_widget()`][Self::set_mnemonic_widget()].
1183    ///
1184    /// # Returns
1185    ///
1186    /// the target of the label’s mnemonic,
1187    ///   or `NULL` if none has been set and the default algorithm will be used.
1188    #[doc(alias = "gtk_label_get_mnemonic_widget")]
1189    #[doc(alias = "get_mnemonic_widget")]
1190    #[doc(alias = "mnemonic-widget")]
1191    pub fn mnemonic_widget(&self) -> Option<Widget> {
1192        unsafe { from_glib_none(ffi::gtk_label_get_mnemonic_widget(self.to_glib_none().0)) }
1193    }
1194
1195    /// Returns natural line wrap mode used by the label.
1196    ///
1197    /// See [`set_natural_wrap_mode()`][Self::set_natural_wrap_mode()].
1198    ///
1199    /// # Returns
1200    ///
1201    /// the natural line wrap mode
1202    #[cfg(feature = "v4_6")]
1203    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
1204    #[doc(alias = "gtk_label_get_natural_wrap_mode")]
1205    #[doc(alias = "get_natural_wrap_mode")]
1206    #[doc(alias = "natural-wrap-mode")]
1207    pub fn natural_wrap_mode(&self) -> NaturalWrapMode {
1208        unsafe { from_glib(ffi::gtk_label_get_natural_wrap_mode(self.to_glib_none().0)) }
1209    }
1210
1211    /// Returns whether the label is selectable.
1212    ///
1213    /// # Returns
1214    ///
1215    /// true if the user can copy text from the label
1216    #[doc(alias = "gtk_label_get_selectable")]
1217    #[doc(alias = "get_selectable")]
1218    #[doc(alias = "selectable")]
1219    pub fn is_selectable(&self) -> bool {
1220        unsafe { from_glib(ffi::gtk_label_get_selectable(self.to_glib_none().0)) }
1221    }
1222
1223    /// Gets the selected range of characters in the label.
1224    ///
1225    /// The returned @start and @end positions are in characters.
1226    ///
1227    /// # Returns
1228    ///
1229    /// true if selection is non-empty
1230    ///
1231    /// ## `start`
1232    /// return location for start of selection
1233    ///
1234    /// ## `end`
1235    /// return location for end of selection
1236    #[doc(alias = "gtk_label_get_selection_bounds")]
1237    #[doc(alias = "get_selection_bounds")]
1238    pub fn selection_bounds(&self) -> Option<(i32, i32)> {
1239        unsafe {
1240            let mut start = std::mem::MaybeUninit::uninit();
1241            let mut end = std::mem::MaybeUninit::uninit();
1242            let ret = from_glib(ffi::gtk_label_get_selection_bounds(
1243                self.to_glib_none().0,
1244                start.as_mut_ptr(),
1245                end.as_mut_ptr(),
1246            ));
1247            if ret {
1248                Some((start.assume_init(), end.assume_init()))
1249            } else {
1250                None
1251            }
1252        }
1253    }
1254
1255    /// Returns whether the label is in single line mode.
1256    ///
1257    /// # Returns
1258    ///
1259    /// true if the label is in single line mode
1260    #[doc(alias = "gtk_label_get_single_line_mode")]
1261    #[doc(alias = "get_single_line_mode")]
1262    #[doc(alias = "single-line-mode")]
1263    pub fn is_single_line_mode(&self) -> bool {
1264        unsafe { from_glib(ffi::gtk_label_get_single_line_mode(self.to_glib_none().0)) }
1265    }
1266
1267    /// Gets the tab stops for the label.
1268    ///
1269    /// The returned array will be `NULL` if “standard” (8-space) tabs are used.
1270    ///
1271    /// # Returns
1272    ///
1273    /// copy of default tab array,
1274    ///   or `NULL` if standard tabs are used
1275    #[cfg(feature = "v4_8")]
1276    #[cfg_attr(docsrs, doc(cfg(feature = "v4_8")))]
1277    #[doc(alias = "gtk_label_get_tabs")]
1278    #[doc(alias = "get_tabs")]
1279    pub fn tabs(&self) -> Option<pango::TabArray> {
1280        unsafe { from_glib_full(ffi::gtk_label_get_tabs(self.to_glib_none().0)) }
1281    }
1282
1283    /// Gets the text of the label.
1284    ///
1285    /// The returned text is as it appears on screen. This does not include
1286    /// any embedded underlines indicating mnemonics or Pango markup. (See
1287    /// [`label()`][Self::label()])
1288    ///
1289    /// # Returns
1290    ///
1291    /// the text in the label widget
1292    #[doc(alias = "gtk_label_get_text")]
1293    #[doc(alias = "get_text")]
1294    pub fn text(&self) -> glib::GString {
1295        unsafe { from_glib_none(ffi::gtk_label_get_text(self.to_glib_none().0)) }
1296    }
1297
1298    /// Returns whether the label’s text is interpreted as Pango markup.
1299    ///
1300    /// See [`set_use_markup()`][Self::set_use_markup()].
1301    ///
1302    /// # Returns
1303    ///
1304    /// true if the label’s text will be parsed for markup
1305    #[doc(alias = "gtk_label_get_use_markup")]
1306    #[doc(alias = "get_use_markup")]
1307    #[doc(alias = "use-markup")]
1308    pub fn uses_markup(&self) -> bool {
1309        unsafe { from_glib(ffi::gtk_label_get_use_markup(self.to_glib_none().0)) }
1310    }
1311
1312    /// Returns whether underlines in the label indicate mnemonics.
1313    ///
1314    /// See [`set_use_underline()`][Self::set_use_underline()].
1315    ///
1316    /// # Returns
1317    ///
1318    /// true if underlines in the label indicate mnemonics
1319    #[doc(alias = "gtk_label_get_use_underline")]
1320    #[doc(alias = "get_use_underline")]
1321    #[doc(alias = "use-underline")]
1322    pub fn uses_underline(&self) -> bool {
1323        unsafe { from_glib(ffi::gtk_label_get_use_underline(self.to_glib_none().0)) }
1324    }
1325
1326    /// Retrieves the desired width of the label in characters.
1327    ///
1328    /// See [`set_width_chars()`][Self::set_width_chars()].
1329    ///
1330    /// # Returns
1331    ///
1332    /// the desired width of the label, in characters
1333    #[doc(alias = "gtk_label_get_width_chars")]
1334    #[doc(alias = "get_width_chars")]
1335    #[doc(alias = "width-chars")]
1336    pub fn width_chars(&self) -> i32 {
1337        unsafe { ffi::gtk_label_get_width_chars(self.to_glib_none().0) }
1338    }
1339
1340    /// Returns whether lines in the label are automatically wrapped.
1341    ///
1342    /// See [`set_wrap()`][Self::set_wrap()].
1343    ///
1344    /// # Returns
1345    ///
1346    /// true if the lines of the label are automatically wrapped
1347    #[doc(alias = "gtk_label_get_wrap")]
1348    #[doc(alias = "get_wrap")]
1349    #[doc(alias = "wrap")]
1350    pub fn wraps(&self) -> bool {
1351        unsafe { from_glib(ffi::gtk_label_get_wrap(self.to_glib_none().0)) }
1352    }
1353
1354    /// Returns line wrap mode used by the label.
1355    ///
1356    /// See [`set_wrap_mode()`][Self::set_wrap_mode()].
1357    ///
1358    /// # Returns
1359    ///
1360    /// the line wrap mode
1361    #[doc(alias = "gtk_label_get_wrap_mode")]
1362    #[doc(alias = "get_wrap_mode")]
1363    #[doc(alias = "wrap-mode")]
1364    pub fn wrap_mode(&self) -> pango::WrapMode {
1365        unsafe { from_glib(ffi::gtk_label_get_wrap_mode(self.to_glib_none().0)) }
1366    }
1367
1368    /// Gets the `xalign` of the label.
1369    ///
1370    /// See the [`xalign`][struct@crate::Label#xalign] property.
1371    ///
1372    /// # Returns
1373    ///
1374    /// the xalign value
1375    #[doc(alias = "gtk_label_get_xalign")]
1376    #[doc(alias = "get_xalign")]
1377    pub fn xalign(&self) -> f32 {
1378        unsafe { ffi::gtk_label_get_xalign(self.to_glib_none().0) }
1379    }
1380
1381    /// Gets the `yalign` of the label.
1382    ///
1383    /// See the [`yalign`][struct@crate::Label#yalign] property.
1384    ///
1385    /// # Returns
1386    ///
1387    /// the yalign value
1388    #[doc(alias = "gtk_label_get_yalign")]
1389    #[doc(alias = "get_yalign")]
1390    pub fn yalign(&self) -> f32 {
1391        unsafe { ffi::gtk_label_get_yalign(self.to_glib_none().0) }
1392    }
1393
1394    /// Selects a range of characters in the label, if the label is selectable.
1395    ///
1396    /// See [`set_selectable()`][Self::set_selectable()]. If the label is not selectable,
1397    /// this function has no effect. If @start_offset or
1398    /// @end_offset are -1, then the end of the label will be substituted.
1399    /// ## `start_offset`
1400    /// start offset, in characters
1401    /// ## `end_offset`
1402    /// end offset, in characters
1403    #[doc(alias = "gtk_label_select_region")]
1404    pub fn select_region(&self, start_offset: i32, end_offset: i32) {
1405        unsafe {
1406            ffi::gtk_label_select_region(self.to_glib_none().0, start_offset, end_offset);
1407        }
1408    }
1409
1410    /// Apply attributes to the label text.
1411    ///
1412    /// The attributes set with this function will be applied and merged with
1413    /// any other attributes previously effected by way of the
1414    /// [`use-underline`][struct@crate::Label#use-underline] or [`use-markup`][struct@crate::Label#use-markup]
1415    /// properties
1416    ///
1417    /// While it is not recommended to mix markup strings with manually set
1418    /// attributes, if you must; know that the attributes will be applied
1419    /// to the label after the markup string is parsed.
1420    /// ## `attrs`
1421    /// a list of style attributes
1422    #[doc(alias = "gtk_label_set_attributes")]
1423    #[doc(alias = "attributes")]
1424    pub fn set_attributes(&self, attrs: Option<&pango::AttrList>) {
1425        unsafe {
1426            ffi::gtk_label_set_attributes(self.to_glib_none().0, attrs.to_glib_none().0);
1427        }
1428    }
1429
1430    /// Sets the mode used to ellipsize the text.
1431    ///
1432    /// The text will be ellipsized if there is not
1433    /// enough space to render the entire string.
1434    /// ## `mode`
1435    /// the ellipsization mode
1436    #[doc(alias = "gtk_label_set_ellipsize")]
1437    #[doc(alias = "ellipsize")]
1438    pub fn set_ellipsize(&self, mode: pango::EllipsizeMode) {
1439        unsafe {
1440            ffi::gtk_label_set_ellipsize(self.to_glib_none().0, mode.into_glib());
1441        }
1442    }
1443
1444    /// Sets a menu model to add to the context menu of the label.
1445    /// ## `model`
1446    /// a menu model
1447    #[doc(alias = "gtk_label_set_extra_menu")]
1448    #[doc(alias = "extra-menu")]
1449    pub fn set_extra_menu(&self, model: Option<&impl IsA<gio::MenuModel>>) {
1450        unsafe {
1451            ffi::gtk_label_set_extra_menu(
1452                self.to_glib_none().0,
1453                model.map(|p| p.as_ref()).to_glib_none().0,
1454            );
1455        }
1456    }
1457
1458    /// Sets the alignment of lines in the label relative to each other.
1459    ///
1460    /// This function has no effect on labels containing only a single line.
1461    ///
1462    /// [enum@Gtk.Justification.left] is the default value when the widget
1463    /// is first created with [`new()`][Self::new()].
1464    ///
1465    /// If you instead want to set the alignment of the label as a whole,
1466    /// use [`WidgetExt::set_halign()`][crate::prelude::WidgetExt::set_halign()] instead.
1467    /// ## `jtype`
1468    /// the new justification
1469    #[doc(alias = "gtk_label_set_justify")]
1470    #[doc(alias = "justify")]
1471    pub fn set_justify(&self, jtype: Justification) {
1472        unsafe {
1473            ffi::gtk_label_set_justify(self.to_glib_none().0, jtype.into_glib());
1474        }
1475    }
1476
1477    /// Sets the text of the label.
1478    ///
1479    /// The label is interpreted as including embedded underlines and/or Pango
1480    /// markup depending on the values of the [`use-underline`][struct@crate::Label#use-underline]
1481    /// and [`use-markup`][struct@crate::Label#use-markup] properties.
1482    /// ## `str`
1483    /// the new text to set for the label
1484    #[doc(alias = "gtk_label_set_label")]
1485    #[doc(alias = "label")]
1486    pub fn set_label(&self, str: &str) {
1487        unsafe {
1488            ffi::gtk_label_set_label(self.to_glib_none().0, str.to_glib_none().0);
1489        }
1490    }
1491
1492    /// Sets the number of lines to which an ellipsized, wrapping label
1493    /// should be limited.
1494    ///
1495    /// This has no effect if the label is not wrapping or ellipsized.
1496    /// Set this to -1 if you don’t want to limit the number of lines.
1497    /// ## `lines`
1498    /// the desired number of lines, or -1
1499    #[doc(alias = "gtk_label_set_lines")]
1500    #[doc(alias = "lines")]
1501    pub fn set_lines(&self, lines: i32) {
1502        unsafe {
1503            ffi::gtk_label_set_lines(self.to_glib_none().0, lines);
1504        }
1505    }
1506
1507    /// Sets the labels text and attributes from markup.
1508    ///
1509    /// The string must be marked up with Pango markup
1510    /// (see `parse_markup()`).
1511    ///
1512    /// If @str is external data, you may need to escape it
1513    /// with `markup_escape_text()` or `markup_printf_escaped()`:
1514    ///
1515    /// **⚠️ The following code is in c ⚠️**
1516    ///
1517    /// ```c
1518    /// GtkWidget *self = gtk_label_new (NULL);
1519    /// const char *str = "...";
1520    /// const char *format = "<span style=\"italic\">\%s</span>";
1521    /// char *markup;
1522    ///
1523    /// markup = g_markup_printf_escaped (format, str);
1524    /// gtk_label_set_markup (GTK_LABEL (self), markup);
1525    /// g_free (markup);
1526    /// ```
1527    ///
1528    /// This function sets the [`use-markup`][struct@crate::Label#use-markup] property
1529    /// to true.
1530    ///
1531    /// Also see [`set_text()`][Self::set_text()].
1532    /// ## `str`
1533    /// the markup string
1534    #[doc(alias = "gtk_label_set_markup")]
1535    pub fn set_markup(&self, str: &str) {
1536        unsafe {
1537            ffi::gtk_label_set_markup(self.to_glib_none().0, str.to_glib_none().0);
1538        }
1539    }
1540
1541    /// Sets the labels text, attributes and mnemonic from markup.
1542    ///
1543    /// Parses @str which is marked up with Pango markup (see `parse_markup()`),
1544    /// setting the label’s text and attribute list based on the parse results.
1545    /// If characters in @str are preceded by an underscore, they are underlined
1546    /// indicating that they represent a keyboard accelerator called a mnemonic.
1547    ///
1548    /// The mnemonic key can be used to activate another widget, chosen
1549    /// automatically, or explicitly using [`set_mnemonic_widget()`][Self::set_mnemonic_widget()].
1550    /// ## `str`
1551    /// the markup string
1552    #[doc(alias = "gtk_label_set_markup_with_mnemonic")]
1553    pub fn set_markup_with_mnemonic(&self, str: &str) {
1554        unsafe {
1555            ffi::gtk_label_set_markup_with_mnemonic(self.to_glib_none().0, str.to_glib_none().0);
1556        }
1557    }
1558
1559    /// Sets the maximum width of the label in characters.
1560    /// ## `n_chars`
1561    /// the new maximum width, in characters.
1562    #[doc(alias = "gtk_label_set_max_width_chars")]
1563    #[doc(alias = "max-width-chars")]
1564    pub fn set_max_width_chars(&self, n_chars: i32) {
1565        unsafe {
1566            ffi::gtk_label_set_max_width_chars(self.to_glib_none().0, n_chars);
1567        }
1568    }
1569
1570    /// Associate the label with its mnemonic target.
1571    ///
1572    /// If the label has been set so that it has a mnemonic key (using
1573    /// i.e. [`set_markup_with_mnemonic()`][Self::set_markup_with_mnemonic()],
1574    /// [`set_text_with_mnemonic()`][Self::set_text_with_mnemonic()],
1575    /// [`with_mnemonic()`][Self::with_mnemonic()]
1576    /// or the [`use_underline`][struct@crate::Label#use_underline] property) the label can
1577    /// be associated with a widget that is the target of the mnemonic.
1578    /// When the label is inside a widget (like a [`Button`][crate::Button] or a
1579    /// [`Notebook`][crate::Notebook] tab) it is automatically associated with the
1580    /// correct widget, but sometimes (i.e. when the target is a [`Entry`][crate::Entry]
1581    /// next to the label) you need to set it explicitly using this function.
1582    ///
1583    /// The target widget will be accelerated by emitting the
1584    /// [`mnemonic-activate`][struct@crate::Widget#mnemonic-activate] signal on it. The default handler
1585    /// for this signal will activate the widget if there are no mnemonic
1586    /// collisions and toggle focus between the colliding widgets otherwise.
1587    /// ## `widget`
1588    /// the target widget
1589    #[doc(alias = "gtk_label_set_mnemonic_widget")]
1590    #[doc(alias = "mnemonic-widget")]
1591    pub fn set_mnemonic_widget(&self, widget: Option<&impl IsA<Widget>>) {
1592        unsafe {
1593            ffi::gtk_label_set_mnemonic_widget(
1594                self.to_glib_none().0,
1595                widget.map(|p| p.as_ref()).to_glib_none().0,
1596            );
1597        }
1598    }
1599
1600    /// Selects the line wrapping for the natural size request.
1601    ///
1602    /// This only affects the natural size requested, for the actual wrapping used,
1603    /// see the [`wrap-mode`][struct@crate::Label#wrap-mode] property.
1604    /// ## `wrap_mode`
1605    /// the line wrapping mode
1606    #[cfg(feature = "v4_6")]
1607    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
1608    #[doc(alias = "gtk_label_set_natural_wrap_mode")]
1609    #[doc(alias = "natural-wrap-mode")]
1610    pub fn set_natural_wrap_mode(&self, wrap_mode: NaturalWrapMode) {
1611        unsafe {
1612            ffi::gtk_label_set_natural_wrap_mode(self.to_glib_none().0, wrap_mode.into_glib());
1613        }
1614    }
1615
1616    /// Makes text in the label selectable.
1617    ///
1618    /// Selectable labels allow the user to select text from the label,
1619    /// for copy-and-paste.
1620    /// ## `setting`
1621    /// true to allow selecting text in the label
1622    #[doc(alias = "gtk_label_set_selectable")]
1623    #[doc(alias = "selectable")]
1624    pub fn set_selectable(&self, setting: bool) {
1625        unsafe {
1626            ffi::gtk_label_set_selectable(self.to_glib_none().0, setting.into_glib());
1627        }
1628    }
1629
1630    /// Sets whether the label is in single line mode.
1631    /// ## `single_line_mode`
1632    /// true to enable single line mode
1633    #[doc(alias = "gtk_label_set_single_line_mode")]
1634    #[doc(alias = "single-line-mode")]
1635    pub fn set_single_line_mode(&self, single_line_mode: bool) {
1636        unsafe {
1637            ffi::gtk_label_set_single_line_mode(
1638                self.to_glib_none().0,
1639                single_line_mode.into_glib(),
1640            );
1641        }
1642    }
1643
1644    /// Sets tab stops for the label.
1645    /// ## `tabs`
1646    /// tab stops
1647    #[cfg(feature = "v4_8")]
1648    #[cfg_attr(docsrs, doc(cfg(feature = "v4_8")))]
1649    #[doc(alias = "gtk_label_set_tabs")]
1650    #[doc(alias = "tabs")]
1651    pub fn set_tabs(&self, tabs: Option<&pango::TabArray>) {
1652        unsafe {
1653            ffi::gtk_label_set_tabs(self.to_glib_none().0, mut_override(tabs.to_glib_none().0));
1654        }
1655    }
1656
1657    /// Sets the text for the label.
1658    ///
1659    /// It overwrites any text that was there before and clears any
1660    /// previously set mnemonic accelerators, and sets the
1661    /// [`use-underline`][struct@crate::Label#use-underline] and
1662    /// [`use-markup`][struct@crate::Label#use-markup] properties to false.
1663    ///
1664    /// Also see [`set_markup()`][Self::set_markup()].
1665    /// ## `str`
1666    /// the text to show in @self
1667    #[doc(alias = "gtk_label_set_text")]
1668    pub fn set_text(&self, str: &str) {
1669        unsafe {
1670            ffi::gtk_label_set_text(self.to_glib_none().0, str.to_glib_none().0);
1671        }
1672    }
1673
1674    /// Sets the text for the label, with mnemonics.
1675    ///
1676    /// If characters in @str are preceded by an underscore, they are underlined
1677    /// indicating that they represent a keyboard accelerator called a mnemonic.
1678    /// The mnemonic key can be used to activate another widget, chosen
1679    /// automatically, or explicitly using [`set_mnemonic_widget()`][Self::set_mnemonic_widget()].
1680    /// ## `str`
1681    /// the text
1682    #[doc(alias = "gtk_label_set_text_with_mnemonic")]
1683    pub fn set_text_with_mnemonic(&self, str: &str) {
1684        unsafe {
1685            ffi::gtk_label_set_text_with_mnemonic(self.to_glib_none().0, str.to_glib_none().0);
1686        }
1687    }
1688
1689    /// Sets whether the text of the label contains markup.
1690    ///
1691    /// See [`set_markup()`][Self::set_markup()].
1692    /// ## `setting`
1693    /// true if the label’s text should be parsed for markup.
1694    #[doc(alias = "gtk_label_set_use_markup")]
1695    #[doc(alias = "use-markup")]
1696    pub fn set_use_markup(&self, setting: bool) {
1697        unsafe {
1698            ffi::gtk_label_set_use_markup(self.to_glib_none().0, setting.into_glib());
1699        }
1700    }
1701
1702    /// Sets whether underlines in the text indicate mnemonics.
1703    /// ## `setting`
1704    /// true if underlines in the text indicate mnemonics
1705    #[doc(alias = "gtk_label_set_use_underline")]
1706    #[doc(alias = "use-underline")]
1707    pub fn set_use_underline(&self, setting: bool) {
1708        unsafe {
1709            ffi::gtk_label_set_use_underline(self.to_glib_none().0, setting.into_glib());
1710        }
1711    }
1712
1713    /// Sets the desired width in characters of the label.
1714    /// ## `n_chars`
1715    /// the new desired width, in characters.
1716    #[doc(alias = "gtk_label_set_width_chars")]
1717    #[doc(alias = "width-chars")]
1718    pub fn set_width_chars(&self, n_chars: i32) {
1719        unsafe {
1720            ffi::gtk_label_set_width_chars(self.to_glib_none().0, n_chars);
1721        }
1722    }
1723
1724    /// Toggles line wrapping within the label.
1725    ///
1726    /// True makes it break lines if text exceeds the widget’s size.
1727    /// false lets the text get cut off by the edge of the widget if
1728    /// it exceeds the widget size.
1729    ///
1730    /// Note that setting line wrapping to true does not make the label
1731    /// wrap at its parent widget’s width, because GTK widgets conceptually
1732    /// can’t make their requisition depend on the parent  widget’s size.
1733    /// For a label that wraps at a specific position, set the label’s width
1734    /// using [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()].
1735    /// ## `wrap`
1736    /// whether to wrap lines
1737    #[doc(alias = "gtk_label_set_wrap")]
1738    #[doc(alias = "wrap")]
1739    pub fn set_wrap(&self, wrap: bool) {
1740        unsafe {
1741            ffi::gtk_label_set_wrap(self.to_glib_none().0, wrap.into_glib());
1742        }
1743    }
1744
1745    /// Controls how line wrapping is done.
1746    ///
1747    /// This only affects the label if line wrapping is on. (See
1748    /// [`set_wrap()`][Self::set_wrap()])
1749    ///
1750    /// The default is [enum@Pango.WrapMode.word], which means
1751    /// wrap on word boundaries.
1752    ///
1753    /// For sizing behavior, also consider the
1754    /// [`natural-wrap-mode`][struct@crate::Label#natural-wrap-mode] property.
1755    /// ## `wrap_mode`
1756    /// the line wrapping mode
1757    #[doc(alias = "gtk_label_set_wrap_mode")]
1758    #[doc(alias = "wrap-mode")]
1759    pub fn set_wrap_mode(&self, wrap_mode: pango::WrapMode) {
1760        unsafe {
1761            ffi::gtk_label_set_wrap_mode(self.to_glib_none().0, wrap_mode.into_glib());
1762        }
1763    }
1764
1765    /// Sets the `xalign` of the label.
1766    ///
1767    /// See the [`xalign`][struct@crate::Label#xalign] property.
1768    /// ## `xalign`
1769    /// the new xalign value, between 0 and 1
1770    #[doc(alias = "gtk_label_set_xalign")]
1771    #[doc(alias = "xalign")]
1772    pub fn set_xalign(&self, xalign: f32) {
1773        unsafe {
1774            ffi::gtk_label_set_xalign(self.to_glib_none().0, xalign);
1775        }
1776    }
1777
1778    /// Sets the `yalign` of the label.
1779    ///
1780    /// See the [`yalign`][struct@crate::Label#yalign] property.
1781    /// ## `yalign`
1782    /// the new yalign value, between 0 and 1
1783    #[doc(alias = "gtk_label_set_yalign")]
1784    #[doc(alias = "yalign")]
1785    pub fn set_yalign(&self, yalign: f32) {
1786        unsafe {
1787            ffi::gtk_label_set_yalign(self.to_glib_none().0, yalign);
1788        }
1789    }
1790
1791    /// Gets emitted when the user activates a link in the label.
1792    ///
1793    /// The `::activate-current-link` is a [keybinding signal](class.SignalAction.html).
1794    ///
1795    /// Applications may also emit the signal with g_signal_emit_by_name()
1796    /// if they need to control activation of URIs programmatically.
1797    ///
1798    /// The default bindings for this signal are all forms of the <kbd>Enter</kbd> key.
1799    #[doc(alias = "activate-current-link")]
1800    pub fn connect_activate_current_link<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1801        unsafe extern "C" fn activate_current_link_trampoline<F: Fn(&Label) + 'static>(
1802            this: *mut ffi::GtkLabel,
1803            f: glib::ffi::gpointer,
1804        ) {
1805            let f: &F = &*(f as *const F);
1806            f(&from_glib_borrow(this))
1807        }
1808        unsafe {
1809            let f: Box_<F> = Box_::new(f);
1810            connect_raw(
1811                self.as_ptr() as *mut _,
1812                c"activate-current-link".as_ptr() as *const _,
1813                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1814                    activate_current_link_trampoline::<F> as *const (),
1815                )),
1816                Box_::into_raw(f),
1817            )
1818        }
1819    }
1820
1821    pub fn emit_activate_current_link(&self) {
1822        self.emit_by_name::<()>("activate-current-link", &[]);
1823    }
1824
1825    /// Gets emitted to activate a URI.
1826    ///
1827    /// Applications may connect to it to override the default behaviour,
1828    /// which is to call [`FileLauncher::launch()`][crate::FileLauncher::launch()].
1829    /// ## `uri`
1830    /// the URI that is activated
1831    ///
1832    /// # Returns
1833    ///
1834    /// true if the link has been activated
1835    #[doc(alias = "activate-link")]
1836    pub fn connect_activate_link<F: Fn(&Self, &str) -> glib::Propagation + 'static>(
1837        &self,
1838        f: F,
1839    ) -> SignalHandlerId {
1840        unsafe extern "C" fn activate_link_trampoline<
1841            F: Fn(&Label, &str) -> glib::Propagation + 'static,
1842        >(
1843            this: *mut ffi::GtkLabel,
1844            uri: *mut std::ffi::c_char,
1845            f: glib::ffi::gpointer,
1846        ) -> glib::ffi::gboolean {
1847            let f: &F = &*(f as *const F);
1848            f(
1849                &from_glib_borrow(this),
1850                &glib::GString::from_glib_borrow(uri),
1851            )
1852            .into_glib()
1853        }
1854        unsafe {
1855            let f: Box_<F> = Box_::new(f);
1856            connect_raw(
1857                self.as_ptr() as *mut _,
1858                c"activate-link".as_ptr() as *const _,
1859                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1860                    activate_link_trampoline::<F> as *const (),
1861                )),
1862                Box_::into_raw(f),
1863            )
1864        }
1865    }
1866
1867    /// Gets emitted to copy the selection to the clipboard.
1868    ///
1869    /// The `::copy-clipboard` signal is a [keybinding signal](class.SignalAction.html).
1870    ///
1871    /// The default binding for this signal is <kbd>Ctrl</kbd>+<kbd>c</kbd>.
1872    #[doc(alias = "copy-clipboard")]
1873    pub fn connect_copy_clipboard<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1874        unsafe extern "C" fn copy_clipboard_trampoline<F: Fn(&Label) + 'static>(
1875            this: *mut ffi::GtkLabel,
1876            f: glib::ffi::gpointer,
1877        ) {
1878            let f: &F = &*(f as *const F);
1879            f(&from_glib_borrow(this))
1880        }
1881        unsafe {
1882            let f: Box_<F> = Box_::new(f);
1883            connect_raw(
1884                self.as_ptr() as *mut _,
1885                c"copy-clipboard".as_ptr() as *const _,
1886                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1887                    copy_clipboard_trampoline::<F> as *const (),
1888                )),
1889                Box_::into_raw(f),
1890            )
1891        }
1892    }
1893
1894    pub fn emit_copy_clipboard(&self) {
1895        self.emit_by_name::<()>("copy-clipboard", &[]);
1896    }
1897
1898    /// Gets emitted when the user initiates a cursor movement.
1899    ///
1900    /// The `::move-cursor` signal is a [keybinding signal](class.SignalAction.html).
1901    /// If the cursor is not visible in @entry, this signal causes the viewport to
1902    /// be moved instead.
1903    ///
1904    /// Applications should not connect to it, but may emit it with
1905    /// `signal_emit_by_name()` if they need to control
1906    /// the cursor programmatically.
1907    ///
1908    /// The default bindings for this signal come in two variants, the
1909    /// variant with the <kbd>Shift</kbd> modifier extends the selection,
1910    /// the variant without the <kbd>Shift</kbd> modifier does not.
1911    /// There are too many key combinations to list them all here.
1912    ///
1913    /// - <kbd>←</kbd>, <kbd>→</kbd>, <kbd>↑</kbd>, <kbd>↓</kbd>
1914    ///   move by individual characters/lines
1915    /// - <kbd>Ctrl</kbd>+<kbd>←</kbd>, etc. move by words/paragraphs
1916    /// - <kbd>Home</kbd> and <kbd>End</kbd> move to the ends of the buffer
1917    /// ## `step`
1918    /// the granularity of the move, as a [`MovementStep`][crate::MovementStep]
1919    /// ## `count`
1920    /// the number of @step units to move
1921    /// ## `extend_selection`
1922    /// true if the move should extend the selection
1923    #[doc(alias = "move-cursor")]
1924    pub fn connect_move_cursor<F: Fn(&Self, MovementStep, i32, bool) + 'static>(
1925        &self,
1926        f: F,
1927    ) -> SignalHandlerId {
1928        unsafe extern "C" fn move_cursor_trampoline<
1929            F: Fn(&Label, MovementStep, i32, bool) + 'static,
1930        >(
1931            this: *mut ffi::GtkLabel,
1932            step: ffi::GtkMovementStep,
1933            count: std::ffi::c_int,
1934            extend_selection: glib::ffi::gboolean,
1935            f: glib::ffi::gpointer,
1936        ) {
1937            let f: &F = &*(f as *const F);
1938            f(
1939                &from_glib_borrow(this),
1940                from_glib(step),
1941                count,
1942                from_glib(extend_selection),
1943            )
1944        }
1945        unsafe {
1946            let f: Box_<F> = Box_::new(f);
1947            connect_raw(
1948                self.as_ptr() as *mut _,
1949                c"move-cursor".as_ptr() as *const _,
1950                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1951                    move_cursor_trampoline::<F> as *const (),
1952                )),
1953                Box_::into_raw(f),
1954            )
1955        }
1956    }
1957
1958    pub fn emit_move_cursor(&self, step: MovementStep, count: i32, extend_selection: bool) {
1959        self.emit_by_name::<()>("move-cursor", &[&step, &count, &extend_selection]);
1960    }
1961
1962    #[doc(alias = "attributes")]
1963    pub fn connect_attributes_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1964        unsafe extern "C" fn notify_attributes_trampoline<F: Fn(&Label) + 'static>(
1965            this: *mut ffi::GtkLabel,
1966            _param_spec: glib::ffi::gpointer,
1967            f: glib::ffi::gpointer,
1968        ) {
1969            let f: &F = &*(f as *const F);
1970            f(&from_glib_borrow(this))
1971        }
1972        unsafe {
1973            let f: Box_<F> = Box_::new(f);
1974            connect_raw(
1975                self.as_ptr() as *mut _,
1976                c"notify::attributes".as_ptr() as *const _,
1977                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1978                    notify_attributes_trampoline::<F> as *const (),
1979                )),
1980                Box_::into_raw(f),
1981            )
1982        }
1983    }
1984
1985    #[doc(alias = "ellipsize")]
1986    pub fn connect_ellipsize_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1987        unsafe extern "C" fn notify_ellipsize_trampoline<F: Fn(&Label) + 'static>(
1988            this: *mut ffi::GtkLabel,
1989            _param_spec: glib::ffi::gpointer,
1990            f: glib::ffi::gpointer,
1991        ) {
1992            let f: &F = &*(f as *const F);
1993            f(&from_glib_borrow(this))
1994        }
1995        unsafe {
1996            let f: Box_<F> = Box_::new(f);
1997            connect_raw(
1998                self.as_ptr() as *mut _,
1999                c"notify::ellipsize".as_ptr() as *const _,
2000                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2001                    notify_ellipsize_trampoline::<F> as *const (),
2002                )),
2003                Box_::into_raw(f),
2004            )
2005        }
2006    }
2007
2008    #[doc(alias = "extra-menu")]
2009    pub fn connect_extra_menu_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2010        unsafe extern "C" fn notify_extra_menu_trampoline<F: Fn(&Label) + 'static>(
2011            this: *mut ffi::GtkLabel,
2012            _param_spec: glib::ffi::gpointer,
2013            f: glib::ffi::gpointer,
2014        ) {
2015            let f: &F = &*(f as *const F);
2016            f(&from_glib_borrow(this))
2017        }
2018        unsafe {
2019            let f: Box_<F> = Box_::new(f);
2020            connect_raw(
2021                self.as_ptr() as *mut _,
2022                c"notify::extra-menu".as_ptr() as *const _,
2023                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2024                    notify_extra_menu_trampoline::<F> as *const (),
2025                )),
2026                Box_::into_raw(f),
2027            )
2028        }
2029    }
2030
2031    #[doc(alias = "justify")]
2032    pub fn connect_justify_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2033        unsafe extern "C" fn notify_justify_trampoline<F: Fn(&Label) + 'static>(
2034            this: *mut ffi::GtkLabel,
2035            _param_spec: glib::ffi::gpointer,
2036            f: glib::ffi::gpointer,
2037        ) {
2038            let f: &F = &*(f as *const F);
2039            f(&from_glib_borrow(this))
2040        }
2041        unsafe {
2042            let f: Box_<F> = Box_::new(f);
2043            connect_raw(
2044                self.as_ptr() as *mut _,
2045                c"notify::justify".as_ptr() as *const _,
2046                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2047                    notify_justify_trampoline::<F> as *const (),
2048                )),
2049                Box_::into_raw(f),
2050            )
2051        }
2052    }
2053
2054    #[doc(alias = "label")]
2055    pub fn connect_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2056        unsafe extern "C" fn notify_label_trampoline<F: Fn(&Label) + 'static>(
2057            this: *mut ffi::GtkLabel,
2058            _param_spec: glib::ffi::gpointer,
2059            f: glib::ffi::gpointer,
2060        ) {
2061            let f: &F = &*(f as *const F);
2062            f(&from_glib_borrow(this))
2063        }
2064        unsafe {
2065            let f: Box_<F> = Box_::new(f);
2066            connect_raw(
2067                self.as_ptr() as *mut _,
2068                c"notify::label".as_ptr() as *const _,
2069                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2070                    notify_label_trampoline::<F> as *const (),
2071                )),
2072                Box_::into_raw(f),
2073            )
2074        }
2075    }
2076
2077    #[doc(alias = "lines")]
2078    pub fn connect_lines_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2079        unsafe extern "C" fn notify_lines_trampoline<F: Fn(&Label) + 'static>(
2080            this: *mut ffi::GtkLabel,
2081            _param_spec: glib::ffi::gpointer,
2082            f: glib::ffi::gpointer,
2083        ) {
2084            let f: &F = &*(f as *const F);
2085            f(&from_glib_borrow(this))
2086        }
2087        unsafe {
2088            let f: Box_<F> = Box_::new(f);
2089            connect_raw(
2090                self.as_ptr() as *mut _,
2091                c"notify::lines".as_ptr() as *const _,
2092                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2093                    notify_lines_trampoline::<F> as *const (),
2094                )),
2095                Box_::into_raw(f),
2096            )
2097        }
2098    }
2099
2100    #[doc(alias = "max-width-chars")]
2101    pub fn connect_max_width_chars_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2102        unsafe extern "C" fn notify_max_width_chars_trampoline<F: Fn(&Label) + 'static>(
2103            this: *mut ffi::GtkLabel,
2104            _param_spec: glib::ffi::gpointer,
2105            f: glib::ffi::gpointer,
2106        ) {
2107            let f: &F = &*(f as *const F);
2108            f(&from_glib_borrow(this))
2109        }
2110        unsafe {
2111            let f: Box_<F> = Box_::new(f);
2112            connect_raw(
2113                self.as_ptr() as *mut _,
2114                c"notify::max-width-chars".as_ptr() as *const _,
2115                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2116                    notify_max_width_chars_trampoline::<F> as *const (),
2117                )),
2118                Box_::into_raw(f),
2119            )
2120        }
2121    }
2122
2123    #[doc(alias = "mnemonic-keyval")]
2124    pub fn connect_mnemonic_keyval_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2125        unsafe extern "C" fn notify_mnemonic_keyval_trampoline<F: Fn(&Label) + 'static>(
2126            this: *mut ffi::GtkLabel,
2127            _param_spec: glib::ffi::gpointer,
2128            f: glib::ffi::gpointer,
2129        ) {
2130            let f: &F = &*(f as *const F);
2131            f(&from_glib_borrow(this))
2132        }
2133        unsafe {
2134            let f: Box_<F> = Box_::new(f);
2135            connect_raw(
2136                self.as_ptr() as *mut _,
2137                c"notify::mnemonic-keyval".as_ptr() as *const _,
2138                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2139                    notify_mnemonic_keyval_trampoline::<F> as *const (),
2140                )),
2141                Box_::into_raw(f),
2142            )
2143        }
2144    }
2145
2146    #[doc(alias = "mnemonic-widget")]
2147    pub fn connect_mnemonic_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2148        unsafe extern "C" fn notify_mnemonic_widget_trampoline<F: Fn(&Label) + 'static>(
2149            this: *mut ffi::GtkLabel,
2150            _param_spec: glib::ffi::gpointer,
2151            f: glib::ffi::gpointer,
2152        ) {
2153            let f: &F = &*(f as *const F);
2154            f(&from_glib_borrow(this))
2155        }
2156        unsafe {
2157            let f: Box_<F> = Box_::new(f);
2158            connect_raw(
2159                self.as_ptr() as *mut _,
2160                c"notify::mnemonic-widget".as_ptr() as *const _,
2161                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2162                    notify_mnemonic_widget_trampoline::<F> as *const (),
2163                )),
2164                Box_::into_raw(f),
2165            )
2166        }
2167    }
2168
2169    #[cfg(feature = "v4_6")]
2170    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
2171    #[doc(alias = "natural-wrap-mode")]
2172    pub fn connect_natural_wrap_mode_notify<F: Fn(&Self) + 'static>(
2173        &self,
2174        f: F,
2175    ) -> SignalHandlerId {
2176        unsafe extern "C" fn notify_natural_wrap_mode_trampoline<F: Fn(&Label) + 'static>(
2177            this: *mut ffi::GtkLabel,
2178            _param_spec: glib::ffi::gpointer,
2179            f: glib::ffi::gpointer,
2180        ) {
2181            let f: &F = &*(f as *const F);
2182            f(&from_glib_borrow(this))
2183        }
2184        unsafe {
2185            let f: Box_<F> = Box_::new(f);
2186            connect_raw(
2187                self.as_ptr() as *mut _,
2188                c"notify::natural-wrap-mode".as_ptr() as *const _,
2189                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2190                    notify_natural_wrap_mode_trampoline::<F> as *const (),
2191                )),
2192                Box_::into_raw(f),
2193            )
2194        }
2195    }
2196
2197    #[doc(alias = "selectable")]
2198    pub fn connect_selectable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2199        unsafe extern "C" fn notify_selectable_trampoline<F: Fn(&Label) + 'static>(
2200            this: *mut ffi::GtkLabel,
2201            _param_spec: glib::ffi::gpointer,
2202            f: glib::ffi::gpointer,
2203        ) {
2204            let f: &F = &*(f as *const F);
2205            f(&from_glib_borrow(this))
2206        }
2207        unsafe {
2208            let f: Box_<F> = Box_::new(f);
2209            connect_raw(
2210                self.as_ptr() as *mut _,
2211                c"notify::selectable".as_ptr() as *const _,
2212                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2213                    notify_selectable_trampoline::<F> as *const (),
2214                )),
2215                Box_::into_raw(f),
2216            )
2217        }
2218    }
2219
2220    #[doc(alias = "single-line-mode")]
2221    pub fn connect_single_line_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2222        unsafe extern "C" fn notify_single_line_mode_trampoline<F: Fn(&Label) + 'static>(
2223            this: *mut ffi::GtkLabel,
2224            _param_spec: glib::ffi::gpointer,
2225            f: glib::ffi::gpointer,
2226        ) {
2227            let f: &F = &*(f as *const F);
2228            f(&from_glib_borrow(this))
2229        }
2230        unsafe {
2231            let f: Box_<F> = Box_::new(f);
2232            connect_raw(
2233                self.as_ptr() as *mut _,
2234                c"notify::single-line-mode".as_ptr() as *const _,
2235                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2236                    notify_single_line_mode_trampoline::<F> as *const (),
2237                )),
2238                Box_::into_raw(f),
2239            )
2240        }
2241    }
2242
2243    #[cfg(feature = "v4_8")]
2244    #[cfg_attr(docsrs, doc(cfg(feature = "v4_8")))]
2245    #[doc(alias = "tabs")]
2246    pub fn connect_tabs_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2247        unsafe extern "C" fn notify_tabs_trampoline<F: Fn(&Label) + 'static>(
2248            this: *mut ffi::GtkLabel,
2249            _param_spec: glib::ffi::gpointer,
2250            f: glib::ffi::gpointer,
2251        ) {
2252            let f: &F = &*(f as *const F);
2253            f(&from_glib_borrow(this))
2254        }
2255        unsafe {
2256            let f: Box_<F> = Box_::new(f);
2257            connect_raw(
2258                self.as_ptr() as *mut _,
2259                c"notify::tabs".as_ptr() as *const _,
2260                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2261                    notify_tabs_trampoline::<F> as *const (),
2262                )),
2263                Box_::into_raw(f),
2264            )
2265        }
2266    }
2267
2268    #[doc(alias = "use-markup")]
2269    pub fn connect_use_markup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2270        unsafe extern "C" fn notify_use_markup_trampoline<F: Fn(&Label) + 'static>(
2271            this: *mut ffi::GtkLabel,
2272            _param_spec: glib::ffi::gpointer,
2273            f: glib::ffi::gpointer,
2274        ) {
2275            let f: &F = &*(f as *const F);
2276            f(&from_glib_borrow(this))
2277        }
2278        unsafe {
2279            let f: Box_<F> = Box_::new(f);
2280            connect_raw(
2281                self.as_ptr() as *mut _,
2282                c"notify::use-markup".as_ptr() as *const _,
2283                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2284                    notify_use_markup_trampoline::<F> as *const (),
2285                )),
2286                Box_::into_raw(f),
2287            )
2288        }
2289    }
2290
2291    #[doc(alias = "use-underline")]
2292    pub fn connect_use_underline_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2293        unsafe extern "C" fn notify_use_underline_trampoline<F: Fn(&Label) + 'static>(
2294            this: *mut ffi::GtkLabel,
2295            _param_spec: glib::ffi::gpointer,
2296            f: glib::ffi::gpointer,
2297        ) {
2298            let f: &F = &*(f as *const F);
2299            f(&from_glib_borrow(this))
2300        }
2301        unsafe {
2302            let f: Box_<F> = Box_::new(f);
2303            connect_raw(
2304                self.as_ptr() as *mut _,
2305                c"notify::use-underline".as_ptr() as *const _,
2306                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2307                    notify_use_underline_trampoline::<F> as *const (),
2308                )),
2309                Box_::into_raw(f),
2310            )
2311        }
2312    }
2313
2314    #[doc(alias = "width-chars")]
2315    pub fn connect_width_chars_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2316        unsafe extern "C" fn notify_width_chars_trampoline<F: Fn(&Label) + 'static>(
2317            this: *mut ffi::GtkLabel,
2318            _param_spec: glib::ffi::gpointer,
2319            f: glib::ffi::gpointer,
2320        ) {
2321            let f: &F = &*(f as *const F);
2322            f(&from_glib_borrow(this))
2323        }
2324        unsafe {
2325            let f: Box_<F> = Box_::new(f);
2326            connect_raw(
2327                self.as_ptr() as *mut _,
2328                c"notify::width-chars".as_ptr() as *const _,
2329                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2330                    notify_width_chars_trampoline::<F> as *const (),
2331                )),
2332                Box_::into_raw(f),
2333            )
2334        }
2335    }
2336
2337    #[doc(alias = "wrap")]
2338    pub fn connect_wrap_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2339        unsafe extern "C" fn notify_wrap_trampoline<F: Fn(&Label) + 'static>(
2340            this: *mut ffi::GtkLabel,
2341            _param_spec: glib::ffi::gpointer,
2342            f: glib::ffi::gpointer,
2343        ) {
2344            let f: &F = &*(f as *const F);
2345            f(&from_glib_borrow(this))
2346        }
2347        unsafe {
2348            let f: Box_<F> = Box_::new(f);
2349            connect_raw(
2350                self.as_ptr() as *mut _,
2351                c"notify::wrap".as_ptr() as *const _,
2352                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2353                    notify_wrap_trampoline::<F> as *const (),
2354                )),
2355                Box_::into_raw(f),
2356            )
2357        }
2358    }
2359
2360    #[doc(alias = "wrap-mode")]
2361    pub fn connect_wrap_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2362        unsafe extern "C" fn notify_wrap_mode_trampoline<F: Fn(&Label) + 'static>(
2363            this: *mut ffi::GtkLabel,
2364            _param_spec: glib::ffi::gpointer,
2365            f: glib::ffi::gpointer,
2366        ) {
2367            let f: &F = &*(f as *const F);
2368            f(&from_glib_borrow(this))
2369        }
2370        unsafe {
2371            let f: Box_<F> = Box_::new(f);
2372            connect_raw(
2373                self.as_ptr() as *mut _,
2374                c"notify::wrap-mode".as_ptr() as *const _,
2375                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2376                    notify_wrap_mode_trampoline::<F> as *const (),
2377                )),
2378                Box_::into_raw(f),
2379            )
2380        }
2381    }
2382
2383    #[doc(alias = "xalign")]
2384    pub fn connect_xalign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2385        unsafe extern "C" fn notify_xalign_trampoline<F: Fn(&Label) + 'static>(
2386            this: *mut ffi::GtkLabel,
2387            _param_spec: glib::ffi::gpointer,
2388            f: glib::ffi::gpointer,
2389        ) {
2390            let f: &F = &*(f as *const F);
2391            f(&from_glib_borrow(this))
2392        }
2393        unsafe {
2394            let f: Box_<F> = Box_::new(f);
2395            connect_raw(
2396                self.as_ptr() as *mut _,
2397                c"notify::xalign".as_ptr() as *const _,
2398                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2399                    notify_xalign_trampoline::<F> as *const (),
2400                )),
2401                Box_::into_raw(f),
2402            )
2403        }
2404    }
2405
2406    #[doc(alias = "yalign")]
2407    pub fn connect_yalign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2408        unsafe extern "C" fn notify_yalign_trampoline<F: Fn(&Label) + 'static>(
2409            this: *mut ffi::GtkLabel,
2410            _param_spec: glib::ffi::gpointer,
2411            f: glib::ffi::gpointer,
2412        ) {
2413            let f: &F = &*(f as *const F);
2414            f(&from_glib_borrow(this))
2415        }
2416        unsafe {
2417            let f: Box_<F> = Box_::new(f);
2418            connect_raw(
2419                self.as_ptr() as *mut _,
2420                c"notify::yalign".as_ptr() as *const _,
2421                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2422                    notify_yalign_trampoline::<F> as *const (),
2423                )),
2424                Box_::into_raw(f),
2425            )
2426        }
2427    }
2428}
2429
2430impl Default for Label {
2431    fn default() -> Self {
2432        glib::object::Object::new::<Self>()
2433    }
2434}
2435
2436// rustdoc-stripper-ignore-next
2437/// A [builder-pattern] type to construct [`Label`] objects.
2438///
2439/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
2440#[must_use = "The builder must be built to be used"]
2441pub struct LabelBuilder {
2442    builder: glib::object::ObjectBuilder<'static, Label>,
2443}
2444
2445impl LabelBuilder {
2446    fn new() -> Self {
2447        Self {
2448            builder: glib::object::Object::builder(),
2449        }
2450    }
2451
2452    /// A list of style attributes to apply to the text of the label.
2453    pub fn attributes(self, attributes: &pango::AttrList) -> Self {
2454        Self {
2455            builder: self.builder.property("attributes", attributes.clone()),
2456        }
2457    }
2458
2459    /// The preferred place to ellipsize the string, if the label does
2460    /// not have enough room to display the entire string.
2461    ///
2462    /// Note that setting this property to a value other than
2463    /// [enum.Pango.EllipsizeMode.none] has the side-effect that the label requests
2464    /// only enough space to display the ellipsis "...". In particular, this
2465    /// means that ellipsizing labels do not work well in notebook tabs, unless
2466    /// the [`tab-expand`][struct@crate::NotebookPage#tab-expand] child property is set to true.
2467    ///
2468    /// Other ways to set a label's width are [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()]
2469    /// and [`Label::set_width_chars()`][crate::Label::set_width_chars()].
2470    pub fn ellipsize(self, ellipsize: pango::EllipsizeMode) -> Self {
2471        Self {
2472            builder: self.builder.property("ellipsize", ellipsize),
2473        }
2474    }
2475
2476    /// A menu model whose contents will be appended to the context menu.
2477    pub fn extra_menu(self, extra_menu: &impl IsA<gio::MenuModel>) -> Self {
2478        Self {
2479            builder: self
2480                .builder
2481                .property("extra-menu", extra_menu.clone().upcast()),
2482        }
2483    }
2484
2485    /// The alignment of the lines in the text of the label, relative to each other.
2486    ///
2487    /// This does *not* affect the alignment of the label within its allocation.
2488    /// See [`xalign`][struct@crate::Label#xalign] for that.
2489    pub fn justify(self, justify: Justification) -> Self {
2490        Self {
2491            builder: self.builder.property("justify", justify),
2492        }
2493    }
2494
2495    /// The contents of the label.
2496    ///
2497    /// If the string contains Pango markup (see `parse_markup()`),
2498    /// you will have to set the [`use-markup`][struct@crate::Label#use-markup] property to
2499    /// true in order for the label to display the markup attributes. See also
2500    /// [`Label::set_markup()`][crate::Label::set_markup()] for a convenience function that sets both
2501    /// this property and the [`use-markup`][struct@crate::Label#use-markup] property at the
2502    /// same time.
2503    ///
2504    /// If the string contains underlines acting as mnemonics, you will have to
2505    /// set the [`use-underline`][struct@crate::Label#use-underline] property to true in order
2506    /// for the label to display them.
2507    pub fn label(self, label: impl Into<glib::GString>) -> Self {
2508        Self {
2509            builder: self.builder.property("label", label.into()),
2510        }
2511    }
2512
2513    /// The number of lines to which an ellipsized, wrapping label
2514    /// should display before it gets ellipsized. This both prevents the label
2515    /// from ellipsizing before this many lines are displayed, and limits the
2516    /// height request of the label to this many lines.
2517    ///
2518    /// ::: warning
2519    ///     Setting this property has unintuitive and unfortunate consequences
2520    ///     for the minimum _width_ of the label. Specifically, if the height
2521    ///     of the label is such that it fits a smaller number of lines than
2522    ///     the value of this property, the label can not be ellipsized at all,
2523    ///     which means it must be wide enough to fit all the text fully.
2524    ///
2525    /// This property has no effect if the label is not wrapping or ellipsized.
2526    ///
2527    /// Set this property to -1 if you don't want to limit the number of lines.
2528    pub fn lines(self, lines: i32) -> Self {
2529        Self {
2530            builder: self.builder.property("lines", lines),
2531        }
2532    }
2533
2534    /// The desired maximum width of the label, in characters.
2535    ///
2536    /// If this property is set to -1, the width will be calculated automatically.
2537    ///
2538    /// See the section on [text layout](class.Label.html#text-layout) for details
2539    /// of how [`width-chars`][struct@crate::Label#width-chars] and [`max-width-chars`][struct@crate::Label#max-width-chars]
2540    /// determine the width of ellipsized and wrapped labels.
2541    pub fn max_width_chars(self, max_width_chars: i32) -> Self {
2542        Self {
2543            builder: self.builder.property("max-width-chars", max_width_chars),
2544        }
2545    }
2546
2547    /// The widget to be activated when the labels mnemonic key is pressed.
2548    pub fn mnemonic_widget(self, mnemonic_widget: &impl IsA<Widget>) -> Self {
2549        Self {
2550            builder: self
2551                .builder
2552                .property("mnemonic-widget", mnemonic_widget.clone().upcast()),
2553        }
2554    }
2555
2556    /// Select the line wrapping for the natural size request.
2557    ///
2558    /// This only affects the natural size requested. For the actual wrapping
2559    /// used, see the [`wrap-mode`][struct@crate::Label#wrap-mode] property.
2560    ///
2561    /// The default is [enum@Gtk.NaturalWrapMode.inherit], which inherits
2562    /// the behavior of the [`wrap-mode`][struct@crate::Label#wrap-mode] property.
2563    #[cfg(feature = "v4_6")]
2564    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
2565    pub fn natural_wrap_mode(self, natural_wrap_mode: NaturalWrapMode) -> Self {
2566        Self {
2567            builder: self
2568                .builder
2569                .property("natural-wrap-mode", natural_wrap_mode),
2570        }
2571    }
2572
2573    /// Whether the label text can be selected with the mouse.
2574    pub fn selectable(self, selectable: bool) -> Self {
2575        Self {
2576            builder: self.builder.property("selectable", selectable),
2577        }
2578    }
2579
2580    /// Whether the label is in single line mode.
2581    ///
2582    /// In single line mode, the height of the label does not depend on the
2583    /// actual text, it is always set to ascent + descent of the font. This
2584    /// can be an advantage in situations where resizing the label because
2585    /// of text changes would be distracting, e.g. in a statusbar.
2586    pub fn single_line_mode(self, single_line_mode: bool) -> Self {
2587        Self {
2588            builder: self.builder.property("single-line-mode", single_line_mode),
2589        }
2590    }
2591
2592    /// Custom tabs for this label.
2593    #[cfg(feature = "v4_8")]
2594    #[cfg_attr(docsrs, doc(cfg(feature = "v4_8")))]
2595    pub fn tabs(self, tabs: &pango::TabArray) -> Self {
2596        Self {
2597            builder: self.builder.property("tabs", tabs),
2598        }
2599    }
2600
2601    /// True if the text of the label includes Pango markup.
2602    ///
2603    /// See `parse_markup()`.
2604    pub fn use_markup(self, use_markup: bool) -> Self {
2605        Self {
2606            builder: self.builder.property("use-markup", use_markup),
2607        }
2608    }
2609
2610    /// True if the text of the label indicates a mnemonic with an `_`
2611    /// before the mnemonic character.
2612    pub fn use_underline(self, use_underline: bool) -> Self {
2613        Self {
2614            builder: self.builder.property("use-underline", use_underline),
2615        }
2616    }
2617
2618    /// The desired width of the label, in characters.
2619    ///
2620    /// If this property is set to -1, the width will be calculated automatically.
2621    ///
2622    /// See the section on [text layout](class.Label.html#text-layout) for details
2623    /// of how [`width-chars`][struct@crate::Label#width-chars] and [`max-width-chars`][struct@crate::Label#max-width-chars]
2624    /// determine the width of ellipsized and wrapped labels.
2625    pub fn width_chars(self, width_chars: i32) -> Self {
2626        Self {
2627            builder: self.builder.property("width-chars", width_chars),
2628        }
2629    }
2630
2631    /// True if the label text will wrap if it gets too wide.
2632    pub fn wrap(self, wrap: bool) -> Self {
2633        Self {
2634            builder: self.builder.property("wrap", wrap),
2635        }
2636    }
2637
2638    /// Controls how the line wrapping is done.
2639    ///
2640    /// This only affects the formatting if line wrapping is on (see the
2641    /// [`wrap`][struct@crate::Label#wrap] property). The default is [enum@Pango.WrapMode.word],
2642    /// which means wrap on word boundaries.
2643    ///
2644    /// For sizing behavior, also consider the [`natural-wrap-mode`][struct@crate::Label#natural-wrap-mode]
2645    /// property.
2646    pub fn wrap_mode(self, wrap_mode: pango::WrapMode) -> Self {
2647        Self {
2648            builder: self.builder.property("wrap-mode", wrap_mode),
2649        }
2650    }
2651
2652    /// The horizontal alignment of the label text inside its size allocation.
2653    ///
2654    /// Compare this to [`halign`][struct@crate::Widget#halign], which determines how the
2655    /// labels size allocation is positioned in the space available for the label.
2656    pub fn xalign(self, xalign: f32) -> Self {
2657        Self {
2658            builder: self.builder.property("xalign", xalign),
2659        }
2660    }
2661
2662    /// The vertical alignment of the label text inside its size allocation.
2663    ///
2664    /// Compare this to [`valign`][struct@crate::Widget#valign], which determines how the
2665    /// labels size allocation is positioned in the space available for the label.
2666    pub fn yalign(self, yalign: f32) -> Self {
2667        Self {
2668            builder: self.builder.property("yalign", yalign),
2669        }
2670    }
2671
2672    /// Whether the widget or any of its descendents can accept
2673    /// the input focus.
2674    ///
2675    /// This property is meant to be set by widget implementations,
2676    /// typically in their instance init function.
2677    pub fn can_focus(self, can_focus: bool) -> Self {
2678        Self {
2679            builder: self.builder.property("can-focus", can_focus),
2680        }
2681    }
2682
2683    /// Whether the widget can receive pointer events.
2684    pub fn can_target(self, can_target: bool) -> Self {
2685        Self {
2686            builder: self.builder.property("can-target", can_target),
2687        }
2688    }
2689
2690    /// A list of css classes applied to this widget.
2691    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
2692        Self {
2693            builder: self.builder.property("css-classes", css_classes.into()),
2694        }
2695    }
2696
2697    /// The name of this widget in the CSS tree.
2698    ///
2699    /// This property is meant to be set by widget implementations,
2700    /// typically in their instance init function.
2701    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
2702        Self {
2703            builder: self.builder.property("css-name", css_name.into()),
2704        }
2705    }
2706
2707    /// The cursor used by @widget.
2708    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
2709        Self {
2710            builder: self.builder.property("cursor", cursor.clone()),
2711        }
2712    }
2713
2714    /// Whether the widget should grab focus when it is clicked with the mouse.
2715    ///
2716    /// This property is only relevant for widgets that can take focus.
2717    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
2718        Self {
2719            builder: self.builder.property("focus-on-click", focus_on_click),
2720        }
2721    }
2722
2723    /// Whether this widget itself will accept the input focus.
2724    pub fn focusable(self, focusable: bool) -> Self {
2725        Self {
2726            builder: self.builder.property("focusable", focusable),
2727        }
2728    }
2729
2730    /// How to distribute horizontal space if widget gets extra space.
2731    pub fn halign(self, halign: Align) -> Self {
2732        Self {
2733            builder: self.builder.property("halign", halign),
2734        }
2735    }
2736
2737    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
2738    /// signal on @widget.
2739    ///
2740    /// A true value indicates that @widget can have a tooltip, in this case
2741    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
2742    /// determine whether it will provide a tooltip or not.
2743    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
2744        Self {
2745            builder: self.builder.property("has-tooltip", has_tooltip),
2746        }
2747    }
2748
2749    /// Overrides for height request of the widget.
2750    ///
2751    /// If this is -1, the natural request will be used.
2752    pub fn height_request(self, height_request: i32) -> Self {
2753        Self {
2754            builder: self.builder.property("height-request", height_request),
2755        }
2756    }
2757
2758    /// Whether to expand horizontally.
2759    pub fn hexpand(self, hexpand: bool) -> Self {
2760        Self {
2761            builder: self.builder.property("hexpand", hexpand),
2762        }
2763    }
2764
2765    /// Whether to use the `hexpand` property.
2766    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
2767        Self {
2768            builder: self.builder.property("hexpand-set", hexpand_set),
2769        }
2770    }
2771
2772    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
2773    /// the preferred size of the widget, and allocate its children.
2774    ///
2775    /// This property is meant to be set by widget implementations,
2776    /// typically in their instance init function.
2777    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
2778        Self {
2779            builder: self
2780                .builder
2781                .property("layout-manager", layout_manager.clone().upcast()),
2782        }
2783    }
2784
2785    /// Makes this widget act like a modal dialog, with respect to
2786    /// event delivery.
2787    ///
2788    /// Global event controllers will not handle events with targets
2789    /// inside the widget, unless they are set up to ignore propagation
2790    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
2791    #[cfg(feature = "v4_18")]
2792    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
2793    pub fn limit_events(self, limit_events: bool) -> Self {
2794        Self {
2795            builder: self.builder.property("limit-events", limit_events),
2796        }
2797    }
2798
2799    /// Margin on bottom side of widget.
2800    ///
2801    /// This property adds margin outside of the widget's normal size
2802    /// request, the margin will be added in addition to the size from
2803    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2804    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
2805        Self {
2806            builder: self.builder.property("margin-bottom", margin_bottom),
2807        }
2808    }
2809
2810    /// Margin on end of widget, horizontally.
2811    ///
2812    /// This property supports left-to-right and right-to-left text
2813    /// directions.
2814    ///
2815    /// This property adds margin outside of the widget's normal size
2816    /// request, the margin will be added in addition to the size from
2817    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2818    pub fn margin_end(self, margin_end: i32) -> Self {
2819        Self {
2820            builder: self.builder.property("margin-end", margin_end),
2821        }
2822    }
2823
2824    /// Margin on start of widget, horizontally.
2825    ///
2826    /// This property supports left-to-right and right-to-left text
2827    /// directions.
2828    ///
2829    /// This property adds margin outside of the widget's normal size
2830    /// request, the margin will be added in addition to the size from
2831    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2832    pub fn margin_start(self, margin_start: i32) -> Self {
2833        Self {
2834            builder: self.builder.property("margin-start", margin_start),
2835        }
2836    }
2837
2838    /// Margin on top side of widget.
2839    ///
2840    /// This property adds margin outside of the widget's normal size
2841    /// request, the margin will be added in addition to the size from
2842    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2843    pub fn margin_top(self, margin_top: i32) -> Self {
2844        Self {
2845            builder: self.builder.property("margin-top", margin_top),
2846        }
2847    }
2848
2849    /// The name of the widget.
2850    pub fn name(self, name: impl Into<glib::GString>) -> Self {
2851        Self {
2852            builder: self.builder.property("name", name.into()),
2853        }
2854    }
2855
2856    /// The requested opacity of the widget.
2857    pub fn opacity(self, opacity: f64) -> Self {
2858        Self {
2859            builder: self.builder.property("opacity", opacity),
2860        }
2861    }
2862
2863    /// How content outside the widget's content area is treated.
2864    ///
2865    /// This property is meant to be set by widget implementations,
2866    /// typically in their instance init function.
2867    pub fn overflow(self, overflow: Overflow) -> Self {
2868        Self {
2869            builder: self.builder.property("overflow", overflow),
2870        }
2871    }
2872
2873    /// Whether the widget will receive the default action when it is focused.
2874    pub fn receives_default(self, receives_default: bool) -> Self {
2875        Self {
2876            builder: self.builder.property("receives-default", receives_default),
2877        }
2878    }
2879
2880    /// Whether the widget responds to input.
2881    pub fn sensitive(self, sensitive: bool) -> Self {
2882        Self {
2883            builder: self.builder.property("sensitive", sensitive),
2884        }
2885    }
2886
2887    /// Sets the text of tooltip to be the given string, which is marked up
2888    /// with Pango markup.
2889    ///
2890    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
2891    ///
2892    /// This is a convenience property which will take care of getting the
2893    /// tooltip shown if the given string is not `NULL`:
2894    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
2895    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
2896    /// the default signal handler.
2897    ///
2898    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
2899    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
2900    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
2901        Self {
2902            builder: self
2903                .builder
2904                .property("tooltip-markup", tooltip_markup.into()),
2905        }
2906    }
2907
2908    /// Sets the text of tooltip to be the given string.
2909    ///
2910    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
2911    ///
2912    /// This is a convenience property which will take care of getting the
2913    /// tooltip shown if the given string is not `NULL`:
2914    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
2915    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
2916    /// the default signal handler.
2917    ///
2918    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
2919    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
2920    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
2921        Self {
2922            builder: self.builder.property("tooltip-text", tooltip_text.into()),
2923        }
2924    }
2925
2926    /// How to distribute vertical space if widget gets extra space.
2927    pub fn valign(self, valign: Align) -> Self {
2928        Self {
2929            builder: self.builder.property("valign", valign),
2930        }
2931    }
2932
2933    /// Whether to expand vertically.
2934    pub fn vexpand(self, vexpand: bool) -> Self {
2935        Self {
2936            builder: self.builder.property("vexpand", vexpand),
2937        }
2938    }
2939
2940    /// Whether to use the `vexpand` property.
2941    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
2942        Self {
2943            builder: self.builder.property("vexpand-set", vexpand_set),
2944        }
2945    }
2946
2947    /// Whether the widget is visible.
2948    pub fn visible(self, visible: bool) -> Self {
2949        Self {
2950            builder: self.builder.property("visible", visible),
2951        }
2952    }
2953
2954    /// Overrides for width request of the widget.
2955    ///
2956    /// If this is -1, the natural request will be used.
2957    pub fn width_request(self, width_request: i32) -> Self {
2958        Self {
2959            builder: self.builder.property("width-request", width_request),
2960        }
2961    }
2962
2963    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
2964    ///
2965    /// The accessible role cannot be changed once set.
2966    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
2967        Self {
2968            builder: self.builder.property("accessible-role", accessible_role),
2969        }
2970    }
2971
2972    // rustdoc-stripper-ignore-next
2973    /// Build the [`Label`].
2974    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
2975    pub fn build(self) -> Label {
2976        assert_initialized_main_thread!();
2977        self.builder.build()
2978    }
2979}