[go: up one dir, main page]

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    #[doc(alias = "GtkRevealer")]
18    pub struct Revealer(Object<ffi::GtkRevealer>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
19
20    match fn {
21        type_ => || ffi::gtk_revealer_get_type(),
22    }
23}
24
25impl Revealer {
26    #[doc(alias = "gtk_revealer_new")]
27    pub fn new() -> Revealer {
28        assert_initialized_main_thread!();
29        unsafe { Widget::from_glib_none(ffi::gtk_revealer_new()).unsafe_cast() }
30    }
31
32    // rustdoc-stripper-ignore-next
33    /// Creates a new builder-pattern struct instance to construct [`Revealer`] objects.
34    ///
35    /// This method returns an instance of [`RevealerBuilder`](crate::builders::RevealerBuilder) which can be used to create [`Revealer`] objects.
36    pub fn builder() -> RevealerBuilder {
37        RevealerBuilder::new()
38    }
39
40    #[doc(alias = "gtk_revealer_get_child")]
41    #[doc(alias = "get_child")]
42    pub fn child(&self) -> Option<Widget> {
43        unsafe { from_glib_none(ffi::gtk_revealer_get_child(self.to_glib_none().0)) }
44    }
45
46    #[doc(alias = "gtk_revealer_get_child_revealed")]
47    #[doc(alias = "get_child_revealed")]
48    #[doc(alias = "child-revealed")]
49    pub fn is_child_revealed(&self) -> bool {
50        unsafe { from_glib(ffi::gtk_revealer_get_child_revealed(self.to_glib_none().0)) }
51    }
52
53    #[doc(alias = "gtk_revealer_get_reveal_child")]
54    #[doc(alias = "get_reveal_child")]
55    #[doc(alias = "reveal-child")]
56    pub fn reveals_child(&self) -> bool {
57        unsafe { from_glib(ffi::gtk_revealer_get_reveal_child(self.to_glib_none().0)) }
58    }
59
60    #[doc(alias = "gtk_revealer_get_transition_duration")]
61    #[doc(alias = "get_transition_duration")]
62    #[doc(alias = "transition-duration")]
63    pub fn transition_duration(&self) -> u32 {
64        unsafe { ffi::gtk_revealer_get_transition_duration(self.to_glib_none().0) }
65    }
66
67    #[doc(alias = "gtk_revealer_get_transition_type")]
68    #[doc(alias = "get_transition_type")]
69    #[doc(alias = "transition-type")]
70    pub fn transition_type(&self) -> RevealerTransitionType {
71        unsafe { from_glib(ffi::gtk_revealer_get_transition_type(self.to_glib_none().0)) }
72    }
73
74    #[doc(alias = "gtk_revealer_set_child")]
75    #[doc(alias = "child")]
76    pub fn set_child(&self, child: Option<&impl IsA<Widget>>) {
77        unsafe {
78            ffi::gtk_revealer_set_child(
79                self.to_glib_none().0,
80                child.map(|p| p.as_ref()).to_glib_none().0,
81            );
82        }
83    }
84
85    #[doc(alias = "gtk_revealer_set_reveal_child")]
86    #[doc(alias = "reveal-child")]
87    pub fn set_reveal_child(&self, reveal_child: bool) {
88        unsafe {
89            ffi::gtk_revealer_set_reveal_child(self.to_glib_none().0, reveal_child.into_glib());
90        }
91    }
92
93    #[doc(alias = "gtk_revealer_set_transition_duration")]
94    #[doc(alias = "transition-duration")]
95    pub fn set_transition_duration(&self, duration: u32) {
96        unsafe {
97            ffi::gtk_revealer_set_transition_duration(self.to_glib_none().0, duration);
98        }
99    }
100
101    #[doc(alias = "gtk_revealer_set_transition_type")]
102    #[doc(alias = "transition-type")]
103    pub fn set_transition_type(&self, transition: RevealerTransitionType) {
104        unsafe {
105            ffi::gtk_revealer_set_transition_type(self.to_glib_none().0, transition.into_glib());
106        }
107    }
108
109    #[doc(alias = "child")]
110    pub fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
111        unsafe extern "C" fn notify_child_trampoline<F: Fn(&Revealer) + 'static>(
112            this: *mut ffi::GtkRevealer,
113            _param_spec: glib::ffi::gpointer,
114            f: glib::ffi::gpointer,
115        ) {
116            let f: &F = &*(f as *const F);
117            f(&from_glib_borrow(this))
118        }
119        unsafe {
120            let f: Box_<F> = Box_::new(f);
121            connect_raw(
122                self.as_ptr() as *mut _,
123                c"notify::child".as_ptr() as *const _,
124                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
125                    notify_child_trampoline::<F> as *const (),
126                )),
127                Box_::into_raw(f),
128            )
129        }
130    }
131
132    #[doc(alias = "child-revealed")]
133    pub fn connect_child_revealed_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
134        unsafe extern "C" fn notify_child_revealed_trampoline<F: Fn(&Revealer) + 'static>(
135            this: *mut ffi::GtkRevealer,
136            _param_spec: glib::ffi::gpointer,
137            f: glib::ffi::gpointer,
138        ) {
139            let f: &F = &*(f as *const F);
140            f(&from_glib_borrow(this))
141        }
142        unsafe {
143            let f: Box_<F> = Box_::new(f);
144            connect_raw(
145                self.as_ptr() as *mut _,
146                c"notify::child-revealed".as_ptr() as *const _,
147                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
148                    notify_child_revealed_trampoline::<F> as *const (),
149                )),
150                Box_::into_raw(f),
151            )
152        }
153    }
154
155    #[doc(alias = "reveal-child")]
156    pub fn connect_reveal_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
157        unsafe extern "C" fn notify_reveal_child_trampoline<F: Fn(&Revealer) + 'static>(
158            this: *mut ffi::GtkRevealer,
159            _param_spec: glib::ffi::gpointer,
160            f: glib::ffi::gpointer,
161        ) {
162            let f: &F = &*(f as *const F);
163            f(&from_glib_borrow(this))
164        }
165        unsafe {
166            let f: Box_<F> = Box_::new(f);
167            connect_raw(
168                self.as_ptr() as *mut _,
169                c"notify::reveal-child".as_ptr() as *const _,
170                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
171                    notify_reveal_child_trampoline::<F> as *const (),
172                )),
173                Box_::into_raw(f),
174            )
175        }
176    }
177
178    #[doc(alias = "transition-duration")]
179    pub fn connect_transition_duration_notify<F: Fn(&Self) + 'static>(
180        &self,
181        f: F,
182    ) -> SignalHandlerId {
183        unsafe extern "C" fn notify_transition_duration_trampoline<F: Fn(&Revealer) + 'static>(
184            this: *mut ffi::GtkRevealer,
185            _param_spec: glib::ffi::gpointer,
186            f: glib::ffi::gpointer,
187        ) {
188            let f: &F = &*(f as *const F);
189            f(&from_glib_borrow(this))
190        }
191        unsafe {
192            let f: Box_<F> = Box_::new(f);
193            connect_raw(
194                self.as_ptr() as *mut _,
195                c"notify::transition-duration".as_ptr() as *const _,
196                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
197                    notify_transition_duration_trampoline::<F> as *const (),
198                )),
199                Box_::into_raw(f),
200            )
201        }
202    }
203
204    #[doc(alias = "transition-type")]
205    pub fn connect_transition_type_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
206        unsafe extern "C" fn notify_transition_type_trampoline<F: Fn(&Revealer) + 'static>(
207            this: *mut ffi::GtkRevealer,
208            _param_spec: glib::ffi::gpointer,
209            f: glib::ffi::gpointer,
210        ) {
211            let f: &F = &*(f as *const F);
212            f(&from_glib_borrow(this))
213        }
214        unsafe {
215            let f: Box_<F> = Box_::new(f);
216            connect_raw(
217                self.as_ptr() as *mut _,
218                c"notify::transition-type".as_ptr() as *const _,
219                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
220                    notify_transition_type_trampoline::<F> as *const (),
221                )),
222                Box_::into_raw(f),
223            )
224        }
225    }
226}
227
228impl Default for Revealer {
229    fn default() -> Self {
230        Self::new()
231    }
232}
233
234// rustdoc-stripper-ignore-next
235/// A [builder-pattern] type to construct [`Revealer`] objects.
236///
237/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
238#[must_use = "The builder must be built to be used"]
239pub struct RevealerBuilder {
240    builder: glib::object::ObjectBuilder<'static, Revealer>,
241}
242
243impl RevealerBuilder {
244    fn new() -> Self {
245        Self {
246            builder: glib::object::Object::builder(),
247        }
248    }
249
250    pub fn child(self, child: &impl IsA<Widget>) -> Self {
251        Self {
252            builder: self.builder.property("child", child.clone().upcast()),
253        }
254    }
255
256    pub fn reveal_child(self, reveal_child: bool) -> Self {
257        Self {
258            builder: self.builder.property("reveal-child", reveal_child),
259        }
260    }
261
262    pub fn transition_duration(self, transition_duration: u32) -> Self {
263        Self {
264            builder: self
265                .builder
266                .property("transition-duration", transition_duration),
267        }
268    }
269
270    pub fn transition_type(self, transition_type: RevealerTransitionType) -> Self {
271        Self {
272            builder: self.builder.property("transition-type", transition_type),
273        }
274    }
275
276    pub fn can_focus(self, can_focus: bool) -> Self {
277        Self {
278            builder: self.builder.property("can-focus", can_focus),
279        }
280    }
281
282    pub fn can_target(self, can_target: bool) -> Self {
283        Self {
284            builder: self.builder.property("can-target", can_target),
285        }
286    }
287
288    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
289        Self {
290            builder: self.builder.property("css-classes", css_classes.into()),
291        }
292    }
293
294    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
295        Self {
296            builder: self.builder.property("css-name", css_name.into()),
297        }
298    }
299
300    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
301        Self {
302            builder: self.builder.property("cursor", cursor.clone()),
303        }
304    }
305
306    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
307        Self {
308            builder: self.builder.property("focus-on-click", focus_on_click),
309        }
310    }
311
312    pub fn focusable(self, focusable: bool) -> Self {
313        Self {
314            builder: self.builder.property("focusable", focusable),
315        }
316    }
317
318    pub fn halign(self, halign: Align) -> Self {
319        Self {
320            builder: self.builder.property("halign", halign),
321        }
322    }
323
324    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
325        Self {
326            builder: self.builder.property("has-tooltip", has_tooltip),
327        }
328    }
329
330    pub fn height_request(self, height_request: i32) -> Self {
331        Self {
332            builder: self.builder.property("height-request", height_request),
333        }
334    }
335
336    pub fn hexpand(self, hexpand: bool) -> Self {
337        Self {
338            builder: self.builder.property("hexpand", hexpand),
339        }
340    }
341
342    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
343        Self {
344            builder: self.builder.property("hexpand-set", hexpand_set),
345        }
346    }
347
348    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
349        Self {
350            builder: self
351                .builder
352                .property("layout-manager", layout_manager.clone().upcast()),
353        }
354    }
355
356    #[cfg(feature = "v4_18")]
357    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
358    pub fn limit_events(self, limit_events: bool) -> Self {
359        Self {
360            builder: self.builder.property("limit-events", limit_events),
361        }
362    }
363
364    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
365        Self {
366            builder: self.builder.property("margin-bottom", margin_bottom),
367        }
368    }
369
370    pub fn margin_end(self, margin_end: i32) -> Self {
371        Self {
372            builder: self.builder.property("margin-end", margin_end),
373        }
374    }
375
376    pub fn margin_start(self, margin_start: i32) -> Self {
377        Self {
378            builder: self.builder.property("margin-start", margin_start),
379        }
380    }
381
382    pub fn margin_top(self, margin_top: i32) -> Self {
383        Self {
384            builder: self.builder.property("margin-top", margin_top),
385        }
386    }
387
388    pub fn name(self, name: impl Into<glib::GString>) -> Self {
389        Self {
390            builder: self.builder.property("name", name.into()),
391        }
392    }
393
394    pub fn opacity(self, opacity: f64) -> Self {
395        Self {
396            builder: self.builder.property("opacity", opacity),
397        }
398    }
399
400    pub fn overflow(self, overflow: Overflow) -> Self {
401        Self {
402            builder: self.builder.property("overflow", overflow),
403        }
404    }
405
406    pub fn receives_default(self, receives_default: bool) -> Self {
407        Self {
408            builder: self.builder.property("receives-default", receives_default),
409        }
410    }
411
412    pub fn sensitive(self, sensitive: bool) -> Self {
413        Self {
414            builder: self.builder.property("sensitive", sensitive),
415        }
416    }
417
418    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
419        Self {
420            builder: self
421                .builder
422                .property("tooltip-markup", tooltip_markup.into()),
423        }
424    }
425
426    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
427        Self {
428            builder: self.builder.property("tooltip-text", tooltip_text.into()),
429        }
430    }
431
432    pub fn valign(self, valign: Align) -> Self {
433        Self {
434            builder: self.builder.property("valign", valign),
435        }
436    }
437
438    pub fn vexpand(self, vexpand: bool) -> Self {
439        Self {
440            builder: self.builder.property("vexpand", vexpand),
441        }
442    }
443
444    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
445        Self {
446            builder: self.builder.property("vexpand-set", vexpand_set),
447        }
448    }
449
450    pub fn visible(self, visible: bool) -> Self {
451        Self {
452            builder: self.builder.property("visible", visible),
453        }
454    }
455
456    pub fn width_request(self, width_request: i32) -> Self {
457        Self {
458            builder: self.builder.property("width-request", width_request),
459        }
460    }
461
462    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
463        Self {
464            builder: self.builder.property("accessible-role", accessible_role),
465        }
466    }
467
468    // rustdoc-stripper-ignore-next
469    /// Build the [`Revealer`].
470    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
471    pub fn build(self) -> Revealer {
472        assert_initialized_main_thread!();
473        self.builder.build()
474    }
475}