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 Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, LayoutManager, Overflow,
7 Widget, ffi,
8};
9use glib::{
10 prelude::*,
11 signal::{SignalHandlerId, connect_raw},
12 translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17 /// 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 [enum@Gtk.AccessibleRole.group] role.
29 ///
30 /// Starting from GTK 4.12, [`AspectFrame`][crate::AspectFrame] uses the [enum@Gtk.AccessibleRole.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 unsafe {
546 let f: &F = &*(f as *const F);
547 f(&from_glib_borrow(this))
548 }
549 }
550 unsafe {
551 let f: Box_<F> = Box_::new(f);
552 connect_raw(
553 self.as_ptr() as *mut _,
554 c"notify::child".as_ptr() as *const _,
555 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
556 notify_child_trampoline::<F> as *const (),
557 )),
558 Box_::into_raw(f),
559 )
560 }
561 }
562
563 #[doc(alias = "obey-child")]
564 pub fn connect_obey_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
565 unsafe extern "C" fn notify_obey_child_trampoline<F: Fn(&AspectFrame) + 'static>(
566 this: *mut ffi::GtkAspectFrame,
567 _param_spec: glib::ffi::gpointer,
568 f: glib::ffi::gpointer,
569 ) {
570 unsafe {
571 let f: &F = &*(f as *const F);
572 f(&from_glib_borrow(this))
573 }
574 }
575 unsafe {
576 let f: Box_<F> = Box_::new(f);
577 connect_raw(
578 self.as_ptr() as *mut _,
579 c"notify::obey-child".as_ptr() as *const _,
580 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
581 notify_obey_child_trampoline::<F> as *const (),
582 )),
583 Box_::into_raw(f),
584 )
585 }
586 }
587
588 #[doc(alias = "ratio")]
589 pub fn connect_ratio_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
590 unsafe extern "C" fn notify_ratio_trampoline<F: Fn(&AspectFrame) + 'static>(
591 this: *mut ffi::GtkAspectFrame,
592 _param_spec: glib::ffi::gpointer,
593 f: glib::ffi::gpointer,
594 ) {
595 unsafe {
596 let f: &F = &*(f as *const F);
597 f(&from_glib_borrow(this))
598 }
599 }
600 unsafe {
601 let f: Box_<F> = Box_::new(f);
602 connect_raw(
603 self.as_ptr() as *mut _,
604 c"notify::ratio".as_ptr() as *const _,
605 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
606 notify_ratio_trampoline::<F> as *const (),
607 )),
608 Box_::into_raw(f),
609 )
610 }
611 }
612
613 #[doc(alias = "xalign")]
614 pub fn connect_xalign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
615 unsafe extern "C" fn notify_xalign_trampoline<F: Fn(&AspectFrame) + 'static>(
616 this: *mut ffi::GtkAspectFrame,
617 _param_spec: glib::ffi::gpointer,
618 f: glib::ffi::gpointer,
619 ) {
620 unsafe {
621 let f: &F = &*(f as *const F);
622 f(&from_glib_borrow(this))
623 }
624 }
625 unsafe {
626 let f: Box_<F> = Box_::new(f);
627 connect_raw(
628 self.as_ptr() as *mut _,
629 c"notify::xalign".as_ptr() as *const _,
630 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
631 notify_xalign_trampoline::<F> as *const (),
632 )),
633 Box_::into_raw(f),
634 )
635 }
636 }
637
638 #[doc(alias = "yalign")]
639 pub fn connect_yalign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
640 unsafe extern "C" fn notify_yalign_trampoline<F: Fn(&AspectFrame) + 'static>(
641 this: *mut ffi::GtkAspectFrame,
642 _param_spec: glib::ffi::gpointer,
643 f: glib::ffi::gpointer,
644 ) {
645 unsafe {
646 let f: &F = &*(f as *const F);
647 f(&from_glib_borrow(this))
648 }
649 }
650 unsafe {
651 let f: Box_<F> = Box_::new(f);
652 connect_raw(
653 self.as_ptr() as *mut _,
654 c"notify::yalign".as_ptr() as *const _,
655 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
656 notify_yalign_trampoline::<F> as *const (),
657 )),
658 Box_::into_raw(f),
659 )
660 }
661 }
662}
663
664impl Default for AspectFrame {
665 fn default() -> Self {
666 glib::object::Object::new::<Self>()
667 }
668}
669
670// rustdoc-stripper-ignore-next
671/// A [builder-pattern] type to construct [`AspectFrame`] objects.
672///
673/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
674#[must_use = "The builder must be built to be used"]
675pub struct AspectFrameBuilder {
676 builder: glib::object::ObjectBuilder<'static, AspectFrame>,
677}
678
679impl AspectFrameBuilder {
680 fn new() -> Self {
681 Self {
682 builder: glib::object::Object::builder(),
683 }
684 }
685
686 /// The child widget.
687 pub fn child(self, child: &impl IsA<Widget>) -> Self {
688 Self {
689 builder: self.builder.property("child", child.clone().upcast()),
690 }
691 }
692
693 /// Whether the [`AspectFrame`][crate::AspectFrame] should use the aspect ratio of its child.
694 pub fn obey_child(self, obey_child: bool) -> Self {
695 Self {
696 builder: self.builder.property("obey-child", obey_child),
697 }
698 }
699
700 /// The aspect ratio to be used by the [`AspectFrame`][crate::AspectFrame].
701 ///
702 /// This property is only used if
703 /// [`obey-child`][struct@crate::AspectFrame#obey-child] is set to [`false`].
704 pub fn ratio(self, ratio: f32) -> Self {
705 Self {
706 builder: self.builder.property("ratio", ratio),
707 }
708 }
709
710 /// The horizontal alignment of the child.
711 pub fn xalign(self, xalign: f32) -> Self {
712 Self {
713 builder: self.builder.property("xalign", xalign),
714 }
715 }
716
717 /// The vertical alignment of the child.
718 pub fn yalign(self, yalign: f32) -> Self {
719 Self {
720 builder: self.builder.property("yalign", yalign),
721 }
722 }
723
724 /// Whether the widget or any of its descendents can accept
725 /// the input focus.
726 ///
727 /// This property is meant to be set by widget implementations,
728 /// typically in their instance init function.
729 pub fn can_focus(self, can_focus: bool) -> Self {
730 Self {
731 builder: self.builder.property("can-focus", can_focus),
732 }
733 }
734
735 /// Whether the widget can receive pointer events.
736 pub fn can_target(self, can_target: bool) -> Self {
737 Self {
738 builder: self.builder.property("can-target", can_target),
739 }
740 }
741
742 /// A list of css classes applied to this widget.
743 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
744 Self {
745 builder: self.builder.property("css-classes", css_classes.into()),
746 }
747 }
748
749 /// The name of this widget in the CSS tree.
750 ///
751 /// This property is meant to be set by widget implementations,
752 /// typically in their instance init function.
753 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
754 Self {
755 builder: self.builder.property("css-name", css_name.into()),
756 }
757 }
758
759 /// The cursor used by @widget.
760 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
761 Self {
762 builder: self.builder.property("cursor", cursor.clone()),
763 }
764 }
765
766 /// Whether the widget should grab focus when it is clicked with the mouse.
767 ///
768 /// This property is only relevant for widgets that can take focus.
769 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
770 Self {
771 builder: self.builder.property("focus-on-click", focus_on_click),
772 }
773 }
774
775 /// Whether this widget itself will accept the input focus.
776 pub fn focusable(self, focusable: bool) -> Self {
777 Self {
778 builder: self.builder.property("focusable", focusable),
779 }
780 }
781
782 /// How to distribute horizontal space if widget gets extra space.
783 pub fn halign(self, halign: Align) -> Self {
784 Self {
785 builder: self.builder.property("halign", halign),
786 }
787 }
788
789 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
790 /// signal on @widget.
791 ///
792 /// A true value indicates that @widget can have a tooltip, in this case
793 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
794 /// determine whether it will provide a tooltip or not.
795 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
796 Self {
797 builder: self.builder.property("has-tooltip", has_tooltip),
798 }
799 }
800
801 /// Overrides for height request of the widget.
802 ///
803 /// If this is -1, the natural request will be used.
804 pub fn height_request(self, height_request: i32) -> Self {
805 Self {
806 builder: self.builder.property("height-request", height_request),
807 }
808 }
809
810 /// Whether to expand horizontally.
811 pub fn hexpand(self, hexpand: bool) -> Self {
812 Self {
813 builder: self.builder.property("hexpand", hexpand),
814 }
815 }
816
817 /// Whether to use the `hexpand` property.
818 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
819 Self {
820 builder: self.builder.property("hexpand-set", hexpand_set),
821 }
822 }
823
824 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
825 /// the preferred size of the widget, and allocate its children.
826 ///
827 /// This property is meant to be set by widget implementations,
828 /// typically in their instance init function.
829 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
830 Self {
831 builder: self
832 .builder
833 .property("layout-manager", layout_manager.clone().upcast()),
834 }
835 }
836
837 /// Makes this widget act like a modal dialog, with respect to
838 /// event delivery.
839 ///
840 /// Global event controllers will not handle events with targets
841 /// inside the widget, unless they are set up to ignore propagation
842 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
843 #[cfg(feature = "v4_18")]
844 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
845 pub fn limit_events(self, limit_events: bool) -> Self {
846 Self {
847 builder: self.builder.property("limit-events", limit_events),
848 }
849 }
850
851 /// Margin on bottom side of widget.
852 ///
853 /// This property adds margin outside of the widget's normal size
854 /// request, the margin will be added in addition to the size from
855 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
856 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
857 Self {
858 builder: self.builder.property("margin-bottom", margin_bottom),
859 }
860 }
861
862 /// Margin on end of widget, horizontally.
863 ///
864 /// This property supports left-to-right and right-to-left text
865 /// directions.
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_end(self, margin_end: i32) -> Self {
871 Self {
872 builder: self.builder.property("margin-end", margin_end),
873 }
874 }
875
876 /// Margin on start 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_start(self, margin_start: i32) -> Self {
885 Self {
886 builder: self.builder.property("margin-start", margin_start),
887 }
888 }
889
890 /// Margin on top side of widget.
891 ///
892 /// This property adds margin outside of the widget's normal size
893 /// request, the margin will be added in addition to the size from
894 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
895 pub fn margin_top(self, margin_top: i32) -> Self {
896 Self {
897 builder: self.builder.property("margin-top", margin_top),
898 }
899 }
900
901 /// The name of the widget.
902 pub fn name(self, name: impl Into<glib::GString>) -> Self {
903 Self {
904 builder: self.builder.property("name", name.into()),
905 }
906 }
907
908 /// The requested opacity of the widget.
909 pub fn opacity(self, opacity: f64) -> Self {
910 Self {
911 builder: self.builder.property("opacity", opacity),
912 }
913 }
914
915 /// How content outside the widget's content area is treated.
916 ///
917 /// This property is meant to be set by widget implementations,
918 /// typically in their instance init function.
919 pub fn overflow(self, overflow: Overflow) -> Self {
920 Self {
921 builder: self.builder.property("overflow", overflow),
922 }
923 }
924
925 /// Whether the widget will receive the default action when it is focused.
926 pub fn receives_default(self, receives_default: bool) -> Self {
927 Self {
928 builder: self.builder.property("receives-default", receives_default),
929 }
930 }
931
932 /// Whether the widget responds to input.
933 pub fn sensitive(self, sensitive: bool) -> Self {
934 Self {
935 builder: self.builder.property("sensitive", sensitive),
936 }
937 }
938
939 /// Sets the text of tooltip to be the given string, which is marked up
940 /// with Pango markup.
941 ///
942 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
943 ///
944 /// This is a convenience property which will take care of getting the
945 /// tooltip shown if the given string is not `NULL`:
946 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
947 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
948 /// the default signal handler.
949 ///
950 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
951 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
952 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
953 Self {
954 builder: self
955 .builder
956 .property("tooltip-markup", tooltip_markup.into()),
957 }
958 }
959
960 /// Sets the text of tooltip to be the given string.
961 ///
962 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
963 ///
964 /// This is a convenience property which will take care of getting the
965 /// tooltip shown if the given string is not `NULL`:
966 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
967 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
968 /// the default signal handler.
969 ///
970 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
971 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
972 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
973 Self {
974 builder: self.builder.property("tooltip-text", tooltip_text.into()),
975 }
976 }
977
978 /// How to distribute vertical space if widget gets extra space.
979 pub fn valign(self, valign: Align) -> Self {
980 Self {
981 builder: self.builder.property("valign", valign),
982 }
983 }
984
985 /// Whether to expand vertically.
986 pub fn vexpand(self, vexpand: bool) -> Self {
987 Self {
988 builder: self.builder.property("vexpand", vexpand),
989 }
990 }
991
992 /// Whether to use the `vexpand` property.
993 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
994 Self {
995 builder: self.builder.property("vexpand-set", vexpand_set),
996 }
997 }
998
999 /// Whether the widget is visible.
1000 pub fn visible(self, visible: bool) -> Self {
1001 Self {
1002 builder: self.builder.property("visible", visible),
1003 }
1004 }
1005
1006 /// Overrides for width request of the widget.
1007 ///
1008 /// If this is -1, the natural request will be used.
1009 pub fn width_request(self, width_request: i32) -> Self {
1010 Self {
1011 builder: self.builder.property("width-request", width_request),
1012 }
1013 }
1014
1015 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1016 ///
1017 /// The accessible role cannot be changed once set.
1018 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1019 Self {
1020 builder: self.builder.property("accessible-role", accessible_role),
1021 }
1022 }
1023
1024 // rustdoc-stripper-ignore-next
1025 /// Build the [`AspectFrame`].
1026 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1027 pub fn build(self) -> AspectFrame {
1028 assert_initialized_main_thread!();
1029 self.builder.build()
1030 }
1031}