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