gtk/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
5use crate::{Align, Buildable, Container, Justification, Menu, Misc, MovementStep, Widget, ffi};
6use glib::{
7 object::ObjectType as _,
8 prelude::*,
9 signal::{SignalHandlerId, connect_raw},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 /// The [`Label`][crate::Label] widget displays a small amount of text. As the name
16 /// implies, most labels are used to label another widget such as a
17 /// [`Button`][crate::Button], a [`MenuItem`][crate::MenuItem], or a [`ComboBox`][crate::ComboBox].
18 ///
19 /// # CSS nodes
20 ///
21 ///
22 ///
23 /// **⚠️ The following code is in plain ⚠️**
24 ///
25 /// ```plain
26 /// label
27 /// ├── [selection]
28 /// ├── [link]
29 /// ┊
30 /// ╰── [link]
31 /// ```
32 ///
33 /// GtkLabel has a single CSS node with the name label. A wide variety
34 /// of style classes may be applied to labels, such as .title, .subtitle,
35 /// .dim-label, etc. In the [`ShortcutsWindow`][crate::ShortcutsWindow], labels are used wth the
36 /// .keycap style class.
37 ///
38 /// If the label has a selection, it gets a subnode with name selection.
39 ///
40 /// If the label has links, there is one subnode per link. These subnodes
41 /// carry the link or visited state depending on whether they have been
42 /// visited.
43 ///
44 /// # GtkLabel as GtkBuildable
45 ///
46 /// The GtkLabel implementation of the GtkBuildable interface supports a
47 /// custom ``<attributes>`` element, which supports any number of ``<attribute>``
48 /// elements. The ``<attribute>`` element has attributes named “name“, “value“,
49 /// “start“ and “end“ and allows you to specify `PangoAttribute` values for
50 /// this label.
51 ///
52 /// An example of a UI definition fragment specifying Pango attributes:
53 ///
54 ///
55 ///
56 /// **⚠️ The following code is in xml ⚠️**
57 ///
58 /// ```xml
59 /// <object class="GtkLabel">
60 /// <attributes>
61 /// <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
62 /// <attribute name="background" value="red" start="5" end="10"/>
63 /// </attributes>
64 /// </object>
65 /// ```
66 ///
67 /// The start and end attributes specify the range of characters to which the
68 /// Pango attribute applies. If start and end are not specified, the attribute is
69 /// applied to the whole text. Note that specifying ranges does not make much
70 /// sense with translatable attributes. Use markup embedded in the translatable
71 /// content instead.
72 ///
73 /// # Mnemonics
74 ///
75 /// Labels may contain “mnemonics”. Mnemonics are
76 /// underlined characters in the label, used for keyboard navigation.
77 /// Mnemonics are created by providing a string with an underscore before
78 /// the mnemonic character, such as `"_File"`, to the
79 /// functions [`with_mnemonic()`][Self::with_mnemonic()] or
80 /// [`LabelExt::set_text_with_mnemonic()`][crate::prelude::LabelExt::set_text_with_mnemonic()].
81 ///
82 /// Mnemonics automatically activate any activatable widget the label is
83 /// inside, such as a [`Button`][crate::Button]; if the label is not inside the
84 /// mnemonic’s target widget, you have to tell the label about the target
85 /// using [`LabelExt::set_mnemonic_widget()`][crate::prelude::LabelExt::set_mnemonic_widget()]. Here’s a simple example where
86 /// the label is inside a button:
87 ///
88 ///
89 ///
90 /// **⚠️ The following code is in C ⚠️**
91 ///
92 /// ```C
93 /// // Pressing Alt+H will activate this button
94 /// GtkWidget *button = gtk_button_new ();
95 /// GtkWidget *label = gtk_label_new_with_mnemonic ("_Hello");
96 /// gtk_container_add (GTK_CONTAINER (button), label);
97 /// ```
98 ///
99 /// There’s a convenience function to create buttons with a mnemonic label
100 /// already inside:
101 ///
102 ///
103 ///
104 /// **⚠️ The following code is in C ⚠️**
105 ///
106 /// ```C
107 /// // Pressing Alt+H will activate this button
108 /// GtkWidget *button = gtk_button_new_with_mnemonic ("_Hello");
109 /// ```
110 ///
111 /// To create a mnemonic for a widget alongside the label, such as a
112 /// [`Entry`][crate::Entry], you have to point the label at the entry with
113 /// [`LabelExt::set_mnemonic_widget()`][crate::prelude::LabelExt::set_mnemonic_widget()]:
114 ///
115 ///
116 ///
117 /// **⚠️ The following code is in C ⚠️**
118 ///
119 /// ```C
120 /// // Pressing Alt+H will focus the entry
121 /// GtkWidget *entry = gtk_entry_new ();
122 /// GtkWidget *label = gtk_label_new_with_mnemonic ("_Hello");
123 /// gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
124 /// ```
125 ///
126 /// # Markup (styled text)
127 ///
128 /// To make it easy to format text in a label (changing colors,
129 /// fonts, etc.), label text can be provided in a simple
130 /// [markup format][PangoMarkupFormat].
131 ///
132 /// Here’s how to create a label with a small font:
133 ///
134 ///
135 /// **⚠️ The following code is in C ⚠️**
136 ///
137 /// ```C
138 /// GtkWidget *label = gtk_label_new (NULL);
139 /// gtk_label_set_markup (GTK_LABEL (label), "<small>Small text</small>");
140 /// ```
141 ///
142 /// (See [complete documentation][PangoMarkupFormat] of available
143 /// tags in the Pango manual.)
144 ///
145 /// The markup passed to [`LabelExt::set_markup()`][crate::prelude::LabelExt::set_markup()] must be valid; for example,
146 /// literal <, > and & characters must be escaped as <, >, and &.
147 /// If you pass text obtained from the user, file, or a network to
148 /// [`LabelExt::set_markup()`][crate::prelude::LabelExt::set_markup()], you’ll want to escape it with
149 /// `g_markup_escape_text()` or `g_markup_printf_escaped()`.
150 ///
151 /// Markup strings are just a convenient way to set the [`pango::AttrList`][crate::pango::AttrList] on
152 /// a label; [`LabelExt::set_attributes()`][crate::prelude::LabelExt::set_attributes()] may be a simpler way to set
153 /// attributes in some cases. Be careful though; [`pango::AttrList`][crate::pango::AttrList] tends to
154 /// cause internationalization problems, unless you’re applying attributes
155 /// to the entire string (i.e. unless you set the range of each attribute
156 /// to [0, `G_MAXINT`)). The reason is that specifying the start_index and
157 /// end_index for a `PangoAttribute` requires knowledge of the exact string
158 /// being displayed, so translations will cause problems.
159 ///
160 /// # Selectable labels
161 ///
162 /// Labels can be made selectable with [`LabelExt::set_selectable()`][crate::prelude::LabelExt::set_selectable()].
163 /// Selectable labels allow the user to copy the label contents to
164 /// the clipboard. Only labels that contain useful-to-copy information
165 /// — such as error messages — should be made selectable.
166 ///
167 /// # Text layout # {`label`-text-layout}
168 ///
169 /// A label can contain any number of paragraphs, but will have
170 /// performance problems if it contains more than a small number.
171 /// Paragraphs are separated by newlines or other paragraph separators
172 /// understood by Pango.
173 ///
174 /// Labels can automatically wrap text if you call
175 /// [`LabelExt::set_line_wrap()`][crate::prelude::LabelExt::set_line_wrap()].
176 ///
177 /// [`LabelExt::set_justify()`][crate::prelude::LabelExt::set_justify()] sets how the lines in a label align
178 /// with one another. If you want to set how the label as a whole
179 /// aligns in its available space, see the [`halign`][struct@crate::Widget#halign] and
180 /// [`valign`][struct@crate::Widget#valign] properties.
181 ///
182 /// The [`width-chars`][struct@crate::Label#width-chars] and [`max-width-chars`][struct@crate::Label#max-width-chars] properties
183 /// can be used to control the size allocation of ellipsized or wrapped
184 /// labels. For ellipsizing labels, if either is specified (and less
185 /// than the actual text size), it is used as the minimum width, and the actual
186 /// text size is used as the natural width of the label. For wrapping labels,
187 /// width-chars is used as the minimum width, if specified, and max-width-chars
188 /// is used as the natural width. Even if max-width-chars specified, wrapping
189 /// labels will be rewrapped to use all of the available width.
190 ///
191 /// Note that the interpretation of [`width-chars`][struct@crate::Label#width-chars] and
192 /// [`max-width-chars`][struct@crate::Label#max-width-chars] has changed a bit with the introduction of
193 /// [width-for-height geometry management.][geometry-management]
194 ///
195 /// # Links
196 ///
197 /// Since 2.18, GTK+ supports markup for clickable hyperlinks in addition
198 /// to regular Pango markup. The markup for links is borrowed from HTML,
199 /// using the ``<a>`` with “href“ and “title“ attributes. GTK+ renders links
200 /// similar to the way they appear in web browsers, with colored, underlined
201 /// text. The “title“ attribute is displayed as a tooltip on the link.
202 ///
203 /// An example looks like this:
204 ///
205 ///
206 ///
207 /// **⚠️ The following code is in C ⚠️**
208 ///
209 /// ```C
210 /// const gchar *text =
211 /// "Go to the"
212 /// "<a href=\"http://www.gtk.org title=\"<i>Our</i> website\">"
213 /// "GTK+ website</a> for more...";
214 /// GtkWidget *label = gtk_label_new (NULL);
215 /// gtk_label_set_markup (GTK_LABEL (label), text);
216 /// ```
217 ///
218 /// It is possible to implement custom handling for links and their tooltips with
219 /// the [`activate-link`][struct@crate::Label#activate-link] signal and the [`LabelExt::current_uri()`][crate::prelude::LabelExt::current_uri()] function.
220 ///
221 /// ## Properties
222 ///
223 ///
224 /// #### `angle`
225 /// The angle that the baseline of the label makes with the horizontal,
226 /// in degrees, measured counterclockwise. An angle of 90 reads from
227 /// from bottom to top, an angle of 270, from top to bottom. Ignored
228 /// if the label is selectable.
229 ///
230 /// Readable | Writable
231 ///
232 ///
233 /// #### `attributes`
234 /// Readable | Writable
235 ///
236 ///
237 /// #### `cursor-position`
238 /// Readable
239 ///
240 ///
241 /// #### `ellipsize`
242 /// The preferred place to ellipsize the string, if the label does
243 /// not have enough room to display the entire string, specified as a
244 /// [`pango::EllipsizeMode`][crate::pango::EllipsizeMode].
245 ///
246 /// Note that setting this property to a value other than
247 /// [`pango::EllipsizeMode::None`][crate::pango::EllipsizeMode::None] has the side-effect that the label requests
248 /// only enough space to display the ellipsis "...". In particular, this
249 /// means that ellipsizing labels do not work well in notebook tabs, unless
250 /// the [`Notebook`][crate::Notebook] tab-expand child property is set to [`true`]. Other ways
251 /// to set a label's width are [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] and
252 /// [`LabelExt::set_width_chars()`][crate::prelude::LabelExt::set_width_chars()].
253 ///
254 /// Readable | Writable
255 ///
256 ///
257 /// #### `justify`
258 /// Readable | Writable
259 ///
260 ///
261 /// #### `label`
262 /// The contents of the label.
263 ///
264 /// If the string contains [Pango XML markup][PangoMarkupFormat], you will
265 /// have to set the [`use-markup`][struct@crate::Label#use-markup] property to [`true`] in order for the
266 /// label to display the markup attributes. See also [`LabelExt::set_markup()`][crate::prelude::LabelExt::set_markup()]
267 /// for a convenience function that sets both this property and the
268 /// [`use-markup`][struct@crate::Label#use-markup] property at the same time.
269 ///
270 /// If the string contains underlines acting as mnemonics, you will have to
271 /// set the [`use-underline`][struct@crate::Label#use-underline] property to [`true`] in order for the label
272 /// to display them.
273 ///
274 /// Readable | Writable
275 ///
276 ///
277 /// #### `lines`
278 /// The number of lines to which an ellipsized, wrapping label
279 /// should be limited. This property has no effect if the
280 /// label is not wrapping or ellipsized. Set this property to
281 /// -1 if you don't want to limit the number of lines.
282 ///
283 /// Readable | Writable
284 ///
285 ///
286 /// #### `max-width-chars`
287 /// The desired maximum width of the label, in characters. If this property
288 /// is set to -1, the width will be calculated automatically.
289 ///
290 /// See the section on [text layout][label-text-layout]
291 /// for details of how [`width-chars`][struct@crate::Label#width-chars] and [`max-width-chars`][struct@crate::Label#max-width-chars]
292 /// determine the width of ellipsized and wrapped labels.
293 ///
294 /// Readable | Writable
295 ///
296 ///
297 /// #### `mnemonic-keyval`
298 /// Readable
299 ///
300 ///
301 /// #### `mnemonic-widget`
302 /// Readable | Writable
303 ///
304 ///
305 /// #### `pattern`
306 /// Writable
307 ///
308 ///
309 /// #### `selectable`
310 /// Readable | Writable
311 ///
312 ///
313 /// #### `selection-bound`
314 /// Readable
315 ///
316 ///
317 /// #### `single-line-mode`
318 /// Whether the label is in single line mode. In single line mode,
319 /// the height of the label does not depend on the actual text, it
320 /// is always set to ascent + descent of the font. This can be an
321 /// advantage in situations where resizing the label because of text
322 /// changes would be distracting, e.g. in a statusbar.
323 ///
324 /// Readable | Writable
325 ///
326 ///
327 /// #### `track-visited-links`
328 /// Set this property to [`true`] to make the label track which links
329 /// have been visited. It will then apply the [`StateFlags::VISITED`][crate::StateFlags::VISITED]
330 /// when rendering this link, in addition to [`StateFlags::LINK`][crate::StateFlags::LINK].
331 ///
332 /// Readable | Writable
333 ///
334 ///
335 /// #### `use-markup`
336 /// Readable | Writable
337 ///
338 ///
339 /// #### `use-underline`
340 /// Readable | Writable
341 ///
342 ///
343 /// #### `width-chars`
344 /// The desired width of the label, in characters. If this property is set to
345 /// -1, the width will be calculated automatically.
346 ///
347 /// See the section on [text layout][label-text-layout]
348 /// for details of how [`width-chars`][struct@crate::Label#width-chars] and [`max-width-chars`][struct@crate::Label#max-width-chars]
349 /// determine the width of ellipsized and wrapped labels.
350 ///
351 /// Readable | Writable
352 ///
353 ///
354 /// #### `wrap`
355 /// Readable | Writable
356 ///
357 ///
358 /// #### `wrap-mode`
359 /// If line wrapping is on (see the [`wrap`][struct@crate::Label#wrap] property) this controls
360 /// how the line wrapping is done. The default is [`pango::WrapMode::Word`][crate::pango::WrapMode::Word], which
361 /// means wrap on word boundaries.
362 ///
363 /// Readable | Writable
364 ///
365 ///
366 /// #### `xalign`
367 /// The xalign property determines the horizontal aligment of the label text
368 /// inside the labels size allocation. Compare this to [`halign`][struct@crate::Widget#halign],
369 /// which determines how the labels size allocation is positioned in the
370 /// space available for the label.
371 ///
372 /// Readable | Writable
373 ///
374 ///
375 /// #### `yalign`
376 /// The yalign property determines the vertical aligment of the label text
377 /// inside the labels size allocation. Compare this to [`valign`][struct@crate::Widget#valign],
378 /// which determines how the labels size allocation is positioned in the
379 /// space available for the label.
380 ///
381 /// Readable | Writable
382 /// <details><summary><h4>Misc</h4></summary>
383 ///
384 ///
385 /// #### `xalign`
386 /// The horizontal alignment. A value of 0.0 means left alignment (or right
387 /// on RTL locales); a value of 1.0 means right alignment (or left on RTL
388 /// locales).
389 ///
390 /// Readable | Writable
391 ///
392 ///
393 /// #### `xpad`
394 /// The amount of space to add on the left and right of the widget, in
395 /// pixels.
396 ///
397 /// Readable | Writable
398 ///
399 ///
400 /// #### `yalign`
401 /// The vertical alignment. A value of 0.0 means top alignment;
402 /// a value of 1.0 means bottom alignment.
403 ///
404 /// Readable | Writable
405 ///
406 ///
407 /// #### `ypad`
408 /// The amount of space to add on the top and bottom of the widget, in
409 /// pixels.
410 ///
411 /// Readable | Writable
412 /// </details>
413 /// <details><summary><h4>Widget</h4></summary>
414 ///
415 ///
416 /// #### `app-paintable`
417 /// Readable | Writable
418 ///
419 ///
420 /// #### `can-default`
421 /// Readable | Writable
422 ///
423 ///
424 /// #### `can-focus`
425 /// Readable | Writable
426 ///
427 ///
428 /// #### `composite-child`
429 /// Readable
430 ///
431 ///
432 /// #### `double-buffered`
433 /// Whether the widget is double buffered.
434 ///
435 /// Readable | Writable
436 ///
437 ///
438 /// #### `events`
439 /// Readable | Writable
440 ///
441 ///
442 /// #### `expand`
443 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
444 ///
445 /// Readable | Writable
446 ///
447 ///
448 /// #### `focus-on-click`
449 /// Whether the widget should grab focus when it is clicked with the mouse.
450 ///
451 /// This property is only relevant for widgets that can take focus.
452 ///
453 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
454 /// GtkComboBox) implemented this property individually.
455 ///
456 /// Readable | Writable
457 ///
458 ///
459 /// #### `halign`
460 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
461 ///
462 /// Readable | Writable
463 ///
464 ///
465 /// #### `has-default`
466 /// Readable | Writable
467 ///
468 ///
469 /// #### `has-focus`
470 /// Readable | Writable
471 ///
472 ///
473 /// #### `has-tooltip`
474 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
475 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
476 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
477 /// whether it will provide a tooltip or not.
478 ///
479 /// Note that setting this property to [`true`] for the first time will change
480 /// the event masks of the GdkWindows of this widget to include leave-notify
481 /// and motion-notify events. This cannot and will not be undone when the
482 /// property is set to [`false`] again.
483 ///
484 /// Readable | Writable
485 ///
486 ///
487 /// #### `height-request`
488 /// Readable | Writable
489 ///
490 ///
491 /// #### `hexpand`
492 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
493 ///
494 /// Readable | Writable
495 ///
496 ///
497 /// #### `hexpand-set`
498 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
499 ///
500 /// Readable | Writable
501 ///
502 ///
503 /// #### `is-focus`
504 /// Readable | Writable
505 ///
506 ///
507 /// #### `margin`
508 /// Sets all four sides' margin at once. If read, returns max
509 /// margin on any side.
510 ///
511 /// Readable | Writable
512 ///
513 ///
514 /// #### `margin-bottom`
515 /// Margin on bottom side of widget.
516 ///
517 /// This property adds margin outside of the widget's normal size
518 /// request, the margin will be added in addition to the size from
519 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
520 ///
521 /// Readable | Writable
522 ///
523 ///
524 /// #### `margin-end`
525 /// Margin on end of widget, horizontally. This property supports
526 /// left-to-right and right-to-left text directions.
527 ///
528 /// This property adds margin outside of the widget's normal size
529 /// request, the margin will be added in addition to the size from
530 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
531 ///
532 /// Readable | Writable
533 ///
534 ///
535 /// #### `margin-left`
536 /// Margin on left side of widget.
537 ///
538 /// This property adds margin outside of the widget's normal size
539 /// request, the margin will be added in addition to the size from
540 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
541 ///
542 /// Readable | Writable
543 ///
544 ///
545 /// #### `margin-right`
546 /// Margin on right side of widget.
547 ///
548 /// This property adds margin outside of the widget's normal size
549 /// request, the margin will be added in addition to the size from
550 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
551 ///
552 /// Readable | Writable
553 ///
554 ///
555 /// #### `margin-start`
556 /// Margin on start of widget, horizontally. This property supports
557 /// left-to-right and right-to-left text directions.
558 ///
559 /// This property adds margin outside of the widget's normal size
560 /// request, the margin will be added in addition to the size from
561 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
562 ///
563 /// Readable | Writable
564 ///
565 ///
566 /// #### `margin-top`
567 /// Margin on top side of widget.
568 ///
569 /// This property adds margin outside of the widget's normal size
570 /// request, the margin will be added in addition to the size from
571 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
572 ///
573 /// Readable | Writable
574 ///
575 ///
576 /// #### `name`
577 /// Readable | Writable
578 ///
579 ///
580 /// #### `no-show-all`
581 /// Readable | Writable
582 ///
583 ///
584 /// #### `opacity`
585 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
586 /// more details about window opacity.
587 ///
588 /// Before 3.8 this was only available in GtkWindow
589 ///
590 /// Readable | Writable
591 ///
592 ///
593 /// #### `parent`
594 /// Readable | Writable
595 ///
596 ///
597 /// #### `receives-default`
598 /// Readable | Writable
599 ///
600 ///
601 /// #### `scale-factor`
602 /// The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
603 /// more details about widget scaling.
604 ///
605 /// Readable
606 ///
607 ///
608 /// #### `sensitive`
609 /// Readable | Writable
610 ///
611 ///
612 /// #### `style`
613 /// The style of the widget, which contains information about how it will look (colors, etc).
614 ///
615 /// Readable | Writable
616 ///
617 ///
618 /// #### `tooltip-markup`
619 /// Sets the text of tooltip to be the given string, which is marked up
620 /// with the [Pango text markup language][PangoMarkupFormat].
621 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
622 ///
623 /// This is a convenience property which will take care of getting the
624 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
625 /// will automatically be set to [`true`] and there will be taken care of
626 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
627 ///
628 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
629 /// are set, the last one wins.
630 ///
631 /// Readable | Writable
632 ///
633 ///
634 /// #### `tooltip-text`
635 /// Sets the text of tooltip to be the given string.
636 ///
637 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
638 ///
639 /// This is a convenience property which will take care of getting the
640 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
641 /// will automatically be set to [`true`] and there will be taken care of
642 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
643 ///
644 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
645 /// are set, the last one wins.
646 ///
647 /// Readable | Writable
648 ///
649 ///
650 /// #### `valign`
651 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
652 ///
653 /// Readable | Writable
654 ///
655 ///
656 /// #### `vexpand`
657 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
658 ///
659 /// Readable | Writable
660 ///
661 ///
662 /// #### `vexpand-set`
663 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
664 ///
665 /// Readable | Writable
666 ///
667 ///
668 /// #### `visible`
669 /// Readable | Writable
670 ///
671 ///
672 /// #### `width-request`
673 /// Readable | Writable
674 ///
675 ///
676 /// #### `window`
677 /// The widget's window if it is realized, [`None`] otherwise.
678 ///
679 /// Readable
680 /// </details>
681 ///
682 /// ## Signals
683 ///
684 ///
685 /// #### `activate-current-link`
686 /// A [keybinding signal][GtkBindingSignal]
687 /// which gets emitted when the user activates a link in the label.
688 ///
689 /// Applications may also emit the signal with `g_signal_emit_by_name()`
690 /// if they need to control activation of URIs programmatically.
691 ///
692 /// The default bindings for this signal are all forms of the Enter key.
693 ///
694 /// Action
695 ///
696 ///
697 /// #### `activate-link`
698 /// The signal which gets emitted to activate a URI.
699 /// Applications may connect to it to override the default behaviour,
700 /// which is to call [`show_uri_on_window()`][crate::show_uri_on_window()].
701 ///
702 ///
703 ///
704 ///
705 /// #### `copy-clipboard`
706 /// The ::copy-clipboard signal is a
707 /// [keybinding signal][GtkBindingSignal]
708 /// which gets emitted to copy the selection to the clipboard.
709 ///
710 /// The default binding for this signal is Ctrl-c.
711 ///
712 /// Action
713 ///
714 ///
715 /// #### `move-cursor`
716 /// The ::move-cursor signal is a
717 /// [keybinding signal][GtkBindingSignal]
718 /// which gets emitted when the user initiates a cursor movement.
719 /// If the cursor is not visible in `entry`, this signal causes
720 /// the viewport to be moved instead.
721 ///
722 /// Applications should not connect to it, but may emit it with
723 /// `g_signal_emit_by_name()` if they need to control the cursor
724 /// programmatically.
725 ///
726 /// The default bindings for this signal come in two variants,
727 /// the variant with the Shift modifier extends the selection,
728 /// the variant without the Shift modifer does not.
729 /// There are too many key combinations to list them all here.
730 /// - Arrow keys move by individual characters/lines
731 /// - Ctrl-arrow key combinations move by words/paragraphs
732 /// - Home/End keys move to the ends of the buffer
733 ///
734 /// Action
735 ///
736 ///
737 /// #### `populate-popup`
738 /// The ::populate-popup signal gets emitted before showing the
739 /// context menu of the label. Note that only selectable labels
740 /// have context menus.
741 ///
742 /// If you need to add items to the context menu, connect
743 /// to this signal and append your menuitems to the `menu`.
744 ///
745 ///
746 /// <details><summary><h4>Widget</h4></summary>
747 ///
748 ///
749 /// #### `accel-closures-changed`
750 ///
751 ///
752 ///
753 /// #### `button-press-event`
754 /// The ::button-press-event signal will be emitted when a button
755 /// (typically from a mouse) is pressed.
756 ///
757 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
758 /// widget needs to enable the [`gdk::EventMask::BUTTON_PRESS_MASK`][crate::gdk::EventMask::BUTTON_PRESS_MASK] mask.
759 ///
760 /// This signal will be sent to the grab widget if there is one.
761 ///
762 ///
763 ///
764 ///
765 /// #### `button-release-event`
766 /// The ::button-release-event signal will be emitted when a button
767 /// (typically from a mouse) is released.
768 ///
769 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
770 /// widget needs to enable the [`gdk::EventMask::BUTTON_RELEASE_MASK`][crate::gdk::EventMask::BUTTON_RELEASE_MASK] mask.
771 ///
772 /// This signal will be sent to the grab widget if there is one.
773 ///
774 ///
775 ///
776 ///
777 /// #### `can-activate-accel`
778 /// Determines whether an accelerator that activates the signal
779 /// identified by `signal_id` can currently be activated.
780 /// This signal is present to allow applications and derived
781 /// widgets to override the default [`Widget`][crate::Widget] handling
782 /// for determining whether an accelerator can be activated.
783 ///
784 ///
785 ///
786 ///
787 /// #### `child-notify`
788 /// The ::child-notify signal is emitted for each
789 /// [child property][child-properties] that has
790 /// changed on an object. The signal's detail holds the property name.
791 ///
792 /// Detailed
793 ///
794 ///
795 /// #### `composited-changed`
796 /// The ::composited-changed signal is emitted when the composited
797 /// status of `widgets` screen changes.
798 /// See [`Screen::is_composited()`][crate::gdk::Screen::is_composited()].
799 ///
800 /// Action
801 ///
802 ///
803 /// #### `configure-event`
804 /// The ::configure-event signal will be emitted when the size, position or
805 /// stacking of the `widget`'s window has changed.
806 ///
807 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
808 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
809 /// automatically for all new windows.
810 ///
811 ///
812 ///
813 ///
814 /// #### `damage-event`
815 /// Emitted when a redirected window belonging to `widget` gets drawn into.
816 /// The region/area members of the event shows what area of the redirected
817 /// drawable was drawn into.
818 ///
819 ///
820 ///
821 ///
822 /// #### `delete-event`
823 /// The ::delete-event signal is emitted if a user requests that
824 /// a toplevel window is closed. The default handler for this signal
825 /// destroys the window. Connecting [`WidgetExtManual::hide_on_delete()`][crate::prelude::WidgetExtManual::hide_on_delete()] to
826 /// this signal will cause the window to be hidden instead, so that
827 /// it can later be shown again without reconstructing it.
828 ///
829 ///
830 ///
831 ///
832 /// #### `destroy`
833 /// Signals that all holders of a reference to the widget should release
834 /// the reference that they hold. May result in finalization of the widget
835 /// if all references are released.
836 ///
837 /// This signal is not suitable for saving widget state.
838 ///
839 ///
840 ///
841 ///
842 /// #### `destroy-event`
843 /// The ::destroy-event signal is emitted when a [`gdk::Window`][crate::gdk::Window] is destroyed.
844 /// You rarely get this signal, because most widgets disconnect themselves
845 /// from their window before they destroy it, so no widget owns the
846 /// window at destroy time.
847 ///
848 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
849 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
850 /// automatically for all new windows.
851 ///
852 ///
853 ///
854 ///
855 /// #### `direction-changed`
856 /// The ::direction-changed signal is emitted when the text direction
857 /// of a widget changes.
858 ///
859 ///
860 ///
861 ///
862 /// #### `drag-begin`
863 /// The ::drag-begin signal is emitted on the drag source when a drag is
864 /// started. A typical reason to connect to this signal is to set up a
865 /// custom drag icon with e.g. [`WidgetExt::drag_source_set_icon_pixbuf()`][crate::prelude::WidgetExt::drag_source_set_icon_pixbuf()].
866 ///
867 /// Note that some widgets set up a drag icon in the default handler of
868 /// this signal, so you may have to use `g_signal_connect_after()` to
869 /// override what the default handler did.
870 ///
871 ///
872 ///
873 ///
874 /// #### `drag-data-delete`
875 /// The ::drag-data-delete signal is emitted on the drag source when a drag
876 /// with the action [`gdk::DragAction::MOVE`][crate::gdk::DragAction::MOVE] is successfully completed. The signal
877 /// handler is responsible for deleting the data that has been dropped. What
878 /// "delete" means depends on the context of the drag operation.
879 ///
880 ///
881 ///
882 ///
883 /// #### `drag-data-get`
884 /// The ::drag-data-get signal is emitted on the drag source when the drop
885 /// site requests the data which is dragged. It is the responsibility of
886 /// the signal handler to fill `data` with the data in the format which
887 /// is indicated by `info`. See [`SelectionData::set()`][crate::SelectionData::set()] and
888 /// [`SelectionData::set_text()`][crate::SelectionData::set_text()].
889 ///
890 ///
891 ///
892 ///
893 /// #### `drag-data-received`
894 /// The ::drag-data-received signal is emitted on the drop site when the
895 /// dragged data has been received. If the data was received in order to
896 /// determine whether the drop will be accepted, the handler is expected
897 /// to call `gdk_drag_status()` and not finish the drag.
898 /// If the data was received in response to a [`drag-drop`][struct@crate::Widget#drag-drop] signal
899 /// (and this is the last target to be received), the handler for this
900 /// signal is expected to process the received data and then call
901 /// `gtk_drag_finish()`, setting the `success` parameter depending on
902 /// whether the data was processed successfully.
903 ///
904 /// Applications must create some means to determine why the signal was emitted
905 /// and therefore whether to call `gdk_drag_status()` or `gtk_drag_finish()`.
906 ///
907 /// The handler may inspect the selected action with
908 /// [`DragContext::selected_action()`][crate::gdk::DragContext::selected_action()] before calling
909 /// `gtk_drag_finish()`, e.g. to implement [`gdk::DragAction::ASK`][crate::gdk::DragAction::ASK] as
910 /// shown in the following example:
911 ///
912 ///
913 /// **⚠️ The following code is in C ⚠️**
914 ///
915 /// ```C
916 /// void
917 /// drag_data_received (GtkWidget *widget,
918 /// GdkDragContext *context,
919 /// gint x,
920 /// gint y,
921 /// GtkSelectionData *data,
922 /// guint info,
923 /// guint time)
924 /// {
925 /// if ((data->length >= 0) && (data->format == 8))
926 /// {
927 /// GdkDragAction action;
928 ///
929 /// // handle data here
930 ///
931 /// action = gdk_drag_context_get_selected_action (context);
932 /// if (action == GDK_ACTION_ASK)
933 /// {
934 /// GtkWidget *dialog;
935 /// gint response;
936 ///
937 /// dialog = gtk_message_dialog_new (NULL,
938 /// GTK_DIALOG_MODAL |
939 /// GTK_DIALOG_DESTROY_WITH_PARENT,
940 /// GTK_MESSAGE_INFO,
941 /// GTK_BUTTONS_YES_NO,
942 /// "Move the data ?\n");
943 /// response = gtk_dialog_run (GTK_DIALOG (dialog));
944 /// gtk_widget_destroy (dialog);
945 ///
946 /// if (response == GTK_RESPONSE_YES)
947 /// action = GDK_ACTION_MOVE;
948 /// else
949 /// action = GDK_ACTION_COPY;
950 /// }
951 ///
952 /// gtk_drag_finish (context, TRUE, action == GDK_ACTION_MOVE, time);
953 /// }
954 /// else
955 /// gtk_drag_finish (context, FALSE, FALSE, time);
956 /// }
957 /// ```
958 ///
959 ///
960 ///
961 ///
962 /// #### `drag-drop`
963 /// The ::drag-drop signal is emitted on the drop site when the user drops
964 /// the data onto the widget. The signal handler must determine whether
965 /// the cursor position is in a drop zone or not. If it is not in a drop
966 /// zone, it returns [`false`] and no further processing is necessary.
967 /// Otherwise, the handler returns [`true`]. In this case, the handler must
968 /// ensure that `gtk_drag_finish()` is called to let the source know that
969 /// the drop is done. The call to `gtk_drag_finish()` can be done either
970 /// directly or in a [`drag-data-received`][struct@crate::Widget#drag-data-received] handler which gets
971 /// triggered by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] to receive the data for one
972 /// or more of the supported targets.
973 ///
974 ///
975 ///
976 ///
977 /// #### `drag-end`
978 /// The ::drag-end signal is emitted on the drag source when a drag is
979 /// finished. A typical reason to connect to this signal is to undo
980 /// things done in [`drag-begin`][struct@crate::Widget#drag-begin].
981 ///
982 ///
983 ///
984 ///
985 /// #### `drag-failed`
986 /// The ::drag-failed signal is emitted on the drag source when a drag has
987 /// failed. The signal handler may hook custom code to handle a failed DnD
988 /// operation based on the type of error, it returns [`true`] is the failure has
989 /// been already handled (not showing the default "drag operation failed"
990 /// animation), otherwise it returns [`false`].
991 ///
992 ///
993 ///
994 ///
995 /// #### `drag-leave`
996 /// The ::drag-leave signal is emitted on the drop site when the cursor
997 /// leaves the widget. A typical reason to connect to this signal is to
998 /// undo things done in [`drag-motion`][struct@crate::Widget#drag-motion], e.g. undo highlighting
999 /// with [`WidgetExt::drag_unhighlight()`][crate::prelude::WidgetExt::drag_unhighlight()].
1000 ///
1001 ///
1002 /// Likewise, the [`drag-leave`][struct@crate::Widget#drag-leave] signal is also emitted before the
1003 /// ::drag-drop signal, for instance to allow cleaning up of a preview item
1004 /// created in the [`drag-motion`][struct@crate::Widget#drag-motion] signal handler.
1005 ///
1006 ///
1007 ///
1008 ///
1009 /// #### `drag-motion`
1010 /// The ::drag-motion signal is emitted on the drop site when the user
1011 /// moves the cursor over the widget during a drag. The signal handler
1012 /// must determine whether the cursor position is in a drop zone or not.
1013 /// If it is not in a drop zone, it returns [`false`] and no further processing
1014 /// is necessary. Otherwise, the handler returns [`true`]. In this case, the
1015 /// handler is responsible for providing the necessary information for
1016 /// displaying feedback to the user, by calling `gdk_drag_status()`.
1017 ///
1018 /// If the decision whether the drop will be accepted or rejected can't be
1019 /// made based solely on the cursor position and the type of the data, the
1020 /// handler may inspect the dragged data by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] and
1021 /// defer the `gdk_drag_status()` call to the [`drag-data-received`][struct@crate::Widget#drag-data-received]
1022 /// handler. Note that you must pass [`DestDefaults::DROP`][crate::DestDefaults::DROP],
1023 /// [`DestDefaults::MOTION`][crate::DestDefaults::MOTION] or [`DestDefaults::ALL`][crate::DestDefaults::ALL] to [`WidgetExtManual::drag_dest_set()`][crate::prelude::WidgetExtManual::drag_dest_set()]
1024 /// when using the drag-motion signal that way.
1025 ///
1026 /// Also note that there is no drag-enter signal. The drag receiver has to
1027 /// keep track of whether he has received any drag-motion signals since the
1028 /// last [`drag-leave`][struct@crate::Widget#drag-leave] and if not, treat the drag-motion signal as
1029 /// an "enter" signal. Upon an "enter", the handler will typically highlight
1030 /// the drop site with [`WidgetExt::drag_highlight()`][crate::prelude::WidgetExt::drag_highlight()].
1031 ///
1032 ///
1033 /// **⚠️ The following code is in C ⚠️**
1034 ///
1035 /// ```C
1036 /// static void
1037 /// drag_motion (GtkWidget *widget,
1038 /// GdkDragContext *context,
1039 /// gint x,
1040 /// gint y,
1041 /// guint time)
1042 /// {
1043 /// GdkAtom target;
1044 ///
1045 /// PrivateData *private_data = GET_PRIVATE_DATA (widget);
1046 ///
1047 /// if (!private_data->drag_highlight)
1048 /// {
1049 /// private_data->drag_highlight = 1;
1050 /// gtk_drag_highlight (widget);
1051 /// }
1052 ///
1053 /// target = gtk_drag_dest_find_target (widget, context, NULL);
1054 /// if (target == GDK_NONE)
1055 /// gdk_drag_status (context, 0, time);
1056 /// else
1057 /// {
1058 /// private_data->pending_status
1059 /// = gdk_drag_context_get_suggested_action (context);
1060 /// gtk_drag_get_data (widget, context, target, time);
1061 /// }
1062 ///
1063 /// return TRUE;
1064 /// }
1065 ///
1066 /// static void
1067 /// drag_data_received (GtkWidget *widget,
1068 /// GdkDragContext *context,
1069 /// gint x,
1070 /// gint y,
1071 /// GtkSelectionData *selection_data,
1072 /// guint info,
1073 /// guint time)
1074 /// {
1075 /// PrivateData *private_data = GET_PRIVATE_DATA (widget);
1076 ///
1077 /// if (private_data->suggested_action)
1078 /// {
1079 /// private_data->suggested_action = 0;
1080 ///
1081 /// // We are getting this data due to a request in drag_motion,
1082 /// // rather than due to a request in drag_drop, so we are just
1083 /// // supposed to call gdk_drag_status(), not actually paste in
1084 /// // the data.
1085 ///
1086 /// str = gtk_selection_data_get_text (selection_data);
1087 /// if (!data_is_acceptable (str))
1088 /// gdk_drag_status (context, 0, time);
1089 /// else
1090 /// gdk_drag_status (context,
1091 /// private_data->suggested_action,
1092 /// time);
1093 /// }
1094 /// else
1095 /// {
1096 /// // accept the drop
1097 /// }
1098 /// }
1099 /// ```
1100 ///
1101 ///
1102 ///
1103 ///
1104 /// #### `draw`
1105 /// This signal is emitted when a widget is supposed to render itself.
1106 /// The `widget`'s top left corner must be painted at the origin of
1107 /// the passed in context and be sized to the values returned by
1108 /// [`WidgetExt::allocated_width()`][crate::prelude::WidgetExt::allocated_width()] and
1109 /// [`WidgetExt::allocated_height()`][crate::prelude::WidgetExt::allocated_height()].
1110 ///
1111 /// Signal handlers connected to this signal can modify the cairo
1112 /// context passed as `cr` in any way they like and don't need to
1113 /// restore it. The signal emission takes care of calling `cairo_save()`
1114 /// before and `cairo_restore()` after invoking the handler.
1115 ///
1116 /// The signal handler will get a `cr` with a clip region already set to the
1117 /// widget's dirty region, i.e. to the area that needs repainting. Complicated
1118 /// widgets that want to avoid redrawing themselves completely can get the full
1119 /// extents of the clip region with `gdk_cairo_get_clip_rectangle()`, or they can
1120 /// get a finer-grained representation of the dirty region with
1121 /// `cairo_copy_clip_rectangle_list()`.
1122 ///
1123 ///
1124 ///
1125 ///
1126 /// #### `enter-notify-event`
1127 /// The ::enter-notify-event will be emitted when the pointer enters
1128 /// the `widget`'s window.
1129 ///
1130 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1131 /// to enable the [`gdk::EventMask::ENTER_NOTIFY_MASK`][crate::gdk::EventMask::ENTER_NOTIFY_MASK] mask.
1132 ///
1133 /// This signal will be sent to the grab widget if there is one.
1134 ///
1135 ///
1136 ///
1137 ///
1138 /// #### `event`
1139 /// The GTK+ main loop will emit three signals for each GDK event delivered
1140 /// to a widget: one generic ::event signal, another, more specific,
1141 /// signal that matches the type of event delivered (e.g.
1142 /// [`key-press-event`][struct@crate::Widget#key-press-event]) and finally a generic
1143 /// [`event-after`][struct@crate::Widget#event-after] signal.
1144 ///
1145 ///
1146 ///
1147 ///
1148 /// #### `event-after`
1149 /// After the emission of the [`event`][struct@crate::Widget#event] signal and (optionally)
1150 /// the second more specific signal, ::event-after will be emitted
1151 /// regardless of the previous two signals handlers return values.
1152 ///
1153 ///
1154 ///
1155 ///
1156 /// #### `focus`
1157 ///
1158 ///
1159 ///
1160 /// #### `focus-in-event`
1161 /// The ::focus-in-event signal will be emitted when the keyboard focus
1162 /// enters the `widget`'s window.
1163 ///
1164 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1165 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
1166 ///
1167 ///
1168 ///
1169 ///
1170 /// #### `focus-out-event`
1171 /// The ::focus-out-event signal will be emitted when the keyboard focus
1172 /// leaves the `widget`'s window.
1173 ///
1174 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1175 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
1176 ///
1177 ///
1178 ///
1179 ///
1180 /// #### `grab-broken-event`
1181 /// Emitted when a pointer or keyboard grab on a window belonging
1182 /// to `widget` gets broken.
1183 ///
1184 /// On X11, this happens when the grab window becomes unviewable
1185 /// (i.e. it or one of its ancestors is unmapped), or if the same
1186 /// application grabs the pointer or keyboard again.
1187 ///
1188 ///
1189 ///
1190 ///
1191 /// #### `grab-focus`
1192 /// Action
1193 ///
1194 ///
1195 /// #### `grab-notify`
1196 /// The ::grab-notify signal is emitted when a widget becomes
1197 /// shadowed by a GTK+ grab (not a pointer or keyboard grab) on
1198 /// another widget, or when it becomes unshadowed due to a grab
1199 /// being removed.
1200 ///
1201 /// A widget is shadowed by a [`WidgetExt::grab_add()`][crate::prelude::WidgetExt::grab_add()] when the topmost
1202 /// grab widget in the grab stack of its window group is not
1203 /// its ancestor.
1204 ///
1205 ///
1206 ///
1207 ///
1208 /// #### `hide`
1209 /// The ::hide signal is emitted when `widget` is hidden, for example with
1210 /// [`WidgetExt::hide()`][crate::prelude::WidgetExt::hide()].
1211 ///
1212 ///
1213 ///
1214 ///
1215 /// #### `hierarchy-changed`
1216 /// The ::hierarchy-changed signal is emitted when the
1217 /// anchored state of a widget changes. A widget is
1218 /// “anchored” when its toplevel
1219 /// ancestor is a [`Window`][crate::Window]. This signal is emitted when
1220 /// a widget changes from un-anchored to anchored or vice-versa.
1221 ///
1222 ///
1223 ///
1224 ///
1225 /// #### `key-press-event`
1226 /// The ::key-press-event signal is emitted when a key is pressed. The signal
1227 /// emission will reoccur at the key-repeat rate when the key is kept pressed.
1228 ///
1229 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1230 /// to enable the [`gdk::EventMask::KEY_PRESS_MASK`][crate::gdk::EventMask::KEY_PRESS_MASK] mask.
1231 ///
1232 /// This signal will be sent to the grab widget if there is one.
1233 ///
1234 ///
1235 ///
1236 ///
1237 /// #### `key-release-event`
1238 /// The ::key-release-event signal is emitted when a key is released.
1239 ///
1240 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1241 /// to enable the [`gdk::EventMask::KEY_RELEASE_MASK`][crate::gdk::EventMask::KEY_RELEASE_MASK] mask.
1242 ///
1243 /// This signal will be sent to the grab widget if there is one.
1244 ///
1245 ///
1246 ///
1247 ///
1248 /// #### `keynav-failed`
1249 /// Gets emitted if keyboard navigation fails.
1250 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
1251 ///
1252 ///
1253 ///
1254 ///
1255 /// #### `leave-notify-event`
1256 /// The ::leave-notify-event will be emitted when the pointer leaves
1257 /// the `widget`'s window.
1258 ///
1259 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1260 /// to enable the [`gdk::EventMask::LEAVE_NOTIFY_MASK`][crate::gdk::EventMask::LEAVE_NOTIFY_MASK] mask.
1261 ///
1262 /// This signal will be sent to the grab widget if there is one.
1263 ///
1264 ///
1265 ///
1266 ///
1267 /// #### `map`
1268 /// The ::map signal is emitted when `widget` is going to be mapped, that is
1269 /// when the widget is visible (which is controlled with
1270 /// [`WidgetExt::set_visible()`][crate::prelude::WidgetExt::set_visible()]) and all its parents up to the toplevel widget
1271 /// are also visible. Once the map has occurred, [`map-event`][struct@crate::Widget#map-event] will
1272 /// be emitted.
1273 ///
1274 /// The ::map signal can be used to determine whether a widget will be drawn,
1275 /// for instance it can resume an animation that was stopped during the
1276 /// emission of [`unmap`][struct@crate::Widget#unmap].
1277 ///
1278 ///
1279 ///
1280 ///
1281 /// #### `map-event`
1282 /// The ::map-event signal will be emitted when the `widget`'s window is
1283 /// mapped. A window is mapped when it becomes visible on the screen.
1284 ///
1285 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1286 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
1287 /// automatically for all new windows.
1288 ///
1289 ///
1290 ///
1291 ///
1292 /// #### `mnemonic-activate`
1293 /// The default handler for this signal activates `widget` if `group_cycling`
1294 /// is [`false`], or just makes `widget` grab focus if `group_cycling` is [`true`].
1295 ///
1296 ///
1297 ///
1298 ///
1299 /// #### `motion-notify-event`
1300 /// The ::motion-notify-event signal is emitted when the pointer moves
1301 /// over the widget's [`gdk::Window`][crate::gdk::Window].
1302 ///
1303 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget
1304 /// needs to enable the [`gdk::EventMask::POINTER_MOTION_MASK`][crate::gdk::EventMask::POINTER_MOTION_MASK] mask.
1305 ///
1306 /// This signal will be sent to the grab widget if there is one.
1307 ///
1308 ///
1309 ///
1310 ///
1311 /// #### `move-focus`
1312 /// Action
1313 ///
1314 ///
1315 /// #### `parent-set`
1316 /// The ::parent-set signal is emitted when a new parent
1317 /// has been set on a widget.
1318 ///
1319 ///
1320 ///
1321 ///
1322 /// #### `popup-menu`
1323 /// This signal gets emitted whenever a widget should pop up a context
1324 /// menu. This usually happens through the standard key binding mechanism;
1325 /// by pressing a certain key while a widget is focused, the user can cause
1326 /// the widget to pop up a menu. For example, the [`Entry`][crate::Entry] widget creates
1327 /// a menu with clipboard commands. See the
1328 /// [Popup Menu Migration Checklist][checklist-popup-menu]
1329 /// for an example of how to use this signal.
1330 ///
1331 /// Action
1332 ///
1333 ///
1334 /// #### `property-notify-event`
1335 /// The ::property-notify-event signal will be emitted when a property on
1336 /// the `widget`'s window has been changed or deleted.
1337 ///
1338 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1339 /// to enable the [`gdk::EventMask::PROPERTY_CHANGE_MASK`][crate::gdk::EventMask::PROPERTY_CHANGE_MASK] mask.
1340 ///
1341 ///
1342 ///
1343 ///
1344 /// #### `proximity-in-event`
1345 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1346 /// to enable the [`gdk::EventMask::PROXIMITY_IN_MASK`][crate::gdk::EventMask::PROXIMITY_IN_MASK] mask.
1347 ///
1348 /// This signal will be sent to the grab widget if there is one.
1349 ///
1350 ///
1351 ///
1352 ///
1353 /// #### `proximity-out-event`
1354 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1355 /// to enable the [`gdk::EventMask::PROXIMITY_OUT_MASK`][crate::gdk::EventMask::PROXIMITY_OUT_MASK] mask.
1356 ///
1357 /// This signal will be sent to the grab widget if there is one.
1358 ///
1359 ///
1360 ///
1361 ///
1362 /// #### `query-tooltip`
1363 /// Emitted when [`has-tooltip`][struct@crate::Widget#has-tooltip] is [`true`] and the hover timeout
1364 /// has expired with the cursor hovering "above" `widget`; or emitted when `widget` got
1365 /// focus in keyboard mode.
1366 ///
1367 /// Using the given coordinates, the signal handler should determine
1368 /// whether a tooltip should be shown for `widget`. If this is the case
1369 /// [`true`] should be returned, [`false`] otherwise. Note that if
1370 /// `keyboard_mode` is [`true`], the values of `x` and `y` are undefined and
1371 /// should not be used.
1372 ///
1373 /// The signal handler is free to manipulate `tooltip` with the therefore
1374 /// destined function calls.
1375 ///
1376 ///
1377 ///
1378 ///
1379 /// #### `realize`
1380 /// The ::realize signal is emitted when `widget` is associated with a
1381 /// [`gdk::Window`][crate::gdk::Window], which means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called or the
1382 /// widget has been mapped (that is, it is going to be drawn).
1383 ///
1384 ///
1385 ///
1386 ///
1387 /// #### `screen-changed`
1388 /// The ::screen-changed signal gets emitted when the
1389 /// screen of a widget has changed.
1390 ///
1391 ///
1392 ///
1393 ///
1394 /// #### `scroll-event`
1395 /// The ::scroll-event signal is emitted when a button in the 4 to 7
1396 /// range is pressed. Wheel mice are usually configured to generate
1397 /// button press events for buttons 4 and 5 when the wheel is turned.
1398 ///
1399 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1400 /// to enable the [`gdk::EventMask::SCROLL_MASK`][crate::gdk::EventMask::SCROLL_MASK] mask.
1401 ///
1402 /// This signal will be sent to the grab widget if there is one.
1403 ///
1404 ///
1405 ///
1406 ///
1407 /// #### `selection-clear-event`
1408 /// The ::selection-clear-event signal will be emitted when the
1409 /// the `widget`'s window has lost ownership of a selection.
1410 ///
1411 ///
1412 ///
1413 ///
1414 /// #### `selection-get`
1415 ///
1416 ///
1417 ///
1418 /// #### `selection-notify-event`
1419 ///
1420 ///
1421 ///
1422 /// #### `selection-received`
1423 ///
1424 ///
1425 ///
1426 /// #### `selection-request-event`
1427 /// The ::selection-request-event signal will be emitted when
1428 /// another client requests ownership of the selection owned by
1429 /// the `widget`'s window.
1430 ///
1431 ///
1432 ///
1433 ///
1434 /// #### `show`
1435 /// The ::show signal is emitted when `widget` is shown, for example with
1436 /// [`WidgetExt::show()`][crate::prelude::WidgetExt::show()].
1437 ///
1438 ///
1439 ///
1440 ///
1441 /// #### `show-help`
1442 /// Action
1443 ///
1444 ///
1445 /// #### `size-allocate`
1446 ///
1447 ///
1448 ///
1449 /// #### `state-changed`
1450 /// The ::state-changed signal is emitted when the widget state changes.
1451 /// See `gtk_widget_get_state()`.
1452 ///
1453 ///
1454 ///
1455 ///
1456 /// #### `state-flags-changed`
1457 /// The ::state-flags-changed signal is emitted when the widget state
1458 /// changes, see [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
1459 ///
1460 ///
1461 ///
1462 ///
1463 /// #### `style-set`
1464 /// The ::style-set signal is emitted when a new style has been set
1465 /// on a widget. Note that style-modifying functions like
1466 /// `gtk_widget_modify_base()` also cause this signal to be emitted.
1467 ///
1468 /// Note that this signal is emitted for changes to the deprecated
1469 /// `GtkStyle`. To track changes to the [`StyleContext`][crate::StyleContext] associated
1470 /// with a widget, use the [`style-updated`][struct@crate::Widget#style-updated] signal.
1471 ///
1472 ///
1473 ///
1474 ///
1475 /// #### `style-updated`
1476 /// The ::style-updated signal is a convenience signal that is emitted when the
1477 /// [`changed`][struct@crate::StyleContext#changed] signal is emitted on the `widget`'s associated
1478 /// [`StyleContext`][crate::StyleContext] as returned by [`WidgetExt::style_context()`][crate::prelude::WidgetExt::style_context()].
1479 ///
1480 /// Note that style-modifying functions like `gtk_widget_override_color()` also
1481 /// cause this signal to be emitted.
1482 ///
1483 ///
1484 ///
1485 ///
1486 /// #### `touch-event`
1487 ///
1488 ///
1489 ///
1490 /// #### `unmap`
1491 /// The ::unmap signal is emitted when `widget` is going to be unmapped, which
1492 /// means that either it or any of its parents up to the toplevel widget have
1493 /// been set as hidden.
1494 ///
1495 /// As ::unmap indicates that a widget will not be shown any longer, it can be
1496 /// used to, for example, stop an animation on the widget.
1497 ///
1498 ///
1499 ///
1500 ///
1501 /// #### `unmap-event`
1502 /// The ::unmap-event signal will be emitted when the `widget`'s window is
1503 /// unmapped. A window is unmapped when it becomes invisible on the screen.
1504 ///
1505 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1506 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
1507 /// automatically for all new windows.
1508 ///
1509 ///
1510 ///
1511 ///
1512 /// #### `unrealize`
1513 /// The ::unrealize signal is emitted when the [`gdk::Window`][crate::gdk::Window] associated with
1514 /// `widget` is destroyed, which means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been
1515 /// called or the widget has been unmapped (that is, it is going to be
1516 /// hidden).
1517 ///
1518 ///
1519 ///
1520 ///
1521 /// #### `visibility-notify-event`
1522 /// The ::visibility-notify-event will be emitted when the `widget`'s
1523 /// window is obscured or unobscured.
1524 ///
1525 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1526 /// to enable the [`gdk::EventMask::VISIBILITY_NOTIFY_MASK`][crate::gdk::EventMask::VISIBILITY_NOTIFY_MASK] mask.
1527 ///
1528 ///
1529 ///
1530 ///
1531 /// #### `window-state-event`
1532 /// The ::window-state-event will be emitted when the state of the
1533 /// toplevel window associated to the `widget` changes.
1534 ///
1535 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget
1536 /// needs to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable
1537 /// this mask automatically for all new windows.
1538 ///
1539 ///
1540 /// </details>
1541 ///
1542 /// # Implements
1543 ///
1544 /// [`LabelExt`][trait@crate::prelude::LabelExt], [`MiscExt`][trait@crate::prelude::MiscExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
1545 #[doc(alias = "GtkLabel")]
1546 pub struct Label(Object<ffi::GtkLabel, ffi::GtkLabelClass>) @extends Misc, Widget, @implements Buildable;
1547
1548 match fn {
1549 type_ => || ffi::gtk_label_get_type(),
1550 }
1551}
1552
1553impl Label {
1554 pub const NONE: Option<&'static Label> = None;
1555
1556 /// Creates a new label with the given text inside it. You can
1557 /// pass [`None`] to get an empty label widget.
1558 /// ## `str`
1559 /// The text of the label
1560 ///
1561 /// # Returns
1562 ///
1563 /// the new [`Label`][crate::Label]
1564 #[doc(alias = "gtk_label_new")]
1565 pub fn new(str: Option<&str>) -> Label {
1566 assert_initialized_main_thread!();
1567 unsafe { Widget::from_glib_none(ffi::gtk_label_new(str.to_glib_none().0)).unsafe_cast() }
1568 }
1569
1570 /// Creates a new [`Label`][crate::Label], containing the text in `str`.
1571 ///
1572 /// If characters in `str` are preceded by an underscore, they are
1573 /// underlined. If you need a literal underscore character in a label, use
1574 /// '__' (two underscores). The first underlined character represents a
1575 /// keyboard accelerator called a mnemonic. The mnemonic key can be used
1576 /// to activate another widget, chosen automatically, or explicitly using
1577 /// [`LabelExt::set_mnemonic_widget()`][crate::prelude::LabelExt::set_mnemonic_widget()].
1578 ///
1579 /// If [`LabelExt::set_mnemonic_widget()`][crate::prelude::LabelExt::set_mnemonic_widget()] is not called, then the first
1580 /// activatable ancestor of the [`Label`][crate::Label] will be chosen as the mnemonic
1581 /// widget. For instance, if the label is inside a button or menu item,
1582 /// the button or menu item will automatically become the mnemonic widget
1583 /// and be activated by the mnemonic.
1584 /// ## `str`
1585 /// The text of the label, with an underscore in front of the
1586 /// mnemonic character
1587 ///
1588 /// # Returns
1589 ///
1590 /// the new [`Label`][crate::Label]
1591 #[doc(alias = "gtk_label_new_with_mnemonic")]
1592 #[doc(alias = "new_with_mnemonic")]
1593 pub fn with_mnemonic(str: &str) -> Label {
1594 assert_initialized_main_thread!();
1595 unsafe {
1596 Widget::from_glib_none(ffi::gtk_label_new_with_mnemonic(str.to_glib_none().0))
1597 .unsafe_cast()
1598 }
1599 }
1600
1601 // rustdoc-stripper-ignore-next
1602 /// Creates a new builder-pattern struct instance to construct [`Label`] objects.
1603 ///
1604 /// This method returns an instance of [`LabelBuilder`](crate::builders::LabelBuilder) which can be used to create [`Label`] objects.
1605 pub fn builder() -> LabelBuilder {
1606 LabelBuilder::new()
1607 }
1608}
1609
1610impl Default for Label {
1611 fn default() -> Self {
1612 glib::object::Object::new::<Self>()
1613 }
1614}
1615
1616// rustdoc-stripper-ignore-next
1617/// A [builder-pattern] type to construct [`Label`] objects.
1618///
1619/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1620#[must_use = "The builder must be built to be used"]
1621pub struct LabelBuilder {
1622 builder: glib::object::ObjectBuilder<'static, Label>,
1623}
1624
1625impl LabelBuilder {
1626 fn new() -> Self {
1627 Self {
1628 builder: glib::object::Object::builder(),
1629 }
1630 }
1631
1632 /// The angle that the baseline of the label makes with the horizontal,
1633 /// in degrees, measured counterclockwise. An angle of 90 reads from
1634 /// from bottom to top, an angle of 270, from top to bottom. Ignored
1635 /// if the label is selectable.
1636 pub fn angle(self, angle: f64) -> Self {
1637 Self {
1638 builder: self.builder.property("angle", angle),
1639 }
1640 }
1641
1642 pub fn attributes(self, attributes: &pango::AttrList) -> Self {
1643 Self {
1644 builder: self.builder.property("attributes", attributes.clone()),
1645 }
1646 }
1647
1648 /// The preferred place to ellipsize the string, if the label does
1649 /// not have enough room to display the entire string, specified as a
1650 /// [`pango::EllipsizeMode`][crate::pango::EllipsizeMode].
1651 ///
1652 /// Note that setting this property to a value other than
1653 /// [`pango::EllipsizeMode::None`][crate::pango::EllipsizeMode::None] has the side-effect that the label requests
1654 /// only enough space to display the ellipsis "...". In particular, this
1655 /// means that ellipsizing labels do not work well in notebook tabs, unless
1656 /// the [`Notebook`][crate::Notebook] tab-expand child property is set to [`true`]. Other ways
1657 /// to set a label's width are [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] and
1658 /// [`LabelExt::set_width_chars()`][crate::prelude::LabelExt::set_width_chars()].
1659 pub fn ellipsize(self, ellipsize: pango::EllipsizeMode) -> Self {
1660 Self {
1661 builder: self.builder.property("ellipsize", ellipsize),
1662 }
1663 }
1664
1665 pub fn justify(self, justify: Justification) -> Self {
1666 Self {
1667 builder: self.builder.property("justify", justify),
1668 }
1669 }
1670
1671 /// The contents of the label.
1672 ///
1673 /// If the string contains [Pango XML markup][PangoMarkupFormat], you will
1674 /// have to set the [`use-markup`][struct@crate::Label#use-markup] property to [`true`] in order for the
1675 /// label to display the markup attributes. See also [`LabelExt::set_markup()`][crate::prelude::LabelExt::set_markup()]
1676 /// for a convenience function that sets both this property and the
1677 /// [`use-markup`][struct@crate::Label#use-markup] property at the same time.
1678 ///
1679 /// If the string contains underlines acting as mnemonics, you will have to
1680 /// set the [`use-underline`][struct@crate::Label#use-underline] property to [`true`] in order for the label
1681 /// to display them.
1682 pub fn label(self, label: impl Into<glib::GString>) -> Self {
1683 Self {
1684 builder: self.builder.property("label", label.into()),
1685 }
1686 }
1687
1688 /// The number of lines to which an ellipsized, wrapping label
1689 /// should be limited. This property has no effect if the
1690 /// label is not wrapping or ellipsized. Set this property to
1691 /// -1 if you don't want to limit the number of lines.
1692 pub fn lines(self, lines: i32) -> Self {
1693 Self {
1694 builder: self.builder.property("lines", lines),
1695 }
1696 }
1697
1698 /// The desired maximum width of the label, in characters. If this property
1699 /// is set to -1, the width will be calculated automatically.
1700 ///
1701 /// See the section on [text layout][label-text-layout]
1702 /// for details of how [`width-chars`][struct@crate::Label#width-chars] and [`max-width-chars`][struct@crate::Label#max-width-chars]
1703 /// determine the width of ellipsized and wrapped labels.
1704 pub fn max_width_chars(self, max_width_chars: i32) -> Self {
1705 Self {
1706 builder: self.builder.property("max-width-chars", max_width_chars),
1707 }
1708 }
1709
1710 pub fn mnemonic_widget(self, mnemonic_widget: &impl IsA<Widget>) -> Self {
1711 Self {
1712 builder: self
1713 .builder
1714 .property("mnemonic-widget", mnemonic_widget.clone().upcast()),
1715 }
1716 }
1717
1718 pub fn pattern(self, pattern: impl Into<glib::GString>) -> Self {
1719 Self {
1720 builder: self.builder.property("pattern", pattern.into()),
1721 }
1722 }
1723
1724 pub fn selectable(self, selectable: bool) -> Self {
1725 Self {
1726 builder: self.builder.property("selectable", selectable),
1727 }
1728 }
1729
1730 /// Whether the label is in single line mode. In single line mode,
1731 /// the height of the label does not depend on the actual text, it
1732 /// is always set to ascent + descent of the font. This can be an
1733 /// advantage in situations where resizing the label because of text
1734 /// changes would be distracting, e.g. in a statusbar.
1735 pub fn single_line_mode(self, single_line_mode: bool) -> Self {
1736 Self {
1737 builder: self.builder.property("single-line-mode", single_line_mode),
1738 }
1739 }
1740
1741 /// Set this property to [`true`] to make the label track which links
1742 /// have been visited. It will then apply the [`StateFlags::VISITED`][crate::StateFlags::VISITED]
1743 /// when rendering this link, in addition to [`StateFlags::LINK`][crate::StateFlags::LINK].
1744 pub fn track_visited_links(self, track_visited_links: bool) -> Self {
1745 Self {
1746 builder: self
1747 .builder
1748 .property("track-visited-links", track_visited_links),
1749 }
1750 }
1751
1752 pub fn use_markup(self, use_markup: bool) -> Self {
1753 Self {
1754 builder: self.builder.property("use-markup", use_markup),
1755 }
1756 }
1757
1758 pub fn use_underline(self, use_underline: bool) -> Self {
1759 Self {
1760 builder: self.builder.property("use-underline", use_underline),
1761 }
1762 }
1763
1764 /// The desired width of the label, in characters. If this property is set to
1765 /// -1, the width will be calculated automatically.
1766 ///
1767 /// See the section on [text layout][label-text-layout]
1768 /// for details of how [`width-chars`][struct@crate::Label#width-chars] and [`max-width-chars`][struct@crate::Label#max-width-chars]
1769 /// determine the width of ellipsized and wrapped labels.
1770 pub fn width_chars(self, width_chars: i32) -> Self {
1771 Self {
1772 builder: self.builder.property("width-chars", width_chars),
1773 }
1774 }
1775
1776 pub fn wrap(self, wrap: bool) -> Self {
1777 Self {
1778 builder: self.builder.property("wrap", wrap),
1779 }
1780 }
1781
1782 /// If line wrapping is on (see the [`wrap`][struct@crate::Label#wrap] property) this controls
1783 /// how the line wrapping is done. The default is [`pango::WrapMode::Word`][crate::pango::WrapMode::Word], which
1784 /// means wrap on word boundaries.
1785 pub fn wrap_mode(self, wrap_mode: pango::WrapMode) -> Self {
1786 Self {
1787 builder: self.builder.property("wrap-mode", wrap_mode),
1788 }
1789 }
1790
1791 /// The xalign property determines the horizontal aligment of the label text
1792 /// inside the labels size allocation. Compare this to [`halign`][struct@crate::Widget#halign],
1793 /// which determines how the labels size allocation is positioned in the
1794 /// space available for the label.
1795 pub fn xalign(self, xalign: f32) -> Self {
1796 Self {
1797 builder: self.builder.property("xalign", xalign),
1798 }
1799 }
1800
1801 /// The yalign property determines the vertical aligment of the label text
1802 /// inside the labels size allocation. Compare this to [`valign`][struct@crate::Widget#valign],
1803 /// which determines how the labels size allocation is positioned in the
1804 /// space available for the label.
1805 pub fn yalign(self, yalign: f32) -> Self {
1806 Self {
1807 builder: self.builder.property("yalign", yalign),
1808 }
1809 }
1810
1811 pub fn app_paintable(self, app_paintable: bool) -> Self {
1812 Self {
1813 builder: self.builder.property("app-paintable", app_paintable),
1814 }
1815 }
1816
1817 pub fn can_default(self, can_default: bool) -> Self {
1818 Self {
1819 builder: self.builder.property("can-default", can_default),
1820 }
1821 }
1822
1823 pub fn can_focus(self, can_focus: bool) -> Self {
1824 Self {
1825 builder: self.builder.property("can-focus", can_focus),
1826 }
1827 }
1828
1829 pub fn events(self, events: gdk::EventMask) -> Self {
1830 Self {
1831 builder: self.builder.property("events", events),
1832 }
1833 }
1834
1835 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
1836 pub fn expand(self, expand: bool) -> Self {
1837 Self {
1838 builder: self.builder.property("expand", expand),
1839 }
1840 }
1841
1842 /// Whether the widget should grab focus when it is clicked with the mouse.
1843 ///
1844 /// This property is only relevant for widgets that can take focus.
1845 ///
1846 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
1847 /// GtkComboBox) implemented this property individually.
1848 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1849 Self {
1850 builder: self.builder.property("focus-on-click", focus_on_click),
1851 }
1852 }
1853
1854 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
1855 pub fn halign(self, halign: Align) -> Self {
1856 Self {
1857 builder: self.builder.property("halign", halign),
1858 }
1859 }
1860
1861 pub fn has_default(self, has_default: bool) -> Self {
1862 Self {
1863 builder: self.builder.property("has-default", has_default),
1864 }
1865 }
1866
1867 pub fn has_focus(self, has_focus: bool) -> Self {
1868 Self {
1869 builder: self.builder.property("has-focus", has_focus),
1870 }
1871 }
1872
1873 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
1874 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
1875 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
1876 /// whether it will provide a tooltip or not.
1877 ///
1878 /// Note that setting this property to [`true`] for the first time will change
1879 /// the event masks of the GdkWindows of this widget to include leave-notify
1880 /// and motion-notify events. This cannot and will not be undone when the
1881 /// property is set to [`false`] again.
1882 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1883 Self {
1884 builder: self.builder.property("has-tooltip", has_tooltip),
1885 }
1886 }
1887
1888 pub fn height_request(self, height_request: i32) -> Self {
1889 Self {
1890 builder: self.builder.property("height-request", height_request),
1891 }
1892 }
1893
1894 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
1895 pub fn hexpand(self, hexpand: bool) -> Self {
1896 Self {
1897 builder: self.builder.property("hexpand", hexpand),
1898 }
1899 }
1900
1901 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
1902 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1903 Self {
1904 builder: self.builder.property("hexpand-set", hexpand_set),
1905 }
1906 }
1907
1908 pub fn is_focus(self, is_focus: bool) -> Self {
1909 Self {
1910 builder: self.builder.property("is-focus", is_focus),
1911 }
1912 }
1913
1914 /// Sets all four sides' margin at once. If read, returns max
1915 /// margin on any side.
1916 pub fn margin(self, margin: i32) -> Self {
1917 Self {
1918 builder: self.builder.property("margin", margin),
1919 }
1920 }
1921
1922 /// Margin on bottom side of widget.
1923 ///
1924 /// This property adds margin outside of the widget's normal size
1925 /// request, the margin will be added in addition to the size from
1926 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1927 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1928 Self {
1929 builder: self.builder.property("margin-bottom", margin_bottom),
1930 }
1931 }
1932
1933 /// Margin on end of widget, horizontally. This property supports
1934 /// left-to-right and right-to-left text directions.
1935 ///
1936 /// This property adds margin outside of the widget's normal size
1937 /// request, the margin will be added in addition to the size from
1938 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1939 pub fn margin_end(self, margin_end: i32) -> Self {
1940 Self {
1941 builder: self.builder.property("margin-end", margin_end),
1942 }
1943 }
1944
1945 /// Margin on start of widget, horizontally. This property supports
1946 /// left-to-right and right-to-left text directions.
1947 ///
1948 /// This property adds margin outside of the widget's normal size
1949 /// request, the margin will be added in addition to the size from
1950 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1951 pub fn margin_start(self, margin_start: i32) -> Self {
1952 Self {
1953 builder: self.builder.property("margin-start", margin_start),
1954 }
1955 }
1956
1957 /// Margin on top side of widget.
1958 ///
1959 /// This property adds margin outside of the widget's normal size
1960 /// request, the margin will be added in addition to the size from
1961 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1962 pub fn margin_top(self, margin_top: i32) -> Self {
1963 Self {
1964 builder: self.builder.property("margin-top", margin_top),
1965 }
1966 }
1967
1968 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1969 Self {
1970 builder: self.builder.property("name", name.into()),
1971 }
1972 }
1973
1974 pub fn no_show_all(self, no_show_all: bool) -> Self {
1975 Self {
1976 builder: self.builder.property("no-show-all", no_show_all),
1977 }
1978 }
1979
1980 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
1981 /// more details about window opacity.
1982 ///
1983 /// Before 3.8 this was only available in GtkWindow
1984 pub fn opacity(self, opacity: f64) -> Self {
1985 Self {
1986 builder: self.builder.property("opacity", opacity),
1987 }
1988 }
1989
1990 pub fn parent(self, parent: &impl IsA<Container>) -> Self {
1991 Self {
1992 builder: self.builder.property("parent", parent.clone().upcast()),
1993 }
1994 }
1995
1996 pub fn receives_default(self, receives_default: bool) -> Self {
1997 Self {
1998 builder: self.builder.property("receives-default", receives_default),
1999 }
2000 }
2001
2002 pub fn sensitive(self, sensitive: bool) -> Self {
2003 Self {
2004 builder: self.builder.property("sensitive", sensitive),
2005 }
2006 }
2007
2008 /// Sets the text of tooltip to be the given string, which is marked up
2009 /// with the [Pango text markup language][PangoMarkupFormat].
2010 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
2011 ///
2012 /// This is a convenience property which will take care of getting the
2013 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
2014 /// will automatically be set to [`true`] and there will be taken care of
2015 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
2016 ///
2017 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
2018 /// are set, the last one wins.
2019 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
2020 Self {
2021 builder: self
2022 .builder
2023 .property("tooltip-markup", tooltip_markup.into()),
2024 }
2025 }
2026
2027 /// Sets the text of tooltip to be the given string.
2028 ///
2029 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
2030 ///
2031 /// This is a convenience property which will take care of getting the
2032 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
2033 /// will automatically be set to [`true`] and there will be taken care of
2034 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
2035 ///
2036 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
2037 /// are set, the last one wins.
2038 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
2039 Self {
2040 builder: self.builder.property("tooltip-text", tooltip_text.into()),
2041 }
2042 }
2043
2044 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
2045 pub fn valign(self, valign: Align) -> Self {
2046 Self {
2047 builder: self.builder.property("valign", valign),
2048 }
2049 }
2050
2051 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
2052 pub fn vexpand(self, vexpand: bool) -> Self {
2053 Self {
2054 builder: self.builder.property("vexpand", vexpand),
2055 }
2056 }
2057
2058 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
2059 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
2060 Self {
2061 builder: self.builder.property("vexpand-set", vexpand_set),
2062 }
2063 }
2064
2065 pub fn visible(self, visible: bool) -> Self {
2066 Self {
2067 builder: self.builder.property("visible", visible),
2068 }
2069 }
2070
2071 pub fn width_request(self, width_request: i32) -> Self {
2072 Self {
2073 builder: self.builder.property("width-request", width_request),
2074 }
2075 }
2076
2077 // rustdoc-stripper-ignore-next
2078 /// Build the [`Label`].
2079 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
2080 pub fn build(self) -> Label {
2081 assert_initialized_main_thread!();
2082 self.builder.build()
2083 }
2084}
2085
2086/// Trait containing all [`struct@Label`] methods.
2087///
2088/// # Implementors
2089///
2090/// [`AccelLabel`][struct@crate::AccelLabel], [`Label`][struct@crate::Label]
2091pub trait LabelExt: IsA<Label> + 'static {
2092 /// Gets the angle of rotation for the label. See
2093 /// [`set_angle()`][Self::set_angle()].
2094 ///
2095 /// # Returns
2096 ///
2097 /// the angle of rotation for the label
2098 #[doc(alias = "gtk_label_get_angle")]
2099 #[doc(alias = "get_angle")]
2100 fn angle(&self) -> f64 {
2101 unsafe { ffi::gtk_label_get_angle(self.as_ref().to_glib_none().0) }
2102 }
2103
2104 /// Gets the attribute list that was set on the label using
2105 /// [`set_attributes()`][Self::set_attributes()], if any. This function does
2106 /// not reflect attributes that come from the labels markup
2107 /// (see [`set_markup()`][Self::set_markup()]). If you want to get the
2108 /// effective attributes for the label, use
2109 /// pango_layout_get_attribute (gtk_label_get_layout (label)).
2110 ///
2111 /// # Returns
2112 ///
2113 /// the attribute list, or [`None`]
2114 /// if none was set.
2115 #[doc(alias = "gtk_label_get_attributes")]
2116 #[doc(alias = "get_attributes")]
2117 fn attributes(&self) -> Option<pango::AttrList> {
2118 unsafe {
2119 from_glib_none(ffi::gtk_label_get_attributes(
2120 self.as_ref().to_glib_none().0,
2121 ))
2122 }
2123 }
2124
2125 /// Returns the URI for the currently active link in the label.
2126 /// The active link is the one under the mouse pointer or, in a
2127 /// selectable label, the link in which the text cursor is currently
2128 /// positioned.
2129 ///
2130 /// This function is intended for use in a [`activate-link`][struct@crate::Label#activate-link] handler
2131 /// or for use in a [`query-tooltip`][struct@crate::Widget#query-tooltip] handler.
2132 ///
2133 /// # Returns
2134 ///
2135 /// the currently active URI. The string is owned by GTK+ and must
2136 /// not be freed or modified.
2137 #[doc(alias = "gtk_label_get_current_uri")]
2138 #[doc(alias = "get_current_uri")]
2139 fn current_uri(&self) -> Option<glib::GString> {
2140 unsafe {
2141 from_glib_none(ffi::gtk_label_get_current_uri(
2142 self.as_ref().to_glib_none().0,
2143 ))
2144 }
2145 }
2146
2147 /// Returns the ellipsizing position of the label. See [`set_ellipsize()`][Self::set_ellipsize()].
2148 ///
2149 /// # Returns
2150 ///
2151 /// [`pango::EllipsizeMode`][crate::pango::EllipsizeMode]
2152 #[doc(alias = "gtk_label_get_ellipsize")]
2153 #[doc(alias = "get_ellipsize")]
2154 fn ellipsize(&self) -> pango::EllipsizeMode {
2155 unsafe { from_glib(ffi::gtk_label_get_ellipsize(self.as_ref().to_glib_none().0)) }
2156 }
2157
2158 /// Returns the justification of the label. See [`set_justify()`][Self::set_justify()].
2159 ///
2160 /// # Returns
2161 ///
2162 /// [`Justification`][crate::Justification]
2163 #[doc(alias = "gtk_label_get_justify")]
2164 #[doc(alias = "get_justify")]
2165 fn justify(&self) -> Justification {
2166 unsafe { from_glib(ffi::gtk_label_get_justify(self.as_ref().to_glib_none().0)) }
2167 }
2168
2169 /// Fetches the text from a label widget including any embedded
2170 /// underlines indicating mnemonics and Pango markup. (See
2171 /// [`text()`][Self::text()]).
2172 ///
2173 /// # Returns
2174 ///
2175 /// the text of the label widget. This string is
2176 /// owned by the widget and must not be modified or freed.
2177 #[doc(alias = "gtk_label_get_label")]
2178 #[doc(alias = "get_label")]
2179 fn label(&self) -> glib::GString {
2180 unsafe { from_glib_none(ffi::gtk_label_get_label(self.as_ref().to_glib_none().0)) }
2181 }
2182
2183 /// Gets the [`pango::Layout`][crate::pango::Layout] used to display the label.
2184 /// The layout is useful to e.g. convert text positions to
2185 /// pixel positions, in combination with [`layout_offsets()`][Self::layout_offsets()].
2186 /// The returned layout is owned by the `self` so need not be
2187 /// freed by the caller. The `self` is free to recreate its layout at
2188 /// any time, so it should be considered read-only.
2189 ///
2190 /// # Returns
2191 ///
2192 /// the [`pango::Layout`][crate::pango::Layout] for this label
2193 #[doc(alias = "gtk_label_get_layout")]
2194 #[doc(alias = "get_layout")]
2195 fn layout(&self) -> Option<pango::Layout> {
2196 unsafe { from_glib_none(ffi::gtk_label_get_layout(self.as_ref().to_glib_none().0)) }
2197 }
2198
2199 /// Obtains the coordinates where the label will draw the [`pango::Layout`][crate::pango::Layout]
2200 /// representing the text in the label; useful to convert mouse events
2201 /// into coordinates inside the [`pango::Layout`][crate::pango::Layout], e.g. to take some action
2202 /// if some part of the label is clicked. Of course you will need to
2203 /// create a [`EventBox`][crate::EventBox] to receive the events, and pack the label
2204 /// inside it, since labels are windowless (they return [`false`] from
2205 /// [`WidgetExt::has_window()`][crate::prelude::WidgetExt::has_window()]). Remember
2206 /// when using the [`pango::Layout`][crate::pango::Layout] functions you need to convert to
2207 /// and from pixels using PANGO_PIXELS() or `PANGO_SCALE`.
2208 ///
2209 /// # Returns
2210 ///
2211 ///
2212 /// ## `x`
2213 /// location to store X offset of layout, or [`None`]
2214 ///
2215 /// ## `y`
2216 /// location to store Y offset of layout, or [`None`]
2217 #[doc(alias = "gtk_label_get_layout_offsets")]
2218 #[doc(alias = "get_layout_offsets")]
2219 fn layout_offsets(&self) -> (i32, i32) {
2220 unsafe {
2221 let mut x = std::mem::MaybeUninit::uninit();
2222 let mut y = std::mem::MaybeUninit::uninit();
2223 ffi::gtk_label_get_layout_offsets(
2224 self.as_ref().to_glib_none().0,
2225 x.as_mut_ptr(),
2226 y.as_mut_ptr(),
2227 );
2228 (x.assume_init(), y.assume_init())
2229 }
2230 }
2231
2232 /// Returns whether lines in the label are automatically wrapped.
2233 /// See [`set_line_wrap()`][Self::set_line_wrap()].
2234 ///
2235 /// # Returns
2236 ///
2237 /// [`true`] if the lines of the label are automatically wrapped.
2238 #[doc(alias = "gtk_label_get_line_wrap")]
2239 #[doc(alias = "get_line_wrap")]
2240 fn is_line_wrap(&self) -> bool {
2241 unsafe { from_glib(ffi::gtk_label_get_line_wrap(self.as_ref().to_glib_none().0)) }
2242 }
2243
2244 /// Returns line wrap mode used by the label. See [`set_line_wrap_mode()`][Self::set_line_wrap_mode()].
2245 ///
2246 /// # Returns
2247 ///
2248 /// [`true`] if the lines of the label are automatically wrapped.
2249 #[doc(alias = "gtk_label_get_line_wrap_mode")]
2250 #[doc(alias = "get_line_wrap_mode")]
2251 fn line_wrap_mode(&self) -> pango::WrapMode {
2252 unsafe {
2253 from_glib(ffi::gtk_label_get_line_wrap_mode(
2254 self.as_ref().to_glib_none().0,
2255 ))
2256 }
2257 }
2258
2259 /// Gets the number of lines to which an ellipsized, wrapping
2260 /// label should be limited. See [`set_lines()`][Self::set_lines()].
2261 ///
2262 /// # Returns
2263 ///
2264 /// The number of lines
2265 #[doc(alias = "gtk_label_get_lines")]
2266 #[doc(alias = "get_lines")]
2267 fn lines(&self) -> i32 {
2268 unsafe { ffi::gtk_label_get_lines(self.as_ref().to_glib_none().0) }
2269 }
2270
2271 /// Retrieves the desired maximum width of `self`, in characters. See
2272 /// [`set_width_chars()`][Self::set_width_chars()].
2273 ///
2274 /// # Returns
2275 ///
2276 /// the maximum width of the label in characters.
2277 #[doc(alias = "gtk_label_get_max_width_chars")]
2278 #[doc(alias = "get_max_width_chars")]
2279 #[doc(alias = "max-width-chars")]
2280 fn max_width_chars(&self) -> i32 {
2281 unsafe { ffi::gtk_label_get_max_width_chars(self.as_ref().to_glib_none().0) }
2282 }
2283
2284 /// If the label has been set so that it has an mnemonic key this function
2285 /// returns the keyval used for the mnemonic accelerator. If there is no
2286 /// mnemonic set up it returns `GDK_KEY_VoidSymbol`.
2287 ///
2288 /// # Returns
2289 ///
2290 /// GDK keyval usable for accelerators, or `GDK_KEY_VoidSymbol`
2291 #[doc(alias = "gtk_label_get_mnemonic_keyval")]
2292 #[doc(alias = "get_mnemonic_keyval")]
2293 #[doc(alias = "mnemonic-keyval")]
2294 fn mnemonic_keyval(&self) -> u32 {
2295 unsafe { ffi::gtk_label_get_mnemonic_keyval(self.as_ref().to_glib_none().0) }
2296 }
2297
2298 /// Retrieves the target of the mnemonic (keyboard shortcut) of this
2299 /// label. See [`set_mnemonic_widget()`][Self::set_mnemonic_widget()].
2300 ///
2301 /// # Returns
2302 ///
2303 /// the target of the label’s mnemonic,
2304 /// or [`None`] if none has been set and the default algorithm will be used.
2305 #[doc(alias = "gtk_label_get_mnemonic_widget")]
2306 #[doc(alias = "get_mnemonic_widget")]
2307 #[doc(alias = "mnemonic-widget")]
2308 fn mnemonic_widget(&self) -> Option<Widget> {
2309 unsafe {
2310 from_glib_none(ffi::gtk_label_get_mnemonic_widget(
2311 self.as_ref().to_glib_none().0,
2312 ))
2313 }
2314 }
2315
2316 /// Gets the value set by [`set_selectable()`][Self::set_selectable()].
2317 ///
2318 /// # Returns
2319 ///
2320 /// [`true`] if the user can copy text from the label
2321 #[doc(alias = "gtk_label_get_selectable")]
2322 #[doc(alias = "get_selectable")]
2323 #[doc(alias = "selectable")]
2324 fn is_selectable(&self) -> bool {
2325 unsafe {
2326 from_glib(ffi::gtk_label_get_selectable(
2327 self.as_ref().to_glib_none().0,
2328 ))
2329 }
2330 }
2331
2332 /// Gets the selected range of characters in the label, returning [`true`]
2333 /// if there’s a selection.
2334 ///
2335 /// # Returns
2336 ///
2337 /// [`true`] if selection is non-empty
2338 ///
2339 /// ## `start`
2340 /// return location for start of selection, as a character offset
2341 ///
2342 /// ## `end`
2343 /// return location for end of selection, as a character offset
2344 #[doc(alias = "gtk_label_get_selection_bounds")]
2345 #[doc(alias = "get_selection_bounds")]
2346 fn selection_bounds(&self) -> Option<(i32, i32)> {
2347 unsafe {
2348 let mut start = std::mem::MaybeUninit::uninit();
2349 let mut end = std::mem::MaybeUninit::uninit();
2350 let ret = from_glib(ffi::gtk_label_get_selection_bounds(
2351 self.as_ref().to_glib_none().0,
2352 start.as_mut_ptr(),
2353 end.as_mut_ptr(),
2354 ));
2355 if ret {
2356 Some((start.assume_init(), end.assume_init()))
2357 } else {
2358 None
2359 }
2360 }
2361 }
2362
2363 /// Returns whether the label is in single line mode.
2364 ///
2365 /// # Returns
2366 ///
2367 /// [`true`] when the label is in single line mode.
2368 #[doc(alias = "gtk_label_get_single_line_mode")]
2369 #[doc(alias = "get_single_line_mode")]
2370 #[doc(alias = "single-line-mode")]
2371 fn is_single_line_mode(&self) -> bool {
2372 unsafe {
2373 from_glib(ffi::gtk_label_get_single_line_mode(
2374 self.as_ref().to_glib_none().0,
2375 ))
2376 }
2377 }
2378
2379 /// Fetches the text from a label widget, as displayed on the
2380 /// screen. This does not include any embedded underlines
2381 /// indicating mnemonics or Pango markup. (See [`label()`][Self::label()])
2382 ///
2383 /// # Returns
2384 ///
2385 /// the text in the label widget. This is the internal
2386 /// string used by the label, and must not be modified.
2387 #[doc(alias = "gtk_label_get_text")]
2388 #[doc(alias = "get_text")]
2389 fn text(&self) -> glib::GString {
2390 unsafe { from_glib_none(ffi::gtk_label_get_text(self.as_ref().to_glib_none().0)) }
2391 }
2392
2393 /// Returns whether the label is currently keeping track
2394 /// of clicked links.
2395 ///
2396 /// # Returns
2397 ///
2398 /// [`true`] if clicked links are remembered
2399 #[doc(alias = "gtk_label_get_track_visited_links")]
2400 #[doc(alias = "get_track_visited_links")]
2401 #[doc(alias = "track-visited-links")]
2402 fn tracks_visited_links(&self) -> bool {
2403 unsafe {
2404 from_glib(ffi::gtk_label_get_track_visited_links(
2405 self.as_ref().to_glib_none().0,
2406 ))
2407 }
2408 }
2409
2410 /// Returns whether the label’s text is interpreted as marked up with
2411 /// the [Pango text markup language][PangoMarkupFormat].
2412 /// See gtk_label_set_use_markup ().
2413 ///
2414 /// # Returns
2415 ///
2416 /// [`true`] if the label’s text will be parsed for markup.
2417 #[doc(alias = "gtk_label_get_use_markup")]
2418 #[doc(alias = "get_use_markup")]
2419 #[doc(alias = "use-markup")]
2420 fn uses_markup(&self) -> bool {
2421 unsafe {
2422 from_glib(ffi::gtk_label_get_use_markup(
2423 self.as_ref().to_glib_none().0,
2424 ))
2425 }
2426 }
2427
2428 /// Returns whether an embedded underline in the label indicates a
2429 /// mnemonic. See [`set_use_underline()`][Self::set_use_underline()].
2430 ///
2431 /// # Returns
2432 ///
2433 /// [`true`] whether an embedded underline in the label indicates
2434 /// the mnemonic accelerator keys.
2435 #[doc(alias = "gtk_label_get_use_underline")]
2436 #[doc(alias = "get_use_underline")]
2437 #[doc(alias = "use-underline")]
2438 fn uses_underline(&self) -> bool {
2439 unsafe {
2440 from_glib(ffi::gtk_label_get_use_underline(
2441 self.as_ref().to_glib_none().0,
2442 ))
2443 }
2444 }
2445
2446 /// Retrieves the desired width of `self`, in characters. See
2447 /// [`set_width_chars()`][Self::set_width_chars()].
2448 ///
2449 /// # Returns
2450 ///
2451 /// the width of the label in characters.
2452 #[doc(alias = "gtk_label_get_width_chars")]
2453 #[doc(alias = "get_width_chars")]
2454 #[doc(alias = "width-chars")]
2455 fn width_chars(&self) -> i32 {
2456 unsafe { ffi::gtk_label_get_width_chars(self.as_ref().to_glib_none().0) }
2457 }
2458
2459 /// Gets the [`xalign`][struct@crate::Label#xalign] property for `self`.
2460 ///
2461 /// # Returns
2462 ///
2463 /// the xalign property
2464 #[doc(alias = "gtk_label_get_xalign")]
2465 #[doc(alias = "get_xalign")]
2466 fn xalign(&self) -> f32 {
2467 unsafe { ffi::gtk_label_get_xalign(self.as_ref().to_glib_none().0) }
2468 }
2469
2470 /// Gets the [`yalign`][struct@crate::Label#yalign] property for `self`.
2471 ///
2472 /// # Returns
2473 ///
2474 /// the yalign property
2475 #[doc(alias = "gtk_label_get_yalign")]
2476 #[doc(alias = "get_yalign")]
2477 fn yalign(&self) -> f32 {
2478 unsafe { ffi::gtk_label_get_yalign(self.as_ref().to_glib_none().0) }
2479 }
2480
2481 /// Selects a range of characters in the label, if the label is selectable.
2482 /// See [`set_selectable()`][Self::set_selectable()]. If the label is not selectable,
2483 /// this function has no effect. If `start_offset` or
2484 /// `end_offset` are -1, then the end of the label will be substituted.
2485 /// ## `start_offset`
2486 /// start offset (in characters not bytes)
2487 /// ## `end_offset`
2488 /// end offset (in characters not bytes)
2489 #[doc(alias = "gtk_label_select_region")]
2490 fn select_region(&self, start_offset: i32, end_offset: i32) {
2491 unsafe {
2492 ffi::gtk_label_select_region(self.as_ref().to_glib_none().0, start_offset, end_offset);
2493 }
2494 }
2495
2496 /// Sets the angle of rotation for the label. An angle of 90 reads from
2497 /// from bottom to top, an angle of 270, from top to bottom. The angle
2498 /// setting for the label is ignored if the label is selectable,
2499 /// wrapped, or ellipsized.
2500 /// ## `angle`
2501 /// the angle that the baseline of the label makes with
2502 /// the horizontal, in degrees, measured counterclockwise
2503 #[doc(alias = "gtk_label_set_angle")]
2504 #[doc(alias = "angle")]
2505 fn set_angle(&self, angle: f64) {
2506 unsafe {
2507 ffi::gtk_label_set_angle(self.as_ref().to_glib_none().0, angle);
2508 }
2509 }
2510
2511 /// Sets a [`pango::AttrList`][crate::pango::AttrList]; the attributes in the list are applied to the
2512 /// label text.
2513 ///
2514 /// The attributes set with this function will be applied
2515 /// and merged with any other attributes previously effected by way
2516 /// of the [`use-underline`][struct@crate::Label#use-underline] or [`use-markup`][struct@crate::Label#use-markup] properties.
2517 /// While it is not recommended to mix markup strings with manually set
2518 /// attributes, if you must; know that the attributes will be applied
2519 /// to the label after the markup string is parsed.
2520 /// ## `attrs`
2521 /// a [`pango::AttrList`][crate::pango::AttrList], or [`None`]
2522 #[doc(alias = "gtk_label_set_attributes")]
2523 #[doc(alias = "attributes")]
2524 fn set_attributes(&self, attrs: Option<&pango::AttrList>) {
2525 unsafe {
2526 ffi::gtk_label_set_attributes(self.as_ref().to_glib_none().0, attrs.to_glib_none().0);
2527 }
2528 }
2529
2530 /// Sets the mode used to ellipsize (add an ellipsis: "...") to the text
2531 /// if there is not enough space to render the entire string.
2532 /// ## `mode`
2533 /// a [`pango::EllipsizeMode`][crate::pango::EllipsizeMode]
2534 #[doc(alias = "gtk_label_set_ellipsize")]
2535 #[doc(alias = "ellipsize")]
2536 fn set_ellipsize(&self, mode: pango::EllipsizeMode) {
2537 unsafe {
2538 ffi::gtk_label_set_ellipsize(self.as_ref().to_glib_none().0, mode.into_glib());
2539 }
2540 }
2541
2542 /// Sets the alignment of the lines in the text of the label relative to
2543 /// each other. [`Justification::Left`][crate::Justification::Left] is the default value when the widget is
2544 /// first created with [`Label::new()`][crate::Label::new()]. If you instead want to set the
2545 /// alignment of the label as a whole, use [`WidgetExt::set_halign()`][crate::prelude::WidgetExt::set_halign()] instead.
2546 /// [`set_justify()`][Self::set_justify()] has no effect on labels containing only a
2547 /// single line.
2548 /// ## `jtype`
2549 /// a [`Justification`][crate::Justification]
2550 #[doc(alias = "gtk_label_set_justify")]
2551 #[doc(alias = "justify")]
2552 fn set_justify(&self, jtype: Justification) {
2553 unsafe {
2554 ffi::gtk_label_set_justify(self.as_ref().to_glib_none().0, jtype.into_glib());
2555 }
2556 }
2557
2558 /// Sets the text of the label. The label is interpreted as
2559 /// including embedded underlines and/or Pango markup depending
2560 /// on the values of the [`use-underline`][struct@crate::Label#use-underline] and
2561 /// [`use-markup`][struct@crate::Label#use-markup] properties.
2562 /// ## `str`
2563 /// the new text to set for the label
2564 #[doc(alias = "gtk_label_set_label")]
2565 #[doc(alias = "label")]
2566 fn set_label(&self, str: &str) {
2567 unsafe {
2568 ffi::gtk_label_set_label(self.as_ref().to_glib_none().0, str.to_glib_none().0);
2569 }
2570 }
2571
2572 /// Toggles line wrapping within the [`Label`][crate::Label] widget. [`true`] makes it break
2573 /// lines if text exceeds the widget’s size. [`false`] lets the text get cut off
2574 /// by the edge of the widget if it exceeds the widget size.
2575 ///
2576 /// Note that setting line wrapping to [`true`] does not make the label
2577 /// wrap at its parent container’s width, because GTK+ widgets
2578 /// conceptually can’t make their requisition depend on the parent
2579 /// container’s size. For a label that wraps at a specific position,
2580 /// set the label’s width using [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()].
2581 /// ## `wrap`
2582 /// the setting
2583 #[doc(alias = "gtk_label_set_line_wrap")]
2584 fn set_line_wrap(&self, wrap: bool) {
2585 unsafe {
2586 ffi::gtk_label_set_line_wrap(self.as_ref().to_glib_none().0, wrap.into_glib());
2587 }
2588 }
2589
2590 /// If line wrapping is on (see [`set_line_wrap()`][Self::set_line_wrap()]) this controls how
2591 /// the line wrapping is done. The default is [`pango::WrapMode::Word`][crate::pango::WrapMode::Word] which means
2592 /// wrap on word boundaries.
2593 /// ## `wrap_mode`
2594 /// the line wrapping mode
2595 #[doc(alias = "gtk_label_set_line_wrap_mode")]
2596 fn set_line_wrap_mode(&self, wrap_mode: pango::WrapMode) {
2597 unsafe {
2598 ffi::gtk_label_set_line_wrap_mode(
2599 self.as_ref().to_glib_none().0,
2600 wrap_mode.into_glib(),
2601 );
2602 }
2603 }
2604
2605 /// Sets the number of lines to which an ellipsized, wrapping label
2606 /// should be limited. This has no effect if the label is not wrapping
2607 /// or ellipsized. Set this to -1 if you don’t want to limit the
2608 /// number of lines.
2609 /// ## `lines`
2610 /// the desired number of lines, or -1
2611 #[doc(alias = "gtk_label_set_lines")]
2612 #[doc(alias = "lines")]
2613 fn set_lines(&self, lines: i32) {
2614 unsafe {
2615 ffi::gtk_label_set_lines(self.as_ref().to_glib_none().0, lines);
2616 }
2617 }
2618
2619 /// Parses `str` which is marked up with the
2620 /// [Pango text markup language][PangoMarkupFormat], setting the
2621 /// label’s text and attribute list based on the parse results.
2622 ///
2623 /// If the `str` is external data, you may need to escape it with
2624 /// `g_markup_escape_text()` or `g_markup_printf_escaped()`:
2625 ///
2626 ///
2627 ///
2628 /// **⚠️ The following code is in C ⚠️**
2629 ///
2630 /// ```C
2631 /// GtkWidget *label = gtk_label_new (NULL);
2632 /// const char *str = "some text";
2633 /// const char *format = "<span style=\"italic\">\%s</span>";
2634 /// char *markup;
2635 ///
2636 /// markup = g_markup_printf_escaped (format, str);
2637 /// gtk_label_set_markup (GTK_LABEL (label), markup);
2638 /// g_free (markup);
2639 /// ```
2640 ///
2641 /// This function will set the [`use-markup`][struct@crate::Label#use-markup] property to [`true`] as
2642 /// a side effect.
2643 ///
2644 /// If you set the label contents using the [`label`][struct@crate::Label#label] property you
2645 /// should also ensure that you set the [`use-markup`][struct@crate::Label#use-markup] property
2646 /// accordingly.
2647 ///
2648 /// See also: [`set_text()`][Self::set_text()]
2649 /// ## `str`
2650 /// a markup string (see [Pango markup format][PangoMarkupFormat])
2651 #[doc(alias = "gtk_label_set_markup")]
2652 fn set_markup(&self, str: &str) {
2653 unsafe {
2654 ffi::gtk_label_set_markup(self.as_ref().to_glib_none().0, str.to_glib_none().0);
2655 }
2656 }
2657
2658 /// Parses `str` which is marked up with the
2659 /// [Pango text markup language][PangoMarkupFormat],
2660 /// setting the label’s text and attribute list based on the parse results.
2661 /// If characters in `str` are preceded by an underscore, they are underlined
2662 /// indicating that they represent a keyboard accelerator called a mnemonic.
2663 ///
2664 /// The mnemonic key can be used to activate another widget, chosen
2665 /// automatically, or explicitly using [`set_mnemonic_widget()`][Self::set_mnemonic_widget()].
2666 /// ## `str`
2667 /// a markup string (see
2668 /// [Pango markup format][PangoMarkupFormat])
2669 #[doc(alias = "gtk_label_set_markup_with_mnemonic")]
2670 fn set_markup_with_mnemonic(&self, str: &str) {
2671 unsafe {
2672 ffi::gtk_label_set_markup_with_mnemonic(
2673 self.as_ref().to_glib_none().0,
2674 str.to_glib_none().0,
2675 );
2676 }
2677 }
2678
2679 /// Sets the desired maximum width in characters of `self` to `n_chars`.
2680 /// ## `n_chars`
2681 /// the new desired maximum width, in characters.
2682 #[doc(alias = "gtk_label_set_max_width_chars")]
2683 #[doc(alias = "max-width-chars")]
2684 fn set_max_width_chars(&self, n_chars: i32) {
2685 unsafe {
2686 ffi::gtk_label_set_max_width_chars(self.as_ref().to_glib_none().0, n_chars);
2687 }
2688 }
2689
2690 /// If the label has been set so that it has an mnemonic key (using
2691 /// i.e. [`set_markup_with_mnemonic()`][Self::set_markup_with_mnemonic()],
2692 /// [`set_text_with_mnemonic()`][Self::set_text_with_mnemonic()], [`Label::with_mnemonic()`][crate::Label::with_mnemonic()]
2693 /// or the “use_underline” property) the label can be associated with a
2694 /// widget that is the target of the mnemonic. When the label is inside
2695 /// a widget (like a [`Button`][crate::Button] or a [`Notebook`][crate::Notebook] tab) it is
2696 /// automatically associated with the correct widget, but sometimes
2697 /// (i.e. when the target is a [`Entry`][crate::Entry] next to the label) you need to
2698 /// set it explicitly using this function.
2699 ///
2700 /// The target widget will be accelerated by emitting the
2701 /// GtkWidget::mnemonic-activate signal on it. The default handler for
2702 /// this signal will activate the widget if there are no mnemonic collisions
2703 /// and toggle focus between the colliding widgets otherwise.
2704 /// ## `widget`
2705 /// the target [`Widget`][crate::Widget], or [`None`] to unset
2706 #[doc(alias = "gtk_label_set_mnemonic_widget")]
2707 #[doc(alias = "mnemonic-widget")]
2708 fn set_mnemonic_widget(&self, widget: Option<&impl IsA<Widget>>) {
2709 unsafe {
2710 ffi::gtk_label_set_mnemonic_widget(
2711 self.as_ref().to_glib_none().0,
2712 widget.map(|p| p.as_ref()).to_glib_none().0,
2713 );
2714 }
2715 }
2716
2717 /// The pattern of underlines you want under the existing text within the
2718 /// [`Label`][crate::Label] widget. For example if the current text of the label says
2719 /// “FooBarBaz” passing a pattern of “___ ___” will underline
2720 /// “Foo” and “Baz” but not “Bar”.
2721 /// ## `pattern`
2722 /// The pattern as described above.
2723 #[doc(alias = "gtk_label_set_pattern")]
2724 #[doc(alias = "pattern")]
2725 fn set_pattern(&self, pattern: &str) {
2726 unsafe {
2727 ffi::gtk_label_set_pattern(self.as_ref().to_glib_none().0, pattern.to_glib_none().0);
2728 }
2729 }
2730
2731 /// Selectable labels allow the user to select text from the label, for
2732 /// copy-and-paste.
2733 /// ## `setting`
2734 /// [`true`] to allow selecting text in the label
2735 #[doc(alias = "gtk_label_set_selectable")]
2736 #[doc(alias = "selectable")]
2737 fn set_selectable(&self, setting: bool) {
2738 unsafe {
2739 ffi::gtk_label_set_selectable(self.as_ref().to_glib_none().0, setting.into_glib());
2740 }
2741 }
2742
2743 /// Sets whether the label is in single line mode.
2744 /// ## `single_line_mode`
2745 /// [`true`] if the label should be in single line mode
2746 #[doc(alias = "gtk_label_set_single_line_mode")]
2747 #[doc(alias = "single-line-mode")]
2748 fn set_single_line_mode(&self, single_line_mode: bool) {
2749 unsafe {
2750 ffi::gtk_label_set_single_line_mode(
2751 self.as_ref().to_glib_none().0,
2752 single_line_mode.into_glib(),
2753 );
2754 }
2755 }
2756
2757 /// Sets the text within the [`Label`][crate::Label] widget. It overwrites any text that
2758 /// was there before.
2759 ///
2760 /// This function will clear any previously set mnemonic accelerators, and
2761 /// set the [`use-underline`][struct@crate::Label#use-underline] property to [`false`] as a side effect.
2762 ///
2763 /// This function will set the [`use-markup`][struct@crate::Label#use-markup] property to [`false`]
2764 /// as a side effect.
2765 ///
2766 /// See also: [`set_markup()`][Self::set_markup()]
2767 /// ## `str`
2768 /// The text you want to set
2769 #[doc(alias = "gtk_label_set_text")]
2770 fn set_text(&self, str: &str) {
2771 unsafe {
2772 ffi::gtk_label_set_text(self.as_ref().to_glib_none().0, str.to_glib_none().0);
2773 }
2774 }
2775
2776 /// Sets the label’s text from the string `str`.
2777 /// If characters in `str` are preceded by an underscore, they are underlined
2778 /// indicating that they represent a keyboard accelerator called a mnemonic.
2779 /// The mnemonic key can be used to activate another widget, chosen
2780 /// automatically, or explicitly using [`set_mnemonic_widget()`][Self::set_mnemonic_widget()].
2781 /// ## `str`
2782 /// a string
2783 #[doc(alias = "gtk_label_set_text_with_mnemonic")]
2784 fn set_text_with_mnemonic(&self, str: &str) {
2785 unsafe {
2786 ffi::gtk_label_set_text_with_mnemonic(
2787 self.as_ref().to_glib_none().0,
2788 str.to_glib_none().0,
2789 );
2790 }
2791 }
2792
2793 /// Sets whether the label should keep track of clicked
2794 /// links (and use a different color for them).
2795 /// ## `track_links`
2796 /// [`true`] to track visited links
2797 #[doc(alias = "gtk_label_set_track_visited_links")]
2798 #[doc(alias = "track-visited-links")]
2799 fn set_track_visited_links(&self, track_links: bool) {
2800 unsafe {
2801 ffi::gtk_label_set_track_visited_links(
2802 self.as_ref().to_glib_none().0,
2803 track_links.into_glib(),
2804 );
2805 }
2806 }
2807
2808 /// Sets whether the text of the label contains markup in
2809 /// [Pango’s text markup language][PangoMarkupFormat].
2810 /// See [`set_markup()`][Self::set_markup()].
2811 /// ## `setting`
2812 /// [`true`] if the label’s text should be parsed for markup.
2813 #[doc(alias = "gtk_label_set_use_markup")]
2814 #[doc(alias = "use-markup")]
2815 fn set_use_markup(&self, setting: bool) {
2816 unsafe {
2817 ffi::gtk_label_set_use_markup(self.as_ref().to_glib_none().0, setting.into_glib());
2818 }
2819 }
2820
2821 /// If true, an underline in the text indicates the next character should be
2822 /// used for the mnemonic accelerator key.
2823 /// ## `setting`
2824 /// [`true`] if underlines in the text indicate mnemonics
2825 #[doc(alias = "gtk_label_set_use_underline")]
2826 #[doc(alias = "use-underline")]
2827 fn set_use_underline(&self, setting: bool) {
2828 unsafe {
2829 ffi::gtk_label_set_use_underline(self.as_ref().to_glib_none().0, setting.into_glib());
2830 }
2831 }
2832
2833 /// Sets the desired width in characters of `self` to `n_chars`.
2834 /// ## `n_chars`
2835 /// the new desired width, in characters.
2836 #[doc(alias = "gtk_label_set_width_chars")]
2837 #[doc(alias = "width-chars")]
2838 fn set_width_chars(&self, n_chars: i32) {
2839 unsafe {
2840 ffi::gtk_label_set_width_chars(self.as_ref().to_glib_none().0, n_chars);
2841 }
2842 }
2843
2844 /// Sets the [`xalign`][struct@crate::Label#xalign] property for `self`.
2845 /// ## `xalign`
2846 /// the new xalign value, between 0 and 1
2847 #[doc(alias = "gtk_label_set_xalign")]
2848 #[doc(alias = "xalign")]
2849 fn set_xalign(&self, xalign: f32) {
2850 unsafe {
2851 ffi::gtk_label_set_xalign(self.as_ref().to_glib_none().0, xalign);
2852 }
2853 }
2854
2855 /// Sets the [`yalign`][struct@crate::Label#yalign] property for `self`.
2856 /// ## `yalign`
2857 /// the new yalign value, between 0 and 1
2858 #[doc(alias = "gtk_label_set_yalign")]
2859 #[doc(alias = "yalign")]
2860 fn set_yalign(&self, yalign: f32) {
2861 unsafe {
2862 ffi::gtk_label_set_yalign(self.as_ref().to_glib_none().0, yalign);
2863 }
2864 }
2865
2866 #[doc(alias = "cursor-position")]
2867 fn cursor_position(&self) -> i32 {
2868 ObjectExt::property(self.as_ref(), "cursor-position")
2869 }
2870
2871 #[doc(alias = "selection-bound")]
2872 fn selection_bound(&self) -> i32 {
2873 ObjectExt::property(self.as_ref(), "selection-bound")
2874 }
2875
2876 fn wraps(&self) -> bool {
2877 ObjectExt::property(self.as_ref(), "wrap")
2878 }
2879
2880 fn set_wrap(&self, wrap: bool) {
2881 ObjectExt::set_property(self.as_ref(), "wrap", wrap)
2882 }
2883
2884 /// If line wrapping is on (see the [`wrap`][struct@crate::Label#wrap] property) this controls
2885 /// how the line wrapping is done. The default is [`pango::WrapMode::Word`][crate::pango::WrapMode::Word], which
2886 /// means wrap on word boundaries.
2887 #[doc(alias = "wrap-mode")]
2888 fn wrap_mode(&self) -> pango::WrapMode {
2889 ObjectExt::property(self.as_ref(), "wrap-mode")
2890 }
2891
2892 /// If line wrapping is on (see the [`wrap`][struct@crate::Label#wrap] property) this controls
2893 /// how the line wrapping is done. The default is [`pango::WrapMode::Word`][crate::pango::WrapMode::Word], which
2894 /// means wrap on word boundaries.
2895 #[doc(alias = "wrap-mode")]
2896 fn set_wrap_mode(&self, wrap_mode: pango::WrapMode) {
2897 ObjectExt::set_property(self.as_ref(), "wrap-mode", wrap_mode)
2898 }
2899
2900 /// A [keybinding signal][GtkBindingSignal]
2901 /// which gets emitted when the user activates a link in the label.
2902 ///
2903 /// Applications may also emit the signal with `g_signal_emit_by_name()`
2904 /// if they need to control activation of URIs programmatically.
2905 ///
2906 /// The default bindings for this signal are all forms of the Enter key.
2907 #[doc(alias = "activate-current-link")]
2908 fn connect_activate_current_link<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2909 unsafe extern "C" fn activate_current_link_trampoline<
2910 P: IsA<Label>,
2911 F: Fn(&P) + 'static,
2912 >(
2913 this: *mut ffi::GtkLabel,
2914 f: glib::ffi::gpointer,
2915 ) {
2916 unsafe {
2917 let f: &F = &*(f as *const F);
2918 f(Label::from_glib_borrow(this).unsafe_cast_ref())
2919 }
2920 }
2921 unsafe {
2922 let f: Box_<F> = Box_::new(f);
2923 connect_raw(
2924 self.as_ptr() as *mut _,
2925 c"activate-current-link".as_ptr(),
2926 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2927 activate_current_link_trampoline::<Self, F> as *const (),
2928 )),
2929 Box_::into_raw(f),
2930 )
2931 }
2932 }
2933
2934 fn emit_activate_current_link(&self) {
2935 self.emit_by_name::<()>("activate-current-link", &[]);
2936 }
2937
2938 /// The signal which gets emitted to activate a URI.
2939 /// Applications may connect to it to override the default behaviour,
2940 /// which is to call [`show_uri_on_window()`][crate::show_uri_on_window()].
2941 /// ## `uri`
2942 /// the URI that is activated
2943 ///
2944 /// # Returns
2945 ///
2946 /// [`true`] if the link has been activated
2947 #[doc(alias = "activate-link")]
2948 fn connect_activate_link<F: Fn(&Self, &str) -> glib::Propagation + 'static>(
2949 &self,
2950 f: F,
2951 ) -> SignalHandlerId {
2952 unsafe extern "C" fn activate_link_trampoline<
2953 P: IsA<Label>,
2954 F: Fn(&P, &str) -> glib::Propagation + 'static,
2955 >(
2956 this: *mut ffi::GtkLabel,
2957 uri: *mut std::ffi::c_char,
2958 f: glib::ffi::gpointer,
2959 ) -> glib::ffi::gboolean {
2960 unsafe {
2961 let f: &F = &*(f as *const F);
2962 f(
2963 Label::from_glib_borrow(this).unsafe_cast_ref(),
2964 &glib::GString::from_glib_borrow(uri),
2965 )
2966 .into_glib()
2967 }
2968 }
2969 unsafe {
2970 let f: Box_<F> = Box_::new(f);
2971 connect_raw(
2972 self.as_ptr() as *mut _,
2973 c"activate-link".as_ptr(),
2974 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2975 activate_link_trampoline::<Self, F> as *const (),
2976 )),
2977 Box_::into_raw(f),
2978 )
2979 }
2980 }
2981
2982 /// The ::copy-clipboard signal is a
2983 /// [keybinding signal][GtkBindingSignal]
2984 /// which gets emitted to copy the selection to the clipboard.
2985 ///
2986 /// The default binding for this signal is Ctrl-c.
2987 #[doc(alias = "copy-clipboard")]
2988 fn connect_copy_clipboard<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2989 unsafe extern "C" fn copy_clipboard_trampoline<P: IsA<Label>, F: Fn(&P) + 'static>(
2990 this: *mut ffi::GtkLabel,
2991 f: glib::ffi::gpointer,
2992 ) {
2993 unsafe {
2994 let f: &F = &*(f as *const F);
2995 f(Label::from_glib_borrow(this).unsafe_cast_ref())
2996 }
2997 }
2998 unsafe {
2999 let f: Box_<F> = Box_::new(f);
3000 connect_raw(
3001 self.as_ptr() as *mut _,
3002 c"copy-clipboard".as_ptr(),
3003 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3004 copy_clipboard_trampoline::<Self, F> as *const (),
3005 )),
3006 Box_::into_raw(f),
3007 )
3008 }
3009 }
3010
3011 fn emit_copy_clipboard(&self) {
3012 self.emit_by_name::<()>("copy-clipboard", &[]);
3013 }
3014
3015 /// The ::move-cursor signal is a
3016 /// [keybinding signal][GtkBindingSignal]
3017 /// which gets emitted when the user initiates a cursor movement.
3018 /// If the cursor is not visible in `entry`, this signal causes
3019 /// the viewport to be moved instead.
3020 ///
3021 /// Applications should not connect to it, but may emit it with
3022 /// `g_signal_emit_by_name()` if they need to control the cursor
3023 /// programmatically.
3024 ///
3025 /// The default bindings for this signal come in two variants,
3026 /// the variant with the Shift modifier extends the selection,
3027 /// the variant without the Shift modifer does not.
3028 /// There are too many key combinations to list them all here.
3029 /// - Arrow keys move by individual characters/lines
3030 /// - Ctrl-arrow key combinations move by words/paragraphs
3031 /// - Home/End keys move to the ends of the buffer
3032 /// ## `step`
3033 /// the granularity of the move, as a [`MovementStep`][crate::MovementStep]
3034 /// ## `count`
3035 /// the number of `step` units to move
3036 /// ## `extend_selection`
3037 /// [`true`] if the move should extend the selection
3038 #[doc(alias = "move-cursor")]
3039 fn connect_move_cursor<F: Fn(&Self, MovementStep, i32, bool) + 'static>(
3040 &self,
3041 f: F,
3042 ) -> SignalHandlerId {
3043 unsafe extern "C" fn move_cursor_trampoline<
3044 P: IsA<Label>,
3045 F: Fn(&P, MovementStep, i32, bool) + 'static,
3046 >(
3047 this: *mut ffi::GtkLabel,
3048 step: ffi::GtkMovementStep,
3049 count: std::ffi::c_int,
3050 extend_selection: glib::ffi::gboolean,
3051 f: glib::ffi::gpointer,
3052 ) {
3053 unsafe {
3054 let f: &F = &*(f as *const F);
3055 f(
3056 Label::from_glib_borrow(this).unsafe_cast_ref(),
3057 from_glib(step),
3058 count,
3059 from_glib(extend_selection),
3060 )
3061 }
3062 }
3063 unsafe {
3064 let f: Box_<F> = Box_::new(f);
3065 connect_raw(
3066 self.as_ptr() as *mut _,
3067 c"move-cursor".as_ptr(),
3068 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3069 move_cursor_trampoline::<Self, F> as *const (),
3070 )),
3071 Box_::into_raw(f),
3072 )
3073 }
3074 }
3075
3076 fn emit_move_cursor(&self, step: MovementStep, count: i32, extend_selection: bool) {
3077 self.emit_by_name::<()>("move-cursor", &[&step, &count, &extend_selection]);
3078 }
3079
3080 /// The ::populate-popup signal gets emitted before showing the
3081 /// context menu of the label. Note that only selectable labels
3082 /// have context menus.
3083 ///
3084 /// If you need to add items to the context menu, connect
3085 /// to this signal and append your menuitems to the `menu`.
3086 /// ## `menu`
3087 /// the menu that is being populated
3088 #[doc(alias = "populate-popup")]
3089 fn connect_populate_popup<F: Fn(&Self, &Menu) + 'static>(&self, f: F) -> SignalHandlerId {
3090 unsafe extern "C" fn populate_popup_trampoline<
3091 P: IsA<Label>,
3092 F: Fn(&P, &Menu) + 'static,
3093 >(
3094 this: *mut ffi::GtkLabel,
3095 menu: *mut ffi::GtkMenu,
3096 f: glib::ffi::gpointer,
3097 ) {
3098 unsafe {
3099 let f: &F = &*(f as *const F);
3100 f(
3101 Label::from_glib_borrow(this).unsafe_cast_ref(),
3102 &from_glib_borrow(menu),
3103 )
3104 }
3105 }
3106 unsafe {
3107 let f: Box_<F> = Box_::new(f);
3108 connect_raw(
3109 self.as_ptr() as *mut _,
3110 c"populate-popup".as_ptr(),
3111 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3112 populate_popup_trampoline::<Self, F> as *const (),
3113 )),
3114 Box_::into_raw(f),
3115 )
3116 }
3117 }
3118
3119 #[doc(alias = "angle")]
3120 fn connect_angle_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3121 unsafe extern "C" fn notify_angle_trampoline<P: IsA<Label>, F: Fn(&P) + 'static>(
3122 this: *mut ffi::GtkLabel,
3123 _param_spec: glib::ffi::gpointer,
3124 f: glib::ffi::gpointer,
3125 ) {
3126 unsafe {
3127 let f: &F = &*(f as *const F);
3128 f(Label::from_glib_borrow(this).unsafe_cast_ref())
3129 }
3130 }
3131 unsafe {
3132 let f: Box_<F> = Box_::new(f);
3133 connect_raw(
3134 self.as_ptr() as *mut _,
3135 c"notify::angle".as_ptr(),
3136 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3137 notify_angle_trampoline::<Self, F> as *const (),
3138 )),
3139 Box_::into_raw(f),
3140 )
3141 }
3142 }
3143
3144 #[doc(alias = "attributes")]
3145 fn connect_attributes_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3146 unsafe extern "C" fn notify_attributes_trampoline<P: IsA<Label>, F: Fn(&P) + 'static>(
3147 this: *mut ffi::GtkLabel,
3148 _param_spec: glib::ffi::gpointer,
3149 f: glib::ffi::gpointer,
3150 ) {
3151 unsafe {
3152 let f: &F = &*(f as *const F);
3153 f(Label::from_glib_borrow(this).unsafe_cast_ref())
3154 }
3155 }
3156 unsafe {
3157 let f: Box_<F> = Box_::new(f);
3158 connect_raw(
3159 self.as_ptr() as *mut _,
3160 c"notify::attributes".as_ptr(),
3161 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3162 notify_attributes_trampoline::<Self, F> as *const (),
3163 )),
3164 Box_::into_raw(f),
3165 )
3166 }
3167 }
3168
3169 #[doc(alias = "cursor-position")]
3170 fn connect_cursor_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3171 unsafe extern "C" fn notify_cursor_position_trampoline<
3172 P: IsA<Label>,
3173 F: Fn(&P) + 'static,
3174 >(
3175 this: *mut ffi::GtkLabel,
3176 _param_spec: glib::ffi::gpointer,
3177 f: glib::ffi::gpointer,
3178 ) {
3179 unsafe {
3180 let f: &F = &*(f as *const F);
3181 f(Label::from_glib_borrow(this).unsafe_cast_ref())
3182 }
3183 }
3184 unsafe {
3185 let f: Box_<F> = Box_::new(f);
3186 connect_raw(
3187 self.as_ptr() as *mut _,
3188 c"notify::cursor-position".as_ptr(),
3189 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3190 notify_cursor_position_trampoline::<Self, F> as *const (),
3191 )),
3192 Box_::into_raw(f),
3193 )
3194 }
3195 }
3196
3197 #[doc(alias = "ellipsize")]
3198 fn connect_ellipsize_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3199 unsafe extern "C" fn notify_ellipsize_trampoline<P: IsA<Label>, F: Fn(&P) + 'static>(
3200 this: *mut ffi::GtkLabel,
3201 _param_spec: glib::ffi::gpointer,
3202 f: glib::ffi::gpointer,
3203 ) {
3204 unsafe {
3205 let f: &F = &*(f as *const F);
3206 f(Label::from_glib_borrow(this).unsafe_cast_ref())
3207 }
3208 }
3209 unsafe {
3210 let f: Box_<F> = Box_::new(f);
3211 connect_raw(
3212 self.as_ptr() as *mut _,
3213 c"notify::ellipsize".as_ptr(),
3214 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3215 notify_ellipsize_trampoline::<Self, F> as *const (),
3216 )),
3217 Box_::into_raw(f),
3218 )
3219 }
3220 }
3221
3222 #[doc(alias = "justify")]
3223 fn connect_justify_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3224 unsafe extern "C" fn notify_justify_trampoline<P: IsA<Label>, F: Fn(&P) + 'static>(
3225 this: *mut ffi::GtkLabel,
3226 _param_spec: glib::ffi::gpointer,
3227 f: glib::ffi::gpointer,
3228 ) {
3229 unsafe {
3230 let f: &F = &*(f as *const F);
3231 f(Label::from_glib_borrow(this).unsafe_cast_ref())
3232 }
3233 }
3234 unsafe {
3235 let f: Box_<F> = Box_::new(f);
3236 connect_raw(
3237 self.as_ptr() as *mut _,
3238 c"notify::justify".as_ptr(),
3239 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3240 notify_justify_trampoline::<Self, F> as *const (),
3241 )),
3242 Box_::into_raw(f),
3243 )
3244 }
3245 }
3246
3247 #[doc(alias = "label")]
3248 fn connect_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3249 unsafe extern "C" fn notify_label_trampoline<P: IsA<Label>, F: Fn(&P) + 'static>(
3250 this: *mut ffi::GtkLabel,
3251 _param_spec: glib::ffi::gpointer,
3252 f: glib::ffi::gpointer,
3253 ) {
3254 unsafe {
3255 let f: &F = &*(f as *const F);
3256 f(Label::from_glib_borrow(this).unsafe_cast_ref())
3257 }
3258 }
3259 unsafe {
3260 let f: Box_<F> = Box_::new(f);
3261 connect_raw(
3262 self.as_ptr() as *mut _,
3263 c"notify::label".as_ptr(),
3264 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3265 notify_label_trampoline::<Self, F> as *const (),
3266 )),
3267 Box_::into_raw(f),
3268 )
3269 }
3270 }
3271
3272 #[doc(alias = "lines")]
3273 fn connect_lines_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3274 unsafe extern "C" fn notify_lines_trampoline<P: IsA<Label>, F: Fn(&P) + 'static>(
3275 this: *mut ffi::GtkLabel,
3276 _param_spec: glib::ffi::gpointer,
3277 f: glib::ffi::gpointer,
3278 ) {
3279 unsafe {
3280 let f: &F = &*(f as *const F);
3281 f(Label::from_glib_borrow(this).unsafe_cast_ref())
3282 }
3283 }
3284 unsafe {
3285 let f: Box_<F> = Box_::new(f);
3286 connect_raw(
3287 self.as_ptr() as *mut _,
3288 c"notify::lines".as_ptr(),
3289 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3290 notify_lines_trampoline::<Self, F> as *const (),
3291 )),
3292 Box_::into_raw(f),
3293 )
3294 }
3295 }
3296
3297 #[doc(alias = "max-width-chars")]
3298 fn connect_max_width_chars_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3299 unsafe extern "C" fn notify_max_width_chars_trampoline<
3300 P: IsA<Label>,
3301 F: Fn(&P) + 'static,
3302 >(
3303 this: *mut ffi::GtkLabel,
3304 _param_spec: glib::ffi::gpointer,
3305 f: glib::ffi::gpointer,
3306 ) {
3307 unsafe {
3308 let f: &F = &*(f as *const F);
3309 f(Label::from_glib_borrow(this).unsafe_cast_ref())
3310 }
3311 }
3312 unsafe {
3313 let f: Box_<F> = Box_::new(f);
3314 connect_raw(
3315 self.as_ptr() as *mut _,
3316 c"notify::max-width-chars".as_ptr(),
3317 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3318 notify_max_width_chars_trampoline::<Self, F> as *const (),
3319 )),
3320 Box_::into_raw(f),
3321 )
3322 }
3323 }
3324
3325 #[doc(alias = "mnemonic-keyval")]
3326 fn connect_mnemonic_keyval_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3327 unsafe extern "C" fn notify_mnemonic_keyval_trampoline<
3328 P: IsA<Label>,
3329 F: Fn(&P) + 'static,
3330 >(
3331 this: *mut ffi::GtkLabel,
3332 _param_spec: glib::ffi::gpointer,
3333 f: glib::ffi::gpointer,
3334 ) {
3335 unsafe {
3336 let f: &F = &*(f as *const F);
3337 f(Label::from_glib_borrow(this).unsafe_cast_ref())
3338 }
3339 }
3340 unsafe {
3341 let f: Box_<F> = Box_::new(f);
3342 connect_raw(
3343 self.as_ptr() as *mut _,
3344 c"notify::mnemonic-keyval".as_ptr(),
3345 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3346 notify_mnemonic_keyval_trampoline::<Self, F> as *const (),
3347 )),
3348 Box_::into_raw(f),
3349 )
3350 }
3351 }
3352
3353 #[doc(alias = "mnemonic-widget")]
3354 fn connect_mnemonic_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3355 unsafe extern "C" fn notify_mnemonic_widget_trampoline<
3356 P: IsA<Label>,
3357 F: Fn(&P) + 'static,
3358 >(
3359 this: *mut ffi::GtkLabel,
3360 _param_spec: glib::ffi::gpointer,
3361 f: glib::ffi::gpointer,
3362 ) {
3363 unsafe {
3364 let f: &F = &*(f as *const F);
3365 f(Label::from_glib_borrow(this).unsafe_cast_ref())
3366 }
3367 }
3368 unsafe {
3369 let f: Box_<F> = Box_::new(f);
3370 connect_raw(
3371 self.as_ptr() as *mut _,
3372 c"notify::mnemonic-widget".as_ptr(),
3373 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3374 notify_mnemonic_widget_trampoline::<Self, F> as *const (),
3375 )),
3376 Box_::into_raw(f),
3377 )
3378 }
3379 }
3380
3381 #[doc(alias = "pattern")]
3382 fn connect_pattern_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3383 unsafe extern "C" fn notify_pattern_trampoline<P: IsA<Label>, F: Fn(&P) + 'static>(
3384 this: *mut ffi::GtkLabel,
3385 _param_spec: glib::ffi::gpointer,
3386 f: glib::ffi::gpointer,
3387 ) {
3388 unsafe {
3389 let f: &F = &*(f as *const F);
3390 f(Label::from_glib_borrow(this).unsafe_cast_ref())
3391 }
3392 }
3393 unsafe {
3394 let f: Box_<F> = Box_::new(f);
3395 connect_raw(
3396 self.as_ptr() as *mut _,
3397 c"notify::pattern".as_ptr(),
3398 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3399 notify_pattern_trampoline::<Self, F> as *const (),
3400 )),
3401 Box_::into_raw(f),
3402 )
3403 }
3404 }
3405
3406 #[doc(alias = "selectable")]
3407 fn connect_selectable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3408 unsafe extern "C" fn notify_selectable_trampoline<P: IsA<Label>, F: Fn(&P) + 'static>(
3409 this: *mut ffi::GtkLabel,
3410 _param_spec: glib::ffi::gpointer,
3411 f: glib::ffi::gpointer,
3412 ) {
3413 unsafe {
3414 let f: &F = &*(f as *const F);
3415 f(Label::from_glib_borrow(this).unsafe_cast_ref())
3416 }
3417 }
3418 unsafe {
3419 let f: Box_<F> = Box_::new(f);
3420 connect_raw(
3421 self.as_ptr() as *mut _,
3422 c"notify::selectable".as_ptr(),
3423 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3424 notify_selectable_trampoline::<Self, F> as *const (),
3425 )),
3426 Box_::into_raw(f),
3427 )
3428 }
3429 }
3430
3431 #[doc(alias = "selection-bound")]
3432 fn connect_selection_bound_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3433 unsafe extern "C" fn notify_selection_bound_trampoline<
3434 P: IsA<Label>,
3435 F: Fn(&P) + 'static,
3436 >(
3437 this: *mut ffi::GtkLabel,
3438 _param_spec: glib::ffi::gpointer,
3439 f: glib::ffi::gpointer,
3440 ) {
3441 unsafe {
3442 let f: &F = &*(f as *const F);
3443 f(Label::from_glib_borrow(this).unsafe_cast_ref())
3444 }
3445 }
3446 unsafe {
3447 let f: Box_<F> = Box_::new(f);
3448 connect_raw(
3449 self.as_ptr() as *mut _,
3450 c"notify::selection-bound".as_ptr(),
3451 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3452 notify_selection_bound_trampoline::<Self, F> as *const (),
3453 )),
3454 Box_::into_raw(f),
3455 )
3456 }
3457 }
3458
3459 #[doc(alias = "single-line-mode")]
3460 fn connect_single_line_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3461 unsafe extern "C" fn notify_single_line_mode_trampoline<
3462 P: IsA<Label>,
3463 F: Fn(&P) + 'static,
3464 >(
3465 this: *mut ffi::GtkLabel,
3466 _param_spec: glib::ffi::gpointer,
3467 f: glib::ffi::gpointer,
3468 ) {
3469 unsafe {
3470 let f: &F = &*(f as *const F);
3471 f(Label::from_glib_borrow(this).unsafe_cast_ref())
3472 }
3473 }
3474 unsafe {
3475 let f: Box_<F> = Box_::new(f);
3476 connect_raw(
3477 self.as_ptr() as *mut _,
3478 c"notify::single-line-mode".as_ptr(),
3479 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3480 notify_single_line_mode_trampoline::<Self, F> as *const (),
3481 )),
3482 Box_::into_raw(f),
3483 )
3484 }
3485 }
3486
3487 #[doc(alias = "track-visited-links")]
3488 fn connect_track_visited_links_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3489 unsafe extern "C" fn notify_track_visited_links_trampoline<
3490 P: IsA<Label>,
3491 F: Fn(&P) + 'static,
3492 >(
3493 this: *mut ffi::GtkLabel,
3494 _param_spec: glib::ffi::gpointer,
3495 f: glib::ffi::gpointer,
3496 ) {
3497 unsafe {
3498 let f: &F = &*(f as *const F);
3499 f(Label::from_glib_borrow(this).unsafe_cast_ref())
3500 }
3501 }
3502 unsafe {
3503 let f: Box_<F> = Box_::new(f);
3504 connect_raw(
3505 self.as_ptr() as *mut _,
3506 c"notify::track-visited-links".as_ptr(),
3507 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3508 notify_track_visited_links_trampoline::<Self, F> as *const (),
3509 )),
3510 Box_::into_raw(f),
3511 )
3512 }
3513 }
3514
3515 #[doc(alias = "use-markup")]
3516 fn connect_use_markup_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3517 unsafe extern "C" fn notify_use_markup_trampoline<P: IsA<Label>, F: Fn(&P) + 'static>(
3518 this: *mut ffi::GtkLabel,
3519 _param_spec: glib::ffi::gpointer,
3520 f: glib::ffi::gpointer,
3521 ) {
3522 unsafe {
3523 let f: &F = &*(f as *const F);
3524 f(Label::from_glib_borrow(this).unsafe_cast_ref())
3525 }
3526 }
3527 unsafe {
3528 let f: Box_<F> = Box_::new(f);
3529 connect_raw(
3530 self.as_ptr() as *mut _,
3531 c"notify::use-markup".as_ptr(),
3532 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3533 notify_use_markup_trampoline::<Self, F> as *const (),
3534 )),
3535 Box_::into_raw(f),
3536 )
3537 }
3538 }
3539
3540 #[doc(alias = "use-underline")]
3541 fn connect_use_underline_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3542 unsafe extern "C" fn notify_use_underline_trampoline<P: IsA<Label>, F: Fn(&P) + 'static>(
3543 this: *mut ffi::GtkLabel,
3544 _param_spec: glib::ffi::gpointer,
3545 f: glib::ffi::gpointer,
3546 ) {
3547 unsafe {
3548 let f: &F = &*(f as *const F);
3549 f(Label::from_glib_borrow(this).unsafe_cast_ref())
3550 }
3551 }
3552 unsafe {
3553 let f: Box_<F> = Box_::new(f);
3554 connect_raw(
3555 self.as_ptr() as *mut _,
3556 c"notify::use-underline".as_ptr(),
3557 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3558 notify_use_underline_trampoline::<Self, F> as *const (),
3559 )),
3560 Box_::into_raw(f),
3561 )
3562 }
3563 }
3564
3565 #[doc(alias = "width-chars")]
3566 fn connect_width_chars_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3567 unsafe extern "C" fn notify_width_chars_trampoline<P: IsA<Label>, F: Fn(&P) + 'static>(
3568 this: *mut ffi::GtkLabel,
3569 _param_spec: glib::ffi::gpointer,
3570 f: glib::ffi::gpointer,
3571 ) {
3572 unsafe {
3573 let f: &F = &*(f as *const F);
3574 f(Label::from_glib_borrow(this).unsafe_cast_ref())
3575 }
3576 }
3577 unsafe {
3578 let f: Box_<F> = Box_::new(f);
3579 connect_raw(
3580 self.as_ptr() as *mut _,
3581 c"notify::width-chars".as_ptr(),
3582 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3583 notify_width_chars_trampoline::<Self, F> as *const (),
3584 )),
3585 Box_::into_raw(f),
3586 )
3587 }
3588 }
3589
3590 #[doc(alias = "wrap")]
3591 fn connect_wrap_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3592 unsafe extern "C" fn notify_wrap_trampoline<P: IsA<Label>, F: Fn(&P) + 'static>(
3593 this: *mut ffi::GtkLabel,
3594 _param_spec: glib::ffi::gpointer,
3595 f: glib::ffi::gpointer,
3596 ) {
3597 unsafe {
3598 let f: &F = &*(f as *const F);
3599 f(Label::from_glib_borrow(this).unsafe_cast_ref())
3600 }
3601 }
3602 unsafe {
3603 let f: Box_<F> = Box_::new(f);
3604 connect_raw(
3605 self.as_ptr() as *mut _,
3606 c"notify::wrap".as_ptr(),
3607 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3608 notify_wrap_trampoline::<Self, F> as *const (),
3609 )),
3610 Box_::into_raw(f),
3611 )
3612 }
3613 }
3614
3615 #[doc(alias = "wrap-mode")]
3616 fn connect_wrap_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3617 unsafe extern "C" fn notify_wrap_mode_trampoline<P: IsA<Label>, F: Fn(&P) + 'static>(
3618 this: *mut ffi::GtkLabel,
3619 _param_spec: glib::ffi::gpointer,
3620 f: glib::ffi::gpointer,
3621 ) {
3622 unsafe {
3623 let f: &F = &*(f as *const F);
3624 f(Label::from_glib_borrow(this).unsafe_cast_ref())
3625 }
3626 }
3627 unsafe {
3628 let f: Box_<F> = Box_::new(f);
3629 connect_raw(
3630 self.as_ptr() as *mut _,
3631 c"notify::wrap-mode".as_ptr(),
3632 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3633 notify_wrap_mode_trampoline::<Self, F> as *const (),
3634 )),
3635 Box_::into_raw(f),
3636 )
3637 }
3638 }
3639}
3640
3641impl<O: IsA<Label>> LabelExt for O {}