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