libadwaita/auto/
carousel_indicator_dots.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, Carousel};
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "AdwCarouselIndicatorDots")]
16    pub struct CarouselIndicatorDots(Object<ffi::AdwCarouselIndicatorDots, ffi::AdwCarouselIndicatorDotsClass>) @extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
17
18    match fn {
19        type_ => || ffi::adw_carousel_indicator_dots_get_type(),
20    }
21}
22
23impl CarouselIndicatorDots {
24    #[doc(alias = "adw_carousel_indicator_dots_new")]
25    pub fn new() -> CarouselIndicatorDots {
26        assert_initialized_main_thread!();
27        unsafe { gtk::Widget::from_glib_none(ffi::adw_carousel_indicator_dots_new()).unsafe_cast() }
28    }
29
30    // rustdoc-stripper-ignore-next
31    /// Creates a new builder-pattern struct instance to construct [`CarouselIndicatorDots`] objects.
32    ///
33    /// This method returns an instance of [`CarouselIndicatorDotsBuilder`](crate::builders::CarouselIndicatorDotsBuilder) which can be used to create [`CarouselIndicatorDots`] objects.
34    pub fn builder() -> CarouselIndicatorDotsBuilder {
35        CarouselIndicatorDotsBuilder::new()
36    }
37
38    #[doc(alias = "adw_carousel_indicator_dots_get_carousel")]
39    #[doc(alias = "get_carousel")]
40    pub fn carousel(&self) -> Option<Carousel> {
41        unsafe {
42            from_glib_none(ffi::adw_carousel_indicator_dots_get_carousel(
43                self.to_glib_none().0,
44            ))
45        }
46    }
47
48    #[doc(alias = "adw_carousel_indicator_dots_set_carousel")]
49    #[doc(alias = "carousel")]
50    pub fn set_carousel(&self, carousel: Option<&Carousel>) {
51        unsafe {
52            ffi::adw_carousel_indicator_dots_set_carousel(
53                self.to_glib_none().0,
54                carousel.to_glib_none().0,
55            );
56        }
57    }
58
59    #[doc(alias = "carousel")]
60    pub fn connect_carousel_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
61        unsafe extern "C" fn notify_carousel_trampoline<F: Fn(&CarouselIndicatorDots) + 'static>(
62            this: *mut ffi::AdwCarouselIndicatorDots,
63            _param_spec: glib::ffi::gpointer,
64            f: glib::ffi::gpointer,
65        ) {
66            let f: &F = &*(f as *const F);
67            f(&from_glib_borrow(this))
68        }
69        unsafe {
70            let f: Box_<F> = Box_::new(f);
71            connect_raw(
72                self.as_ptr() as *mut _,
73                c"notify::carousel".as_ptr() as *const _,
74                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
75                    notify_carousel_trampoline::<F> as *const (),
76                )),
77                Box_::into_raw(f),
78            )
79        }
80    }
81}
82
83impl Default for CarouselIndicatorDots {
84    fn default() -> Self {
85        Self::new()
86    }
87}
88
89// rustdoc-stripper-ignore-next
90/// A [builder-pattern] type to construct [`CarouselIndicatorDots`] objects.
91///
92/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
93#[must_use = "The builder must be built to be used"]
94pub struct CarouselIndicatorDotsBuilder {
95    builder: glib::object::ObjectBuilder<'static, CarouselIndicatorDots>,
96}
97
98impl CarouselIndicatorDotsBuilder {
99    fn new() -> Self {
100        Self {
101            builder: glib::object::Object::builder(),
102        }
103    }
104
105    pub fn carousel(self, carousel: &Carousel) -> Self {
106        Self {
107            builder: self.builder.property("carousel", carousel.clone()),
108        }
109    }
110
111    pub fn can_focus(self, can_focus: bool) -> Self {
112        Self {
113            builder: self.builder.property("can-focus", can_focus),
114        }
115    }
116
117    pub fn can_target(self, can_target: bool) -> Self {
118        Self {
119            builder: self.builder.property("can-target", can_target),
120        }
121    }
122
123    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
124        Self {
125            builder: self.builder.property("css-classes", css_classes.into()),
126        }
127    }
128
129    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
130        Self {
131            builder: self.builder.property("css-name", css_name.into()),
132        }
133    }
134
135    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
136        Self {
137            builder: self.builder.property("cursor", cursor.clone()),
138        }
139    }
140
141    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
142        Self {
143            builder: self.builder.property("focus-on-click", focus_on_click),
144        }
145    }
146
147    pub fn focusable(self, focusable: bool) -> Self {
148        Self {
149            builder: self.builder.property("focusable", focusable),
150        }
151    }
152
153    pub fn halign(self, halign: gtk::Align) -> Self {
154        Self {
155            builder: self.builder.property("halign", halign),
156        }
157    }
158
159    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
160        Self {
161            builder: self.builder.property("has-tooltip", has_tooltip),
162        }
163    }
164
165    pub fn height_request(self, height_request: i32) -> Self {
166        Self {
167            builder: self.builder.property("height-request", height_request),
168        }
169    }
170
171    pub fn hexpand(self, hexpand: bool) -> Self {
172        Self {
173            builder: self.builder.property("hexpand", hexpand),
174        }
175    }
176
177    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
178        Self {
179            builder: self.builder.property("hexpand-set", hexpand_set),
180        }
181    }
182
183    pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
184        Self {
185            builder: self
186                .builder
187                .property("layout-manager", layout_manager.clone().upcast()),
188        }
189    }
190
191    #[cfg(feature = "gtk_v4_18")]
192    #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
193    pub fn limit_events(self, limit_events: bool) -> Self {
194        Self {
195            builder: self.builder.property("limit-events", limit_events),
196        }
197    }
198
199    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
200        Self {
201            builder: self.builder.property("margin-bottom", margin_bottom),
202        }
203    }
204
205    pub fn margin_end(self, margin_end: i32) -> Self {
206        Self {
207            builder: self.builder.property("margin-end", margin_end),
208        }
209    }
210
211    pub fn margin_start(self, margin_start: i32) -> Self {
212        Self {
213            builder: self.builder.property("margin-start", margin_start),
214        }
215    }
216
217    pub fn margin_top(self, margin_top: i32) -> Self {
218        Self {
219            builder: self.builder.property("margin-top", margin_top),
220        }
221    }
222
223    pub fn name(self, name: impl Into<glib::GString>) -> Self {
224        Self {
225            builder: self.builder.property("name", name.into()),
226        }
227    }
228
229    pub fn opacity(self, opacity: f64) -> Self {
230        Self {
231            builder: self.builder.property("opacity", opacity),
232        }
233    }
234
235    pub fn overflow(self, overflow: gtk::Overflow) -> Self {
236        Self {
237            builder: self.builder.property("overflow", overflow),
238        }
239    }
240
241    pub fn receives_default(self, receives_default: bool) -> Self {
242        Self {
243            builder: self.builder.property("receives-default", receives_default),
244        }
245    }
246
247    pub fn sensitive(self, sensitive: bool) -> Self {
248        Self {
249            builder: self.builder.property("sensitive", sensitive),
250        }
251    }
252
253    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
254        Self {
255            builder: self
256                .builder
257                .property("tooltip-markup", tooltip_markup.into()),
258        }
259    }
260
261    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
262        Self {
263            builder: self.builder.property("tooltip-text", tooltip_text.into()),
264        }
265    }
266
267    pub fn valign(self, valign: gtk::Align) -> Self {
268        Self {
269            builder: self.builder.property("valign", valign),
270        }
271    }
272
273    pub fn vexpand(self, vexpand: bool) -> Self {
274        Self {
275            builder: self.builder.property("vexpand", vexpand),
276        }
277    }
278
279    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
280        Self {
281            builder: self.builder.property("vexpand-set", vexpand_set),
282        }
283    }
284
285    pub fn visible(self, visible: bool) -> Self {
286        Self {
287            builder: self.builder.property("visible", visible),
288        }
289    }
290
291    pub fn width_request(self, width_request: i32) -> Self {
292        Self {
293            builder: self.builder.property("width-request", width_request),
294        }
295    }
296
297    pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
298        Self {
299            builder: self.builder.property("accessible-role", accessible_role),
300        }
301    }
302
303    pub fn orientation(self, orientation: gtk::Orientation) -> Self {
304        Self {
305            builder: self.builder.property("orientation", orientation),
306        }
307    }
308
309    // rustdoc-stripper-ignore-next
310    /// Build the [`CarouselIndicatorDots`].
311    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
312    pub fn build(self) -> CarouselIndicatorDots {
313        assert_initialized_main_thread!();
314        self.builder.build()
315    }
316}