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