Skip to main content

gtk/auto/
shortcut_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::{
6    Align, BaselinePosition, Box, Buildable, Container, Orientable, Orientation, ResizeMode,
7    Widget, ffi,
8};
9use glib::{
10    prelude::*,
11    signal::{SignalHandlerId, connect_raw},
12    translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17    /// [`ShortcutLabel`][crate::ShortcutLabel] is a widget that represents a single keyboard shortcut or gesture
18    /// in the user interface.
19    ///
20    /// ## Properties
21    ///
22    ///
23    /// #### `accelerator`
24    ///  The accelerator that `self_` displays. See [`accelerator`][struct@crate::ShortcutsShortcut#accelerator]
25    /// for the accepted syntax.
26    ///
27    /// Readable | Writable
28    ///
29    ///
30    /// #### `disabled-text`
31    ///  The text that is displayed when no accelerator is set.
32    ///
33    /// Readable | Writable
34    /// <details><summary><h4>Box</h4></summary>
35    ///
36    ///
37    /// #### `baseline-position`
38    ///  Readable | Writable
39    ///
40    ///
41    /// #### `homogeneous`
42    ///  Readable | Writable
43    ///
44    ///
45    /// #### `spacing`
46    ///  Readable | Writable
47    /// </details>
48    /// <details><summary><h4>Container</h4></summary>
49    ///
50    ///
51    /// #### `border-width`
52    ///  Readable | Writable
53    ///
54    ///
55    /// #### `child`
56    ///  Writable
57    ///
58    ///
59    /// #### `resize-mode`
60    ///  Readable | Writable
61    /// </details>
62    /// <details><summary><h4>Widget</h4></summary>
63    ///
64    ///
65    /// #### `app-paintable`
66    ///  Readable | Writable
67    ///
68    ///
69    /// #### `can-default`
70    ///  Readable | Writable
71    ///
72    ///
73    /// #### `can-focus`
74    ///  Readable | Writable
75    ///
76    ///
77    /// #### `composite-child`
78    ///  Readable
79    ///
80    ///
81    /// #### `double-buffered`
82    ///  Whether the widget is double buffered.
83    ///
84    /// Readable | Writable
85    ///
86    ///
87    /// #### `events`
88    ///  Readable | Writable
89    ///
90    ///
91    /// #### `expand`
92    ///  Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
93    ///
94    /// Readable | Writable
95    ///
96    ///
97    /// #### `focus-on-click`
98    ///  Whether the widget should grab focus when it is clicked with the mouse.
99    ///
100    /// This property is only relevant for widgets that can take focus.
101    ///
102    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
103    /// GtkComboBox) implemented this property individually.
104    ///
105    /// Readable | Writable
106    ///
107    ///
108    /// #### `halign`
109    ///  How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
110    ///
111    /// Readable | Writable
112    ///
113    ///
114    /// #### `has-default`
115    ///  Readable | Writable
116    ///
117    ///
118    /// #### `has-focus`
119    ///  Readable | Writable
120    ///
121    ///
122    /// #### `has-tooltip`
123    ///  Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
124    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
125    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
126    /// whether it will provide a tooltip or not.
127    ///
128    /// Note that setting this property to [`true`] for the first time will change
129    /// the event masks of the GdkWindows of this widget to include leave-notify
130    /// and motion-notify events. This cannot and will not be undone when the
131    /// property is set to [`false`] again.
132    ///
133    /// Readable | Writable
134    ///
135    ///
136    /// #### `height-request`
137    ///  Readable | Writable
138    ///
139    ///
140    /// #### `hexpand`
141    ///  Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
142    ///
143    /// Readable | Writable
144    ///
145    ///
146    /// #### `hexpand-set`
147    ///  Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
148    ///
149    /// Readable | Writable
150    ///
151    ///
152    /// #### `is-focus`
153    ///  Readable | Writable
154    ///
155    ///
156    /// #### `margin`
157    ///  Sets all four sides' margin at once. If read, returns max
158    /// margin on any side.
159    ///
160    /// Readable | Writable
161    ///
162    ///
163    /// #### `margin-bottom`
164    ///  Margin on bottom side of widget.
165    ///
166    /// This property adds margin outside of the widget's normal size
167    /// request, the margin will be added in addition to the size from
168    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
169    ///
170    /// Readable | Writable
171    ///
172    ///
173    /// #### `margin-end`
174    ///  Margin on end of widget, horizontally. This property supports
175    /// left-to-right and right-to-left text directions.
176    ///
177    /// This property adds margin outside of the widget's normal size
178    /// request, the margin will be added in addition to the size from
179    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
180    ///
181    /// Readable | Writable
182    ///
183    ///
184    /// #### `margin-left`
185    ///  Margin on left side of widget.
186    ///
187    /// This property adds margin outside of the widget's normal size
188    /// request, the margin will be added in addition to the size from
189    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
190    ///
191    /// Readable | Writable
192    ///
193    ///
194    /// #### `margin-right`
195    ///  Margin on right side of widget.
196    ///
197    /// This property adds margin outside of the widget's normal size
198    /// request, the margin will be added in addition to the size from
199    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
200    ///
201    /// Readable | Writable
202    ///
203    ///
204    /// #### `margin-start`
205    ///  Margin on start of widget, horizontally. This property supports
206    /// left-to-right and right-to-left text directions.
207    ///
208    /// This property adds margin outside of the widget's normal size
209    /// request, the margin will be added in addition to the size from
210    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
211    ///
212    /// Readable | Writable
213    ///
214    ///
215    /// #### `margin-top`
216    ///  Margin on top side of widget.
217    ///
218    /// This property adds margin outside of the widget's normal size
219    /// request, the margin will be added in addition to the size from
220    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
221    ///
222    /// Readable | Writable
223    ///
224    ///
225    /// #### `name`
226    ///  Readable | Writable
227    ///
228    ///
229    /// #### `no-show-all`
230    ///  Readable | Writable
231    ///
232    ///
233    /// #### `opacity`
234    ///  The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
235    /// more details about window opacity.
236    ///
237    /// Before 3.8 this was only available in GtkWindow
238    ///
239    /// Readable | Writable
240    ///
241    ///
242    /// #### `parent`
243    ///  Readable | Writable
244    ///
245    ///
246    /// #### `receives-default`
247    ///  Readable | Writable
248    ///
249    ///
250    /// #### `scale-factor`
251    ///  The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
252    /// more details about widget scaling.
253    ///
254    /// Readable
255    ///
256    ///
257    /// #### `sensitive`
258    ///  Readable | Writable
259    ///
260    ///
261    /// #### `style`
262    ///  The style of the widget, which contains information about how it will look (colors, etc).
263    ///
264    /// Readable | Writable
265    ///
266    ///
267    /// #### `tooltip-markup`
268    ///  Sets the text of tooltip to be the given string, which is marked up
269    /// with the [Pango text markup language][PangoMarkupFormat].
270    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
271    ///
272    /// This is a convenience property which will take care of getting the
273    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
274    /// will automatically be set to [`true`] and there will be taken care of
275    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
276    ///
277    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
278    /// are set, the last one wins.
279    ///
280    /// Readable | Writable
281    ///
282    ///
283    /// #### `tooltip-text`
284    ///  Sets the text of tooltip to be the given string.
285    ///
286    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
287    ///
288    /// This is a convenience property which will take care of getting the
289    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
290    /// will automatically be set to [`true`] and there will be taken care of
291    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
292    ///
293    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
294    /// are set, the last one wins.
295    ///
296    /// Readable | Writable
297    ///
298    ///
299    /// #### `valign`
300    ///  How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
301    ///
302    /// Readable | Writable
303    ///
304    ///
305    /// #### `vexpand`
306    ///  Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
307    ///
308    /// Readable | Writable
309    ///
310    ///
311    /// #### `vexpand-set`
312    ///  Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
313    ///
314    /// Readable | Writable
315    ///
316    ///
317    /// #### `visible`
318    ///  Readable | Writable
319    ///
320    ///
321    /// #### `width-request`
322    ///  Readable | Writable
323    ///
324    ///
325    /// #### `window`
326    ///  The widget's window if it is realized, [`None`] otherwise.
327    ///
328    /// Readable
329    /// </details>
330    /// <details><summary><h4>Orientable</h4></summary>
331    ///
332    ///
333    /// #### `orientation`
334    ///  The orientation of the orientable.
335    ///
336    /// Readable | Writable
337    /// </details>
338    ///
339    /// # Implements
340    ///
341    /// [`BoxExt`][trait@crate::prelude::BoxExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`OrientableExt`][trait@crate::prelude::OrientableExt], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
342    #[doc(alias = "GtkShortcutLabel")]
343    pub struct ShortcutLabel(Object<ffi::GtkShortcutLabel, ffi::GtkShortcutLabelClass>) @extends Box, Container, Widget, @implements Buildable, Orientable;
344
345    match fn {
346        type_ => || ffi::gtk_shortcut_label_get_type(),
347    }
348}
349
350impl ShortcutLabel {
351    /// Creates a new [`ShortcutLabel`][crate::ShortcutLabel] with `accelerator` set.
352    /// ## `accelerator`
353    /// the initial accelerator
354    ///
355    /// # Returns
356    ///
357    /// a newly-allocated [`ShortcutLabel`][crate::ShortcutLabel]
358    #[doc(alias = "gtk_shortcut_label_new")]
359    pub fn new(accelerator: &str) -> ShortcutLabel {
360        assert_initialized_main_thread!();
361        unsafe {
362            Widget::from_glib_none(ffi::gtk_shortcut_label_new(accelerator.to_glib_none().0))
363                .unsafe_cast()
364        }
365    }
366
367    // rustdoc-stripper-ignore-next
368    /// Creates a new builder-pattern struct instance to construct [`ShortcutLabel`] objects.
369    ///
370    /// This method returns an instance of [`ShortcutLabelBuilder`](crate::builders::ShortcutLabelBuilder) which can be used to create [`ShortcutLabel`] objects.
371    pub fn builder() -> ShortcutLabelBuilder {
372        ShortcutLabelBuilder::new()
373    }
374
375    /// Retrieves the current accelerator of `self`.
376    ///
377    /// # Returns
378    ///
379    /// the current accelerator.
380    #[doc(alias = "gtk_shortcut_label_get_accelerator")]
381    #[doc(alias = "get_accelerator")]
382    pub fn accelerator(&self) -> Option<glib::GString> {
383        unsafe {
384            from_glib_none(ffi::gtk_shortcut_label_get_accelerator(
385                self.to_glib_none().0,
386            ))
387        }
388    }
389
390    /// Retrieves the text that is displayed when no accelerator is set.
391    ///
392    /// # Returns
393    ///
394    /// the current text displayed when no
395    /// accelerator is set.
396    #[doc(alias = "gtk_shortcut_label_get_disabled_text")]
397    #[doc(alias = "get_disabled_text")]
398    #[doc(alias = "disabled-text")]
399    pub fn disabled_text(&self) -> Option<glib::GString> {
400        unsafe {
401            from_glib_none(ffi::gtk_shortcut_label_get_disabled_text(
402                self.to_glib_none().0,
403            ))
404        }
405    }
406
407    /// Sets the accelerator to be displayed by `self`.
408    /// ## `accelerator`
409    /// the new accelerator
410    #[doc(alias = "gtk_shortcut_label_set_accelerator")]
411    #[doc(alias = "accelerator")]
412    pub fn set_accelerator(&self, accelerator: &str) {
413        unsafe {
414            ffi::gtk_shortcut_label_set_accelerator(
415                self.to_glib_none().0,
416                accelerator.to_glib_none().0,
417            );
418        }
419    }
420
421    /// Sets the text to be displayed by `self` when no accelerator is set.
422    /// ## `disabled_text`
423    /// the text to be displayed when no accelerator is set
424    #[doc(alias = "gtk_shortcut_label_set_disabled_text")]
425    #[doc(alias = "disabled-text")]
426    pub fn set_disabled_text(&self, disabled_text: &str) {
427        unsafe {
428            ffi::gtk_shortcut_label_set_disabled_text(
429                self.to_glib_none().0,
430                disabled_text.to_glib_none().0,
431            );
432        }
433    }
434
435    #[doc(alias = "accelerator")]
436    pub fn connect_accelerator_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
437        unsafe extern "C" fn notify_accelerator_trampoline<F: Fn(&ShortcutLabel) + 'static>(
438            this: *mut ffi::GtkShortcutLabel,
439            _param_spec: glib::ffi::gpointer,
440            f: glib::ffi::gpointer,
441        ) {
442            unsafe {
443                let f: &F = &*(f as *const F);
444                f(&from_glib_borrow(this))
445            }
446        }
447        unsafe {
448            let f: Box_<F> = Box_::new(f);
449            connect_raw(
450                self.as_ptr() as *mut _,
451                c"notify::accelerator".as_ptr(),
452                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
453                    notify_accelerator_trampoline::<F> as *const (),
454                )),
455                Box_::into_raw(f),
456            )
457        }
458    }
459
460    #[doc(alias = "disabled-text")]
461    pub fn connect_disabled_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
462        unsafe extern "C" fn notify_disabled_text_trampoline<F: Fn(&ShortcutLabel) + 'static>(
463            this: *mut ffi::GtkShortcutLabel,
464            _param_spec: glib::ffi::gpointer,
465            f: glib::ffi::gpointer,
466        ) {
467            unsafe {
468                let f: &F = &*(f as *const F);
469                f(&from_glib_borrow(this))
470            }
471        }
472        unsafe {
473            let f: Box_<F> = Box_::new(f);
474            connect_raw(
475                self.as_ptr() as *mut _,
476                c"notify::disabled-text".as_ptr(),
477                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
478                    notify_disabled_text_trampoline::<F> as *const (),
479                )),
480                Box_::into_raw(f),
481            )
482        }
483    }
484}
485
486impl Default for ShortcutLabel {
487    fn default() -> Self {
488        glib::object::Object::new::<Self>()
489    }
490}
491
492// rustdoc-stripper-ignore-next
493/// A [builder-pattern] type to construct [`ShortcutLabel`] objects.
494///
495/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
496#[must_use = "The builder must be built to be used"]
497pub struct ShortcutLabelBuilder {
498    builder: glib::object::ObjectBuilder<'static, ShortcutLabel>,
499}
500
501impl ShortcutLabelBuilder {
502    fn new() -> Self {
503        Self {
504            builder: glib::object::Object::builder(),
505        }
506    }
507
508    /// The accelerator that `self_` displays. See [`accelerator`][struct@crate::ShortcutsShortcut#accelerator]
509    /// for the accepted syntax.
510    pub fn accelerator(self, accelerator: impl Into<glib::GString>) -> Self {
511        Self {
512            builder: self.builder.property("accelerator", accelerator.into()),
513        }
514    }
515
516    /// The text that is displayed when no accelerator is set.
517    pub fn disabled_text(self, disabled_text: impl Into<glib::GString>) -> Self {
518        Self {
519            builder: self.builder.property("disabled-text", disabled_text.into()),
520        }
521    }
522
523    pub fn baseline_position(self, baseline_position: BaselinePosition) -> Self {
524        Self {
525            builder: self
526                .builder
527                .property("baseline-position", baseline_position),
528        }
529    }
530
531    pub fn homogeneous(self, homogeneous: bool) -> Self {
532        Self {
533            builder: self.builder.property("homogeneous", homogeneous),
534        }
535    }
536
537    pub fn spacing(self, spacing: i32) -> Self {
538        Self {
539            builder: self.builder.property("spacing", spacing),
540        }
541    }
542
543    pub fn border_width(self, border_width: u32) -> Self {
544        Self {
545            builder: self.builder.property("border-width", border_width),
546        }
547    }
548
549    pub fn child(self, child: &impl IsA<Widget>) -> Self {
550        Self {
551            builder: self.builder.property("child", child.clone().upcast()),
552        }
553    }
554
555    pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
556        Self {
557            builder: self.builder.property("resize-mode", resize_mode),
558        }
559    }
560
561    pub fn app_paintable(self, app_paintable: bool) -> Self {
562        Self {
563            builder: self.builder.property("app-paintable", app_paintable),
564        }
565    }
566
567    pub fn can_default(self, can_default: bool) -> Self {
568        Self {
569            builder: self.builder.property("can-default", can_default),
570        }
571    }
572
573    pub fn can_focus(self, can_focus: bool) -> Self {
574        Self {
575            builder: self.builder.property("can-focus", can_focus),
576        }
577    }
578
579    pub fn events(self, events: gdk::EventMask) -> Self {
580        Self {
581            builder: self.builder.property("events", events),
582        }
583    }
584
585    /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
586    pub fn expand(self, expand: bool) -> Self {
587        Self {
588            builder: self.builder.property("expand", expand),
589        }
590    }
591
592    /// Whether the widget should grab focus when it is clicked with the mouse.
593    ///
594    /// This property is only relevant for widgets that can take focus.
595    ///
596    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
597    /// GtkComboBox) implemented this property individually.
598    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
599        Self {
600            builder: self.builder.property("focus-on-click", focus_on_click),
601        }
602    }
603
604    /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
605    pub fn halign(self, halign: Align) -> Self {
606        Self {
607            builder: self.builder.property("halign", halign),
608        }
609    }
610
611    pub fn has_default(self, has_default: bool) -> Self {
612        Self {
613            builder: self.builder.property("has-default", has_default),
614        }
615    }
616
617    pub fn has_focus(self, has_focus: bool) -> Self {
618        Self {
619            builder: self.builder.property("has-focus", has_focus),
620        }
621    }
622
623    /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
624    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
625    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
626    /// whether it will provide a tooltip or not.
627    ///
628    /// Note that setting this property to [`true`] for the first time will change
629    /// the event masks of the GdkWindows of this widget to include leave-notify
630    /// and motion-notify events. This cannot and will not be undone when the
631    /// property is set to [`false`] again.
632    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
633        Self {
634            builder: self.builder.property("has-tooltip", has_tooltip),
635        }
636    }
637
638    pub fn height_request(self, height_request: i32) -> Self {
639        Self {
640            builder: self.builder.property("height-request", height_request),
641        }
642    }
643
644    /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
645    pub fn hexpand(self, hexpand: bool) -> Self {
646        Self {
647            builder: self.builder.property("hexpand", hexpand),
648        }
649    }
650
651    /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
652    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
653        Self {
654            builder: self.builder.property("hexpand-set", hexpand_set),
655        }
656    }
657
658    pub fn is_focus(self, is_focus: bool) -> Self {
659        Self {
660            builder: self.builder.property("is-focus", is_focus),
661        }
662    }
663
664    /// Sets all four sides' margin at once. If read, returns max
665    /// margin on any side.
666    pub fn margin(self, margin: i32) -> Self {
667        Self {
668            builder: self.builder.property("margin", margin),
669        }
670    }
671
672    /// Margin on bottom side of widget.
673    ///
674    /// This property adds margin outside of the widget's normal size
675    /// request, the margin will be added in addition to the size from
676    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
677    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
678        Self {
679            builder: self.builder.property("margin-bottom", margin_bottom),
680        }
681    }
682
683    /// Margin on end of widget, horizontally. This property supports
684    /// left-to-right and right-to-left text directions.
685    ///
686    /// This property adds margin outside of the widget's normal size
687    /// request, the margin will be added in addition to the size from
688    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
689    pub fn margin_end(self, margin_end: i32) -> Self {
690        Self {
691            builder: self.builder.property("margin-end", margin_end),
692        }
693    }
694
695    /// Margin on start of widget, horizontally. This property supports
696    /// left-to-right and right-to-left text directions.
697    ///
698    /// This property adds margin outside of the widget's normal size
699    /// request, the margin will be added in addition to the size from
700    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
701    pub fn margin_start(self, margin_start: i32) -> Self {
702        Self {
703            builder: self.builder.property("margin-start", margin_start),
704        }
705    }
706
707    /// Margin on top side of widget.
708    ///
709    /// This property adds margin outside of the widget's normal size
710    /// request, the margin will be added in addition to the size from
711    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
712    pub fn margin_top(self, margin_top: i32) -> Self {
713        Self {
714            builder: self.builder.property("margin-top", margin_top),
715        }
716    }
717
718    pub fn name(self, name: impl Into<glib::GString>) -> Self {
719        Self {
720            builder: self.builder.property("name", name.into()),
721        }
722    }
723
724    pub fn no_show_all(self, no_show_all: bool) -> Self {
725        Self {
726            builder: self.builder.property("no-show-all", no_show_all),
727        }
728    }
729
730    /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
731    /// more details about window opacity.
732    ///
733    /// Before 3.8 this was only available in GtkWindow
734    pub fn opacity(self, opacity: f64) -> Self {
735        Self {
736            builder: self.builder.property("opacity", opacity),
737        }
738    }
739
740    pub fn parent(self, parent: &impl IsA<Container>) -> Self {
741        Self {
742            builder: self.builder.property("parent", parent.clone().upcast()),
743        }
744    }
745
746    pub fn receives_default(self, receives_default: bool) -> Self {
747        Self {
748            builder: self.builder.property("receives-default", receives_default),
749        }
750    }
751
752    pub fn sensitive(self, sensitive: bool) -> Self {
753        Self {
754            builder: self.builder.property("sensitive", sensitive),
755        }
756    }
757
758    /// Sets the text of tooltip to be the given string, which is marked up
759    /// with the [Pango text markup language][PangoMarkupFormat].
760    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
761    ///
762    /// This is a convenience property which will take care of getting the
763    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
764    /// will automatically be set to [`true`] and there will be taken care of
765    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
766    ///
767    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
768    /// are set, the last one wins.
769    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
770        Self {
771            builder: self
772                .builder
773                .property("tooltip-markup", tooltip_markup.into()),
774        }
775    }
776
777    /// Sets the text of tooltip to be the given string.
778    ///
779    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
780    ///
781    /// This is a convenience property which will take care of getting the
782    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
783    /// will automatically be set to [`true`] and there will be taken care of
784    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
785    ///
786    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
787    /// are set, the last one wins.
788    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
789        Self {
790            builder: self.builder.property("tooltip-text", tooltip_text.into()),
791        }
792    }
793
794    /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
795    pub fn valign(self, valign: Align) -> Self {
796        Self {
797            builder: self.builder.property("valign", valign),
798        }
799    }
800
801    /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
802    pub fn vexpand(self, vexpand: bool) -> Self {
803        Self {
804            builder: self.builder.property("vexpand", vexpand),
805        }
806    }
807
808    /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
809    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
810        Self {
811            builder: self.builder.property("vexpand-set", vexpand_set),
812        }
813    }
814
815    pub fn visible(self, visible: bool) -> Self {
816        Self {
817            builder: self.builder.property("visible", visible),
818        }
819    }
820
821    pub fn width_request(self, width_request: i32) -> Self {
822        Self {
823            builder: self.builder.property("width-request", width_request),
824        }
825    }
826
827    /// The orientation of the orientable.
828    pub fn orientation(self, orientation: Orientation) -> Self {
829        Self {
830            builder: self.builder.property("orientation", orientation),
831        }
832    }
833
834    // rustdoc-stripper-ignore-next
835    /// Build the [`ShortcutLabel`].
836    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
837    pub fn build(self) -> ShortcutLabel {
838        assert_initialized_main_thread!();
839        self.builder.build()
840    }
841}