Skip to main content

gtk/auto/
accel_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, Label, Misc, Widget, ffi};
6use glib::{
7    prelude::*,
8    signal::{SignalHandlerId, connect_raw},
9    translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    ///
15    /// label
16    /// ╰── accelerator
17    /// ]|
18    ///
19    /// Like [`Label`][crate::Label], GtkAccelLabel has a main CSS node with the name label.
20    /// It adds a subnode with name accelerator.
21    ///
22    /// ## Properties
23    ///
24    ///
25    /// #### `accel-closure`
26    ///  Readable | Writable
27    ///
28    ///
29    /// #### `accel-widget`
30    ///  Readable | Writable
31    /// <details><summary><h4>Label</h4></summary>
32    ///
33    ///
34    /// #### `angle`
35    ///  The angle that the baseline of the label makes with the horizontal,
36    /// in degrees, measured counterclockwise. An angle of 90 reads from
37    /// from bottom to top, an angle of 270, from top to bottom. Ignored
38    /// if the label is selectable.
39    ///
40    /// Readable | Writable
41    ///
42    ///
43    /// #### `attributes`
44    ///  Readable | Writable
45    ///
46    ///
47    /// #### `cursor-position`
48    ///  Readable
49    ///
50    ///
51    /// #### `ellipsize`
52    ///  The preferred place to ellipsize the string, if the label does
53    /// not have enough room to display the entire string, specified as a
54    /// [`pango::EllipsizeMode`][crate::pango::EllipsizeMode].
55    ///
56    /// Note that setting this property to a value other than
57    /// [`pango::EllipsizeMode::None`][crate::pango::EllipsizeMode::None] has the side-effect that the label requests
58    /// only enough space to display the ellipsis "...". In particular, this
59    /// means that ellipsizing labels do not work well in notebook tabs, unless
60    /// the [`Notebook`][crate::Notebook] tab-expand child property is set to [`true`]. Other ways
61    /// to set a label's width are [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] and
62    /// [`LabelExt::set_width_chars()`][crate::prelude::LabelExt::set_width_chars()].
63    ///
64    /// Readable | Writable
65    ///
66    ///
67    /// #### `justify`
68    ///  Readable | Writable
69    ///
70    ///
71    /// #### `label`
72    ///  The contents of the label.
73    ///
74    /// If the string contains [Pango XML markup][PangoMarkupFormat], you will
75    /// have to set the [`use-markup`][struct@crate::Label#use-markup] property to [`true`] in order for the
76    /// label to display the markup attributes. See also [`LabelExt::set_markup()`][crate::prelude::LabelExt::set_markup()]
77    /// for a convenience function that sets both this property and the
78    /// [`use-markup`][struct@crate::Label#use-markup] property at the same time.
79    ///
80    /// If the string contains underlines acting as mnemonics, you will have to
81    /// set the [`use-underline`][struct@crate::Label#use-underline] property to [`true`] in order for the label
82    /// to display them.
83    ///
84    /// Readable | Writable
85    ///
86    ///
87    /// #### `lines`
88    ///  The number of lines to which an ellipsized, wrapping label
89    /// should be limited. This property has no effect if the
90    /// label is not wrapping or ellipsized. Set this property to
91    /// -1 if you don't want to limit the number of lines.
92    ///
93    /// Readable | Writable
94    ///
95    ///
96    /// #### `max-width-chars`
97    ///  The desired maximum width of the label, in characters. If this property
98    /// is set to -1, the width will be calculated automatically.
99    ///
100    /// See the section on [text layout][label-text-layout]
101    /// for details of how [`width-chars`][struct@crate::Label#width-chars] and [`max-width-chars`][struct@crate::Label#max-width-chars]
102    /// determine the width of ellipsized and wrapped labels.
103    ///
104    /// Readable | Writable
105    ///
106    ///
107    /// #### `mnemonic-keyval`
108    ///  Readable
109    ///
110    ///
111    /// #### `mnemonic-widget`
112    ///  Readable | Writable
113    ///
114    ///
115    /// #### `pattern`
116    ///  Writable
117    ///
118    ///
119    /// #### `selectable`
120    ///  Readable | Writable
121    ///
122    ///
123    /// #### `selection-bound`
124    ///  Readable
125    ///
126    ///
127    /// #### `single-line-mode`
128    ///  Whether the label is in single line mode. In single line mode,
129    /// the height of the label does not depend on the actual text, it
130    /// is always set to ascent + descent of the font. This can be an
131    /// advantage in situations where resizing the label because of text
132    /// changes would be distracting, e.g. in a statusbar.
133    ///
134    /// Readable | Writable
135    ///
136    ///
137    /// #### `track-visited-links`
138    ///  Set this property to [`true`] to make the label track which links
139    /// have been visited. It will then apply the [`StateFlags::VISITED`][crate::StateFlags::VISITED]
140    /// when rendering this link, in addition to [`StateFlags::LINK`][crate::StateFlags::LINK].
141    ///
142    /// Readable | Writable
143    ///
144    ///
145    /// #### `use-markup`
146    ///  Readable | Writable
147    ///
148    ///
149    /// #### `use-underline`
150    ///  Readable | Writable
151    ///
152    ///
153    /// #### `width-chars`
154    ///  The desired width of the label, in characters. If this property is set to
155    /// -1, the width will be calculated automatically.
156    ///
157    /// See the section on [text layout][label-text-layout]
158    /// for details of how [`width-chars`][struct@crate::Label#width-chars] and [`max-width-chars`][struct@crate::Label#max-width-chars]
159    /// determine the width of ellipsized and wrapped labels.
160    ///
161    /// Readable | Writable
162    ///
163    ///
164    /// #### `wrap`
165    ///  Readable | Writable
166    ///
167    ///
168    /// #### `wrap-mode`
169    ///  If line wrapping is on (see the [`wrap`][struct@crate::Label#wrap] property) this controls
170    /// how the line wrapping is done. The default is [`pango::WrapMode::Word`][crate::pango::WrapMode::Word], which
171    /// means wrap on word boundaries.
172    ///
173    /// Readable | Writable
174    ///
175    ///
176    /// #### `xalign`
177    ///  The xalign property determines the horizontal aligment of the label text
178    /// inside the labels size allocation. Compare this to [`halign`][struct@crate::Widget#halign],
179    /// which determines how the labels size allocation is positioned in the
180    /// space available for the label.
181    ///
182    /// Readable | Writable
183    ///
184    ///
185    /// #### `yalign`
186    ///  The yalign property determines the vertical aligment of the label text
187    /// inside the labels size allocation. Compare this to [`valign`][struct@crate::Widget#valign],
188    /// which determines how the labels size allocation is positioned in the
189    /// space available for the label.
190    ///
191    /// Readable | Writable
192    /// </details>
193    /// <details><summary><h4>Misc</h4></summary>
194    ///
195    ///
196    /// #### `xalign`
197    ///  The horizontal alignment. A value of 0.0 means left alignment (or right
198    /// on RTL locales); a value of 1.0 means right alignment (or left on RTL
199    /// locales).
200    ///
201    /// Readable | Writable
202    ///
203    ///
204    /// #### `xpad`
205    ///  The amount of space to add on the left and right of the widget, in
206    /// pixels.
207    ///
208    /// Readable | Writable
209    ///
210    ///
211    /// #### `yalign`
212    ///  The vertical alignment. A value of 0.0 means top alignment;
213    /// a value of 1.0 means bottom alignment.
214    ///
215    /// Readable | Writable
216    ///
217    ///
218    /// #### `ypad`
219    ///  The amount of space to add on the top and bottom of the widget, in
220    /// pixels.
221    ///
222    /// Readable | Writable
223    /// </details>
224    /// <details><summary><h4>Widget</h4></summary>
225    ///
226    ///
227    /// #### `app-paintable`
228    ///  Readable | Writable
229    ///
230    ///
231    /// #### `can-default`
232    ///  Readable | Writable
233    ///
234    ///
235    /// #### `can-focus`
236    ///  Readable | Writable
237    ///
238    ///
239    /// #### `composite-child`
240    ///  Readable
241    ///
242    ///
243    /// #### `double-buffered`
244    ///  Whether the widget is double buffered.
245    ///
246    /// Readable | Writable
247    ///
248    ///
249    /// #### `events`
250    ///  Readable | Writable
251    ///
252    ///
253    /// #### `expand`
254    ///  Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
255    ///
256    /// Readable | Writable
257    ///
258    ///
259    /// #### `focus-on-click`
260    ///  Whether the widget should grab focus when it is clicked with the mouse.
261    ///
262    /// This property is only relevant for widgets that can take focus.
263    ///
264    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
265    /// GtkComboBox) implemented this property individually.
266    ///
267    /// Readable | Writable
268    ///
269    ///
270    /// #### `halign`
271    ///  How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
272    ///
273    /// Readable | Writable
274    ///
275    ///
276    /// #### `has-default`
277    ///  Readable | Writable
278    ///
279    ///
280    /// #### `has-focus`
281    ///  Readable | Writable
282    ///
283    ///
284    /// #### `has-tooltip`
285    ///  Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
286    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
287    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
288    /// whether it will provide a tooltip or not.
289    ///
290    /// Note that setting this property to [`true`] for the first time will change
291    /// the event masks of the GdkWindows of this widget to include leave-notify
292    /// and motion-notify events. This cannot and will not be undone when the
293    /// property is set to [`false`] again.
294    ///
295    /// Readable | Writable
296    ///
297    ///
298    /// #### `height-request`
299    ///  Readable | Writable
300    ///
301    ///
302    /// #### `hexpand`
303    ///  Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
304    ///
305    /// Readable | Writable
306    ///
307    ///
308    /// #### `hexpand-set`
309    ///  Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
310    ///
311    /// Readable | Writable
312    ///
313    ///
314    /// #### `is-focus`
315    ///  Readable | Writable
316    ///
317    ///
318    /// #### `margin`
319    ///  Sets all four sides' margin at once. If read, returns max
320    /// margin on any side.
321    ///
322    /// Readable | Writable
323    ///
324    ///
325    /// #### `margin-bottom`
326    ///  Margin on bottom side of widget.
327    ///
328    /// This property adds margin outside of the widget's normal size
329    /// request, the margin will be added in addition to the size from
330    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
331    ///
332    /// Readable | Writable
333    ///
334    ///
335    /// #### `margin-end`
336    ///  Margin on end of widget, horizontally. This property supports
337    /// left-to-right and right-to-left text directions.
338    ///
339    /// This property adds margin outside of the widget's normal size
340    /// request, the margin will be added in addition to the size from
341    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
342    ///
343    /// Readable | Writable
344    ///
345    ///
346    /// #### `margin-left`
347    ///  Margin on left side of widget.
348    ///
349    /// This property adds margin outside of the widget's normal size
350    /// request, the margin will be added in addition to the size from
351    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
352    ///
353    /// Readable | Writable
354    ///
355    ///
356    /// #### `margin-right`
357    ///  Margin on right side of widget.
358    ///
359    /// This property adds margin outside of the widget's normal size
360    /// request, the margin will be added in addition to the size from
361    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
362    ///
363    /// Readable | Writable
364    ///
365    ///
366    /// #### `margin-start`
367    ///  Margin on start of widget, horizontally. This property supports
368    /// left-to-right and right-to-left text directions.
369    ///
370    /// This property adds margin outside of the widget's normal size
371    /// request, the margin will be added in addition to the size from
372    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
373    ///
374    /// Readable | Writable
375    ///
376    ///
377    /// #### `margin-top`
378    ///  Margin on top side of widget.
379    ///
380    /// This property adds margin outside of the widget's normal size
381    /// request, the margin will be added in addition to the size from
382    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
383    ///
384    /// Readable | Writable
385    ///
386    ///
387    /// #### `name`
388    ///  Readable | Writable
389    ///
390    ///
391    /// #### `no-show-all`
392    ///  Readable | Writable
393    ///
394    ///
395    /// #### `opacity`
396    ///  The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
397    /// more details about window opacity.
398    ///
399    /// Before 3.8 this was only available in GtkWindow
400    ///
401    /// Readable | Writable
402    ///
403    ///
404    /// #### `parent`
405    ///  Readable | Writable
406    ///
407    ///
408    /// #### `receives-default`
409    ///  Readable | Writable
410    ///
411    ///
412    /// #### `scale-factor`
413    ///  The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
414    /// more details about widget scaling.
415    ///
416    /// Readable
417    ///
418    ///
419    /// #### `sensitive`
420    ///  Readable | Writable
421    ///
422    ///
423    /// #### `style`
424    ///  The style of the widget, which contains information about how it will look (colors, etc).
425    ///
426    /// Readable | Writable
427    ///
428    ///
429    /// #### `tooltip-markup`
430    ///  Sets the text of tooltip to be the given string, which is marked up
431    /// with the [Pango text markup language][PangoMarkupFormat].
432    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
433    ///
434    /// This is a convenience property which will take care of getting the
435    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
436    /// will automatically be set to [`true`] and there will be taken care of
437    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
438    ///
439    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
440    /// are set, the last one wins.
441    ///
442    /// Readable | Writable
443    ///
444    ///
445    /// #### `tooltip-text`
446    ///  Sets the text of tooltip to be the given string.
447    ///
448    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
449    ///
450    /// This is a convenience property which will take care of getting the
451    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
452    /// will automatically be set to [`true`] and there will be taken care of
453    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
454    ///
455    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
456    /// are set, the last one wins.
457    ///
458    /// Readable | Writable
459    ///
460    ///
461    /// #### `valign`
462    ///  How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
463    ///
464    /// Readable | Writable
465    ///
466    ///
467    /// #### `vexpand`
468    ///  Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
469    ///
470    /// Readable | Writable
471    ///
472    ///
473    /// #### `vexpand-set`
474    ///  Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
475    ///
476    /// Readable | Writable
477    ///
478    ///
479    /// #### `visible`
480    ///  Readable | Writable
481    ///
482    ///
483    /// #### `width-request`
484    ///  Readable | Writable
485    ///
486    ///
487    /// #### `window`
488    ///  The widget's window if it is realized, [`None`] otherwise.
489    ///
490    /// Readable
491    /// </details>
492    ///
493    /// # Implements
494    ///
495    /// [`AccelLabelExt`][trait@crate::prelude::AccelLabelExt], [`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]
496    #[doc(alias = "GtkAccelLabel")]
497    pub struct AccelLabel(Object<ffi::GtkAccelLabel, ffi::GtkAccelLabelClass>) @extends Label, Misc, Widget, @implements Buildable;
498
499    match fn {
500        type_ => || ffi::gtk_accel_label_get_type(),
501    }
502}
503
504impl AccelLabel {
505    pub const NONE: Option<&'static AccelLabel> = None;
506
507    /// Creates a new [`AccelLabel`][crate::AccelLabel].
508    /// ## `string`
509    /// the label string. Must be non-[`None`].
510    ///
511    /// # Returns
512    ///
513    /// a new [`AccelLabel`][crate::AccelLabel].
514    #[doc(alias = "gtk_accel_label_new")]
515    pub fn new(string: &str) -> AccelLabel {
516        assert_initialized_main_thread!();
517        unsafe {
518            Widget::from_glib_none(ffi::gtk_accel_label_new(string.to_glib_none().0)).unsafe_cast()
519        }
520    }
521
522    // rustdoc-stripper-ignore-next
523    /// Creates a new builder-pattern struct instance to construct [`AccelLabel`] objects.
524    ///
525    /// This method returns an instance of [`AccelLabelBuilder`](crate::builders::AccelLabelBuilder) which can be used to create [`AccelLabel`] objects.
526    pub fn builder() -> AccelLabelBuilder {
527        AccelLabelBuilder::new()
528    }
529}
530
531impl Default for AccelLabel {
532    fn default() -> Self {
533        glib::object::Object::new::<Self>()
534    }
535}
536
537// rustdoc-stripper-ignore-next
538/// A [builder-pattern] type to construct [`AccelLabel`] objects.
539///
540/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
541#[must_use = "The builder must be built to be used"]
542pub struct AccelLabelBuilder {
543    builder: glib::object::ObjectBuilder<'static, AccelLabel>,
544}
545
546impl AccelLabelBuilder {
547    fn new() -> Self {
548        Self {
549            builder: glib::object::Object::builder(),
550        }
551    }
552
553    pub fn accel_closure(self, accel_closure: &glib::Closure) -> Self {
554        Self {
555            builder: self
556                .builder
557                .property("accel-closure", accel_closure.clone()),
558        }
559    }
560
561    pub fn accel_widget(self, accel_widget: &impl IsA<Widget>) -> Self {
562        Self {
563            builder: self
564                .builder
565                .property("accel-widget", accel_widget.clone().upcast()),
566        }
567    }
568
569    /// The angle that the baseline of the label makes with the horizontal,
570    /// in degrees, measured counterclockwise. An angle of 90 reads from
571    /// from bottom to top, an angle of 270, from top to bottom. Ignored
572    /// if the label is selectable.
573    pub fn angle(self, angle: f64) -> Self {
574        Self {
575            builder: self.builder.property("angle", angle),
576        }
577    }
578
579    pub fn attributes(self, attributes: &pango::AttrList) -> Self {
580        Self {
581            builder: self.builder.property("attributes", attributes.clone()),
582        }
583    }
584
585    /// The preferred place to ellipsize the string, if the label does
586    /// not have enough room to display the entire string, specified as a
587    /// [`pango::EllipsizeMode`][crate::pango::EllipsizeMode].
588    ///
589    /// Note that setting this property to a value other than
590    /// [`pango::EllipsizeMode::None`][crate::pango::EllipsizeMode::None] has the side-effect that the label requests
591    /// only enough space to display the ellipsis "...". In particular, this
592    /// means that ellipsizing labels do not work well in notebook tabs, unless
593    /// the [`Notebook`][crate::Notebook] tab-expand child property is set to [`true`]. Other ways
594    /// to set a label's width are [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] and
595    /// [`LabelExt::set_width_chars()`][crate::prelude::LabelExt::set_width_chars()].
596    pub fn ellipsize(self, ellipsize: pango::EllipsizeMode) -> Self {
597        Self {
598            builder: self.builder.property("ellipsize", ellipsize),
599        }
600    }
601
602    pub fn justify(self, justify: Justification) -> Self {
603        Self {
604            builder: self.builder.property("justify", justify),
605        }
606    }
607
608    /// The contents of the label.
609    ///
610    /// If the string contains [Pango XML markup][PangoMarkupFormat], you will
611    /// have to set the [`use-markup`][struct@crate::Label#use-markup] property to [`true`] in order for the
612    /// label to display the markup attributes. See also [`LabelExt::set_markup()`][crate::prelude::LabelExt::set_markup()]
613    /// for a convenience function that sets both this property and the
614    /// [`use-markup`][struct@crate::Label#use-markup] property at the same time.
615    ///
616    /// If the string contains underlines acting as mnemonics, you will have to
617    /// set the [`use-underline`][struct@crate::Label#use-underline] property to [`true`] in order for the label
618    /// to display them.
619    pub fn label(self, label: impl Into<glib::GString>) -> Self {
620        Self {
621            builder: self.builder.property("label", label.into()),
622        }
623    }
624
625    /// The number of lines to which an ellipsized, wrapping label
626    /// should be limited. This property has no effect if the
627    /// label is not wrapping or ellipsized. Set this property to
628    /// -1 if you don't want to limit the number of lines.
629    pub fn lines(self, lines: i32) -> Self {
630        Self {
631            builder: self.builder.property("lines", lines),
632        }
633    }
634
635    /// The desired maximum width of the label, in characters. If this property
636    /// is set to -1, the width will be calculated automatically.
637    ///
638    /// See the section on [text layout][label-text-layout]
639    /// for details of how [`width-chars`][struct@crate::Label#width-chars] and [`max-width-chars`][struct@crate::Label#max-width-chars]
640    /// determine the width of ellipsized and wrapped labels.
641    pub fn max_width_chars(self, max_width_chars: i32) -> Self {
642        Self {
643            builder: self.builder.property("max-width-chars", max_width_chars),
644        }
645    }
646
647    pub fn mnemonic_widget(self, mnemonic_widget: &impl IsA<Widget>) -> Self {
648        Self {
649            builder: self
650                .builder
651                .property("mnemonic-widget", mnemonic_widget.clone().upcast()),
652        }
653    }
654
655    pub fn pattern(self, pattern: impl Into<glib::GString>) -> Self {
656        Self {
657            builder: self.builder.property("pattern", pattern.into()),
658        }
659    }
660
661    pub fn selectable(self, selectable: bool) -> Self {
662        Self {
663            builder: self.builder.property("selectable", selectable),
664        }
665    }
666
667    /// Whether the label is in single line mode. In single line mode,
668    /// the height of the label does not depend on the actual text, it
669    /// is always set to ascent + descent of the font. This can be an
670    /// advantage in situations where resizing the label because of text
671    /// changes would be distracting, e.g. in a statusbar.
672    pub fn single_line_mode(self, single_line_mode: bool) -> Self {
673        Self {
674            builder: self.builder.property("single-line-mode", single_line_mode),
675        }
676    }
677
678    /// Set this property to [`true`] to make the label track which links
679    /// have been visited. It will then apply the [`StateFlags::VISITED`][crate::StateFlags::VISITED]
680    /// when rendering this link, in addition to [`StateFlags::LINK`][crate::StateFlags::LINK].
681    pub fn track_visited_links(self, track_visited_links: bool) -> Self {
682        Self {
683            builder: self
684                .builder
685                .property("track-visited-links", track_visited_links),
686        }
687    }
688
689    pub fn use_markup(self, use_markup: bool) -> Self {
690        Self {
691            builder: self.builder.property("use-markup", use_markup),
692        }
693    }
694
695    pub fn use_underline(self, use_underline: bool) -> Self {
696        Self {
697            builder: self.builder.property("use-underline", use_underline),
698        }
699    }
700
701    /// The desired width of the label, in characters. If this property is set to
702    /// -1, the width will be calculated automatically.
703    ///
704    /// See the section on [text layout][label-text-layout]
705    /// for details of how [`width-chars`][struct@crate::Label#width-chars] and [`max-width-chars`][struct@crate::Label#max-width-chars]
706    /// determine the width of ellipsized and wrapped labels.
707    pub fn width_chars(self, width_chars: i32) -> Self {
708        Self {
709            builder: self.builder.property("width-chars", width_chars),
710        }
711    }
712
713    pub fn wrap(self, wrap: bool) -> Self {
714        Self {
715            builder: self.builder.property("wrap", wrap),
716        }
717    }
718
719    /// If line wrapping is on (see the [`wrap`][struct@crate::Label#wrap] property) this controls
720    /// how the line wrapping is done. The default is [`pango::WrapMode::Word`][crate::pango::WrapMode::Word], which
721    /// means wrap on word boundaries.
722    pub fn wrap_mode(self, wrap_mode: pango::WrapMode) -> Self {
723        Self {
724            builder: self.builder.property("wrap-mode", wrap_mode),
725        }
726    }
727
728    /// The xalign property determines the horizontal aligment of the label text
729    /// inside the labels size allocation. Compare this to [`halign`][struct@crate::Widget#halign],
730    /// which determines how the labels size allocation is positioned in the
731    /// space available for the label.
732    pub fn xalign(self, xalign: f32) -> Self {
733        Self {
734            builder: self.builder.property("xalign", xalign),
735        }
736    }
737
738    /// The yalign property determines the vertical aligment of the label text
739    /// inside the labels size allocation. Compare this to [`valign`][struct@crate::Widget#valign],
740    /// which determines how the labels size allocation is positioned in the
741    /// space available for the label.
742    pub fn yalign(self, yalign: f32) -> Self {
743        Self {
744            builder: self.builder.property("yalign", yalign),
745        }
746    }
747
748    pub fn app_paintable(self, app_paintable: bool) -> Self {
749        Self {
750            builder: self.builder.property("app-paintable", app_paintable),
751        }
752    }
753
754    pub fn can_default(self, can_default: bool) -> Self {
755        Self {
756            builder: self.builder.property("can-default", can_default),
757        }
758    }
759
760    pub fn can_focus(self, can_focus: bool) -> Self {
761        Self {
762            builder: self.builder.property("can-focus", can_focus),
763        }
764    }
765
766    pub fn events(self, events: gdk::EventMask) -> Self {
767        Self {
768            builder: self.builder.property("events", events),
769        }
770    }
771
772    /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
773    pub fn expand(self, expand: bool) -> Self {
774        Self {
775            builder: self.builder.property("expand", expand),
776        }
777    }
778
779    /// Whether the widget should grab focus when it is clicked with the mouse.
780    ///
781    /// This property is only relevant for widgets that can take focus.
782    ///
783    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
784    /// GtkComboBox) implemented this property individually.
785    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
786        Self {
787            builder: self.builder.property("focus-on-click", focus_on_click),
788        }
789    }
790
791    /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
792    pub fn halign(self, halign: Align) -> Self {
793        Self {
794            builder: self.builder.property("halign", halign),
795        }
796    }
797
798    pub fn has_default(self, has_default: bool) -> Self {
799        Self {
800            builder: self.builder.property("has-default", has_default),
801        }
802    }
803
804    pub fn has_focus(self, has_focus: bool) -> Self {
805        Self {
806            builder: self.builder.property("has-focus", has_focus),
807        }
808    }
809
810    /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
811    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
812    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
813    /// whether it will provide a tooltip or not.
814    ///
815    /// Note that setting this property to [`true`] for the first time will change
816    /// the event masks of the GdkWindows of this widget to include leave-notify
817    /// and motion-notify events. This cannot and will not be undone when the
818    /// property is set to [`false`] again.
819    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
820        Self {
821            builder: self.builder.property("has-tooltip", has_tooltip),
822        }
823    }
824
825    pub fn height_request(self, height_request: i32) -> Self {
826        Self {
827            builder: self.builder.property("height-request", height_request),
828        }
829    }
830
831    /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
832    pub fn hexpand(self, hexpand: bool) -> Self {
833        Self {
834            builder: self.builder.property("hexpand", hexpand),
835        }
836    }
837
838    /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
839    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
840        Self {
841            builder: self.builder.property("hexpand-set", hexpand_set),
842        }
843    }
844
845    pub fn is_focus(self, is_focus: bool) -> Self {
846        Self {
847            builder: self.builder.property("is-focus", is_focus),
848        }
849    }
850
851    /// Sets all four sides' margin at once. If read, returns max
852    /// margin on any side.
853    pub fn margin(self, margin: i32) -> Self {
854        Self {
855            builder: self.builder.property("margin", margin),
856        }
857    }
858
859    /// Margin on bottom side of widget.
860    ///
861    /// This property adds margin outside of the widget's normal size
862    /// request, the margin will be added in addition to the size from
863    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
864    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
865        Self {
866            builder: self.builder.property("margin-bottom", margin_bottom),
867        }
868    }
869
870    /// Margin on end of widget, horizontally. This property supports
871    /// left-to-right and right-to-left text directions.
872    ///
873    /// This property adds margin outside of the widget's normal size
874    /// request, the margin will be added in addition to the size from
875    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
876    pub fn margin_end(self, margin_end: i32) -> Self {
877        Self {
878            builder: self.builder.property("margin-end", margin_end),
879        }
880    }
881
882    /// Margin on start of widget, horizontally. This property supports
883    /// left-to-right and right-to-left text directions.
884    ///
885    /// This property adds margin outside of the widget's normal size
886    /// request, the margin will be added in addition to the size from
887    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
888    pub fn margin_start(self, margin_start: i32) -> Self {
889        Self {
890            builder: self.builder.property("margin-start", margin_start),
891        }
892    }
893
894    /// Margin on top side of widget.
895    ///
896    /// This property adds margin outside of the widget's normal size
897    /// request, the margin will be added in addition to the size from
898    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
899    pub fn margin_top(self, margin_top: i32) -> Self {
900        Self {
901            builder: self.builder.property("margin-top", margin_top),
902        }
903    }
904
905    pub fn name(self, name: impl Into<glib::GString>) -> Self {
906        Self {
907            builder: self.builder.property("name", name.into()),
908        }
909    }
910
911    pub fn no_show_all(self, no_show_all: bool) -> Self {
912        Self {
913            builder: self.builder.property("no-show-all", no_show_all),
914        }
915    }
916
917    /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
918    /// more details about window opacity.
919    ///
920    /// Before 3.8 this was only available in GtkWindow
921    pub fn opacity(self, opacity: f64) -> Self {
922        Self {
923            builder: self.builder.property("opacity", opacity),
924        }
925    }
926
927    pub fn parent(self, parent: &impl IsA<Container>) -> Self {
928        Self {
929            builder: self.builder.property("parent", parent.clone().upcast()),
930        }
931    }
932
933    pub fn receives_default(self, receives_default: bool) -> Self {
934        Self {
935            builder: self.builder.property("receives-default", receives_default),
936        }
937    }
938
939    pub fn sensitive(self, sensitive: bool) -> Self {
940        Self {
941            builder: self.builder.property("sensitive", sensitive),
942        }
943    }
944
945    /// Sets the text of tooltip to be the given string, which is marked up
946    /// with the [Pango text markup language][PangoMarkupFormat].
947    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
948    ///
949    /// This is a convenience property which will take care of getting the
950    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
951    /// will automatically be set to [`true`] and there will be taken care of
952    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
953    ///
954    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
955    /// are set, the last one wins.
956    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
957        Self {
958            builder: self
959                .builder
960                .property("tooltip-markup", tooltip_markup.into()),
961        }
962    }
963
964    /// Sets the text of tooltip to be the given string.
965    ///
966    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
967    ///
968    /// This is a convenience property which will take care of getting the
969    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
970    /// will automatically be set to [`true`] and there will be taken care of
971    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
972    ///
973    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
974    /// are set, the last one wins.
975    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
976        Self {
977            builder: self.builder.property("tooltip-text", tooltip_text.into()),
978        }
979    }
980
981    /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
982    pub fn valign(self, valign: Align) -> Self {
983        Self {
984            builder: self.builder.property("valign", valign),
985        }
986    }
987
988    /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
989    pub fn vexpand(self, vexpand: bool) -> Self {
990        Self {
991            builder: self.builder.property("vexpand", vexpand),
992        }
993    }
994
995    /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
996    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
997        Self {
998            builder: self.builder.property("vexpand-set", vexpand_set),
999        }
1000    }
1001
1002    pub fn visible(self, visible: bool) -> Self {
1003        Self {
1004            builder: self.builder.property("visible", visible),
1005        }
1006    }
1007
1008    pub fn width_request(self, width_request: i32) -> Self {
1009        Self {
1010            builder: self.builder.property("width-request", width_request),
1011        }
1012    }
1013
1014    // rustdoc-stripper-ignore-next
1015    /// Build the [`AccelLabel`].
1016    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1017    pub fn build(self) -> AccelLabel {
1018        assert_initialized_main_thread!();
1019        self.builder.build()
1020    }
1021}
1022
1023/// Trait containing all [`struct@AccelLabel`] methods.
1024///
1025/// # Implementors
1026///
1027/// [`AccelLabel`][struct@crate::AccelLabel]
1028pub trait AccelLabelExt: IsA<AccelLabel> + 'static {
1029    /// Gets the keyval and modifier mask set with
1030    /// [`set_accel()`][Self::set_accel()].
1031    ///
1032    /// # Returns
1033    ///
1034    ///
1035    /// ## `accelerator_key`
1036    /// return location for the keyval
1037    ///
1038    /// ## `accelerator_mods`
1039    /// return location for the modifier mask
1040    #[doc(alias = "gtk_accel_label_get_accel")]
1041    #[doc(alias = "get_accel")]
1042    fn accel(&self) -> (u32, gdk::ModifierType) {
1043        unsafe {
1044            let mut accelerator_key = std::mem::MaybeUninit::uninit();
1045            let mut accelerator_mods = std::mem::MaybeUninit::uninit();
1046            ffi::gtk_accel_label_get_accel(
1047                self.as_ref().to_glib_none().0,
1048                accelerator_key.as_mut_ptr(),
1049                accelerator_mods.as_mut_ptr(),
1050            );
1051            (
1052                accelerator_key.assume_init(),
1053                from_glib(accelerator_mods.assume_init()),
1054            )
1055        }
1056    }
1057
1058    /// Fetches the widget monitored by this accelerator label. See
1059    /// [`set_accel_widget()`][Self::set_accel_widget()].
1060    ///
1061    /// # Returns
1062    ///
1063    /// the object monitored by the accelerator label, or [`None`].
1064    #[doc(alias = "gtk_accel_label_get_accel_widget")]
1065    #[doc(alias = "get_accel_widget")]
1066    #[doc(alias = "accel-widget")]
1067    fn accel_widget(&self) -> Option<Widget> {
1068        unsafe {
1069            from_glib_none(ffi::gtk_accel_label_get_accel_widget(
1070                self.as_ref().to_glib_none().0,
1071            ))
1072        }
1073    }
1074
1075    /// Returns the width needed to display the accelerator key(s).
1076    /// This is used by menus to align all of the [`MenuItem`][crate::MenuItem] widgets, and shouldn't
1077    /// be needed by applications.
1078    ///
1079    /// # Returns
1080    ///
1081    /// the width needed to display the accelerator key(s).
1082    #[doc(alias = "gtk_accel_label_get_accel_width")]
1083    #[doc(alias = "get_accel_width")]
1084    fn accel_width(&self) -> u32 {
1085        unsafe { ffi::gtk_accel_label_get_accel_width(self.as_ref().to_glib_none().0) }
1086    }
1087
1088    /// Recreates the string representing the accelerator keys.
1089    /// This should not be needed since the string is automatically updated whenever
1090    /// accelerators are added or removed from the associated widget.
1091    ///
1092    /// # Returns
1093    ///
1094    /// always returns [`false`].
1095    #[doc(alias = "gtk_accel_label_refetch")]
1096    fn refetch(&self) -> bool {
1097        unsafe { from_glib(ffi::gtk_accel_label_refetch(self.as_ref().to_glib_none().0)) }
1098    }
1099
1100    /// Manually sets a keyval and modifier mask as the accelerator rendered
1101    /// by `self`.
1102    ///
1103    /// If a keyval and modifier are explicitly set then these values are
1104    /// used regardless of any associated accel closure or widget.
1105    ///
1106    /// Providing an `accelerator_key` of 0 removes the manual setting.
1107    /// ## `accelerator_key`
1108    /// a keyval, or 0
1109    /// ## `accelerator_mods`
1110    /// the modifier mask for the accel
1111    #[doc(alias = "gtk_accel_label_set_accel")]
1112    fn set_accel(&self, accelerator_key: u32, accelerator_mods: gdk::ModifierType) {
1113        unsafe {
1114            ffi::gtk_accel_label_set_accel(
1115                self.as_ref().to_glib_none().0,
1116                accelerator_key,
1117                accelerator_mods.into_glib(),
1118            );
1119        }
1120    }
1121
1122    /// Sets the closure to be monitored by this accelerator label. The closure
1123    /// must be connected to an accelerator group; see [`AccelGroupExtManual::connect_accel_group()`][crate::prelude::AccelGroupExtManual::connect_accel_group()].
1124    /// Passing [`None`] for `accel_closure` will dissociate `self` from its
1125    /// current closure, if any.
1126    /// ## `accel_closure`
1127    /// the closure to monitor for accelerator changes,
1128    /// or [`None`]
1129    #[doc(alias = "gtk_accel_label_set_accel_closure")]
1130    #[doc(alias = "accel-closure")]
1131    fn set_accel_closure(&self, accel_closure: Option<&glib::Closure>) {
1132        unsafe {
1133            ffi::gtk_accel_label_set_accel_closure(
1134                self.as_ref().to_glib_none().0,
1135                accel_closure.to_glib_none().0,
1136            );
1137        }
1138    }
1139
1140    /// Sets the widget to be monitored by this accelerator label. Passing [`None`] for
1141    /// `accel_widget` will dissociate `self` from its current widget, if any.
1142    /// ## `accel_widget`
1143    /// the widget to be monitored, or [`None`]
1144    #[doc(alias = "gtk_accel_label_set_accel_widget")]
1145    #[doc(alias = "accel-widget")]
1146    fn set_accel_widget(&self, accel_widget: Option<&impl IsA<Widget>>) {
1147        unsafe {
1148            ffi::gtk_accel_label_set_accel_widget(
1149                self.as_ref().to_glib_none().0,
1150                accel_widget.map(|p| p.as_ref()).to_glib_none().0,
1151            );
1152        }
1153    }
1154
1155    #[doc(alias = "accel-closure")]
1156    fn accel_closure(&self) -> Option<glib::Closure> {
1157        ObjectExt::property(self.as_ref(), "accel-closure")
1158    }
1159
1160    #[doc(alias = "accel-closure")]
1161    fn connect_accel_closure_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1162        unsafe extern "C" fn notify_accel_closure_trampoline<
1163            P: IsA<AccelLabel>,
1164            F: Fn(&P) + 'static,
1165        >(
1166            this: *mut ffi::GtkAccelLabel,
1167            _param_spec: glib::ffi::gpointer,
1168            f: glib::ffi::gpointer,
1169        ) {
1170            unsafe {
1171                let f: &F = &*(f as *const F);
1172                f(AccelLabel::from_glib_borrow(this).unsafe_cast_ref())
1173            }
1174        }
1175        unsafe {
1176            let f: Box_<F> = Box_::new(f);
1177            connect_raw(
1178                self.as_ptr() as *mut _,
1179                c"notify::accel-closure".as_ptr(),
1180                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1181                    notify_accel_closure_trampoline::<Self, F> as *const (),
1182                )),
1183                Box_::into_raw(f),
1184            )
1185        }
1186    }
1187
1188    #[doc(alias = "accel-widget")]
1189    fn connect_accel_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1190        unsafe extern "C" fn notify_accel_widget_trampoline<
1191            P: IsA<AccelLabel>,
1192            F: Fn(&P) + 'static,
1193        >(
1194            this: *mut ffi::GtkAccelLabel,
1195            _param_spec: glib::ffi::gpointer,
1196            f: glib::ffi::gpointer,
1197        ) {
1198            unsafe {
1199                let f: &F = &*(f as *const F);
1200                f(AccelLabel::from_glib_borrow(this).unsafe_cast_ref())
1201            }
1202        }
1203        unsafe {
1204            let f: Box_<F> = Box_::new(f);
1205            connect_raw(
1206                self.as_ptr() as *mut _,
1207                c"notify::accel-widget".as_ptr(),
1208                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1209                    notify_accel_widget_trampoline::<Self, F> as *const (),
1210                )),
1211                Box_::into_raw(f),
1212            )
1213        }
1214    }
1215}
1216
1217impl<O: IsA<AccelLabel>> AccelLabelExt for O {}