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