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    ffi, Accessible, AccessibleRole, Align, BaselinePosition, Buildable, ConstraintTarget,
7    LayoutManager, Orientable, Orientation, Overflow, Widget,
8};
9use glib::{
10    prelude::*,
11    signal::{connect_raw, SignalHandlerId},
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            let f: &F = &*(f as *const F);
612            f(&from_glib_borrow(this))
613        }
614        unsafe {
615            let f: Box_<F> = Box_::new(f);
616            connect_raw(
617                self.as_ptr() as *mut _,
618                c"notify::baseline-position".as_ptr() as *const _,
619                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
620                    notify_baseline_position_trampoline::<F> as *const (),
621                )),
622                Box_::into_raw(f),
623            )
624        }
625    }
626
627    #[cfg(feature = "v4_10")]
628    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
629    #[doc(alias = "center-widget")]
630    pub fn connect_center_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
631        unsafe extern "C" fn notify_center_widget_trampoline<F: Fn(&CenterBox) + 'static>(
632            this: *mut ffi::GtkCenterBox,
633            _param_spec: glib::ffi::gpointer,
634            f: glib::ffi::gpointer,
635        ) {
636            let f: &F = &*(f as *const F);
637            f(&from_glib_borrow(this))
638        }
639        unsafe {
640            let f: Box_<F> = Box_::new(f);
641            connect_raw(
642                self.as_ptr() as *mut _,
643                c"notify::center-widget".as_ptr() as *const _,
644                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
645                    notify_center_widget_trampoline::<F> as *const (),
646                )),
647                Box_::into_raw(f),
648            )
649        }
650    }
651
652    #[cfg(feature = "v4_10")]
653    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
654    #[doc(alias = "end-widget")]
655    pub fn connect_end_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
656        unsafe extern "C" fn notify_end_widget_trampoline<F: Fn(&CenterBox) + 'static>(
657            this: *mut ffi::GtkCenterBox,
658            _param_spec: glib::ffi::gpointer,
659            f: glib::ffi::gpointer,
660        ) {
661            let f: &F = &*(f as *const F);
662            f(&from_glib_borrow(this))
663        }
664        unsafe {
665            let f: Box_<F> = Box_::new(f);
666            connect_raw(
667                self.as_ptr() as *mut _,
668                c"notify::end-widget".as_ptr() as *const _,
669                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
670                    notify_end_widget_trampoline::<F> as *const (),
671                )),
672                Box_::into_raw(f),
673            )
674        }
675    }
676
677    #[cfg(feature = "v4_12")]
678    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
679    #[doc(alias = "shrink-center-last")]
680    pub fn connect_shrink_center_last_notify<F: Fn(&Self) + 'static>(
681        &self,
682        f: F,
683    ) -> SignalHandlerId {
684        unsafe extern "C" fn notify_shrink_center_last_trampoline<F: Fn(&CenterBox) + 'static>(
685            this: *mut ffi::GtkCenterBox,
686            _param_spec: glib::ffi::gpointer,
687            f: glib::ffi::gpointer,
688        ) {
689            let f: &F = &*(f as *const F);
690            f(&from_glib_borrow(this))
691        }
692        unsafe {
693            let f: Box_<F> = Box_::new(f);
694            connect_raw(
695                self.as_ptr() as *mut _,
696                c"notify::shrink-center-last".as_ptr() as *const _,
697                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
698                    notify_shrink_center_last_trampoline::<F> as *const (),
699                )),
700                Box_::into_raw(f),
701            )
702        }
703    }
704
705    #[cfg(feature = "v4_10")]
706    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
707    #[doc(alias = "start-widget")]
708    pub fn connect_start_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
709        unsafe extern "C" fn notify_start_widget_trampoline<F: Fn(&CenterBox) + 'static>(
710            this: *mut ffi::GtkCenterBox,
711            _param_spec: glib::ffi::gpointer,
712            f: glib::ffi::gpointer,
713        ) {
714            let f: &F = &*(f as *const F);
715            f(&from_glib_borrow(this))
716        }
717        unsafe {
718            let f: Box_<F> = Box_::new(f);
719            connect_raw(
720                self.as_ptr() as *mut _,
721                c"notify::start-widget".as_ptr() as *const _,
722                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
723                    notify_start_widget_trampoline::<F> as *const (),
724                )),
725                Box_::into_raw(f),
726            )
727        }
728    }
729}
730
731impl Default for CenterBox {
732    fn default() -> Self {
733        Self::new()
734    }
735}
736
737// rustdoc-stripper-ignore-next
738/// A [builder-pattern] type to construct [`CenterBox`] objects.
739///
740/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
741#[must_use = "The builder must be built to be used"]
742pub struct CenterBoxBuilder {
743    builder: glib::object::ObjectBuilder<'static, CenterBox>,
744}
745
746impl CenterBoxBuilder {
747    fn new() -> Self {
748        Self {
749            builder: glib::object::Object::builder(),
750        }
751    }
752
753    /// The position of the baseline aligned widget if extra space is available.
754    pub fn baseline_position(self, baseline_position: BaselinePosition) -> Self {
755        Self {
756            builder: self
757                .builder
758                .property("baseline-position", baseline_position),
759        }
760    }
761
762    /// The widget that is placed at the center position.
763    #[cfg(feature = "v4_10")]
764    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
765    pub fn center_widget(self, center_widget: &impl IsA<Widget>) -> Self {
766        Self {
767            builder: self
768                .builder
769                .property("center-widget", center_widget.clone().upcast()),
770        }
771    }
772
773    /// The widget that is placed at the end position.
774    ///
775    /// In vertical orientation, the end position is at the bottom.
776    /// In horizontal orientation, the end position is at the trailing
777    /// edge with respect to the text direction.
778    #[cfg(feature = "v4_10")]
779    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
780    pub fn end_widget(self, end_widget: &impl IsA<Widget>) -> Self {
781        Self {
782            builder: self
783                .builder
784                .property("end-widget", end_widget.clone().upcast()),
785        }
786    }
787
788    /// Whether to shrink the center widget after other children.
789    ///
790    /// By default, when there's no space to give all three children their
791    /// natural widths, the start and end widgets start shrinking and the
792    /// center child keeps natural width until they reach minimum width.
793    ///
794    /// If false, start and end widgets keep natural width and the
795    /// center widget starts shrinking instead.
796    #[cfg(feature = "v4_12")]
797    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
798    pub fn shrink_center_last(self, shrink_center_last: bool) -> Self {
799        Self {
800            builder: self
801                .builder
802                .property("shrink-center-last", shrink_center_last),
803        }
804    }
805
806    /// The widget that is placed at the start position.
807    ///
808    /// In vertical orientation, the start position is at the top.
809    /// In horizontal orientation, the start position is at the leading
810    /// edge with respect to the text direction.
811    #[cfg(feature = "v4_10")]
812    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
813    pub fn start_widget(self, start_widget: &impl IsA<Widget>) -> Self {
814        Self {
815            builder: self
816                .builder
817                .property("start-widget", start_widget.clone().upcast()),
818        }
819    }
820
821    /// Whether the widget or any of its descendents can accept
822    /// the input focus.
823    ///
824    /// This property is meant to be set by widget implementations,
825    /// typically in their instance init function.
826    pub fn can_focus(self, can_focus: bool) -> Self {
827        Self {
828            builder: self.builder.property("can-focus", can_focus),
829        }
830    }
831
832    /// Whether the widget can receive pointer events.
833    pub fn can_target(self, can_target: bool) -> Self {
834        Self {
835            builder: self.builder.property("can-target", can_target),
836        }
837    }
838
839    /// A list of css classes applied to this widget.
840    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
841        Self {
842            builder: self.builder.property("css-classes", css_classes.into()),
843        }
844    }
845
846    /// The name of this widget in the CSS tree.
847    ///
848    /// This property is meant to be set by widget implementations,
849    /// typically in their instance init function.
850    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
851        Self {
852            builder: self.builder.property("css-name", css_name.into()),
853        }
854    }
855
856    /// The cursor used by @widget.
857    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
858        Self {
859            builder: self.builder.property("cursor", cursor.clone()),
860        }
861    }
862
863    /// Whether the widget should grab focus when it is clicked with the mouse.
864    ///
865    /// This property is only relevant for widgets that can take focus.
866    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
867        Self {
868            builder: self.builder.property("focus-on-click", focus_on_click),
869        }
870    }
871
872    /// Whether this widget itself will accept the input focus.
873    pub fn focusable(self, focusable: bool) -> Self {
874        Self {
875            builder: self.builder.property("focusable", focusable),
876        }
877    }
878
879    /// How to distribute horizontal space if widget gets extra space.
880    pub fn halign(self, halign: Align) -> Self {
881        Self {
882            builder: self.builder.property("halign", halign),
883        }
884    }
885
886    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
887    /// signal on @widget.
888    ///
889    /// A true value indicates that @widget can have a tooltip, in this case
890    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
891    /// determine whether it will provide a tooltip or not.
892    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
893        Self {
894            builder: self.builder.property("has-tooltip", has_tooltip),
895        }
896    }
897
898    /// Overrides for height request of the widget.
899    ///
900    /// If this is -1, the natural request will be used.
901    pub fn height_request(self, height_request: i32) -> Self {
902        Self {
903            builder: self.builder.property("height-request", height_request),
904        }
905    }
906
907    /// Whether to expand horizontally.
908    pub fn hexpand(self, hexpand: bool) -> Self {
909        Self {
910            builder: self.builder.property("hexpand", hexpand),
911        }
912    }
913
914    /// Whether to use the `hexpand` property.
915    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
916        Self {
917            builder: self.builder.property("hexpand-set", hexpand_set),
918        }
919    }
920
921    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
922    /// the preferred size of the widget, and allocate its children.
923    ///
924    /// This property is meant to be set by widget implementations,
925    /// typically in their instance init function.
926    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
927        Self {
928            builder: self
929                .builder
930                .property("layout-manager", layout_manager.clone().upcast()),
931        }
932    }
933
934    /// Makes this widget act like a modal dialog, with respect to
935    /// event delivery.
936    ///
937    /// Global event controllers will not handle events with targets
938    /// inside the widget, unless they are set up to ignore propagation
939    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
940    #[cfg(feature = "v4_18")]
941    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
942    pub fn limit_events(self, limit_events: bool) -> Self {
943        Self {
944            builder: self.builder.property("limit-events", limit_events),
945        }
946    }
947
948    /// Margin on bottom side of widget.
949    ///
950    /// This property adds margin outside of the widget's normal size
951    /// request, the margin will be added in addition to the size from
952    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
953    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
954        Self {
955            builder: self.builder.property("margin-bottom", margin_bottom),
956        }
957    }
958
959    /// Margin on end of widget, horizontally.
960    ///
961    /// This property supports left-to-right and right-to-left text
962    /// directions.
963    ///
964    /// This property adds margin outside of the widget's normal size
965    /// request, the margin will be added in addition to the size from
966    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
967    pub fn margin_end(self, margin_end: i32) -> Self {
968        Self {
969            builder: self.builder.property("margin-end", margin_end),
970        }
971    }
972
973    /// Margin on start of widget, horizontally.
974    ///
975    /// This property supports left-to-right and right-to-left text
976    /// directions.
977    ///
978    /// This property adds margin outside of the widget's normal size
979    /// request, the margin will be added in addition to the size from
980    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
981    pub fn margin_start(self, margin_start: i32) -> Self {
982        Self {
983            builder: self.builder.property("margin-start", margin_start),
984        }
985    }
986
987    /// Margin on top side of widget.
988    ///
989    /// This property adds margin outside of the widget's normal size
990    /// request, the margin will be added in addition to the size from
991    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
992    pub fn margin_top(self, margin_top: i32) -> Self {
993        Self {
994            builder: self.builder.property("margin-top", margin_top),
995        }
996    }
997
998    /// The name of the widget.
999    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1000        Self {
1001            builder: self.builder.property("name", name.into()),
1002        }
1003    }
1004
1005    /// The requested opacity of the widget.
1006    pub fn opacity(self, opacity: f64) -> Self {
1007        Self {
1008            builder: self.builder.property("opacity", opacity),
1009        }
1010    }
1011
1012    /// How content outside the widget's content area is treated.
1013    ///
1014    /// This property is meant to be set by widget implementations,
1015    /// typically in their instance init function.
1016    pub fn overflow(self, overflow: Overflow) -> Self {
1017        Self {
1018            builder: self.builder.property("overflow", overflow),
1019        }
1020    }
1021
1022    /// Whether the widget will receive the default action when it is focused.
1023    pub fn receives_default(self, receives_default: bool) -> Self {
1024        Self {
1025            builder: self.builder.property("receives-default", receives_default),
1026        }
1027    }
1028
1029    /// Whether the widget responds to input.
1030    pub fn sensitive(self, sensitive: bool) -> Self {
1031        Self {
1032            builder: self.builder.property("sensitive", sensitive),
1033        }
1034    }
1035
1036    /// Sets the text of tooltip to be the given string, which is marked up
1037    /// with Pango markup.
1038    ///
1039    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1040    ///
1041    /// This is a convenience property which will take care of getting the
1042    /// tooltip shown if the given string is not `NULL`:
1043    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1044    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1045    /// the default signal handler.
1046    ///
1047    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1048    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1049    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1050        Self {
1051            builder: self
1052                .builder
1053                .property("tooltip-markup", tooltip_markup.into()),
1054        }
1055    }
1056
1057    /// Sets the text of tooltip to be the given string.
1058    ///
1059    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1060    ///
1061    /// This is a convenience property which will take care of getting the
1062    /// tooltip shown if the given string is not `NULL`:
1063    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1064    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1065    /// the default signal handler.
1066    ///
1067    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1068    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1069    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1070        Self {
1071            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1072        }
1073    }
1074
1075    /// How to distribute vertical space if widget gets extra space.
1076    pub fn valign(self, valign: Align) -> Self {
1077        Self {
1078            builder: self.builder.property("valign", valign),
1079        }
1080    }
1081
1082    /// Whether to expand vertically.
1083    pub fn vexpand(self, vexpand: bool) -> Self {
1084        Self {
1085            builder: self.builder.property("vexpand", vexpand),
1086        }
1087    }
1088
1089    /// Whether to use the `vexpand` property.
1090    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1091        Self {
1092            builder: self.builder.property("vexpand-set", vexpand_set),
1093        }
1094    }
1095
1096    /// Whether the widget is visible.
1097    pub fn visible(self, visible: bool) -> Self {
1098        Self {
1099            builder: self.builder.property("visible", visible),
1100        }
1101    }
1102
1103    /// Overrides for width request of the widget.
1104    ///
1105    /// If this is -1, the natural request will be used.
1106    pub fn width_request(self, width_request: i32) -> Self {
1107        Self {
1108            builder: self.builder.property("width-request", width_request),
1109        }
1110    }
1111
1112    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1113    ///
1114    /// The accessible role cannot be changed once set.
1115    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1116        Self {
1117            builder: self.builder.property("accessible-role", accessible_role),
1118        }
1119    }
1120
1121    /// The orientation of the orientable.
1122    pub fn orientation(self, orientation: Orientation) -> Self {
1123        Self {
1124            builder: self.builder.property("orientation", orientation),
1125        }
1126    }
1127
1128    // rustdoc-stripper-ignore-next
1129    /// Build the [`CenterBox`].
1130    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1131    pub fn build(self) -> CenterBox {
1132        assert_initialized_main_thread!();
1133        self.builder.build()
1134    }
1135}