Skip to main content

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