libadwaita/auto/
breakpoint_bin.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files.git)
4// DO NOT EDIT
5
6use crate::{ffi, Breakpoint};
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "AdwBreakpointBin")]
16    pub struct BreakpointBin(Object<ffi::AdwBreakpointBin, ffi::AdwBreakpointBinClass>) @extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget;
17
18    match fn {
19        type_ => || ffi::adw_breakpoint_bin_get_type(),
20    }
21}
22
23impl BreakpointBin {
24    pub const NONE: Option<&'static BreakpointBin> = None;
25
26    #[doc(alias = "adw_breakpoint_bin_new")]
27    pub fn new() -> BreakpointBin {
28        assert_initialized_main_thread!();
29        unsafe { gtk::Widget::from_glib_none(ffi::adw_breakpoint_bin_new()).unsafe_cast() }
30    }
31
32    // rustdoc-stripper-ignore-next
33    /// Creates a new builder-pattern struct instance to construct [`BreakpointBin`] objects.
34    ///
35    /// This method returns an instance of [`BreakpointBinBuilder`](crate::builders::BreakpointBinBuilder) which can be used to create [`BreakpointBin`] objects.
36    pub fn builder() -> BreakpointBinBuilder {
37        BreakpointBinBuilder::new()
38    }
39}
40
41#[cfg(feature = "v1_4")]
42#[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
43impl Default for BreakpointBin {
44    fn default() -> Self {
45        Self::new()
46    }
47}
48
49// rustdoc-stripper-ignore-next
50/// A [builder-pattern] type to construct [`BreakpointBin`] objects.
51///
52/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
53#[must_use = "The builder must be built to be used"]
54pub struct BreakpointBinBuilder {
55    builder: glib::object::ObjectBuilder<'static, BreakpointBin>,
56}
57
58impl BreakpointBinBuilder {
59    fn new() -> Self {
60        Self {
61            builder: glib::object::Object::builder(),
62        }
63    }
64
65    #[cfg(feature = "v1_4")]
66    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
67    pub fn child(self, child: &impl IsA<gtk::Widget>) -> Self {
68        Self {
69            builder: self.builder.property("child", child.clone().upcast()),
70        }
71    }
72
73    pub fn can_focus(self, can_focus: bool) -> Self {
74        Self {
75            builder: self.builder.property("can-focus", can_focus),
76        }
77    }
78
79    pub fn can_target(self, can_target: bool) -> Self {
80        Self {
81            builder: self.builder.property("can-target", can_target),
82        }
83    }
84
85    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
86        Self {
87            builder: self.builder.property("css-classes", css_classes.into()),
88        }
89    }
90
91    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
92        Self {
93            builder: self.builder.property("css-name", css_name.into()),
94        }
95    }
96
97    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
98        Self {
99            builder: self.builder.property("cursor", cursor.clone()),
100        }
101    }
102
103    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
104        Self {
105            builder: self.builder.property("focus-on-click", focus_on_click),
106        }
107    }
108
109    pub fn focusable(self, focusable: bool) -> Self {
110        Self {
111            builder: self.builder.property("focusable", focusable),
112        }
113    }
114
115    pub fn halign(self, halign: gtk::Align) -> Self {
116        Self {
117            builder: self.builder.property("halign", halign),
118        }
119    }
120
121    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
122        Self {
123            builder: self.builder.property("has-tooltip", has_tooltip),
124        }
125    }
126
127    pub fn height_request(self, height_request: i32) -> Self {
128        Self {
129            builder: self.builder.property("height-request", height_request),
130        }
131    }
132
133    pub fn hexpand(self, hexpand: bool) -> Self {
134        Self {
135            builder: self.builder.property("hexpand", hexpand),
136        }
137    }
138
139    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
140        Self {
141            builder: self.builder.property("hexpand-set", hexpand_set),
142        }
143    }
144
145    pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
146        Self {
147            builder: self
148                .builder
149                .property("layout-manager", layout_manager.clone().upcast()),
150        }
151    }
152
153    #[cfg(feature = "gtk_v4_18")]
154    #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
155    pub fn limit_events(self, limit_events: bool) -> Self {
156        Self {
157            builder: self.builder.property("limit-events", limit_events),
158        }
159    }
160
161    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
162        Self {
163            builder: self.builder.property("margin-bottom", margin_bottom),
164        }
165    }
166
167    pub fn margin_end(self, margin_end: i32) -> Self {
168        Self {
169            builder: self.builder.property("margin-end", margin_end),
170        }
171    }
172
173    pub fn margin_start(self, margin_start: i32) -> Self {
174        Self {
175            builder: self.builder.property("margin-start", margin_start),
176        }
177    }
178
179    pub fn margin_top(self, margin_top: i32) -> Self {
180        Self {
181            builder: self.builder.property("margin-top", margin_top),
182        }
183    }
184
185    pub fn name(self, name: impl Into<glib::GString>) -> Self {
186        Self {
187            builder: self.builder.property("name", name.into()),
188        }
189    }
190
191    pub fn opacity(self, opacity: f64) -> Self {
192        Self {
193            builder: self.builder.property("opacity", opacity),
194        }
195    }
196
197    pub fn overflow(self, overflow: gtk::Overflow) -> Self {
198        Self {
199            builder: self.builder.property("overflow", overflow),
200        }
201    }
202
203    pub fn receives_default(self, receives_default: bool) -> Self {
204        Self {
205            builder: self.builder.property("receives-default", receives_default),
206        }
207    }
208
209    pub fn sensitive(self, sensitive: bool) -> Self {
210        Self {
211            builder: self.builder.property("sensitive", sensitive),
212        }
213    }
214
215    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
216        Self {
217            builder: self
218                .builder
219                .property("tooltip-markup", tooltip_markup.into()),
220        }
221    }
222
223    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
224        Self {
225            builder: self.builder.property("tooltip-text", tooltip_text.into()),
226        }
227    }
228
229    pub fn valign(self, valign: gtk::Align) -> Self {
230        Self {
231            builder: self.builder.property("valign", valign),
232        }
233    }
234
235    pub fn vexpand(self, vexpand: bool) -> Self {
236        Self {
237            builder: self.builder.property("vexpand", vexpand),
238        }
239    }
240
241    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
242        Self {
243            builder: self.builder.property("vexpand-set", vexpand_set),
244        }
245    }
246
247    pub fn visible(self, visible: bool) -> Self {
248        Self {
249            builder: self.builder.property("visible", visible),
250        }
251    }
252
253    pub fn width_request(self, width_request: i32) -> Self {
254        Self {
255            builder: self.builder.property("width-request", width_request),
256        }
257    }
258
259    pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
260        Self {
261            builder: self.builder.property("accessible-role", accessible_role),
262        }
263    }
264
265    // rustdoc-stripper-ignore-next
266    /// Build the [`BreakpointBin`].
267    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
268    pub fn build(self) -> BreakpointBin {
269        assert_initialized_main_thread!();
270        self.builder.build()
271    }
272}
273
274pub trait BreakpointBinExt: IsA<BreakpointBin> + 'static {
275    #[doc(alias = "adw_breakpoint_bin_add_breakpoint")]
276    fn add_breakpoint(&self, breakpoint: Breakpoint) {
277        unsafe {
278            ffi::adw_breakpoint_bin_add_breakpoint(
279                self.as_ref().to_glib_none().0,
280                breakpoint.into_glib_ptr(),
281            );
282        }
283    }
284
285    #[doc(alias = "adw_breakpoint_bin_get_child")]
286    #[doc(alias = "get_child")]
287    fn child(&self) -> Option<gtk::Widget> {
288        unsafe {
289            from_glib_none(ffi::adw_breakpoint_bin_get_child(
290                self.as_ref().to_glib_none().0,
291            ))
292        }
293    }
294
295    #[doc(alias = "adw_breakpoint_bin_get_current_breakpoint")]
296    #[doc(alias = "get_current_breakpoint")]
297    #[doc(alias = "current-breakpoint")]
298    fn current_breakpoint(&self) -> Option<Breakpoint> {
299        unsafe {
300            from_glib_none(ffi::adw_breakpoint_bin_get_current_breakpoint(
301                self.as_ref().to_glib_none().0,
302            ))
303        }
304    }
305
306    #[cfg(feature = "v1_5")]
307    #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
308    #[doc(alias = "adw_breakpoint_bin_remove_breakpoint")]
309    fn remove_breakpoint(&self, breakpoint: &Breakpoint) {
310        unsafe {
311            ffi::adw_breakpoint_bin_remove_breakpoint(
312                self.as_ref().to_glib_none().0,
313                breakpoint.to_glib_none().0,
314            );
315        }
316    }
317
318    #[doc(alias = "adw_breakpoint_bin_set_child")]
319    #[doc(alias = "child")]
320    fn set_child(&self, child: Option<&impl IsA<gtk::Widget>>) {
321        unsafe {
322            ffi::adw_breakpoint_bin_set_child(
323                self.as_ref().to_glib_none().0,
324                child.map(|p| p.as_ref()).to_glib_none().0,
325            );
326        }
327    }
328
329    #[cfg(feature = "v1_4")]
330    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
331    #[doc(alias = "child")]
332    fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
333        unsafe extern "C" fn notify_child_trampoline<P: IsA<BreakpointBin>, F: Fn(&P) + 'static>(
334            this: *mut ffi::AdwBreakpointBin,
335            _param_spec: glib::ffi::gpointer,
336            f: glib::ffi::gpointer,
337        ) {
338            let f: &F = &*(f as *const F);
339            f(BreakpointBin::from_glib_borrow(this).unsafe_cast_ref())
340        }
341        unsafe {
342            let f: Box_<F> = Box_::new(f);
343            connect_raw(
344                self.as_ptr() as *mut _,
345                c"notify::child".as_ptr() as *const _,
346                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
347                    notify_child_trampoline::<Self, F> as *const (),
348                )),
349                Box_::into_raw(f),
350            )
351        }
352    }
353
354    #[cfg(feature = "v1_4")]
355    #[cfg_attr(docsrs, doc(cfg(feature = "v1_4")))]
356    #[doc(alias = "current-breakpoint")]
357    fn connect_current_breakpoint_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
358        unsafe extern "C" fn notify_current_breakpoint_trampoline<
359            P: IsA<BreakpointBin>,
360            F: Fn(&P) + 'static,
361        >(
362            this: *mut ffi::AdwBreakpointBin,
363            _param_spec: glib::ffi::gpointer,
364            f: glib::ffi::gpointer,
365        ) {
366            let f: &F = &*(f as *const F);
367            f(BreakpointBin::from_glib_borrow(this).unsafe_cast_ref())
368        }
369        unsafe {
370            let f: Box_<F> = Box_::new(f);
371            connect_raw(
372                self.as_ptr() as *mut _,
373                c"notify::current-breakpoint".as_ptr() as *const _,
374                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
375                    notify_current_breakpoint_trampoline::<Self, F> as *const (),
376                )),
377                Box_::into_raw(f),
378            )
379        }
380    }
381}
382
383impl<O: IsA<BreakpointBin>> BreakpointBinExt for O {}