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
5#[cfg(feature = "v4_10")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
7use crate::Accessible;
8use crate::{
9 AccessibleRole, Align, Buildable, ConstraintTarget, LayoutManager, Orientable, Orientation,
10 Overflow, Widget, ffi,
11};
12use glib::{prelude::*, translate::*};
13
14#[cfg(feature = "v4_10")]
15#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
16glib::wrapper! {
17 ///
18 ///
19 /// A [`Separator`][crate::Separator] can be used to group the widgets within a window.
20 /// It displays a line with a shadow to make it appear sunken into the
21 /// interface.
22 ///
23 /// # CSS nodes
24 ///
25 /// [`Separator`][crate::Separator] has a single CSS node with name separator. The node
26 /// gets one of the .horizontal or .vertical style classes.
27 ///
28 /// # Accessibility
29 ///
30 /// [`Separator`][crate::Separator] uses the [enum@Gtk.AccessibleRole.separator] role.
31 ///
32 /// # Implements
33 ///
34 /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`OrientableExt`][trait@crate::prelude::OrientableExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
35 #[doc(alias = "GtkSeparator")]
36 pub struct Separator(Object<ffi::GtkSeparator>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, Orientable;
37
38 match fn {
39 type_ => || ffi::gtk_separator_get_type(),
40 }
41}
42
43#[cfg(not(feature = "v4_10"))]
44glib::wrapper! {
45 #[doc(alias = "GtkSeparator")]
46 pub struct Separator(Object<ffi::GtkSeparator>) @extends Widget, @implements Buildable, ConstraintTarget, Orientable;
47
48 match fn {
49 type_ => || ffi::gtk_separator_get_type(),
50 }
51}
52
53impl Separator {
54 /// Creates a new [`Separator`][crate::Separator] with the given orientation.
55 /// ## `orientation`
56 /// s orientation.
57 ///
58 /// # Returns
59 ///
60 /// a new [`Separator`][crate::Separator].
61 #[doc(alias = "gtk_separator_new")]
62 pub fn new(orientation: Orientation) -> Separator {
63 assert_initialized_main_thread!();
64 unsafe {
65 Widget::from_glib_none(ffi::gtk_separator_new(orientation.into_glib())).unsafe_cast()
66 }
67 }
68
69 // rustdoc-stripper-ignore-next
70 /// Creates a new builder-pattern struct instance to construct [`Separator`] objects.
71 ///
72 /// This method returns an instance of [`SeparatorBuilder`](crate::builders::SeparatorBuilder) which can be used to create [`Separator`] objects.
73 pub fn builder() -> SeparatorBuilder {
74 SeparatorBuilder::new()
75 }
76}
77
78impl Default for Separator {
79 fn default() -> Self {
80 glib::object::Object::new::<Self>()
81 }
82}
83
84// rustdoc-stripper-ignore-next
85/// A [builder-pattern] type to construct [`Separator`] objects.
86///
87/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
88#[must_use = "The builder must be built to be used"]
89pub struct SeparatorBuilder {
90 builder: glib::object::ObjectBuilder<'static, Separator>,
91}
92
93impl SeparatorBuilder {
94 fn new() -> Self {
95 Self {
96 builder: glib::object::Object::builder(),
97 }
98 }
99
100 /// Whether the widget or any of its descendents can accept
101 /// the input focus.
102 ///
103 /// This property is meant to be set by widget implementations,
104 /// typically in their instance init function.
105 pub fn can_focus(self, can_focus: bool) -> Self {
106 Self {
107 builder: self.builder.property("can-focus", can_focus),
108 }
109 }
110
111 /// Whether the widget can receive pointer events.
112 pub fn can_target(self, can_target: bool) -> Self {
113 Self {
114 builder: self.builder.property("can-target", can_target),
115 }
116 }
117
118 /// A list of css classes applied to this widget.
119 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
120 Self {
121 builder: self.builder.property("css-classes", css_classes.into()),
122 }
123 }
124
125 /// The name of this widget in the CSS tree.
126 ///
127 /// This property is meant to be set by widget implementations,
128 /// typically in their instance init function.
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 /// The cursor used by @widget.
136 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
137 Self {
138 builder: self.builder.property("cursor", cursor.clone()),
139 }
140 }
141
142 /// Whether the widget should grab focus when it is clicked with the mouse.
143 ///
144 /// This property is only relevant for widgets that can take focus.
145 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
146 Self {
147 builder: self.builder.property("focus-on-click", focus_on_click),
148 }
149 }
150
151 /// Whether this widget itself will accept the input focus.
152 pub fn focusable(self, focusable: bool) -> Self {
153 Self {
154 builder: self.builder.property("focusable", focusable),
155 }
156 }
157
158 /// How to distribute horizontal space if widget gets extra space.
159 pub fn halign(self, halign: Align) -> Self {
160 Self {
161 builder: self.builder.property("halign", halign),
162 }
163 }
164
165 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
166 /// signal on @widget.
167 ///
168 /// A true value indicates that @widget can have a tooltip, in this case
169 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
170 /// determine whether it will provide a tooltip or not.
171 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
172 Self {
173 builder: self.builder.property("has-tooltip", has_tooltip),
174 }
175 }
176
177 /// Overrides for height request of the widget.
178 ///
179 /// If this is -1, the natural request will be used.
180 pub fn height_request(self, height_request: i32) -> Self {
181 Self {
182 builder: self.builder.property("height-request", height_request),
183 }
184 }
185
186 /// Whether to expand horizontally.
187 pub fn hexpand(self, hexpand: bool) -> Self {
188 Self {
189 builder: self.builder.property("hexpand", hexpand),
190 }
191 }
192
193 /// Whether to use the `hexpand` property.
194 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
195 Self {
196 builder: self.builder.property("hexpand-set", hexpand_set),
197 }
198 }
199
200 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
201 /// the preferred size of the widget, and allocate its children.
202 ///
203 /// This property is meant to be set by widget implementations,
204 /// typically in their instance init function.
205 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
206 Self {
207 builder: self
208 .builder
209 .property("layout-manager", layout_manager.clone().upcast()),
210 }
211 }
212
213 /// Makes this widget act like a modal dialog, with respect to
214 /// event delivery.
215 ///
216 /// Global event controllers will not handle events with targets
217 /// inside the widget, unless they are set up to ignore propagation
218 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
219 #[cfg(feature = "v4_18")]
220 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
221 pub fn limit_events(self, limit_events: bool) -> Self {
222 Self {
223 builder: self.builder.property("limit-events", limit_events),
224 }
225 }
226
227 /// Margin on bottom side of widget.
228 ///
229 /// This property adds margin outside of the widget's normal size
230 /// request, the margin will be added in addition to the size from
231 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
232 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
233 Self {
234 builder: self.builder.property("margin-bottom", margin_bottom),
235 }
236 }
237
238 /// Margin on end of widget, horizontally.
239 ///
240 /// This property supports left-to-right and right-to-left text
241 /// directions.
242 ///
243 /// This property adds margin outside of the widget's normal size
244 /// request, the margin will be added in addition to the size from
245 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
246 pub fn margin_end(self, margin_end: i32) -> Self {
247 Self {
248 builder: self.builder.property("margin-end", margin_end),
249 }
250 }
251
252 /// Margin on start of widget, horizontally.
253 ///
254 /// This property supports left-to-right and right-to-left text
255 /// directions.
256 ///
257 /// This property adds margin outside of the widget's normal size
258 /// request, the margin will be added in addition to the size from
259 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
260 pub fn margin_start(self, margin_start: i32) -> Self {
261 Self {
262 builder: self.builder.property("margin-start", margin_start),
263 }
264 }
265
266 /// Margin on top side of widget.
267 ///
268 /// This property adds margin outside of the widget's normal size
269 /// request, the margin will be added in addition to the size from
270 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
271 pub fn margin_top(self, margin_top: i32) -> Self {
272 Self {
273 builder: self.builder.property("margin-top", margin_top),
274 }
275 }
276
277 /// The name of the widget.
278 pub fn name(self, name: impl Into<glib::GString>) -> Self {
279 Self {
280 builder: self.builder.property("name", name.into()),
281 }
282 }
283
284 /// The requested opacity of the widget.
285 pub fn opacity(self, opacity: f64) -> Self {
286 Self {
287 builder: self.builder.property("opacity", opacity),
288 }
289 }
290
291 /// How content outside the widget's content area is treated.
292 ///
293 /// This property is meant to be set by widget implementations,
294 /// typically in their instance init function.
295 pub fn overflow(self, overflow: Overflow) -> Self {
296 Self {
297 builder: self.builder.property("overflow", overflow),
298 }
299 }
300
301 /// Whether the widget will receive the default action when it is focused.
302 pub fn receives_default(self, receives_default: bool) -> Self {
303 Self {
304 builder: self.builder.property("receives-default", receives_default),
305 }
306 }
307
308 /// Whether the widget responds to input.
309 pub fn sensitive(self, sensitive: bool) -> Self {
310 Self {
311 builder: self.builder.property("sensitive", sensitive),
312 }
313 }
314
315 /// Sets the text of tooltip to be the given string, which is marked up
316 /// with Pango markup.
317 ///
318 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
319 ///
320 /// This is a convenience property which will take care of getting the
321 /// tooltip shown if the given string is not `NULL`:
322 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
323 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
324 /// the default signal handler.
325 ///
326 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
327 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
328 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
329 Self {
330 builder: self
331 .builder
332 .property("tooltip-markup", tooltip_markup.into()),
333 }
334 }
335
336 /// Sets the text of tooltip to be the given string.
337 ///
338 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
339 ///
340 /// This is a convenience property which will take care of getting the
341 /// tooltip shown if the given string is not `NULL`:
342 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
343 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
344 /// the default signal handler.
345 ///
346 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
347 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
348 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
349 Self {
350 builder: self.builder.property("tooltip-text", tooltip_text.into()),
351 }
352 }
353
354 /// How to distribute vertical space if widget gets extra space.
355 pub fn valign(self, valign: Align) -> Self {
356 Self {
357 builder: self.builder.property("valign", valign),
358 }
359 }
360
361 /// Whether to expand vertically.
362 pub fn vexpand(self, vexpand: bool) -> Self {
363 Self {
364 builder: self.builder.property("vexpand", vexpand),
365 }
366 }
367
368 /// Whether to use the `vexpand` property.
369 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
370 Self {
371 builder: self.builder.property("vexpand-set", vexpand_set),
372 }
373 }
374
375 /// Whether the widget is visible.
376 pub fn visible(self, visible: bool) -> Self {
377 Self {
378 builder: self.builder.property("visible", visible),
379 }
380 }
381
382 /// Overrides for width request of the widget.
383 ///
384 /// If this is -1, the natural request will be used.
385 pub fn width_request(self, width_request: i32) -> Self {
386 Self {
387 builder: self.builder.property("width-request", width_request),
388 }
389 }
390
391 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
392 ///
393 /// The accessible role cannot be changed once set.
394 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
395 Self {
396 builder: self.builder.property("accessible-role", accessible_role),
397 }
398 }
399
400 /// The orientation of the orientable.
401 pub fn orientation(self, orientation: Orientation) -> Self {
402 Self {
403 builder: self.builder.property("orientation", orientation),
404 }
405 }
406
407 // rustdoc-stripper-ignore-next
408 /// Build the [`Separator`].
409 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
410 pub fn build(self) -> Separator {
411 assert_initialized_main_thread!();
412 self.builder.build()
413 }
414}