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