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