Skip to main content

gtk/auto/
button_box.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    Align, BaselinePosition, Box, Buildable, ButtonBoxStyle, Container, Orientable, Orientation,
7    ResizeMode, Widget, ffi,
8};
9use glib::{
10    prelude::*,
11    signal::{SignalHandlerId, connect_raw},
12    translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17    ///
18    ///
19    /// ## Properties
20    ///
21    ///
22    /// #### `layout-style`
23    ///  Readable | Writable
24    /// <details><summary><h4>Box</h4></summary>
25    ///
26    ///
27    /// #### `baseline-position`
28    ///  Readable | Writable
29    ///
30    ///
31    /// #### `homogeneous`
32    ///  Readable | Writable
33    ///
34    ///
35    /// #### `spacing`
36    ///  Readable | Writable
37    /// </details>
38    /// <details><summary><h4>Container</h4></summary>
39    ///
40    ///
41    /// #### `border-width`
42    ///  Readable | Writable
43    ///
44    ///
45    /// #### `child`
46    ///  Writable
47    ///
48    ///
49    /// #### `resize-mode`
50    ///  Readable | Writable
51    /// </details>
52    /// <details><summary><h4>Widget</h4></summary>
53    ///
54    ///
55    /// #### `app-paintable`
56    ///  Readable | Writable
57    ///
58    ///
59    /// #### `can-default`
60    ///  Readable | Writable
61    ///
62    ///
63    /// #### `can-focus`
64    ///  Readable | Writable
65    ///
66    ///
67    /// #### `composite-child`
68    ///  Readable
69    ///
70    ///
71    /// #### `double-buffered`
72    ///  Whether the widget is double buffered.
73    ///
74    /// Readable | Writable
75    ///
76    ///
77    /// #### `events`
78    ///  Readable | Writable
79    ///
80    ///
81    /// #### `expand`
82    ///  Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
83    ///
84    /// Readable | Writable
85    ///
86    ///
87    /// #### `focus-on-click`
88    ///  Whether the widget should grab focus when it is clicked with the mouse.
89    ///
90    /// This property is only relevant for widgets that can take focus.
91    ///
92    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
93    /// GtkComboBox) implemented this property individually.
94    ///
95    /// Readable | Writable
96    ///
97    ///
98    /// #### `halign`
99    ///  How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
100    ///
101    /// Readable | Writable
102    ///
103    ///
104    /// #### `has-default`
105    ///  Readable | Writable
106    ///
107    ///
108    /// #### `has-focus`
109    ///  Readable | Writable
110    ///
111    ///
112    /// #### `has-tooltip`
113    ///  Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
114    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
115    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
116    /// whether it will provide a tooltip or not.
117    ///
118    /// Note that setting this property to [`true`] for the first time will change
119    /// the event masks of the GdkWindows of this widget to include leave-notify
120    /// and motion-notify events. This cannot and will not be undone when the
121    /// property is set to [`false`] again.
122    ///
123    /// Readable | Writable
124    ///
125    ///
126    /// #### `height-request`
127    ///  Readable | Writable
128    ///
129    ///
130    /// #### `hexpand`
131    ///  Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
132    ///
133    /// Readable | Writable
134    ///
135    ///
136    /// #### `hexpand-set`
137    ///  Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
138    ///
139    /// Readable | Writable
140    ///
141    ///
142    /// #### `is-focus`
143    ///  Readable | Writable
144    ///
145    ///
146    /// #### `margin`
147    ///  Sets all four sides' margin at once. If read, returns max
148    /// margin on any side.
149    ///
150    /// Readable | Writable
151    ///
152    ///
153    /// #### `margin-bottom`
154    ///  Margin on bottom side of widget.
155    ///
156    /// This property adds margin outside of the widget's normal size
157    /// request, the margin will be added in addition to the size from
158    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
159    ///
160    /// Readable | Writable
161    ///
162    ///
163    /// #### `margin-end`
164    ///  Margin on end of widget, horizontally. This property supports
165    /// left-to-right and right-to-left text directions.
166    ///
167    /// This property adds margin outside of the widget's normal size
168    /// request, the margin will be added in addition to the size from
169    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
170    ///
171    /// Readable | Writable
172    ///
173    ///
174    /// #### `margin-left`
175    ///  Margin on left side of widget.
176    ///
177    /// This property adds margin outside of the widget's normal size
178    /// request, the margin will be added in addition to the size from
179    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
180    ///
181    /// Readable | Writable
182    ///
183    ///
184    /// #### `margin-right`
185    ///  Margin on right side of widget.
186    ///
187    /// This property adds margin outside of the widget's normal size
188    /// request, the margin will be added in addition to the size from
189    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
190    ///
191    /// Readable | Writable
192    ///
193    ///
194    /// #### `margin-start`
195    ///  Margin on start of widget, horizontally. This property supports
196    /// left-to-right and right-to-left text directions.
197    ///
198    /// This property adds margin outside of the widget's normal size
199    /// request, the margin will be added in addition to the size from
200    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
201    ///
202    /// Readable | Writable
203    ///
204    ///
205    /// #### `margin-top`
206    ///  Margin on top side of widget.
207    ///
208    /// This property adds margin outside of the widget's normal size
209    /// request, the margin will be added in addition to the size from
210    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
211    ///
212    /// Readable | Writable
213    ///
214    ///
215    /// #### `name`
216    ///  Readable | Writable
217    ///
218    ///
219    /// #### `no-show-all`
220    ///  Readable | Writable
221    ///
222    ///
223    /// #### `opacity`
224    ///  The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
225    /// more details about window opacity.
226    ///
227    /// Before 3.8 this was only available in GtkWindow
228    ///
229    /// Readable | Writable
230    ///
231    ///
232    /// #### `parent`
233    ///  Readable | Writable
234    ///
235    ///
236    /// #### `receives-default`
237    ///  Readable | Writable
238    ///
239    ///
240    /// #### `scale-factor`
241    ///  The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
242    /// more details about widget scaling.
243    ///
244    /// Readable
245    ///
246    ///
247    /// #### `sensitive`
248    ///  Readable | Writable
249    ///
250    ///
251    /// #### `style`
252    ///  The style of the widget, which contains information about how it will look (colors, etc).
253    ///
254    /// Readable | Writable
255    ///
256    ///
257    /// #### `tooltip-markup`
258    ///  Sets the text of tooltip to be the given string, which is marked up
259    /// with the [Pango text markup language][PangoMarkupFormat].
260    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
261    ///
262    /// This is a convenience property which will take care of getting the
263    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
264    /// will automatically be set to [`true`] and there will be taken care of
265    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
266    ///
267    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
268    /// are set, the last one wins.
269    ///
270    /// Readable | Writable
271    ///
272    ///
273    /// #### `tooltip-text`
274    ///  Sets the text of tooltip to be the given string.
275    ///
276    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
277    ///
278    /// This is a convenience property which will take care of getting the
279    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
280    /// will automatically be set to [`true`] and there will be taken care of
281    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
282    ///
283    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
284    /// are set, the last one wins.
285    ///
286    /// Readable | Writable
287    ///
288    ///
289    /// #### `valign`
290    ///  How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
291    ///
292    /// Readable | Writable
293    ///
294    ///
295    /// #### `vexpand`
296    ///  Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
297    ///
298    /// Readable | Writable
299    ///
300    ///
301    /// #### `vexpand-set`
302    ///  Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
303    ///
304    /// Readable | Writable
305    ///
306    ///
307    /// #### `visible`
308    ///  Readable | Writable
309    ///
310    ///
311    /// #### `width-request`
312    ///  Readable | Writable
313    ///
314    ///
315    /// #### `window`
316    ///  The widget's window if it is realized, [`None`] otherwise.
317    ///
318    /// Readable
319    /// </details>
320    /// <details><summary><h4>Orientable</h4></summary>
321    ///
322    ///
323    /// #### `orientation`
324    ///  The orientation of the orientable.
325    ///
326    /// Readable | Writable
327    /// </details>
328    ///
329    /// # Implements
330    ///
331    /// [`ButtonBoxExt`][trait@crate::prelude::ButtonBoxExt], [`BoxExt`][trait@crate::prelude::BoxExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`OrientableExt`][trait@crate::prelude::OrientableExt], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
332    #[doc(alias = "GtkButtonBox")]
333    pub struct ButtonBox(Object<ffi::GtkButtonBox, ffi::GtkButtonBoxClass>) @extends Box, Container, Widget, @implements Buildable, Orientable;
334
335    match fn {
336        type_ => || ffi::gtk_button_box_get_type(),
337    }
338}
339
340impl ButtonBox {
341    pub const NONE: Option<&'static ButtonBox> = None;
342
343    /// Creates a new [`ButtonBox`][crate::ButtonBox].
344    /// ## `orientation`
345    /// the box's orientation.
346    ///
347    /// # Returns
348    ///
349    /// a new [`ButtonBox`][crate::ButtonBox].
350    #[doc(alias = "gtk_button_box_new")]
351    pub fn new(orientation: Orientation) -> ButtonBox {
352        assert_initialized_main_thread!();
353        unsafe {
354            Widget::from_glib_none(ffi::gtk_button_box_new(orientation.into_glib())).unsafe_cast()
355        }
356    }
357
358    // rustdoc-stripper-ignore-next
359    /// Creates a new builder-pattern struct instance to construct [`ButtonBox`] objects.
360    ///
361    /// This method returns an instance of [`ButtonBoxBuilder`](crate::builders::ButtonBoxBuilder) which can be used to create [`ButtonBox`] objects.
362    pub fn builder() -> ButtonBoxBuilder {
363        ButtonBoxBuilder::new()
364    }
365}
366
367impl Default for ButtonBox {
368    fn default() -> Self {
369        glib::object::Object::new::<Self>()
370    }
371}
372
373// rustdoc-stripper-ignore-next
374/// A [builder-pattern] type to construct [`ButtonBox`] objects.
375///
376/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
377#[must_use = "The builder must be built to be used"]
378pub struct ButtonBoxBuilder {
379    builder: glib::object::ObjectBuilder<'static, ButtonBox>,
380}
381
382impl ButtonBoxBuilder {
383    fn new() -> Self {
384        Self {
385            builder: glib::object::Object::builder(),
386        }
387    }
388
389    pub fn layout_style(self, layout_style: ButtonBoxStyle) -> Self {
390        Self {
391            builder: self.builder.property("layout-style", layout_style),
392        }
393    }
394
395    pub fn baseline_position(self, baseline_position: BaselinePosition) -> Self {
396        Self {
397            builder: self
398                .builder
399                .property("baseline-position", baseline_position),
400        }
401    }
402
403    pub fn homogeneous(self, homogeneous: bool) -> Self {
404        Self {
405            builder: self.builder.property("homogeneous", homogeneous),
406        }
407    }
408
409    pub fn spacing(self, spacing: i32) -> Self {
410        Self {
411            builder: self.builder.property("spacing", spacing),
412        }
413    }
414
415    pub fn border_width(self, border_width: u32) -> Self {
416        Self {
417            builder: self.builder.property("border-width", border_width),
418        }
419    }
420
421    pub fn child(self, child: &impl IsA<Widget>) -> Self {
422        Self {
423            builder: self.builder.property("child", child.clone().upcast()),
424        }
425    }
426
427    pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
428        Self {
429            builder: self.builder.property("resize-mode", resize_mode),
430        }
431    }
432
433    pub fn app_paintable(self, app_paintable: bool) -> Self {
434        Self {
435            builder: self.builder.property("app-paintable", app_paintable),
436        }
437    }
438
439    pub fn can_default(self, can_default: bool) -> Self {
440        Self {
441            builder: self.builder.property("can-default", can_default),
442        }
443    }
444
445    pub fn can_focus(self, can_focus: bool) -> Self {
446        Self {
447            builder: self.builder.property("can-focus", can_focus),
448        }
449    }
450
451    pub fn events(self, events: gdk::EventMask) -> Self {
452        Self {
453            builder: self.builder.property("events", events),
454        }
455    }
456
457    /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
458    pub fn expand(self, expand: bool) -> Self {
459        Self {
460            builder: self.builder.property("expand", expand),
461        }
462    }
463
464    /// Whether the widget should grab focus when it is clicked with the mouse.
465    ///
466    /// This property is only relevant for widgets that can take focus.
467    ///
468    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
469    /// GtkComboBox) implemented this property individually.
470    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
471        Self {
472            builder: self.builder.property("focus-on-click", focus_on_click),
473        }
474    }
475
476    /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
477    pub fn halign(self, halign: Align) -> Self {
478        Self {
479            builder: self.builder.property("halign", halign),
480        }
481    }
482
483    pub fn has_default(self, has_default: bool) -> Self {
484        Self {
485            builder: self.builder.property("has-default", has_default),
486        }
487    }
488
489    pub fn has_focus(self, has_focus: bool) -> Self {
490        Self {
491            builder: self.builder.property("has-focus", has_focus),
492        }
493    }
494
495    /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
496    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
497    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
498    /// whether it will provide a tooltip or not.
499    ///
500    /// Note that setting this property to [`true`] for the first time will change
501    /// the event masks of the GdkWindows of this widget to include leave-notify
502    /// and motion-notify events. This cannot and will not be undone when the
503    /// property is set to [`false`] again.
504    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
505        Self {
506            builder: self.builder.property("has-tooltip", has_tooltip),
507        }
508    }
509
510    pub fn height_request(self, height_request: i32) -> Self {
511        Self {
512            builder: self.builder.property("height-request", height_request),
513        }
514    }
515
516    /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
517    pub fn hexpand(self, hexpand: bool) -> Self {
518        Self {
519            builder: self.builder.property("hexpand", hexpand),
520        }
521    }
522
523    /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
524    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
525        Self {
526            builder: self.builder.property("hexpand-set", hexpand_set),
527        }
528    }
529
530    pub fn is_focus(self, is_focus: bool) -> Self {
531        Self {
532            builder: self.builder.property("is-focus", is_focus),
533        }
534    }
535
536    /// Sets all four sides' margin at once. If read, returns max
537    /// margin on any side.
538    pub fn margin(self, margin: i32) -> Self {
539        Self {
540            builder: self.builder.property("margin", margin),
541        }
542    }
543
544    /// Margin on bottom side of widget.
545    ///
546    /// This property adds margin outside of the widget's normal size
547    /// request, the margin will be added in addition to the size from
548    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
549    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
550        Self {
551            builder: self.builder.property("margin-bottom", margin_bottom),
552        }
553    }
554
555    /// Margin on end of widget, horizontally. This property supports
556    /// left-to-right and right-to-left text directions.
557    ///
558    /// This property adds margin outside of the widget's normal size
559    /// request, the margin will be added in addition to the size from
560    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
561    pub fn margin_end(self, margin_end: i32) -> Self {
562        Self {
563            builder: self.builder.property("margin-end", margin_end),
564        }
565    }
566
567    /// Margin on start of widget, horizontally. This property supports
568    /// left-to-right and right-to-left text directions.
569    ///
570    /// This property adds margin outside of the widget's normal size
571    /// request, the margin will be added in addition to the size from
572    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
573    pub fn margin_start(self, margin_start: i32) -> Self {
574        Self {
575            builder: self.builder.property("margin-start", margin_start),
576        }
577    }
578
579    /// Margin on top side of widget.
580    ///
581    /// This property adds margin outside of the widget's normal size
582    /// request, the margin will be added in addition to the size from
583    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
584    pub fn margin_top(self, margin_top: i32) -> Self {
585        Self {
586            builder: self.builder.property("margin-top", margin_top),
587        }
588    }
589
590    pub fn name(self, name: impl Into<glib::GString>) -> Self {
591        Self {
592            builder: self.builder.property("name", name.into()),
593        }
594    }
595
596    pub fn no_show_all(self, no_show_all: bool) -> Self {
597        Self {
598            builder: self.builder.property("no-show-all", no_show_all),
599        }
600    }
601
602    /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
603    /// more details about window opacity.
604    ///
605    /// Before 3.8 this was only available in GtkWindow
606    pub fn opacity(self, opacity: f64) -> Self {
607        Self {
608            builder: self.builder.property("opacity", opacity),
609        }
610    }
611
612    pub fn parent(self, parent: &impl IsA<Container>) -> Self {
613        Self {
614            builder: self.builder.property("parent", parent.clone().upcast()),
615        }
616    }
617
618    pub fn receives_default(self, receives_default: bool) -> Self {
619        Self {
620            builder: self.builder.property("receives-default", receives_default),
621        }
622    }
623
624    pub fn sensitive(self, sensitive: bool) -> Self {
625        Self {
626            builder: self.builder.property("sensitive", sensitive),
627        }
628    }
629
630    /// Sets the text of tooltip to be the given string, which is marked up
631    /// with the [Pango text markup language][PangoMarkupFormat].
632    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
633    ///
634    /// This is a convenience property which will take care of getting the
635    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
636    /// will automatically be set to [`true`] and there will be taken care of
637    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
638    ///
639    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
640    /// are set, the last one wins.
641    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
642        Self {
643            builder: self
644                .builder
645                .property("tooltip-markup", tooltip_markup.into()),
646        }
647    }
648
649    /// Sets the text of tooltip to be the given string.
650    ///
651    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
652    ///
653    /// This is a convenience property which will take care of getting the
654    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
655    /// will automatically be set to [`true`] and there will be taken care of
656    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
657    ///
658    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
659    /// are set, the last one wins.
660    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
661        Self {
662            builder: self.builder.property("tooltip-text", tooltip_text.into()),
663        }
664    }
665
666    /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
667    pub fn valign(self, valign: Align) -> Self {
668        Self {
669            builder: self.builder.property("valign", valign),
670        }
671    }
672
673    /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
674    pub fn vexpand(self, vexpand: bool) -> Self {
675        Self {
676            builder: self.builder.property("vexpand", vexpand),
677        }
678    }
679
680    /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
681    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
682        Self {
683            builder: self.builder.property("vexpand-set", vexpand_set),
684        }
685    }
686
687    pub fn visible(self, visible: bool) -> Self {
688        Self {
689            builder: self.builder.property("visible", visible),
690        }
691    }
692
693    pub fn width_request(self, width_request: i32) -> Self {
694        Self {
695            builder: self.builder.property("width-request", width_request),
696        }
697    }
698
699    /// The orientation of the orientable.
700    pub fn orientation(self, orientation: Orientation) -> Self {
701        Self {
702            builder: self.builder.property("orientation", orientation),
703        }
704    }
705
706    // rustdoc-stripper-ignore-next
707    /// Build the [`ButtonBox`].
708    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
709    pub fn build(self) -> ButtonBox {
710        assert_initialized_main_thread!();
711        self.builder.build()
712    }
713}
714
715/// Trait containing all [`struct@ButtonBox`] methods.
716///
717/// # Implementors
718///
719/// [`ButtonBox`][struct@crate::ButtonBox]
720pub trait ButtonBoxExt: IsA<ButtonBox> + 'static {
721    /// Returns whether the child is exempted from homogenous
722    /// sizing.
723    /// ## `child`
724    /// a child of `self`
725    ///
726    /// # Returns
727    ///
728    /// [`true`] if the child is not subject to homogenous sizing
729    #[doc(alias = "gtk_button_box_get_child_non_homogeneous")]
730    #[doc(alias = "get_child_non_homogeneous")]
731    fn child_is_non_homogeneous(&self, child: &impl IsA<Widget>) -> bool {
732        unsafe {
733            from_glib(ffi::gtk_button_box_get_child_non_homogeneous(
734                self.as_ref().to_glib_none().0,
735                child.as_ref().to_glib_none().0,
736            ))
737        }
738    }
739
740    /// Returns whether `child` should appear in a secondary group of children.
741    /// ## `child`
742    /// a child of `self`
743    ///
744    /// # Returns
745    ///
746    /// whether `child` should appear in a secondary group of children.
747    #[doc(alias = "gtk_button_box_get_child_secondary")]
748    #[doc(alias = "get_child_secondary")]
749    fn child_is_secondary(&self, child: &impl IsA<Widget>) -> bool {
750        unsafe {
751            from_glib(ffi::gtk_button_box_get_child_secondary(
752                self.as_ref().to_glib_none().0,
753                child.as_ref().to_glib_none().0,
754            ))
755        }
756    }
757
758    /// Retrieves the method being used to arrange the buttons in a button box.
759    ///
760    /// # Returns
761    ///
762    /// the method used to lay out buttons in `self`.
763    #[doc(alias = "gtk_button_box_get_layout")]
764    #[doc(alias = "get_layout")]
765    fn layout(&self) -> ButtonBoxStyle {
766        unsafe {
767            from_glib(ffi::gtk_button_box_get_layout(
768                self.as_ref().to_glib_none().0,
769            ))
770        }
771    }
772
773    /// Sets whether the child is exempted from homogeous sizing.
774    /// ## `child`
775    /// a child of `self`
776    /// ## `non_homogeneous`
777    /// the new value
778    #[doc(alias = "gtk_button_box_set_child_non_homogeneous")]
779    fn set_child_non_homogeneous(&self, child: &impl IsA<Widget>, non_homogeneous: bool) {
780        unsafe {
781            ffi::gtk_button_box_set_child_non_homogeneous(
782                self.as_ref().to_glib_none().0,
783                child.as_ref().to_glib_none().0,
784                non_homogeneous.into_glib(),
785            );
786        }
787    }
788
789    /// Sets whether `child` should appear in a secondary group of children.
790    /// A typical use of a secondary child is the help button in a dialog.
791    ///
792    /// This group appears after the other children if the style
793    /// is [`ButtonBoxStyle::Start`][crate::ButtonBoxStyle::Start], [`ButtonBoxStyle::Spread`][crate::ButtonBoxStyle::Spread] or
794    /// [`ButtonBoxStyle::Edge`][crate::ButtonBoxStyle::Edge], and before the other children if the style
795    /// is [`ButtonBoxStyle::End`][crate::ButtonBoxStyle::End]. For horizontal button boxes, the definition
796    /// of before/after depends on direction of the widget (see
797    /// [`WidgetExt::set_direction()`][crate::prelude::WidgetExt::set_direction()]). If the style is [`ButtonBoxStyle::Start`][crate::ButtonBoxStyle::Start]
798    /// or [`ButtonBoxStyle::End`][crate::ButtonBoxStyle::End], then the secondary children are aligned at
799    /// the other end of the button box from the main children. For the
800    /// other styles, they appear immediately next to the main children.
801    /// ## `child`
802    /// a child of `self`
803    /// ## `is_secondary`
804    /// if [`true`], the `child` appears in a secondary group of the
805    ///  button box.
806    #[doc(alias = "gtk_button_box_set_child_secondary")]
807    fn set_child_secondary(&self, child: &impl IsA<Widget>, is_secondary: bool) {
808        unsafe {
809            ffi::gtk_button_box_set_child_secondary(
810                self.as_ref().to_glib_none().0,
811                child.as_ref().to_glib_none().0,
812                is_secondary.into_glib(),
813            );
814        }
815    }
816
817    /// Changes the way buttons are arranged in their container.
818    /// ## `layout_style`
819    /// the new layout style
820    #[doc(alias = "gtk_button_box_set_layout")]
821    fn set_layout(&self, layout_style: ButtonBoxStyle) {
822        unsafe {
823            ffi::gtk_button_box_set_layout(
824                self.as_ref().to_glib_none().0,
825                layout_style.into_glib(),
826            );
827        }
828    }
829
830    #[doc(alias = "layout-style")]
831    fn layout_style(&self) -> ButtonBoxStyle {
832        ObjectExt::property(self.as_ref(), "layout-style")
833    }
834
835    #[doc(alias = "layout-style")]
836    fn set_layout_style(&self, layout_style: ButtonBoxStyle) {
837        ObjectExt::set_property(self.as_ref(), "layout-style", layout_style)
838    }
839
840    #[doc(alias = "layout-style")]
841    fn connect_layout_style_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
842        unsafe extern "C" fn notify_layout_style_trampoline<
843            P: IsA<ButtonBox>,
844            F: Fn(&P) + 'static,
845        >(
846            this: *mut ffi::GtkButtonBox,
847            _param_spec: glib::ffi::gpointer,
848            f: glib::ffi::gpointer,
849        ) {
850            unsafe {
851                let f: &F = &*(f as *const F);
852                f(ButtonBox::from_glib_borrow(this).unsafe_cast_ref())
853            }
854        }
855        unsafe {
856            let f: Box_<F> = Box_::new(f);
857            connect_raw(
858                self.as_ptr() as *mut _,
859                c"notify::layout-style".as_ptr(),
860                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
861                    notify_layout_style_trampoline::<Self, F> as *const (),
862                )),
863                Box_::into_raw(f),
864            )
865        }
866    }
867}
868
869impl<O: IsA<ButtonBox>> ButtonBoxExt for O {}