gtk4/auto/revealer.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 ffi, Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, LayoutManager, Overflow,
7 RevealerTransitionType, Widget,
8};
9use glib::{
10 prelude::*,
11 signal::{connect_raw, SignalHandlerId},
12 translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17 /// A [`Revealer`][crate::Revealer] animates the transition of its child from invisible to visible.
18 ///
19 /// The style of transition can be controlled with
20 /// [`set_transition_type()`][Self::set_transition_type()].
21 ///
22 /// These animations respect the [`gtk-enable-animations`][struct@crate::Settings#gtk-enable-animations]
23 /// setting.
24 ///
25 /// # CSS nodes
26 ///
27 /// [`Revealer`][crate::Revealer] has a single CSS node with name revealer.
28 /// When styling [`Revealer`][crate::Revealer] using CSS, remember that it only hides its contents,
29 /// not itself. That means applied margin, padding and borders will be visible even
30 /// when the [`reveal-child`][struct@crate::Revealer#reveal-child] property is set to [`false`].
31 ///
32 /// # Accessibility
33 ///
34 /// [`Revealer`][crate::Revealer] uses the [`AccessibleRole::Group`][crate::AccessibleRole::Group] role.
35 ///
36 /// The child of [`Revealer`][crate::Revealer], if set, is always available in the accessibility
37 /// tree, regardless of the state of the revealer widget.
38 ///
39 /// ## Properties
40 ///
41 ///
42 /// #### `child`
43 /// The child widget.
44 ///
45 /// Readable | Writeable
46 ///
47 ///
48 /// #### `child-revealed`
49 /// Whether the child is revealed and the animation target reached.
50 ///
51 /// Readable
52 ///
53 ///
54 /// #### `reveal-child`
55 /// Whether the revealer should reveal the child.
56 ///
57 /// Readable | Writeable | Construct
58 ///
59 ///
60 /// #### `transition-duration`
61 /// The animation duration, in milliseconds.
62 ///
63 /// Readable | Writeable | Construct
64 ///
65 ///
66 /// #### `transition-type`
67 /// The type of animation used to transition.
68 ///
69 /// Readable | Writeable | Construct
70 /// <details><summary><h4>Widget</h4></summary>
71 ///
72 ///
73 /// #### `can-focus`
74 /// Whether the widget or any of its descendents can accept
75 /// the input focus.
76 ///
77 /// This property is meant to be set by widget implementations,
78 /// typically in their instance init function.
79 ///
80 /// Readable | Writeable
81 ///
82 ///
83 /// #### `can-target`
84 /// Whether the widget can receive pointer events.
85 ///
86 /// Readable | Writeable
87 ///
88 ///
89 /// #### `css-classes`
90 /// A list of css classes applied to this widget.
91 ///
92 /// Readable | Writeable
93 ///
94 ///
95 /// #### `css-name`
96 /// The name of this widget in the CSS tree.
97 ///
98 /// This property is meant to be set by widget implementations,
99 /// typically in their instance init function.
100 ///
101 /// Readable | Writeable | Construct Only
102 ///
103 ///
104 /// #### `cursor`
105 /// The cursor used by @widget.
106 ///
107 /// Readable | Writeable
108 ///
109 ///
110 /// #### `focus-on-click`
111 /// Whether the widget should grab focus when it is clicked with the mouse.
112 ///
113 /// This property is only relevant for widgets that can take focus.
114 ///
115 /// Readable | Writeable
116 ///
117 ///
118 /// #### `focusable`
119 /// Whether this widget itself will accept the input focus.
120 ///
121 /// Readable | Writeable
122 ///
123 ///
124 /// #### `halign`
125 /// How to distribute horizontal space if widget gets extra space.
126 ///
127 /// Readable | Writeable
128 ///
129 ///
130 /// #### `has-default`
131 /// Whether the widget is the default widget.
132 ///
133 /// Readable
134 ///
135 ///
136 /// #### `has-focus`
137 /// Whether the widget has the input focus.
138 ///
139 /// Readable
140 ///
141 ///
142 /// #### `has-tooltip`
143 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
144 /// signal on @widget.
145 ///
146 /// A true value indicates that @widget can have a tooltip, in this case
147 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
148 /// determine whether it will provide a tooltip or not.
149 ///
150 /// Readable | Writeable
151 ///
152 ///
153 /// #### `height-request`
154 /// Overrides for height request of the widget.
155 ///
156 /// If this is -1, the natural request will be used.
157 ///
158 /// Readable | Writeable
159 ///
160 ///
161 /// #### `hexpand`
162 /// Whether to expand horizontally.
163 ///
164 /// Readable | Writeable
165 ///
166 ///
167 /// #### `hexpand-set`
168 /// Whether to use the `hexpand` property.
169 ///
170 /// Readable | Writeable
171 ///
172 ///
173 /// #### `layout-manager`
174 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
175 /// the preferred size of the widget, and allocate its children.
176 ///
177 /// This property is meant to be set by widget implementations,
178 /// typically in their instance init function.
179 ///
180 /// Readable | Writeable
181 ///
182 ///
183 /// #### `limit-events`
184 /// Makes this widget act like a modal dialog, with respect to
185 /// event delivery.
186 ///
187 /// Global event controllers will not handle events with targets
188 /// inside the widget, unless they are set up to ignore propagation
189 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
190 ///
191 /// Readable | Writeable
192 ///
193 ///
194 /// #### `margin-bottom`
195 /// Margin on bottom 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 | Writeable
202 ///
203 ///
204 /// #### `margin-end`
205 /// Margin on end of widget, horizontally.
206 ///
207 /// This property supports left-to-right and right-to-left text
208 /// directions.
209 ///
210 /// This property adds margin outside of the widget's normal size
211 /// request, the margin will be added in addition to the size from
212 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
213 ///
214 /// Readable | Writeable
215 ///
216 ///
217 /// #### `margin-start`
218 /// Margin on start of widget, horizontally.
219 ///
220 /// This property supports left-to-right and right-to-left text
221 /// directions.
222 ///
223 /// This property adds margin outside of the widget's normal size
224 /// request, the margin will be added in addition to the size from
225 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
226 ///
227 /// Readable | Writeable
228 ///
229 ///
230 /// #### `margin-top`
231 /// Margin on top side of widget.
232 ///
233 /// This property adds margin outside of the widget's normal size
234 /// request, the margin will be added in addition to the size from
235 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
236 ///
237 /// Readable | Writeable
238 ///
239 ///
240 /// #### `name`
241 /// The name of the widget.
242 ///
243 /// Readable | Writeable
244 ///
245 ///
246 /// #### `opacity`
247 /// The requested opacity of the widget.
248 ///
249 /// Readable | Writeable
250 ///
251 ///
252 /// #### `overflow`
253 /// How content outside the widget's content area is treated.
254 ///
255 /// This property is meant to be set by widget implementations,
256 /// typically in their instance init function.
257 ///
258 /// Readable | Writeable
259 ///
260 ///
261 /// #### `parent`
262 /// The parent widget of this widget.
263 ///
264 /// Readable
265 ///
266 ///
267 /// #### `receives-default`
268 /// Whether the widget will receive the default action when it is focused.
269 ///
270 /// Readable | Writeable
271 ///
272 ///
273 /// #### `root`
274 /// The [`Root`][crate::Root] widget of the widget tree containing this widget.
275 ///
276 /// This will be `NULL` if the widget is not contained in a root widget.
277 ///
278 /// Readable
279 ///
280 ///
281 /// #### `scale-factor`
282 /// The scale factor of the widget.
283 ///
284 /// Readable
285 ///
286 ///
287 /// #### `sensitive`
288 /// Whether the widget responds to input.
289 ///
290 /// Readable | Writeable
291 ///
292 ///
293 /// #### `tooltip-markup`
294 /// Sets the text of tooltip to be the given string, which is marked up
295 /// with Pango markup.
296 ///
297 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
298 ///
299 /// This is a convenience property which will take care of getting the
300 /// tooltip shown if the given string is not `NULL`:
301 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
302 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
303 /// the default signal handler.
304 ///
305 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
306 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
307 ///
308 /// Readable | Writeable
309 ///
310 ///
311 /// #### `tooltip-text`
312 /// Sets the text of tooltip to be the given string.
313 ///
314 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
315 ///
316 /// This is a convenience property which will take care of getting the
317 /// tooltip shown if the given string is not `NULL`:
318 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
319 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
320 /// the default signal handler.
321 ///
322 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
323 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
324 ///
325 /// Readable | Writeable
326 ///
327 ///
328 /// #### `valign`
329 /// How to distribute vertical space if widget gets extra space.
330 ///
331 /// Readable | Writeable
332 ///
333 ///
334 /// #### `vexpand`
335 /// Whether to expand vertically.
336 ///
337 /// Readable | Writeable
338 ///
339 ///
340 /// #### `vexpand-set`
341 /// Whether to use the `vexpand` property.
342 ///
343 /// Readable | Writeable
344 ///
345 ///
346 /// #### `visible`
347 /// Whether the widget is visible.
348 ///
349 /// Readable | Writeable
350 ///
351 ///
352 /// #### `width-request`
353 /// Overrides for width request of the widget.
354 ///
355 /// If this is -1, the natural request will be used.
356 ///
357 /// Readable | Writeable
358 /// </details>
359 /// <details><summary><h4>Accessible</h4></summary>
360 ///
361 ///
362 /// #### `accessible-role`
363 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
364 ///
365 /// The accessible role cannot be changed once set.
366 ///
367 /// Readable | Writeable
368 /// </details>
369 ///
370 /// # Implements
371 ///
372 /// [`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]
373 #[doc(alias = "GtkRevealer")]
374 pub struct Revealer(Object<ffi::GtkRevealer>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
375
376 match fn {
377 type_ => || ffi::gtk_revealer_get_type(),
378 }
379}
380
381impl Revealer {
382 /// Creates a new [`Revealer`][crate::Revealer].
383 ///
384 /// # Returns
385 ///
386 /// a newly created [`Revealer`][crate::Revealer]
387 #[doc(alias = "gtk_revealer_new")]
388 pub fn new() -> Revealer {
389 assert_initialized_main_thread!();
390 unsafe { Widget::from_glib_none(ffi::gtk_revealer_new()).unsafe_cast() }
391 }
392
393 // rustdoc-stripper-ignore-next
394 /// Creates a new builder-pattern struct instance to construct [`Revealer`] objects.
395 ///
396 /// This method returns an instance of [`RevealerBuilder`](crate::builders::RevealerBuilder) which can be used to create [`Revealer`] objects.
397 pub fn builder() -> RevealerBuilder {
398 RevealerBuilder::new()
399 }
400
401 /// Gets the child widget of @self.
402 ///
403 /// # Returns
404 ///
405 /// the child widget of @self
406 #[doc(alias = "gtk_revealer_get_child")]
407 #[doc(alias = "get_child")]
408 pub fn child(&self) -> Option<Widget> {
409 unsafe { from_glib_none(ffi::gtk_revealer_get_child(self.to_glib_none().0)) }
410 }
411
412 /// Returns whether the child is fully revealed.
413 ///
414 /// In other words, this returns whether the transition
415 /// to the revealed state is completed.
416 ///
417 /// # Returns
418 ///
419 /// [`true`] if the child is fully revealed
420 #[doc(alias = "gtk_revealer_get_child_revealed")]
421 #[doc(alias = "get_child_revealed")]
422 #[doc(alias = "child-revealed")]
423 pub fn is_child_revealed(&self) -> bool {
424 unsafe { from_glib(ffi::gtk_revealer_get_child_revealed(self.to_glib_none().0)) }
425 }
426
427 /// Returns whether the child is currently revealed.
428 ///
429 /// This function returns [`true`] as soon as the transition
430 /// is to the revealed state is started. To learn whether
431 /// the child is fully revealed (ie the transition is completed),
432 /// use [`is_child_revealed()`][Self::is_child_revealed()].
433 ///
434 /// # Returns
435 ///
436 /// [`true`] if the child is revealed.
437 #[doc(alias = "gtk_revealer_get_reveal_child")]
438 #[doc(alias = "get_reveal_child")]
439 #[doc(alias = "reveal-child")]
440 pub fn reveals_child(&self) -> bool {
441 unsafe { from_glib(ffi::gtk_revealer_get_reveal_child(self.to_glib_none().0)) }
442 }
443
444 /// Returns the amount of time (in milliseconds) that
445 /// transitions will take.
446 ///
447 /// # Returns
448 ///
449 /// the transition duration
450 #[doc(alias = "gtk_revealer_get_transition_duration")]
451 #[doc(alias = "get_transition_duration")]
452 #[doc(alias = "transition-duration")]
453 pub fn transition_duration(&self) -> u32 {
454 unsafe { ffi::gtk_revealer_get_transition_duration(self.to_glib_none().0) }
455 }
456
457 /// Gets the type of animation that will be used
458 /// for transitions in @self.
459 ///
460 /// # Returns
461 ///
462 /// the current transition type of @self
463 #[doc(alias = "gtk_revealer_get_transition_type")]
464 #[doc(alias = "get_transition_type")]
465 #[doc(alias = "transition-type")]
466 pub fn transition_type(&self) -> RevealerTransitionType {
467 unsafe { from_glib(ffi::gtk_revealer_get_transition_type(self.to_glib_none().0)) }
468 }
469
470 /// Sets the child widget of @self.
471 /// ## `child`
472 /// the child widget
473 #[doc(alias = "gtk_revealer_set_child")]
474 #[doc(alias = "child")]
475 pub fn set_child(&self, child: Option<&impl IsA<Widget>>) {
476 unsafe {
477 ffi::gtk_revealer_set_child(
478 self.to_glib_none().0,
479 child.map(|p| p.as_ref()).to_glib_none().0,
480 );
481 }
482 }
483
484 /// Tells the [`Revealer`][crate::Revealer] to reveal or conceal its child.
485 ///
486 /// The transition will be animated with the current
487 /// transition type of @self.
488 /// ## `reveal_child`
489 /// [`true`] to reveal the child
490 #[doc(alias = "gtk_revealer_set_reveal_child")]
491 #[doc(alias = "reveal-child")]
492 pub fn set_reveal_child(&self, reveal_child: bool) {
493 unsafe {
494 ffi::gtk_revealer_set_reveal_child(self.to_glib_none().0, reveal_child.into_glib());
495 }
496 }
497
498 /// Sets the duration that transitions will take.
499 /// ## `duration`
500 /// the new duration, in milliseconds
501 #[doc(alias = "gtk_revealer_set_transition_duration")]
502 #[doc(alias = "transition-duration")]
503 pub fn set_transition_duration(&self, duration: u32) {
504 unsafe {
505 ffi::gtk_revealer_set_transition_duration(self.to_glib_none().0, duration);
506 }
507 }
508
509 /// Sets the type of animation that will be used for
510 /// transitions in @self.
511 ///
512 /// Available types include various kinds of fades and slides.
513 /// ## `transition`
514 /// the new transition type
515 #[doc(alias = "gtk_revealer_set_transition_type")]
516 #[doc(alias = "transition-type")]
517 pub fn set_transition_type(&self, transition: RevealerTransitionType) {
518 unsafe {
519 ffi::gtk_revealer_set_transition_type(self.to_glib_none().0, transition.into_glib());
520 }
521 }
522
523 #[doc(alias = "child")]
524 pub fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
525 unsafe extern "C" fn notify_child_trampoline<F: Fn(&Revealer) + 'static>(
526 this: *mut ffi::GtkRevealer,
527 _param_spec: glib::ffi::gpointer,
528 f: glib::ffi::gpointer,
529 ) {
530 let f: &F = &*(f as *const F);
531 f(&from_glib_borrow(this))
532 }
533 unsafe {
534 let f: Box_<F> = Box_::new(f);
535 connect_raw(
536 self.as_ptr() as *mut _,
537 b"notify::child\0".as_ptr() as *const _,
538 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
539 notify_child_trampoline::<F> as *const (),
540 )),
541 Box_::into_raw(f),
542 )
543 }
544 }
545
546 #[doc(alias = "child-revealed")]
547 pub fn connect_child_revealed_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
548 unsafe extern "C" fn notify_child_revealed_trampoline<F: Fn(&Revealer) + 'static>(
549 this: *mut ffi::GtkRevealer,
550 _param_spec: glib::ffi::gpointer,
551 f: glib::ffi::gpointer,
552 ) {
553 let f: &F = &*(f as *const F);
554 f(&from_glib_borrow(this))
555 }
556 unsafe {
557 let f: Box_<F> = Box_::new(f);
558 connect_raw(
559 self.as_ptr() as *mut _,
560 b"notify::child-revealed\0".as_ptr() as *const _,
561 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
562 notify_child_revealed_trampoline::<F> as *const (),
563 )),
564 Box_::into_raw(f),
565 )
566 }
567 }
568
569 #[doc(alias = "reveal-child")]
570 pub fn connect_reveal_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
571 unsafe extern "C" fn notify_reveal_child_trampoline<F: Fn(&Revealer) + 'static>(
572 this: *mut ffi::GtkRevealer,
573 _param_spec: glib::ffi::gpointer,
574 f: glib::ffi::gpointer,
575 ) {
576 let f: &F = &*(f as *const F);
577 f(&from_glib_borrow(this))
578 }
579 unsafe {
580 let f: Box_<F> = Box_::new(f);
581 connect_raw(
582 self.as_ptr() as *mut _,
583 b"notify::reveal-child\0".as_ptr() as *const _,
584 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
585 notify_reveal_child_trampoline::<F> as *const (),
586 )),
587 Box_::into_raw(f),
588 )
589 }
590 }
591
592 #[doc(alias = "transition-duration")]
593 pub fn connect_transition_duration_notify<F: Fn(&Self) + 'static>(
594 &self,
595 f: F,
596 ) -> SignalHandlerId {
597 unsafe extern "C" fn notify_transition_duration_trampoline<F: Fn(&Revealer) + 'static>(
598 this: *mut ffi::GtkRevealer,
599 _param_spec: glib::ffi::gpointer,
600 f: glib::ffi::gpointer,
601 ) {
602 let f: &F = &*(f as *const F);
603 f(&from_glib_borrow(this))
604 }
605 unsafe {
606 let f: Box_<F> = Box_::new(f);
607 connect_raw(
608 self.as_ptr() as *mut _,
609 b"notify::transition-duration\0".as_ptr() as *const _,
610 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
611 notify_transition_duration_trampoline::<F> as *const (),
612 )),
613 Box_::into_raw(f),
614 )
615 }
616 }
617
618 #[doc(alias = "transition-type")]
619 pub fn connect_transition_type_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
620 unsafe extern "C" fn notify_transition_type_trampoline<F: Fn(&Revealer) + 'static>(
621 this: *mut ffi::GtkRevealer,
622 _param_spec: glib::ffi::gpointer,
623 f: glib::ffi::gpointer,
624 ) {
625 let f: &F = &*(f as *const F);
626 f(&from_glib_borrow(this))
627 }
628 unsafe {
629 let f: Box_<F> = Box_::new(f);
630 connect_raw(
631 self.as_ptr() as *mut _,
632 b"notify::transition-type\0".as_ptr() as *const _,
633 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
634 notify_transition_type_trampoline::<F> as *const (),
635 )),
636 Box_::into_raw(f),
637 )
638 }
639 }
640}
641
642impl Default for Revealer {
643 fn default() -> Self {
644 Self::new()
645 }
646}
647
648// rustdoc-stripper-ignore-next
649/// A [builder-pattern] type to construct [`Revealer`] objects.
650///
651/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
652#[must_use = "The builder must be built to be used"]
653pub struct RevealerBuilder {
654 builder: glib::object::ObjectBuilder<'static, Revealer>,
655}
656
657impl RevealerBuilder {
658 fn new() -> Self {
659 Self {
660 builder: glib::object::Object::builder(),
661 }
662 }
663
664 /// The child widget.
665 pub fn child(self, child: &impl IsA<Widget>) -> Self {
666 Self {
667 builder: self.builder.property("child", child.clone().upcast()),
668 }
669 }
670
671 /// Whether the revealer should reveal the child.
672 pub fn reveal_child(self, reveal_child: bool) -> Self {
673 Self {
674 builder: self.builder.property("reveal-child", reveal_child),
675 }
676 }
677
678 /// The animation duration, in milliseconds.
679 pub fn transition_duration(self, transition_duration: u32) -> Self {
680 Self {
681 builder: self
682 .builder
683 .property("transition-duration", transition_duration),
684 }
685 }
686
687 /// The type of animation used to transition.
688 pub fn transition_type(self, transition_type: RevealerTransitionType) -> Self {
689 Self {
690 builder: self.builder.property("transition-type", transition_type),
691 }
692 }
693
694 /// Whether the widget or any of its descendents can accept
695 /// the input focus.
696 ///
697 /// This property is meant to be set by widget implementations,
698 /// typically in their instance init function.
699 pub fn can_focus(self, can_focus: bool) -> Self {
700 Self {
701 builder: self.builder.property("can-focus", can_focus),
702 }
703 }
704
705 /// Whether the widget can receive pointer events.
706 pub fn can_target(self, can_target: bool) -> Self {
707 Self {
708 builder: self.builder.property("can-target", can_target),
709 }
710 }
711
712 /// A list of css classes applied to this widget.
713 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
714 Self {
715 builder: self.builder.property("css-classes", css_classes.into()),
716 }
717 }
718
719 /// The name of this widget in the CSS tree.
720 ///
721 /// This property is meant to be set by widget implementations,
722 /// typically in their instance init function.
723 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
724 Self {
725 builder: self.builder.property("css-name", css_name.into()),
726 }
727 }
728
729 /// The cursor used by @widget.
730 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
731 Self {
732 builder: self.builder.property("cursor", cursor.clone()),
733 }
734 }
735
736 /// Whether the widget should grab focus when it is clicked with the mouse.
737 ///
738 /// This property is only relevant for widgets that can take focus.
739 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
740 Self {
741 builder: self.builder.property("focus-on-click", focus_on_click),
742 }
743 }
744
745 /// Whether this widget itself will accept the input focus.
746 pub fn focusable(self, focusable: bool) -> Self {
747 Self {
748 builder: self.builder.property("focusable", focusable),
749 }
750 }
751
752 /// How to distribute horizontal space if widget gets extra space.
753 pub fn halign(self, halign: Align) -> Self {
754 Self {
755 builder: self.builder.property("halign", halign),
756 }
757 }
758
759 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
760 /// signal on @widget.
761 ///
762 /// A true value indicates that @widget can have a tooltip, in this case
763 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
764 /// determine whether it will provide a tooltip or not.
765 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
766 Self {
767 builder: self.builder.property("has-tooltip", has_tooltip),
768 }
769 }
770
771 /// Overrides for height request of the widget.
772 ///
773 /// If this is -1, the natural request will be used.
774 pub fn height_request(self, height_request: i32) -> Self {
775 Self {
776 builder: self.builder.property("height-request", height_request),
777 }
778 }
779
780 /// Whether to expand horizontally.
781 pub fn hexpand(self, hexpand: bool) -> Self {
782 Self {
783 builder: self.builder.property("hexpand", hexpand),
784 }
785 }
786
787 /// Whether to use the `hexpand` property.
788 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
789 Self {
790 builder: self.builder.property("hexpand-set", hexpand_set),
791 }
792 }
793
794 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
795 /// the preferred size of the widget, and allocate its children.
796 ///
797 /// This property is meant to be set by widget implementations,
798 /// typically in their instance init function.
799 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
800 Self {
801 builder: self
802 .builder
803 .property("layout-manager", layout_manager.clone().upcast()),
804 }
805 }
806
807 /// Makes this widget act like a modal dialog, with respect to
808 /// event delivery.
809 ///
810 /// Global event controllers will not handle events with targets
811 /// inside the widget, unless they are set up to ignore propagation
812 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
813 #[cfg(feature = "v4_18")]
814 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
815 pub fn limit_events(self, limit_events: bool) -> Self {
816 Self {
817 builder: self.builder.property("limit-events", limit_events),
818 }
819 }
820
821 /// Margin on bottom side of widget.
822 ///
823 /// This property adds margin outside of the widget's normal size
824 /// request, the margin will be added in addition to the size from
825 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
826 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
827 Self {
828 builder: self.builder.property("margin-bottom", margin_bottom),
829 }
830 }
831
832 /// Margin on end of widget, horizontally.
833 ///
834 /// This property supports left-to-right and right-to-left text
835 /// directions.
836 ///
837 /// This property adds margin outside of the widget's normal size
838 /// request, the margin will be added in addition to the size from
839 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
840 pub fn margin_end(self, margin_end: i32) -> Self {
841 Self {
842 builder: self.builder.property("margin-end", margin_end),
843 }
844 }
845
846 /// Margin on start of widget, horizontally.
847 ///
848 /// This property supports left-to-right and right-to-left text
849 /// directions.
850 ///
851 /// This property adds margin outside of the widget's normal size
852 /// request, the margin will be added in addition to the size from
853 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
854 pub fn margin_start(self, margin_start: i32) -> Self {
855 Self {
856 builder: self.builder.property("margin-start", margin_start),
857 }
858 }
859
860 /// Margin on top side of widget.
861 ///
862 /// This property adds margin outside of the widget's normal size
863 /// request, the margin will be added in addition to the size from
864 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
865 pub fn margin_top(self, margin_top: i32) -> Self {
866 Self {
867 builder: self.builder.property("margin-top", margin_top),
868 }
869 }
870
871 /// The name of the widget.
872 pub fn name(self, name: impl Into<glib::GString>) -> Self {
873 Self {
874 builder: self.builder.property("name", name.into()),
875 }
876 }
877
878 /// The requested opacity of the widget.
879 pub fn opacity(self, opacity: f64) -> Self {
880 Self {
881 builder: self.builder.property("opacity", opacity),
882 }
883 }
884
885 /// How content outside the widget's content area is treated.
886 ///
887 /// This property is meant to be set by widget implementations,
888 /// typically in their instance init function.
889 pub fn overflow(self, overflow: Overflow) -> Self {
890 Self {
891 builder: self.builder.property("overflow", overflow),
892 }
893 }
894
895 /// Whether the widget will receive the default action when it is focused.
896 pub fn receives_default(self, receives_default: bool) -> Self {
897 Self {
898 builder: self.builder.property("receives-default", receives_default),
899 }
900 }
901
902 /// Whether the widget responds to input.
903 pub fn sensitive(self, sensitive: bool) -> Self {
904 Self {
905 builder: self.builder.property("sensitive", sensitive),
906 }
907 }
908
909 /// Sets the text of tooltip to be the given string, which is marked up
910 /// with Pango markup.
911 ///
912 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
913 ///
914 /// This is a convenience property which will take care of getting the
915 /// tooltip shown if the given string is not `NULL`:
916 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
917 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
918 /// the default signal handler.
919 ///
920 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
921 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
922 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
923 Self {
924 builder: self
925 .builder
926 .property("tooltip-markup", tooltip_markup.into()),
927 }
928 }
929
930 /// Sets the text of tooltip to be the given string.
931 ///
932 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
933 ///
934 /// This is a convenience property which will take care of getting the
935 /// tooltip shown if the given string is not `NULL`:
936 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
937 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
938 /// the default signal handler.
939 ///
940 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
941 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
942 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
943 Self {
944 builder: self.builder.property("tooltip-text", tooltip_text.into()),
945 }
946 }
947
948 /// How to distribute vertical space if widget gets extra space.
949 pub fn valign(self, valign: Align) -> Self {
950 Self {
951 builder: self.builder.property("valign", valign),
952 }
953 }
954
955 /// Whether to expand vertically.
956 pub fn vexpand(self, vexpand: bool) -> Self {
957 Self {
958 builder: self.builder.property("vexpand", vexpand),
959 }
960 }
961
962 /// Whether to use the `vexpand` property.
963 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
964 Self {
965 builder: self.builder.property("vexpand-set", vexpand_set),
966 }
967 }
968
969 /// Whether the widget is visible.
970 pub fn visible(self, visible: bool) -> Self {
971 Self {
972 builder: self.builder.property("visible", visible),
973 }
974 }
975
976 /// Overrides for width request of the widget.
977 ///
978 /// If this is -1, the natural request will be used.
979 pub fn width_request(self, width_request: i32) -> Self {
980 Self {
981 builder: self.builder.property("width-request", width_request),
982 }
983 }
984
985 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
986 ///
987 /// The accessible role cannot be changed once set.
988 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
989 Self {
990 builder: self.builder.property("accessible-role", accessible_role),
991 }
992 }
993
994 // rustdoc-stripper-ignore-next
995 /// Build the [`Revealer`].
996 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
997 pub fn build(self) -> Revealer {
998 assert_initialized_main_thread!();
999 self.builder.build()
1000 }
1001}