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,
8};
9use glib::{
10 prelude::*,
11 signal::{connect_raw, SignalHandlerId},
12 translate::*,
13};
14use std::{boxed::Box as Box_, fmt, mem::transmute};
15
16glib::wrapper! {
17 ///
18 ///
19 /// ## Properties
20 ///
21 ///
22 /// #### `layout-style`
23 /// Readable | Writeable
24 /// <details><summary><h4>Box</h4></summary>
25 ///
26 ///
27 /// #### `baseline-position`
28 /// Readable | Writeable
29 ///
30 ///
31 /// #### `homogeneous`
32 /// Readable | Writeable
33 ///
34 ///
35 /// #### `spacing`
36 /// Readable | Writeable
37 /// </details>
38 /// <details><summary><h4>Container</h4></summary>
39 ///
40 ///
41 /// #### `border-width`
42 /// Readable | Writeable
43 ///
44 ///
45 /// #### `child`
46 /// Writeable
47 ///
48 ///
49 /// #### `resize-mode`
50 /// Readable | Writeable
51 /// </details>
52 /// <details><summary><h4>Widget</h4></summary>
53 ///
54 ///
55 /// #### `app-paintable`
56 /// Readable | Writeable
57 ///
58 ///
59 /// #### `can-default`
60 /// Readable | Writeable
61 ///
62 ///
63 /// #### `can-focus`
64 /// Readable | Writeable
65 ///
66 ///
67 /// #### `composite-child`
68 /// Readable
69 ///
70 ///
71 /// #### `double-buffered`
72 /// Whether the widget is double buffered.
73 ///
74 /// Readable | Writeable
75 ///
76 ///
77 /// #### `events`
78 /// Readable | Writeable
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 | Writeable
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 | Writeable
96 ///
97 ///
98 /// #### `halign`
99 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
100 ///
101 /// Readable | Writeable
102 ///
103 ///
104 /// #### `has-default`
105 /// Readable | Writeable
106 ///
107 ///
108 /// #### `has-focus`
109 /// Readable | Writeable
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 | Writeable
124 ///
125 ///
126 /// #### `height-request`
127 /// Readable | Writeable
128 ///
129 ///
130 /// #### `hexpand`
131 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
132 ///
133 /// Readable | Writeable
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 | Writeable
140 ///
141 ///
142 /// #### `is-focus`
143 /// Readable | Writeable
144 ///
145 ///
146 /// #### `margin`
147 /// Sets all four sides' margin at once. If read, returns max
148 /// margin on any side.
149 ///
150 /// Readable | Writeable
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 | Writeable
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 | Writeable
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 | Writeable
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 | Writeable
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 | Writeable
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 | Writeable
213 ///
214 ///
215 /// #### `name`
216 /// Readable | Writeable
217 ///
218 ///
219 /// #### `no-show-all`
220 /// Readable | Writeable
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 | Writeable
230 ///
231 ///
232 /// #### `parent`
233 /// Readable | Writeable
234 ///
235 ///
236 /// #### `receives-default`
237 /// Readable | Writeable
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 | Writeable
249 ///
250 ///
251 /// #### `style`
252 /// The style of the widget, which contains information about how it will look (colors, etc).
253 ///
254 /// Readable | Writeable
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 | Writeable
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 | Writeable
287 ///
288 ///
289 /// #### `valign`
290 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
291 ///
292 /// Readable | Writeable
293 ///
294 ///
295 /// #### `vexpand`
296 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
297 ///
298 /// Readable | Writeable
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 | Writeable
305 ///
306 ///
307 /// #### `visible`
308 /// Readable | Writeable
309 ///
310 ///
311 /// #### `width-request`
312 /// Readable | Writeable
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 | Writeable
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 self.builder.build()
711 }
712}
713
714mod sealed {
715 pub trait Sealed {}
716 impl<T: super::IsA<super::ButtonBox>> Sealed for T {}
717}
718
719/// Trait containing all [`struct@ButtonBox`] methods.
720///
721/// # Implementors
722///
723/// [`ButtonBox`][struct@crate::ButtonBox]
724pub trait ButtonBoxExt: IsA<ButtonBox> + sealed::Sealed + 'static {
725 /// Returns whether the child is exempted from homogenous
726 /// sizing.
727 /// ## `child`
728 /// a child of `self`
729 ///
730 /// # Returns
731 ///
732 /// [`true`] if the child is not subject to homogenous sizing
733 #[doc(alias = "gtk_button_box_get_child_non_homogeneous")]
734 #[doc(alias = "get_child_non_homogeneous")]
735 fn child_is_non_homogeneous(&self, child: &impl IsA<Widget>) -> bool {
736 unsafe {
737 from_glib(ffi::gtk_button_box_get_child_non_homogeneous(
738 self.as_ref().to_glib_none().0,
739 child.as_ref().to_glib_none().0,
740 ))
741 }
742 }
743
744 /// Returns whether `child` should appear in a secondary group of children.
745 /// ## `child`
746 /// a child of `self`
747 ///
748 /// # Returns
749 ///
750 /// whether `child` should appear in a secondary group of children.
751 #[doc(alias = "gtk_button_box_get_child_secondary")]
752 #[doc(alias = "get_child_secondary")]
753 fn child_is_secondary(&self, child: &impl IsA<Widget>) -> bool {
754 unsafe {
755 from_glib(ffi::gtk_button_box_get_child_secondary(
756 self.as_ref().to_glib_none().0,
757 child.as_ref().to_glib_none().0,
758 ))
759 }
760 }
761
762 /// Retrieves the method being used to arrange the buttons in a button box.
763 ///
764 /// # Returns
765 ///
766 /// the method used to lay out buttons in `self`.
767 #[doc(alias = "gtk_button_box_get_layout")]
768 #[doc(alias = "get_layout")]
769 fn layout(&self) -> ButtonBoxStyle {
770 unsafe {
771 from_glib(ffi::gtk_button_box_get_layout(
772 self.as_ref().to_glib_none().0,
773 ))
774 }
775 }
776
777 /// Sets whether the child is exempted from homogeous sizing.
778 /// ## `child`
779 /// a child of `self`
780 /// ## `non_homogeneous`
781 /// the new value
782 #[doc(alias = "gtk_button_box_set_child_non_homogeneous")]
783 fn set_child_non_homogeneous(&self, child: &impl IsA<Widget>, non_homogeneous: bool) {
784 unsafe {
785 ffi::gtk_button_box_set_child_non_homogeneous(
786 self.as_ref().to_glib_none().0,
787 child.as_ref().to_glib_none().0,
788 non_homogeneous.into_glib(),
789 );
790 }
791 }
792
793 /// Sets whether `child` should appear in a secondary group of children.
794 /// A typical use of a secondary child is the help button in a dialog.
795 ///
796 /// This group appears after the other children if the style
797 /// is [`ButtonBoxStyle::Start`][crate::ButtonBoxStyle::Start], [`ButtonBoxStyle::Spread`][crate::ButtonBoxStyle::Spread] or
798 /// [`ButtonBoxStyle::Edge`][crate::ButtonBoxStyle::Edge], and before the other children if the style
799 /// is [`ButtonBoxStyle::End`][crate::ButtonBoxStyle::End]. For horizontal button boxes, the definition
800 /// of before/after depends on direction of the widget (see
801 /// [`WidgetExt::set_direction()`][crate::prelude::WidgetExt::set_direction()]). If the style is [`ButtonBoxStyle::Start`][crate::ButtonBoxStyle::Start]
802 /// or [`ButtonBoxStyle::End`][crate::ButtonBoxStyle::End], then the secondary children are aligned at
803 /// the other end of the button box from the main children. For the
804 /// other styles, they appear immediately next to the main children.
805 /// ## `child`
806 /// a child of `self`
807 /// ## `is_secondary`
808 /// if [`true`], the `child` appears in a secondary group of the
809 /// button box.
810 #[doc(alias = "gtk_button_box_set_child_secondary")]
811 fn set_child_secondary(&self, child: &impl IsA<Widget>, is_secondary: bool) {
812 unsafe {
813 ffi::gtk_button_box_set_child_secondary(
814 self.as_ref().to_glib_none().0,
815 child.as_ref().to_glib_none().0,
816 is_secondary.into_glib(),
817 );
818 }
819 }
820
821 /// Changes the way buttons are arranged in their container.
822 /// ## `layout_style`
823 /// the new layout style
824 #[doc(alias = "gtk_button_box_set_layout")]
825 fn set_layout(&self, layout_style: ButtonBoxStyle) {
826 unsafe {
827 ffi::gtk_button_box_set_layout(
828 self.as_ref().to_glib_none().0,
829 layout_style.into_glib(),
830 );
831 }
832 }
833
834 #[doc(alias = "layout-style")]
835 fn layout_style(&self) -> ButtonBoxStyle {
836 ObjectExt::property(self.as_ref(), "layout-style")
837 }
838
839 #[doc(alias = "layout-style")]
840 fn set_layout_style(&self, layout_style: ButtonBoxStyle) {
841 ObjectExt::set_property(self.as_ref(), "layout-style", layout_style)
842 }
843
844 #[doc(alias = "layout-style")]
845 fn connect_layout_style_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
846 unsafe extern "C" fn notify_layout_style_trampoline<
847 P: IsA<ButtonBox>,
848 F: Fn(&P) + 'static,
849 >(
850 this: *mut ffi::GtkButtonBox,
851 _param_spec: glib::ffi::gpointer,
852 f: glib::ffi::gpointer,
853 ) {
854 let f: &F = &*(f as *const F);
855 f(ButtonBox::from_glib_borrow(this).unsafe_cast_ref())
856 }
857 unsafe {
858 let f: Box_<F> = Box_::new(f);
859 connect_raw(
860 self.as_ptr() as *mut _,
861 b"notify::layout-style\0".as_ptr() as *const _,
862 Some(transmute::<_, unsafe extern "C" fn()>(
863 notify_layout_style_trampoline::<Self, F> as *const (),
864 )),
865 Box_::into_raw(f),
866 )
867 }
868 }
869}
870
871impl<O: IsA<ButtonBox>> ButtonBoxExt for O {}
872
873impl fmt::Display for ButtonBox {
874 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
875 f.write_str("ButtonBox")
876 }
877}