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 ffi, Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, LayoutManager, Overflow,
8 Widget,
9};
10use glib::{
11 prelude::*,
12 signal::{connect_raw, SignalHandlerId},
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 let f: &F = &*(f as *const F);
474 f(&from_glib_borrow(this))
475 }
476 unsafe {
477 let f: Box_<F> = Box_::new(f);
478 connect_raw(
479 self.as_ptr() as *mut _,
480 b"notify::accelerator\0".as_ptr() as *const _,
481 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
482 notify_accelerator_trampoline::<F> as *const (),
483 )),
484 Box_::into_raw(f),
485 )
486 }
487 }
488
489 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
490 #[doc(alias = "disabled-text")]
491 pub fn connect_disabled_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
492 unsafe extern "C" fn notify_disabled_text_trampoline<F: Fn(&ShortcutLabel) + 'static>(
493 this: *mut ffi::GtkShortcutLabel,
494 _param_spec: glib::ffi::gpointer,
495 f: glib::ffi::gpointer,
496 ) {
497 let f: &F = &*(f as *const F);
498 f(&from_glib_borrow(this))
499 }
500 unsafe {
501 let f: Box_<F> = Box_::new(f);
502 connect_raw(
503 self.as_ptr() as *mut _,
504 b"notify::disabled-text\0".as_ptr() as *const _,
505 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
506 notify_disabled_text_trampoline::<F> as *const (),
507 )),
508 Box_::into_raw(f),
509 )
510 }
511 }
512}
513
514impl Default for ShortcutLabel {
515 fn default() -> Self {
516 glib::object::Object::new::<Self>()
517 }
518}
519
520// rustdoc-stripper-ignore-next
521/// A [builder-pattern] type to construct [`ShortcutLabel`] objects.
522///
523/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
524#[must_use = "The builder must be built to be used"]
525pub struct ShortcutLabelBuilder {
526 builder: glib::object::ObjectBuilder<'static, ShortcutLabel>,
527}
528
529impl ShortcutLabelBuilder {
530 fn new() -> Self {
531 Self {
532 builder: glib::object::Object::builder(),
533 }
534 }
535
536 /// The accelerator that @self_ displays.
537 ///
538 /// See [`accelerator`][struct@crate::ShortcutsShortcut#accelerator]
539 /// for the accepted syntax.
540 /// This widget will be removed in GTK 5
541 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
542 pub fn accelerator(self, accelerator: impl Into<glib::GString>) -> Self {
543 Self {
544 builder: self.builder.property("accelerator", accelerator.into()),
545 }
546 }
547
548 /// The text that is displayed when no accelerator is set.
549 /// This widget will be removed in GTK 5
550 #[cfg_attr(feature = "v4_18", deprecated = "Since 4.18")]
551 pub fn disabled_text(self, disabled_text: impl Into<glib::GString>) -> Self {
552 Self {
553 builder: self.builder.property("disabled-text", disabled_text.into()),
554 }
555 }
556
557 /// Whether the widget or any of its descendents can accept
558 /// the input focus.
559 ///
560 /// This property is meant to be set by widget implementations,
561 /// typically in their instance init function.
562 pub fn can_focus(self, can_focus: bool) -> Self {
563 Self {
564 builder: self.builder.property("can-focus", can_focus),
565 }
566 }
567
568 /// Whether the widget can receive pointer events.
569 pub fn can_target(self, can_target: bool) -> Self {
570 Self {
571 builder: self.builder.property("can-target", can_target),
572 }
573 }
574
575 /// A list of css classes applied to this widget.
576 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
577 Self {
578 builder: self.builder.property("css-classes", css_classes.into()),
579 }
580 }
581
582 /// The name of this widget in the CSS tree.
583 ///
584 /// This property is meant to be set by widget implementations,
585 /// typically in their instance init function.
586 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
587 Self {
588 builder: self.builder.property("css-name", css_name.into()),
589 }
590 }
591
592 /// The cursor used by @widget.
593 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
594 Self {
595 builder: self.builder.property("cursor", cursor.clone()),
596 }
597 }
598
599 /// Whether the widget should grab focus when it is clicked with the mouse.
600 ///
601 /// This property is only relevant for widgets that can take focus.
602 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
603 Self {
604 builder: self.builder.property("focus-on-click", focus_on_click),
605 }
606 }
607
608 /// Whether this widget itself will accept the input focus.
609 pub fn focusable(self, focusable: bool) -> Self {
610 Self {
611 builder: self.builder.property("focusable", focusable),
612 }
613 }
614
615 /// How to distribute horizontal space if widget gets extra space.
616 pub fn halign(self, halign: Align) -> Self {
617 Self {
618 builder: self.builder.property("halign", halign),
619 }
620 }
621
622 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
623 /// signal on @widget.
624 ///
625 /// A true value indicates that @widget can have a tooltip, in this case
626 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
627 /// determine whether it will provide a tooltip or not.
628 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
629 Self {
630 builder: self.builder.property("has-tooltip", has_tooltip),
631 }
632 }
633
634 /// Overrides for height request of the widget.
635 ///
636 /// If this is -1, the natural request will be used.
637 pub fn height_request(self, height_request: i32) -> Self {
638 Self {
639 builder: self.builder.property("height-request", height_request),
640 }
641 }
642
643 /// Whether to expand horizontally.
644 pub fn hexpand(self, hexpand: bool) -> Self {
645 Self {
646 builder: self.builder.property("hexpand", hexpand),
647 }
648 }
649
650 /// Whether to use the `hexpand` property.
651 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
652 Self {
653 builder: self.builder.property("hexpand-set", hexpand_set),
654 }
655 }
656
657 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
658 /// the preferred size of the widget, and allocate its children.
659 ///
660 /// This property is meant to be set by widget implementations,
661 /// typically in their instance init function.
662 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
663 Self {
664 builder: self
665 .builder
666 .property("layout-manager", layout_manager.clone().upcast()),
667 }
668 }
669
670 /// Makes this widget act like a modal dialog, with respect to
671 /// event delivery.
672 ///
673 /// Global event controllers will not handle events with targets
674 /// inside the widget, unless they are set up to ignore propagation
675 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
676 #[cfg(feature = "v4_18")]
677 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
678 pub fn limit_events(self, limit_events: bool) -> Self {
679 Self {
680 builder: self.builder.property("limit-events", limit_events),
681 }
682 }
683
684 /// Margin on bottom side of widget.
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_bottom(self, margin_bottom: i32) -> Self {
690 Self {
691 builder: self.builder.property("margin-bottom", margin_bottom),
692 }
693 }
694
695 /// Margin on end of widget, horizontally.
696 ///
697 /// This property supports left-to-right and right-to-left text
698 /// directions.
699 ///
700 /// This property adds margin outside of the widget's normal size
701 /// request, the margin will be added in addition to the size from
702 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
703 pub fn margin_end(self, margin_end: i32) -> Self {
704 Self {
705 builder: self.builder.property("margin-end", margin_end),
706 }
707 }
708
709 /// Margin on start of widget, horizontally.
710 ///
711 /// This property supports left-to-right and right-to-left text
712 /// directions.
713 ///
714 /// This property adds margin outside of the widget's normal size
715 /// request, the margin will be added in addition to the size from
716 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
717 pub fn margin_start(self, margin_start: i32) -> Self {
718 Self {
719 builder: self.builder.property("margin-start", margin_start),
720 }
721 }
722
723 /// Margin on top side of widget.
724 ///
725 /// This property adds margin outside of the widget's normal size
726 /// request, the margin will be added in addition to the size from
727 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
728 pub fn margin_top(self, margin_top: i32) -> Self {
729 Self {
730 builder: self.builder.property("margin-top", margin_top),
731 }
732 }
733
734 /// The name of the widget.
735 pub fn name(self, name: impl Into<glib::GString>) -> Self {
736 Self {
737 builder: self.builder.property("name", name.into()),
738 }
739 }
740
741 /// The requested opacity of the widget.
742 pub fn opacity(self, opacity: f64) -> Self {
743 Self {
744 builder: self.builder.property("opacity", opacity),
745 }
746 }
747
748 /// How content outside the widget's content area is treated.
749 ///
750 /// This property is meant to be set by widget implementations,
751 /// typically in their instance init function.
752 pub fn overflow(self, overflow: Overflow) -> Self {
753 Self {
754 builder: self.builder.property("overflow", overflow),
755 }
756 }
757
758 /// Whether the widget will receive the default action when it is focused.
759 pub fn receives_default(self, receives_default: bool) -> Self {
760 Self {
761 builder: self.builder.property("receives-default", receives_default),
762 }
763 }
764
765 /// Whether the widget responds to input.
766 pub fn sensitive(self, sensitive: bool) -> Self {
767 Self {
768 builder: self.builder.property("sensitive", sensitive),
769 }
770 }
771
772 /// Sets the text of tooltip to be the given string, which is marked up
773 /// with Pango markup.
774 ///
775 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
776 ///
777 /// This is a convenience property which will take care of getting the
778 /// tooltip shown if the given string is not `NULL`:
779 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
780 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
781 /// the default signal handler.
782 ///
783 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
784 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
785 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
786 Self {
787 builder: self
788 .builder
789 .property("tooltip-markup", tooltip_markup.into()),
790 }
791 }
792
793 /// Sets the text of tooltip to be the given string.
794 ///
795 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
796 ///
797 /// This is a convenience property which will take care of getting the
798 /// tooltip shown if the given string is not `NULL`:
799 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
800 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
801 /// the default signal handler.
802 ///
803 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
804 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
805 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
806 Self {
807 builder: self.builder.property("tooltip-text", tooltip_text.into()),
808 }
809 }
810
811 /// How to distribute vertical space if widget gets extra space.
812 pub fn valign(self, valign: Align) -> Self {
813 Self {
814 builder: self.builder.property("valign", valign),
815 }
816 }
817
818 /// Whether to expand vertically.
819 pub fn vexpand(self, vexpand: bool) -> Self {
820 Self {
821 builder: self.builder.property("vexpand", vexpand),
822 }
823 }
824
825 /// Whether to use the `vexpand` property.
826 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
827 Self {
828 builder: self.builder.property("vexpand-set", vexpand_set),
829 }
830 }
831
832 /// Whether the widget is visible.
833 pub fn visible(self, visible: bool) -> Self {
834 Self {
835 builder: self.builder.property("visible", visible),
836 }
837 }
838
839 /// Overrides for width request of the widget.
840 ///
841 /// If this is -1, the natural request will be used.
842 pub fn width_request(self, width_request: i32) -> Self {
843 Self {
844 builder: self.builder.property("width-request", width_request),
845 }
846 }
847
848 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
849 ///
850 /// The accessible role cannot be changed once set.
851 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
852 Self {
853 builder: self.builder.property("accessible-role", accessible_role),
854 }
855 }
856
857 // rustdoc-stripper-ignore-next
858 /// Build the [`ShortcutLabel`].
859 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
860 pub fn build(self) -> ShortcutLabel {
861 assert_initialized_main_thread!();
862 self.builder.build()
863 }
864}