Skip to main content

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