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