gtk/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::{Align, Buildable, Container, Orientable, Orientation, Widget, ffi};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 /// GtkSeparator is a horizontal or vertical separator widget, depending on the
10 /// value of the [`orientation`][struct@crate::Orientable#orientation] property, used to group the widgets
11 /// within a window. It displays a line with a shadow to make it appear sunken
12 /// into the interface.
13 ///
14 /// # CSS nodes
15 ///
16 /// GtkSeparator has a single CSS node with name separator. The node
17 /// gets one of the .horizontal or .vertical style classes.
18 ///
19 /// # Implements
20 ///
21 /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`OrientableExt`][trait@crate::prelude::OrientableExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
22 #[doc(alias = "GtkSeparator")]
23 pub struct Separator(Object<ffi::GtkSeparator, ffi::GtkSeparatorClass>) @extends Widget, @implements Buildable, Orientable;
24
25 match fn {
26 type_ => || ffi::gtk_separator_get_type(),
27 }
28}
29
30impl Separator {
31 pub const NONE: Option<&'static Separator> = None;
32
33 /// Creates a new [`Separator`][crate::Separator] with the given orientation.
34 /// ## `orientation`
35 /// the separator’s orientation.
36 ///
37 /// # Returns
38 ///
39 /// a new [`Separator`][crate::Separator].
40 #[doc(alias = "gtk_separator_new")]
41 pub fn new(orientation: Orientation) -> Separator {
42 assert_initialized_main_thread!();
43 unsafe {
44 Widget::from_glib_none(ffi::gtk_separator_new(orientation.into_glib())).unsafe_cast()
45 }
46 }
47
48 // rustdoc-stripper-ignore-next
49 /// Creates a new builder-pattern struct instance to construct [`Separator`] objects.
50 ///
51 /// This method returns an instance of [`SeparatorBuilder`](crate::builders::SeparatorBuilder) which can be used to create [`Separator`] objects.
52 pub fn builder() -> SeparatorBuilder {
53 SeparatorBuilder::new()
54 }
55}
56
57impl Default for Separator {
58 fn default() -> Self {
59 glib::object::Object::new::<Self>()
60 }
61}
62
63// rustdoc-stripper-ignore-next
64/// A [builder-pattern] type to construct [`Separator`] objects.
65///
66/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
67#[must_use = "The builder must be built to be used"]
68pub struct SeparatorBuilder {
69 builder: glib::object::ObjectBuilder<'static, Separator>,
70}
71
72impl SeparatorBuilder {
73 fn new() -> Self {
74 Self {
75 builder: glib::object::Object::builder(),
76 }
77 }
78
79 pub fn app_paintable(self, app_paintable: bool) -> Self {
80 Self {
81 builder: self.builder.property("app-paintable", app_paintable),
82 }
83 }
84
85 pub fn can_default(self, can_default: bool) -> Self {
86 Self {
87 builder: self.builder.property("can-default", can_default),
88 }
89 }
90
91 pub fn can_focus(self, can_focus: bool) -> Self {
92 Self {
93 builder: self.builder.property("can-focus", can_focus),
94 }
95 }
96
97 pub fn events(self, events: gdk::EventMask) -> Self {
98 Self {
99 builder: self.builder.property("events", events),
100 }
101 }
102
103 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
104 pub fn expand(self, expand: bool) -> Self {
105 Self {
106 builder: self.builder.property("expand", expand),
107 }
108 }
109
110 /// Whether the widget should grab focus when it is clicked with the mouse.
111 ///
112 /// This property is only relevant for widgets that can take focus.
113 ///
114 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
115 /// GtkComboBox) implemented this property individually.
116 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
117 Self {
118 builder: self.builder.property("focus-on-click", focus_on_click),
119 }
120 }
121
122 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
123 pub fn halign(self, halign: Align) -> Self {
124 Self {
125 builder: self.builder.property("halign", halign),
126 }
127 }
128
129 pub fn has_default(self, has_default: bool) -> Self {
130 Self {
131 builder: self.builder.property("has-default", has_default),
132 }
133 }
134
135 pub fn has_focus(self, has_focus: bool) -> Self {
136 Self {
137 builder: self.builder.property("has-focus", has_focus),
138 }
139 }
140
141 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
142 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
143 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
144 /// whether it will provide a tooltip or not.
145 ///
146 /// Note that setting this property to [`true`] for the first time will change
147 /// the event masks of the GdkWindows of this widget to include leave-notify
148 /// and motion-notify events. This cannot and will not be undone when the
149 /// property is set to [`false`] again.
150 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
151 Self {
152 builder: self.builder.property("has-tooltip", has_tooltip),
153 }
154 }
155
156 pub fn height_request(self, height_request: i32) -> Self {
157 Self {
158 builder: self.builder.property("height-request", height_request),
159 }
160 }
161
162 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
163 pub fn hexpand(self, hexpand: bool) -> Self {
164 Self {
165 builder: self.builder.property("hexpand", hexpand),
166 }
167 }
168
169 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
170 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
171 Self {
172 builder: self.builder.property("hexpand-set", hexpand_set),
173 }
174 }
175
176 pub fn is_focus(self, is_focus: bool) -> Self {
177 Self {
178 builder: self.builder.property("is-focus", is_focus),
179 }
180 }
181
182 /// Sets all four sides' margin at once. If read, returns max
183 /// margin on any side.
184 pub fn margin(self, margin: i32) -> Self {
185 Self {
186 builder: self.builder.property("margin", margin),
187 }
188 }
189
190 /// Margin on bottom side of widget.
191 ///
192 /// This property adds margin outside of the widget's normal size
193 /// request, the margin will be added in addition to the size from
194 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
195 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
196 Self {
197 builder: self.builder.property("margin-bottom", margin_bottom),
198 }
199 }
200
201 /// Margin on end of widget, horizontally. This property supports
202 /// left-to-right and right-to-left text directions.
203 ///
204 /// This property adds margin outside of the widget's normal size
205 /// request, the margin will be added in addition to the size from
206 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
207 pub fn margin_end(self, margin_end: i32) -> Self {
208 Self {
209 builder: self.builder.property("margin-end", margin_end),
210 }
211 }
212
213 /// Margin on start of widget, horizontally. This property supports
214 /// left-to-right and right-to-left text directions.
215 ///
216 /// This property adds margin outside of the widget's normal size
217 /// request, the margin will be added in addition to the size from
218 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
219 pub fn margin_start(self, margin_start: i32) -> Self {
220 Self {
221 builder: self.builder.property("margin-start", margin_start),
222 }
223 }
224
225 /// Margin on top side of widget.
226 ///
227 /// This property adds margin outside of the widget's normal size
228 /// request, the margin will be added in addition to the size from
229 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
230 pub fn margin_top(self, margin_top: i32) -> Self {
231 Self {
232 builder: self.builder.property("margin-top", margin_top),
233 }
234 }
235
236 pub fn name(self, name: impl Into<glib::GString>) -> Self {
237 Self {
238 builder: self.builder.property("name", name.into()),
239 }
240 }
241
242 pub fn no_show_all(self, no_show_all: bool) -> Self {
243 Self {
244 builder: self.builder.property("no-show-all", no_show_all),
245 }
246 }
247
248 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
249 /// more details about window opacity.
250 ///
251 /// Before 3.8 this was only available in GtkWindow
252 pub fn opacity(self, opacity: f64) -> Self {
253 Self {
254 builder: self.builder.property("opacity", opacity),
255 }
256 }
257
258 pub fn parent(self, parent: &impl IsA<Container>) -> Self {
259 Self {
260 builder: self.builder.property("parent", parent.clone().upcast()),
261 }
262 }
263
264 pub fn receives_default(self, receives_default: bool) -> Self {
265 Self {
266 builder: self.builder.property("receives-default", receives_default),
267 }
268 }
269
270 pub fn sensitive(self, sensitive: bool) -> Self {
271 Self {
272 builder: self.builder.property("sensitive", sensitive),
273 }
274 }
275
276 /// Sets the text of tooltip to be the given string, which is marked up
277 /// with the [Pango text markup language][PangoMarkupFormat].
278 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
279 ///
280 /// This is a convenience property which will take care of getting the
281 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
282 /// will automatically be set to [`true`] and there will be taken care of
283 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
284 ///
285 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
286 /// are set, the last one wins.
287 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
288 Self {
289 builder: self
290 .builder
291 .property("tooltip-markup", tooltip_markup.into()),
292 }
293 }
294
295 /// Sets the text of tooltip to be the given string.
296 ///
297 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
298 ///
299 /// This is a convenience property which will take care of getting the
300 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
301 /// will automatically be set to [`true`] and there will be taken care of
302 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
303 ///
304 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
305 /// are set, the last one wins.
306 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
307 Self {
308 builder: self.builder.property("tooltip-text", tooltip_text.into()),
309 }
310 }
311
312 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
313 pub fn valign(self, valign: Align) -> Self {
314 Self {
315 builder: self.builder.property("valign", valign),
316 }
317 }
318
319 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
320 pub fn vexpand(self, vexpand: bool) -> Self {
321 Self {
322 builder: self.builder.property("vexpand", vexpand),
323 }
324 }
325
326 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
327 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
328 Self {
329 builder: self.builder.property("vexpand-set", vexpand_set),
330 }
331 }
332
333 pub fn visible(self, visible: bool) -> Self {
334 Self {
335 builder: self.builder.property("visible", visible),
336 }
337 }
338
339 pub fn width_request(self, width_request: i32) -> Self {
340 Self {
341 builder: self.builder.property("width-request", width_request),
342 }
343 }
344
345 /// The orientation of the orientable.
346 pub fn orientation(self, orientation: Orientation) -> Self {
347 Self {
348 builder: self.builder.property("orientation", orientation),
349 }
350 }
351
352 // rustdoc-stripper-ignore-next
353 /// Build the [`Separator`].
354 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
355 pub fn build(self) -> Separator {
356 assert_initialized_main_thread!();
357 self.builder.build()
358 }
359}