Skip to main content

gtk4/auto/
center_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    Accessible, AccessibleRole, Align, BaselinePosition, Buildable, ConstraintTarget,
7    LayoutManager, Orientable, Orientation, Overflow, 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    /// Arranges three children in a row, keeping the middle child
18    /// centered as well as possible.
19    ///
20    /// <picture>
21    ///   <source srcset="centerbox-dark.png" media="(prefers-color-scheme: dark)">
22    ///   <img alt="An example GtkCenterBox" src="centerbox.png">
23    /// </picture>
24    ///
25    /// To add children to [`CenterBox`][crate::CenterBox], use [`set_start_widget()`][Self::set_start_widget()],
26    /// [`set_center_widget()`][Self::set_center_widget()] and
27    /// [`set_end_widget()`][Self::set_end_widget()].
28    ///
29    /// The sizing and positioning of children can be influenced with the
30    /// align and expand properties of the children.
31    ///
32    /// # GtkCenterBox as GtkBuildable
33    ///
34    /// The [`CenterBox`][crate::CenterBox] implementation of the [`Buildable`][crate::Buildable] interface
35    /// supports placing children in the 3 positions by specifying “start”, “center”
36    /// or “end” as the “type” attribute of a `<child>` element.
37    ///
38    /// # CSS nodes
39    ///
40    /// [`CenterBox`][crate::CenterBox] uses a single CSS node with the name “box”,
41    ///
42    /// The first child of the [`CenterBox`][crate::CenterBox] will be allocated depending on the
43    /// text direction, i.e. in left-to-right layouts it will be allocated on the
44    /// left and in right-to-left layouts on the right.
45    ///
46    /// In vertical orientation, the nodes of the children are arranged from top to
47    /// bottom.
48    ///
49    /// # Accessibility
50    ///
51    /// Until GTK 4.10, [`CenterBox`][crate::CenterBox] used the [enum@Gtk.AccessibleRole.group] role.
52    ///
53    /// Starting from GTK 4.12, [`CenterBox`][crate::CenterBox] uses the [enum@Gtk.AccessibleRole.generic]
54    /// role.
55    ///
56    /// ## Properties
57    ///
58    ///
59    /// #### `baseline-position`
60    ///  The position of the baseline aligned widget if extra space is available.
61    ///
62    /// Readable | Writeable
63    ///
64    ///
65    /// #### `center-widget`
66    ///  The widget that is placed at the center position.
67    ///
68    /// Readable | Writeable
69    ///
70    ///
71    /// #### `end-widget`
72    ///  The widget that is placed at the end position.
73    ///
74    /// In vertical orientation, the end position is at the bottom.
75    /// In horizontal orientation, the end position is at the trailing
76    /// edge with respect to the text direction.
77    ///
78    /// Readable | Writeable
79    ///
80    ///
81    /// #### `shrink-center-last`
82    ///  Whether to shrink the center widget after other children.
83    ///
84    /// By default, when there's no space to give all three children their
85    /// natural widths, the start and end widgets start shrinking and the
86    /// center child keeps natural width until they reach minimum width.
87    ///
88    /// If false, start and end widgets keep natural width and the
89    /// center widget starts shrinking instead.
90    ///
91    /// Readable | Writeable
92    ///
93    ///
94    /// #### `start-widget`
95    ///  The widget that is placed at the start position.
96    ///
97    /// In vertical orientation, the start position is at the top.
98    /// In horizontal orientation, the start position is at the leading
99    /// edge with respect to the text direction.
100    ///
101    /// Readable | Writeable
102    /// <details><summary><h4>Widget</h4></summary>
103    ///
104    ///
105    /// #### `can-focus`
106    ///  Whether the widget or any of its descendents can accept
107    /// the input focus.
108    ///
109    /// This property is meant to be set by widget implementations,
110    /// typically in their instance init function.
111    ///
112    /// Readable | Writeable
113    ///
114    ///
115    /// #### `can-target`
116    ///  Whether the widget can receive pointer events.
117    ///
118    /// Readable | Writeable
119    ///
120    ///
121    /// #### `css-classes`
122    ///  A list of css classes applied to this widget.
123    ///
124    /// Readable | Writeable
125    ///
126    ///
127    /// #### `css-name`
128    ///  The name of this widget in the CSS tree.
129    ///
130    /// This property is meant to be set by widget implementations,
131    /// typically in their instance init function.
132    ///
133    /// Readable | Writeable | Construct Only
134    ///
135    ///
136    /// #### `cursor`
137    ///  The cursor used by @widget.
138    ///
139    /// Readable | Writeable
140    ///
141    ///
142    /// #### `focus-on-click`
143    ///  Whether the widget should grab focus when it is clicked with the mouse.
144    ///
145    /// This property is only relevant for widgets that can take focus.
146    ///
147    /// Readable | Writeable
148    ///
149    ///
150    /// #### `focusable`
151    ///  Whether this widget itself will accept the input focus.
152    ///
153    /// Readable | Writeable
154    ///
155    ///
156    /// #### `halign`
157    ///  How to distribute horizontal space if widget gets extra space.
158    ///
159    /// Readable | Writeable
160    ///
161    ///
162    /// #### `has-default`
163    ///  Whether the widget is the default widget.
164    ///
165    /// Readable
166    ///
167    ///
168    /// #### `has-focus`
169    ///  Whether the widget has the input focus.
170    ///
171    /// Readable
172    ///
173    ///
174    /// #### `has-tooltip`
175    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
176    /// signal on @widget.
177    ///
178    /// A true value indicates that @widget can have a tooltip, in this case
179    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
180    /// determine whether it will provide a tooltip or not.
181    ///
182    /// Readable | Writeable
183    ///
184    ///
185    /// #### `height-request`
186    ///  Overrides for height request of the widget.
187    ///
188    /// If this is -1, the natural request will be used.
189    ///
190    /// Readable | Writeable
191    ///
192    ///
193    /// #### `hexpand`
194    ///  Whether to expand horizontally.
195    ///
196    /// Readable | Writeable
197    ///
198    ///
199    /// #### `hexpand-set`
200    ///  Whether to use the `hexpand` property.
201    ///
202    /// Readable | Writeable
203    ///
204    ///
205    /// #### `layout-manager`
206    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
207    /// the preferred size of the widget, and allocate its children.
208    ///
209    /// This property is meant to be set by widget implementations,
210    /// typically in their instance init function.
211    ///
212    /// Readable | Writeable
213    ///
214    ///
215    /// #### `limit-events`
216    ///  Makes this widget act like a modal dialog, with respect to
217    /// event delivery.
218    ///
219    /// Global event controllers will not handle events with targets
220    /// inside the widget, unless they are set up to ignore propagation
221    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
222    ///
223    /// Readable | Writeable
224    ///
225    ///
226    /// #### `margin-bottom`
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    ///
233    /// Readable | Writeable
234    ///
235    ///
236    /// #### `margin-end`
237    ///  Margin on end of widget, horizontally.
238    ///
239    /// This property supports left-to-right and right-to-left text
240    /// directions.
241    ///
242    /// This property adds margin outside of the widget's normal size
243    /// request, the margin will be added in addition to the size from
244    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
245    ///
246    /// Readable | Writeable
247    ///
248    ///
249    /// #### `margin-start`
250    ///  Margin on start of widget, horizontally.
251    ///
252    /// This property supports left-to-right and right-to-left text
253    /// directions.
254    ///
255    /// This property adds margin outside of the widget's normal size
256    /// request, the margin will be added in addition to the size from
257    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
258    ///
259    /// Readable | Writeable
260    ///
261    ///
262    /// #### `margin-top`
263    ///  Margin on top side of widget.
264    ///
265    /// This property adds margin outside of the widget's normal size
266    /// request, the margin will be added in addition to the size from
267    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
268    ///
269    /// Readable | Writeable
270    ///
271    ///
272    /// #### `name`
273    ///  The name of the widget.
274    ///
275    /// Readable | Writeable
276    ///
277    ///
278    /// #### `opacity`
279    ///  The requested opacity of the widget.
280    ///
281    /// Readable | Writeable
282    ///
283    ///
284    /// #### `overflow`
285    ///  How content outside the widget's content area is treated.
286    ///
287    /// This property is meant to be set by widget implementations,
288    /// typically in their instance init function.
289    ///
290    /// Readable | Writeable
291    ///
292    ///
293    /// #### `parent`
294    ///  The parent widget of this widget.
295    ///
296    /// Readable
297    ///
298    ///
299    /// #### `receives-default`
300    ///  Whether the widget will receive the default action when it is focused.
301    ///
302    /// Readable | Writeable
303    ///
304    ///
305    /// #### `root`
306    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
307    ///
308    /// This will be `NULL` if the widget is not contained in a root widget.
309    ///
310    /// Readable
311    ///
312    ///
313    /// #### `scale-factor`
314    ///  The scale factor of the widget.
315    ///
316    /// Readable
317    ///
318    ///
319    /// #### `sensitive`
320    ///  Whether the widget responds to input.
321    ///
322    /// Readable | Writeable
323    ///
324    ///
325    /// #### `tooltip-markup`
326    ///  Sets the text of tooltip to be the given string, which is marked up
327    /// with Pango markup.
328    ///
329    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
330    ///
331    /// This is a convenience property which will take care of getting the
332    /// tooltip shown if the given string is not `NULL`:
333    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
334    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
335    /// the default signal handler.
336    ///
337    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
338    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
339    ///
340    /// Readable | Writeable
341    ///
342    ///
343    /// #### `tooltip-text`
344    ///  Sets the text of tooltip to be the given string.
345    ///
346    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
347    ///
348    /// This is a convenience property which will take care of getting the
349    /// tooltip shown if the given string is not `NULL`:
350    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
351    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
352    /// the default signal handler.
353    ///
354    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
355    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
356    ///
357    /// Readable | Writeable
358    ///
359    ///
360    /// #### `valign`
361    ///  How to distribute vertical space if widget gets extra space.
362    ///
363    /// Readable | Writeable
364    ///
365    ///
366    /// #### `vexpand`
367    ///  Whether to expand vertically.
368    ///
369    /// Readable | Writeable
370    ///
371    ///
372    /// #### `vexpand-set`
373    ///  Whether to use the `vexpand` property.
374    ///
375    /// Readable | Writeable
376    ///
377    ///
378    /// #### `visible`
379    ///  Whether the widget is visible.
380    ///
381    /// Readable | Writeable
382    ///
383    ///
384    /// #### `width-request`
385    ///  Overrides for width request of the widget.
386    ///
387    /// If this is -1, the natural request will be used.
388    ///
389    /// Readable | Writeable
390    /// </details>
391    /// <details><summary><h4>Accessible</h4></summary>
392    ///
393    ///
394    /// #### `accessible-role`
395    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
396    ///
397    /// The accessible role cannot be changed once set.
398    ///
399    /// Readable | Writeable
400    /// </details>
401    /// <details><summary><h4>Orientable</h4></summary>
402    ///
403    ///
404    /// #### `orientation`
405    ///  The orientation of the orientable.
406    ///
407    /// Readable | Writeable
408    /// </details>
409    ///
410    /// # Implements
411    ///
412    /// [`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]
413    #[doc(alias = "GtkCenterBox")]
414    pub struct CenterBox(Object<ffi::GtkCenterBox, ffi::GtkCenterBoxClass>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, Orientable;
415
416    match fn {
417        type_ => || ffi::gtk_center_box_get_type(),
418    }
419}
420
421impl CenterBox {
422    /// Creates a new [`CenterBox`][crate::CenterBox].
423    ///
424    /// # Returns
425    ///
426    /// the new [`CenterBox`][crate::CenterBox]
427    #[doc(alias = "gtk_center_box_new")]
428    pub fn new() -> CenterBox {
429        assert_initialized_main_thread!();
430        unsafe { Widget::from_glib_none(ffi::gtk_center_box_new()).unsafe_cast() }
431    }
432
433    // rustdoc-stripper-ignore-next
434    /// Creates a new builder-pattern struct instance to construct [`CenterBox`] objects.
435    ///
436    /// This method returns an instance of [`CenterBoxBuilder`](crate::builders::CenterBoxBuilder) which can be used to create [`CenterBox`] objects.
437    pub fn builder() -> CenterBoxBuilder {
438        CenterBoxBuilder::new()
439    }
440
441    /// Gets the baseline position of the center box.
442    ///
443    /// See [`set_baseline_position()`][Self::set_baseline_position()].
444    ///
445    /// # Returns
446    ///
447    /// the baseline position
448    #[doc(alias = "gtk_center_box_get_baseline_position")]
449    #[doc(alias = "get_baseline_position")]
450    #[doc(alias = "baseline-position")]
451    pub fn baseline_position(&self) -> BaselinePosition {
452        unsafe {
453            from_glib(ffi::gtk_center_box_get_baseline_position(
454                self.to_glib_none().0,
455            ))
456        }
457    }
458
459    /// Gets the center widget.
460    ///
461    /// # Returns
462    ///
463    /// the center widget
464    #[doc(alias = "gtk_center_box_get_center_widget")]
465    #[doc(alias = "get_center_widget")]
466    #[doc(alias = "center-widget")]
467    pub fn center_widget(&self) -> Option<Widget> {
468        unsafe { from_glib_none(ffi::gtk_center_box_get_center_widget(self.to_glib_none().0)) }
469    }
470
471    /// Gets the end widget.
472    ///
473    /// # Returns
474    ///
475    /// the end widget
476    #[doc(alias = "gtk_center_box_get_end_widget")]
477    #[doc(alias = "get_end_widget")]
478    #[doc(alias = "end-widget")]
479    pub fn end_widget(&self) -> Option<Widget> {
480        unsafe { from_glib_none(ffi::gtk_center_box_get_end_widget(self.to_glib_none().0)) }
481    }
482
483    /// Gets whether the center widget shrinks after other children.
484    ///
485    /// # Returns
486    ///
487    /// whether to shrink the center widget after others
488    #[cfg(feature = "v4_12")]
489    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
490    #[doc(alias = "gtk_center_box_get_shrink_center_last")]
491    #[doc(alias = "get_shrink_center_last")]
492    #[doc(alias = "shrink-center-last")]
493    pub fn shrinks_center_last(&self) -> bool {
494        unsafe {
495            from_glib(ffi::gtk_center_box_get_shrink_center_last(
496                self.to_glib_none().0,
497            ))
498        }
499    }
500
501    /// Gets the start widget.
502    ///
503    /// # Returns
504    ///
505    /// the start widget
506    #[doc(alias = "gtk_center_box_get_start_widget")]
507    #[doc(alias = "get_start_widget")]
508    #[doc(alias = "start-widget")]
509    pub fn start_widget(&self) -> Option<Widget> {
510        unsafe { from_glib_none(ffi::gtk_center_box_get_start_widget(self.to_glib_none().0)) }
511    }
512
513    /// Sets the baseline position of a center box.
514    ///
515    /// This affects only horizontal boxes with at least one baseline
516    /// aligned child. If there is more vertical space available than
517    /// requested, and the baseline is not allocated by the parent then
518    /// @position is used to allocate the baseline with respect to the
519    /// extra space available.
520    /// ## `position`
521    /// the baseline position
522    #[doc(alias = "gtk_center_box_set_baseline_position")]
523    #[doc(alias = "baseline-position")]
524    pub fn set_baseline_position(&self, position: BaselinePosition) {
525        unsafe {
526            ffi::gtk_center_box_set_baseline_position(self.to_glib_none().0, position.into_glib());
527        }
528    }
529
530    /// Sets the center widget.
531    ///
532    /// To remove the existing center widget, pass `NULL`.
533    /// ## `child`
534    /// the new center widget
535    #[doc(alias = "gtk_center_box_set_center_widget")]
536    #[doc(alias = "center-widget")]
537    pub fn set_center_widget(&self, child: Option<&impl IsA<Widget>>) {
538        unsafe {
539            ffi::gtk_center_box_set_center_widget(
540                self.to_glib_none().0,
541                child.map(|p| p.as_ref()).to_glib_none().0,
542            );
543        }
544    }
545
546    /// Sets the end widget.
547    ///
548    /// To remove the existing end widget, pass `NULL`.
549    /// ## `child`
550    /// the new end widget
551    #[doc(alias = "gtk_center_box_set_end_widget")]
552    #[doc(alias = "end-widget")]
553    pub fn set_end_widget(&self, child: Option<&impl IsA<Widget>>) {
554        unsafe {
555            ffi::gtk_center_box_set_end_widget(
556                self.to_glib_none().0,
557                child.map(|p| p.as_ref()).to_glib_none().0,
558            );
559        }
560    }
561
562    /// Sets whether to shrink the center widget after other children.
563    ///
564    /// By default, when there's no space to give all three children their
565    /// natural widths, the start and end widgets start shrinking and the
566    /// center child keeps natural width until they reach minimum width.
567    ///
568    /// If @shrink_center_last is false, start and end widgets keep natural
569    /// width and the center widget starts shrinking instead.
570    /// ## `shrink_center_last`
571    /// whether to shrink the center widget after others
572    #[cfg(feature = "v4_12")]
573    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
574    #[doc(alias = "gtk_center_box_set_shrink_center_last")]
575    #[doc(alias = "shrink-center-last")]
576    pub fn set_shrink_center_last(&self, shrink_center_last: bool) {
577        unsafe {
578            ffi::gtk_center_box_set_shrink_center_last(
579                self.to_glib_none().0,
580                shrink_center_last.into_glib(),
581            );
582        }
583    }
584
585    /// Sets the start widget.
586    ///
587    /// To remove the existing start widget, pass `NULL`.
588    /// ## `child`
589    /// the new start widget
590    #[doc(alias = "gtk_center_box_set_start_widget")]
591    #[doc(alias = "start-widget")]
592    pub fn set_start_widget(&self, child: Option<&impl IsA<Widget>>) {
593        unsafe {
594            ffi::gtk_center_box_set_start_widget(
595                self.to_glib_none().0,
596                child.map(|p| p.as_ref()).to_glib_none().0,
597            );
598        }
599    }
600
601    #[doc(alias = "baseline-position")]
602    pub fn connect_baseline_position_notify<F: Fn(&Self) + 'static>(
603        &self,
604        f: F,
605    ) -> SignalHandlerId {
606        unsafe extern "C" fn notify_baseline_position_trampoline<F: Fn(&CenterBox) + 'static>(
607            this: *mut ffi::GtkCenterBox,
608            _param_spec: glib::ffi::gpointer,
609            f: glib::ffi::gpointer,
610        ) {
611            unsafe {
612                let f: &F = &*(f as *const F);
613                f(&from_glib_borrow(this))
614            }
615        }
616        unsafe {
617            let f: Box_<F> = Box_::new(f);
618            connect_raw(
619                self.as_ptr() as *mut _,
620                c"notify::baseline-position".as_ptr() as *const _,
621                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
622                    notify_baseline_position_trampoline::<F> as *const (),
623                )),
624                Box_::into_raw(f),
625            )
626        }
627    }
628
629    #[cfg(feature = "v4_10")]
630    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
631    #[doc(alias = "center-widget")]
632    pub fn connect_center_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
633        unsafe extern "C" fn notify_center_widget_trampoline<F: Fn(&CenterBox) + 'static>(
634            this: *mut ffi::GtkCenterBox,
635            _param_spec: glib::ffi::gpointer,
636            f: glib::ffi::gpointer,
637        ) {
638            unsafe {
639                let f: &F = &*(f as *const F);
640                f(&from_glib_borrow(this))
641            }
642        }
643        unsafe {
644            let f: Box_<F> = Box_::new(f);
645            connect_raw(
646                self.as_ptr() as *mut _,
647                c"notify::center-widget".as_ptr() as *const _,
648                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
649                    notify_center_widget_trampoline::<F> as *const (),
650                )),
651                Box_::into_raw(f),
652            )
653        }
654    }
655
656    #[cfg(feature = "v4_10")]
657    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
658    #[doc(alias = "end-widget")]
659    pub fn connect_end_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
660        unsafe extern "C" fn notify_end_widget_trampoline<F: Fn(&CenterBox) + 'static>(
661            this: *mut ffi::GtkCenterBox,
662            _param_spec: glib::ffi::gpointer,
663            f: glib::ffi::gpointer,
664        ) {
665            unsafe {
666                let f: &F = &*(f as *const F);
667                f(&from_glib_borrow(this))
668            }
669        }
670        unsafe {
671            let f: Box_<F> = Box_::new(f);
672            connect_raw(
673                self.as_ptr() as *mut _,
674                c"notify::end-widget".as_ptr() as *const _,
675                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
676                    notify_end_widget_trampoline::<F> as *const (),
677                )),
678                Box_::into_raw(f),
679            )
680        }
681    }
682
683    #[cfg(feature = "v4_12")]
684    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
685    #[doc(alias = "shrink-center-last")]
686    pub fn connect_shrink_center_last_notify<F: Fn(&Self) + 'static>(
687        &self,
688        f: F,
689    ) -> SignalHandlerId {
690        unsafe extern "C" fn notify_shrink_center_last_trampoline<F: Fn(&CenterBox) + 'static>(
691            this: *mut ffi::GtkCenterBox,
692            _param_spec: glib::ffi::gpointer,
693            f: glib::ffi::gpointer,
694        ) {
695            unsafe {
696                let f: &F = &*(f as *const F);
697                f(&from_glib_borrow(this))
698            }
699        }
700        unsafe {
701            let f: Box_<F> = Box_::new(f);
702            connect_raw(
703                self.as_ptr() as *mut _,
704                c"notify::shrink-center-last".as_ptr() as *const _,
705                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
706                    notify_shrink_center_last_trampoline::<F> as *const (),
707                )),
708                Box_::into_raw(f),
709            )
710        }
711    }
712
713    #[cfg(feature = "v4_10")]
714    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
715    #[doc(alias = "start-widget")]
716    pub fn connect_start_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
717        unsafe extern "C" fn notify_start_widget_trampoline<F: Fn(&CenterBox) + 'static>(
718            this: *mut ffi::GtkCenterBox,
719            _param_spec: glib::ffi::gpointer,
720            f: glib::ffi::gpointer,
721        ) {
722            unsafe {
723                let f: &F = &*(f as *const F);
724                f(&from_glib_borrow(this))
725            }
726        }
727        unsafe {
728            let f: Box_<F> = Box_::new(f);
729            connect_raw(
730                self.as_ptr() as *mut _,
731                c"notify::start-widget".as_ptr() as *const _,
732                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
733                    notify_start_widget_trampoline::<F> as *const (),
734                )),
735                Box_::into_raw(f),
736            )
737        }
738    }
739}
740
741impl Default for CenterBox {
742    fn default() -> Self {
743        Self::new()
744    }
745}
746
747// rustdoc-stripper-ignore-next
748/// A [builder-pattern] type to construct [`CenterBox`] objects.
749///
750/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
751#[must_use = "The builder must be built to be used"]
752pub struct CenterBoxBuilder {
753    builder: glib::object::ObjectBuilder<'static, CenterBox>,
754}
755
756impl CenterBoxBuilder {
757    fn new() -> Self {
758        Self {
759            builder: glib::object::Object::builder(),
760        }
761    }
762
763    /// The position of the baseline aligned widget if extra space is available.
764    pub fn baseline_position(self, baseline_position: BaselinePosition) -> Self {
765        Self {
766            builder: self
767                .builder
768                .property("baseline-position", baseline_position),
769        }
770    }
771
772    /// The widget that is placed at the center position.
773    #[cfg(feature = "v4_10")]
774    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
775    pub fn center_widget(self, center_widget: &impl IsA<Widget>) -> Self {
776        Self {
777            builder: self
778                .builder
779                .property("center-widget", center_widget.clone().upcast()),
780        }
781    }
782
783    /// The widget that is placed at the end position.
784    ///
785    /// In vertical orientation, the end position is at the bottom.
786    /// In horizontal orientation, the end position is at the trailing
787    /// edge with respect to the text direction.
788    #[cfg(feature = "v4_10")]
789    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
790    pub fn end_widget(self, end_widget: &impl IsA<Widget>) -> Self {
791        Self {
792            builder: self
793                .builder
794                .property("end-widget", end_widget.clone().upcast()),
795        }
796    }
797
798    /// Whether to shrink the center widget after other children.
799    ///
800    /// By default, when there's no space to give all three children their
801    /// natural widths, the start and end widgets start shrinking and the
802    /// center child keeps natural width until they reach minimum width.
803    ///
804    /// If false, start and end widgets keep natural width and the
805    /// center widget starts shrinking instead.
806    #[cfg(feature = "v4_12")]
807    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
808    pub fn shrink_center_last(self, shrink_center_last: bool) -> Self {
809        Self {
810            builder: self
811                .builder
812                .property("shrink-center-last", shrink_center_last),
813        }
814    }
815
816    /// The widget that is placed at the start position.
817    ///
818    /// In vertical orientation, the start position is at the top.
819    /// In horizontal orientation, the start position is at the leading
820    /// edge with respect to the text direction.
821    #[cfg(feature = "v4_10")]
822    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
823    pub fn start_widget(self, start_widget: &impl IsA<Widget>) -> Self {
824        Self {
825            builder: self
826                .builder
827                .property("start-widget", start_widget.clone().upcast()),
828        }
829    }
830
831    /// Whether the widget or any of its descendents can accept
832    /// the input focus.
833    ///
834    /// This property is meant to be set by widget implementations,
835    /// typically in their instance init function.
836    pub fn can_focus(self, can_focus: bool) -> Self {
837        Self {
838            builder: self.builder.property("can-focus", can_focus),
839        }
840    }
841
842    /// Whether the widget can receive pointer events.
843    pub fn can_target(self, can_target: bool) -> Self {
844        Self {
845            builder: self.builder.property("can-target", can_target),
846        }
847    }
848
849    /// A list of css classes applied to this widget.
850    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
851        Self {
852            builder: self.builder.property("css-classes", css_classes.into()),
853        }
854    }
855
856    /// The name of this widget in the CSS tree.
857    ///
858    /// This property is meant to be set by widget implementations,
859    /// typically in their instance init function.
860    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
861        Self {
862            builder: self.builder.property("css-name", css_name.into()),
863        }
864    }
865
866    /// The cursor used by @widget.
867    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
868        Self {
869            builder: self.builder.property("cursor", cursor.clone()),
870        }
871    }
872
873    /// Whether the widget should grab focus when it is clicked with the mouse.
874    ///
875    /// This property is only relevant for widgets that can take focus.
876    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
877        Self {
878            builder: self.builder.property("focus-on-click", focus_on_click),
879        }
880    }
881
882    /// Whether this widget itself will accept the input focus.
883    pub fn focusable(self, focusable: bool) -> Self {
884        Self {
885            builder: self.builder.property("focusable", focusable),
886        }
887    }
888
889    /// How to distribute horizontal space if widget gets extra space.
890    pub fn halign(self, halign: Align) -> Self {
891        Self {
892            builder: self.builder.property("halign", halign),
893        }
894    }
895
896    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
897    /// signal on @widget.
898    ///
899    /// A true value indicates that @widget can have a tooltip, in this case
900    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
901    /// determine whether it will provide a tooltip or not.
902    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
903        Self {
904            builder: self.builder.property("has-tooltip", has_tooltip),
905        }
906    }
907
908    /// Overrides for height request of the widget.
909    ///
910    /// If this is -1, the natural request will be used.
911    pub fn height_request(self, height_request: i32) -> Self {
912        Self {
913            builder: self.builder.property("height-request", height_request),
914        }
915    }
916
917    /// Whether to expand horizontally.
918    pub fn hexpand(self, hexpand: bool) -> Self {
919        Self {
920            builder: self.builder.property("hexpand", hexpand),
921        }
922    }
923
924    /// Whether to use the `hexpand` property.
925    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
926        Self {
927            builder: self.builder.property("hexpand-set", hexpand_set),
928        }
929    }
930
931    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
932    /// the preferred size of the widget, and allocate its children.
933    ///
934    /// This property is meant to be set by widget implementations,
935    /// typically in their instance init function.
936    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
937        Self {
938            builder: self
939                .builder
940                .property("layout-manager", layout_manager.clone().upcast()),
941        }
942    }
943
944    /// Makes this widget act like a modal dialog, with respect to
945    /// event delivery.
946    ///
947    /// Global event controllers will not handle events with targets
948    /// inside the widget, unless they are set up to ignore propagation
949    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
950    #[cfg(feature = "v4_18")]
951    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
952    pub fn limit_events(self, limit_events: bool) -> Self {
953        Self {
954            builder: self.builder.property("limit-events", limit_events),
955        }
956    }
957
958    /// Margin on bottom side of widget.
959    ///
960    /// This property adds margin outside of the widget's normal size
961    /// request, the margin will be added in addition to the size from
962    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
963    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
964        Self {
965            builder: self.builder.property("margin-bottom", margin_bottom),
966        }
967    }
968
969    /// Margin on end of widget, horizontally.
970    ///
971    /// This property supports left-to-right and right-to-left text
972    /// directions.
973    ///
974    /// This property adds margin outside of the widget's normal size
975    /// request, the margin will be added in addition to the size from
976    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
977    pub fn margin_end(self, margin_end: i32) -> Self {
978        Self {
979            builder: self.builder.property("margin-end", margin_end),
980        }
981    }
982
983    /// Margin on start of widget, horizontally.
984    ///
985    /// This property supports left-to-right and right-to-left text
986    /// directions.
987    ///
988    /// This property adds margin outside of the widget's normal size
989    /// request, the margin will be added in addition to the size from
990    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
991    pub fn margin_start(self, margin_start: i32) -> Self {
992        Self {
993            builder: self.builder.property("margin-start", margin_start),
994        }
995    }
996
997    /// Margin on top side of widget.
998    ///
999    /// This property adds margin outside of the widget's normal size
1000    /// request, the margin will be added in addition to the size from
1001    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1002    pub fn margin_top(self, margin_top: i32) -> Self {
1003        Self {
1004            builder: self.builder.property("margin-top", margin_top),
1005        }
1006    }
1007
1008    /// The name of the widget.
1009    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1010        Self {
1011            builder: self.builder.property("name", name.into()),
1012        }
1013    }
1014
1015    /// The requested opacity of the widget.
1016    pub fn opacity(self, opacity: f64) -> Self {
1017        Self {
1018            builder: self.builder.property("opacity", opacity),
1019        }
1020    }
1021
1022    /// How content outside the widget's content area is treated.
1023    ///
1024    /// This property is meant to be set by widget implementations,
1025    /// typically in their instance init function.
1026    pub fn overflow(self, overflow: Overflow) -> Self {
1027        Self {
1028            builder: self.builder.property("overflow", overflow),
1029        }
1030    }
1031
1032    /// Whether the widget will receive the default action when it is focused.
1033    pub fn receives_default(self, receives_default: bool) -> Self {
1034        Self {
1035            builder: self.builder.property("receives-default", receives_default),
1036        }
1037    }
1038
1039    /// Whether the widget responds to input.
1040    pub fn sensitive(self, sensitive: bool) -> Self {
1041        Self {
1042            builder: self.builder.property("sensitive", sensitive),
1043        }
1044    }
1045
1046    /// Sets the text of tooltip to be the given string, which is marked up
1047    /// with Pango markup.
1048    ///
1049    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1050    ///
1051    /// This is a convenience property which will take care of getting the
1052    /// tooltip shown if the given string is not `NULL`:
1053    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1054    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1055    /// the default signal handler.
1056    ///
1057    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1058    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1059    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1060        Self {
1061            builder: self
1062                .builder
1063                .property("tooltip-markup", tooltip_markup.into()),
1064        }
1065    }
1066
1067    /// Sets the text of tooltip to be the given string.
1068    ///
1069    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1070    ///
1071    /// This is a convenience property which will take care of getting the
1072    /// tooltip shown if the given string is not `NULL`:
1073    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1074    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1075    /// the default signal handler.
1076    ///
1077    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1078    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1079    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1080        Self {
1081            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1082        }
1083    }
1084
1085    /// How to distribute vertical space if widget gets extra space.
1086    pub fn valign(self, valign: Align) -> Self {
1087        Self {
1088            builder: self.builder.property("valign", valign),
1089        }
1090    }
1091
1092    /// Whether to expand vertically.
1093    pub fn vexpand(self, vexpand: bool) -> Self {
1094        Self {
1095            builder: self.builder.property("vexpand", vexpand),
1096        }
1097    }
1098
1099    /// Whether to use the `vexpand` property.
1100    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1101        Self {
1102            builder: self.builder.property("vexpand-set", vexpand_set),
1103        }
1104    }
1105
1106    /// Whether the widget is visible.
1107    pub fn visible(self, visible: bool) -> Self {
1108        Self {
1109            builder: self.builder.property("visible", visible),
1110        }
1111    }
1112
1113    /// Overrides for width request of the widget.
1114    ///
1115    /// If this is -1, the natural request will be used.
1116    pub fn width_request(self, width_request: i32) -> Self {
1117        Self {
1118            builder: self.builder.property("width-request", width_request),
1119        }
1120    }
1121
1122    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1123    ///
1124    /// The accessible role cannot be changed once set.
1125    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1126        Self {
1127            builder: self.builder.property("accessible-role", accessible_role),
1128        }
1129    }
1130
1131    /// The orientation of the orientable.
1132    pub fn orientation(self, orientation: Orientation) -> Self {
1133        Self {
1134            builder: self.builder.property("orientation", orientation),
1135        }
1136    }
1137
1138    // rustdoc-stripper-ignore-next
1139    /// Build the [`CenterBox`].
1140    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1141    pub fn build(self) -> CenterBox {
1142        assert_initialized_main_thread!();
1143        self.builder.build()
1144    }
1145}