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