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