1use crate::{Align, Buildable, Container, Orientable, Orientation, Widget};
6use glib::{prelude::*, translate::*};
7use std::fmt;
8
9glib::wrapper! {
10 #[doc(alias = "GtkSeparator")]
11 pub struct Separator(Object<ffi::GtkSeparator, ffi::GtkSeparatorClass>) @extends Widget, @implements Buildable, Orientable;
12
13 match fn {
14 type_ => || ffi::gtk_separator_get_type(),
15 }
16}
17
18impl Separator {
19 pub const NONE: Option<&'static Separator> = None;
20
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 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#[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 app_paintable(self, app_paintable: bool) -> Self {
61 Self {
62 builder: self.builder.property("app-paintable", app_paintable),
63 }
64 }
65
66 pub fn can_default(self, can_default: bool) -> Self {
67 Self {
68 builder: self.builder.property("can-default", can_default),
69 }
70 }
71
72 pub fn can_focus(self, can_focus: bool) -> Self {
73 Self {
74 builder: self.builder.property("can-focus", can_focus),
75 }
76 }
77
78 pub fn events(self, events: gdk::EventMask) -> Self {
79 Self {
80 builder: self.builder.property("events", events),
81 }
82 }
83
84 pub fn expand(self, expand: bool) -> Self {
85 Self {
86 builder: self.builder.property("expand", expand),
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 halign(self, halign: Align) -> Self {
97 Self {
98 builder: self.builder.property("halign", halign),
99 }
100 }
101
102 pub fn has_default(self, has_default: bool) -> Self {
103 Self {
104 builder: self.builder.property("has-default", has_default),
105 }
106 }
107
108 pub fn has_focus(self, has_focus: bool) -> Self {
109 Self {
110 builder: self.builder.property("has-focus", has_focus),
111 }
112 }
113
114 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
115 Self {
116 builder: self.builder.property("has-tooltip", has_tooltip),
117 }
118 }
119
120 pub fn height_request(self, height_request: i32) -> Self {
121 Self {
122 builder: self.builder.property("height-request", height_request),
123 }
124 }
125
126 pub fn hexpand(self, hexpand: bool) -> Self {
127 Self {
128 builder: self.builder.property("hexpand", hexpand),
129 }
130 }
131
132 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
133 Self {
134 builder: self.builder.property("hexpand-set", hexpand_set),
135 }
136 }
137
138 pub fn is_focus(self, is_focus: bool) -> Self {
139 Self {
140 builder: self.builder.property("is-focus", is_focus),
141 }
142 }
143
144 pub fn margin(self, margin: i32) -> Self {
145 Self {
146 builder: self.builder.property("margin", margin),
147 }
148 }
149
150 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
151 Self {
152 builder: self.builder.property("margin-bottom", margin_bottom),
153 }
154 }
155
156 pub fn margin_end(self, margin_end: i32) -> Self {
157 Self {
158 builder: self.builder.property("margin-end", margin_end),
159 }
160 }
161
162 pub fn margin_start(self, margin_start: i32) -> Self {
163 Self {
164 builder: self.builder.property("margin-start", margin_start),
165 }
166 }
167
168 pub fn margin_top(self, margin_top: i32) -> Self {
169 Self {
170 builder: self.builder.property("margin-top", margin_top),
171 }
172 }
173
174 pub fn name(self, name: impl Into<glib::GString>) -> Self {
175 Self {
176 builder: self.builder.property("name", name.into()),
177 }
178 }
179
180 pub fn no_show_all(self, no_show_all: bool) -> Self {
181 Self {
182 builder: self.builder.property("no-show-all", no_show_all),
183 }
184 }
185
186 pub fn opacity(self, opacity: f64) -> Self {
187 Self {
188 builder: self.builder.property("opacity", opacity),
189 }
190 }
191
192 pub fn parent(self, parent: &impl IsA<Container>) -> Self {
193 Self {
194 builder: self.builder.property("parent", parent.clone().upcast()),
195 }
196 }
197
198 pub fn receives_default(self, receives_default: bool) -> Self {
199 Self {
200 builder: self.builder.property("receives-default", receives_default),
201 }
202 }
203
204 pub fn sensitive(self, sensitive: bool) -> Self {
205 Self {
206 builder: self.builder.property("sensitive", sensitive),
207 }
208 }
209
210 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
211 Self {
212 builder: self
213 .builder
214 .property("tooltip-markup", tooltip_markup.into()),
215 }
216 }
217
218 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
219 Self {
220 builder: self.builder.property("tooltip-text", tooltip_text.into()),
221 }
222 }
223
224 pub fn valign(self, valign: Align) -> Self {
225 Self {
226 builder: self.builder.property("valign", valign),
227 }
228 }
229
230 pub fn vexpand(self, vexpand: bool) -> Self {
231 Self {
232 builder: self.builder.property("vexpand", vexpand),
233 }
234 }
235
236 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
237 Self {
238 builder: self.builder.property("vexpand-set", vexpand_set),
239 }
240 }
241
242 pub fn visible(self, visible: bool) -> Self {
243 Self {
244 builder: self.builder.property("visible", visible),
245 }
246 }
247
248 pub fn width_request(self, width_request: i32) -> Self {
249 Self {
250 builder: self.builder.property("width-request", width_request),
251 }
252 }
253
254 pub fn orientation(self, orientation: Orientation) -> Self {
255 Self {
256 builder: self.builder.property("orientation", orientation),
257 }
258 }
259
260 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
263 pub fn build(self) -> Separator {
264 self.builder.build()
265 }
266}
267
268impl fmt::Display for Separator {
269 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
270 f.write_str("Separator")
271 }
272}