gtk/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::{Align, Bin, Buildable, Container, Frame, ResizeMode, ShadowType, Widget};
6use glib::{
7 prelude::*,
8 signal::{connect_raw, SignalHandlerId},
9 translate::*,
10};
11use std::{boxed::Box as Box_, fmt, mem::transmute};
12
13glib::wrapper! {
14 /// The [`AspectFrame`][crate::AspectFrame] is useful when you want
15 /// pack a widget so that it can resize but always retains
16 /// the same aspect ratio. For instance, one might be
17 /// drawing a small preview of a larger image. [`AspectFrame`][crate::AspectFrame]
18 /// derives from [`Frame`][crate::Frame], so it can draw a label and
19 /// a frame around the child. The frame will be
20 /// “shrink-wrapped” to the size of the child.
21 ///
22 /// # CSS nodes
23 ///
24 /// GtkAspectFrame uses a CSS node with name frame.
25 ///
26 /// ## Properties
27 ///
28 ///
29 /// #### `obey-child`
30 /// Readable | Writeable
31 ///
32 ///
33 /// #### `ratio`
34 /// Readable | Writeable
35 ///
36 ///
37 /// #### `xalign`
38 /// Readable | Writeable
39 ///
40 ///
41 /// #### `yalign`
42 /// Readable | Writeable
43 /// <details><summary><h4>Frame</h4></summary>
44 ///
45 ///
46 /// #### `label`
47 /// Readable | Writeable
48 ///
49 ///
50 /// #### `label-widget`
51 /// Readable | Writeable
52 ///
53 ///
54 /// #### `label-xalign`
55 /// Readable | Writeable
56 ///
57 ///
58 /// #### `label-yalign`
59 /// Readable | Writeable
60 ///
61 ///
62 /// #### `shadow-type`
63 /// Readable | Writeable
64 /// </details>
65 /// <details><summary><h4>Container</h4></summary>
66 ///
67 ///
68 /// #### `border-width`
69 /// Readable | Writeable
70 ///
71 ///
72 /// #### `child`
73 /// Writeable
74 ///
75 ///
76 /// #### `resize-mode`
77 /// Readable | Writeable
78 /// </details>
79 /// <details><summary><h4>Widget</h4></summary>
80 ///
81 ///
82 /// #### `app-paintable`
83 /// Readable | Writeable
84 ///
85 ///
86 /// #### `can-default`
87 /// Readable | Writeable
88 ///
89 ///
90 /// #### `can-focus`
91 /// Readable | Writeable
92 ///
93 ///
94 /// #### `composite-child`
95 /// Readable
96 ///
97 ///
98 /// #### `double-buffered`
99 /// Whether the widget is double buffered.
100 ///
101 /// Readable | Writeable
102 ///
103 ///
104 /// #### `events`
105 /// Readable | Writeable
106 ///
107 ///
108 /// #### `expand`
109 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
110 ///
111 /// Readable | Writeable
112 ///
113 ///
114 /// #### `focus-on-click`
115 /// Whether the widget should grab focus when it is clicked with the mouse.
116 ///
117 /// This property is only relevant for widgets that can take focus.
118 ///
119 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
120 /// GtkComboBox) implemented this property individually.
121 ///
122 /// Readable | Writeable
123 ///
124 ///
125 /// #### `halign`
126 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
127 ///
128 /// Readable | Writeable
129 ///
130 ///
131 /// #### `has-default`
132 /// Readable | Writeable
133 ///
134 ///
135 /// #### `has-focus`
136 /// Readable | Writeable
137 ///
138 ///
139 /// #### `has-tooltip`
140 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
141 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
142 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
143 /// whether it will provide a tooltip or not.
144 ///
145 /// Note that setting this property to [`true`] for the first time will change
146 /// the event masks of the GdkWindows of this widget to include leave-notify
147 /// and motion-notify events. This cannot and will not be undone when the
148 /// property is set to [`false`] again.
149 ///
150 /// Readable | Writeable
151 ///
152 ///
153 /// #### `height-request`
154 /// Readable | Writeable
155 ///
156 ///
157 /// #### `hexpand`
158 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
159 ///
160 /// Readable | Writeable
161 ///
162 ///
163 /// #### `hexpand-set`
164 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
165 ///
166 /// Readable | Writeable
167 ///
168 ///
169 /// #### `is-focus`
170 /// Readable | Writeable
171 ///
172 ///
173 /// #### `margin`
174 /// Sets all four sides' margin at once. If read, returns max
175 /// margin on any side.
176 ///
177 /// Readable | Writeable
178 ///
179 ///
180 /// #### `margin-bottom`
181 /// Margin on bottom side of widget.
182 ///
183 /// This property adds margin outside of the widget's normal size
184 /// request, the margin will be added in addition to the size from
185 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
186 ///
187 /// Readable | Writeable
188 ///
189 ///
190 /// #### `margin-end`
191 /// Margin on end of widget, horizontally. This property supports
192 /// left-to-right and right-to-left text directions.
193 ///
194 /// This property adds margin outside of the widget's normal size
195 /// request, the margin will be added in addition to the size from
196 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
197 ///
198 /// Readable | Writeable
199 ///
200 ///
201 /// #### `margin-left`
202 /// Margin on left side of widget.
203 ///
204 /// This property adds margin outside of the widget's normal size
205 /// request, the margin will be added in addition to the size from
206 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
207 ///
208 /// Readable | Writeable
209 ///
210 ///
211 /// #### `margin-right`
212 /// Margin on right side of widget.
213 ///
214 /// This property adds margin outside of the widget's normal size
215 /// request, the margin will be added in addition to the size from
216 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
217 ///
218 /// Readable | Writeable
219 ///
220 ///
221 /// #### `margin-start`
222 /// Margin on start of widget, horizontally. This property supports
223 /// left-to-right and right-to-left text directions.
224 ///
225 /// This property adds margin outside of the widget's normal size
226 /// request, the margin will be added in addition to the size from
227 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
228 ///
229 /// Readable | Writeable
230 ///
231 ///
232 /// #### `margin-top`
233 /// Margin on top side of widget.
234 ///
235 /// This property adds margin outside of the widget's normal size
236 /// request, the margin will be added in addition to the size from
237 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
238 ///
239 /// Readable | Writeable
240 ///
241 ///
242 /// #### `name`
243 /// Readable | Writeable
244 ///
245 ///
246 /// #### `no-show-all`
247 /// Readable | Writeable
248 ///
249 ///
250 /// #### `opacity`
251 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
252 /// more details about window opacity.
253 ///
254 /// Before 3.8 this was only available in GtkWindow
255 ///
256 /// Readable | Writeable
257 ///
258 ///
259 /// #### `parent`
260 /// Readable | Writeable
261 ///
262 ///
263 /// #### `receives-default`
264 /// Readable | Writeable
265 ///
266 ///
267 /// #### `scale-factor`
268 /// The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
269 /// more details about widget scaling.
270 ///
271 /// Readable
272 ///
273 ///
274 /// #### `sensitive`
275 /// Readable | Writeable
276 ///
277 ///
278 /// #### `style`
279 /// The style of the widget, which contains information about how it will look (colors, etc).
280 ///
281 /// Readable | Writeable
282 ///
283 ///
284 /// #### `tooltip-markup`
285 /// Sets the text of tooltip to be the given string, which is marked up
286 /// with the [Pango text markup language][PangoMarkupFormat].
287 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
288 ///
289 /// This is a convenience property which will take care of getting the
290 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
291 /// will automatically be set to [`true`] and there will be taken care of
292 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
293 ///
294 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
295 /// are set, the last one wins.
296 ///
297 /// Readable | Writeable
298 ///
299 ///
300 /// #### `tooltip-text`
301 /// Sets the text of tooltip to be the given string.
302 ///
303 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
304 ///
305 /// This is a convenience property which will take care of getting the
306 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
307 /// will automatically be set to [`true`] and there will be taken care of
308 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
309 ///
310 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
311 /// are set, the last one wins.
312 ///
313 /// Readable | Writeable
314 ///
315 ///
316 /// #### `valign`
317 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
318 ///
319 /// Readable | Writeable
320 ///
321 ///
322 /// #### `vexpand`
323 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
324 ///
325 /// Readable | Writeable
326 ///
327 ///
328 /// #### `vexpand-set`
329 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
330 ///
331 /// Readable | Writeable
332 ///
333 ///
334 /// #### `visible`
335 /// Readable | Writeable
336 ///
337 ///
338 /// #### `width-request`
339 /// Readable | Writeable
340 ///
341 ///
342 /// #### `window`
343 /// The widget's window if it is realized, [`None`] otherwise.
344 ///
345 /// Readable
346 /// </details>
347 ///
348 /// # Implements
349 ///
350 /// [`AspectFrameExt`][trait@crate::prelude::AspectFrameExt], [`FrameExt`][trait@crate::prelude::FrameExt], [`BinExt`][trait@crate::prelude::BinExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
351 #[doc(alias = "GtkAspectFrame")]
352 pub struct AspectFrame(Object<ffi::GtkAspectFrame, ffi::GtkAspectFrameClass>) @extends Frame, Bin, Container, Widget, @implements Buildable;
353
354 match fn {
355 type_ => || ffi::gtk_aspect_frame_get_type(),
356 }
357}
358
359impl AspectFrame {
360 pub const NONE: Option<&'static AspectFrame> = None;
361
362 /// Create a new [`AspectFrame`][crate::AspectFrame].
363 /// ## `label`
364 /// Label text.
365 /// ## `xalign`
366 /// Horizontal alignment of the child within the allocation of
367 /// the [`AspectFrame`][crate::AspectFrame]. This ranges from 0.0 (left aligned)
368 /// to 1.0 (right aligned)
369 /// ## `yalign`
370 /// Vertical alignment of the child within the allocation of
371 /// the [`AspectFrame`][crate::AspectFrame]. This ranges from 0.0 (top aligned)
372 /// to 1.0 (bottom aligned)
373 /// ## `ratio`
374 /// The desired aspect ratio.
375 /// ## `obey_child`
376 /// If [`true`], `ratio` is ignored, and the aspect
377 /// ratio is taken from the requistion of the child.
378 ///
379 /// # Returns
380 ///
381 /// the new [`AspectFrame`][crate::AspectFrame].
382 #[doc(alias = "gtk_aspect_frame_new")]
383 pub fn new(
384 label: Option<&str>,
385 xalign: f32,
386 yalign: f32,
387 ratio: f32,
388 obey_child: bool,
389 ) -> AspectFrame {
390 assert_initialized_main_thread!();
391 unsafe {
392 Widget::from_glib_none(ffi::gtk_aspect_frame_new(
393 label.to_glib_none().0,
394 xalign,
395 yalign,
396 ratio,
397 obey_child.into_glib(),
398 ))
399 .unsafe_cast()
400 }
401 }
402
403 // rustdoc-stripper-ignore-next
404 /// Creates a new builder-pattern struct instance to construct [`AspectFrame`] objects.
405 ///
406 /// This method returns an instance of [`AspectFrameBuilder`](crate::builders::AspectFrameBuilder) which can be used to create [`AspectFrame`] objects.
407 pub fn builder() -> AspectFrameBuilder {
408 AspectFrameBuilder::new()
409 }
410}
411
412impl Default for AspectFrame {
413 fn default() -> Self {
414 glib::object::Object::new::<Self>()
415 }
416}
417
418// rustdoc-stripper-ignore-next
419/// A [builder-pattern] type to construct [`AspectFrame`] objects.
420///
421/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
422#[must_use = "The builder must be built to be used"]
423pub struct AspectFrameBuilder {
424 builder: glib::object::ObjectBuilder<'static, AspectFrame>,
425}
426
427impl AspectFrameBuilder {
428 fn new() -> Self {
429 Self {
430 builder: glib::object::Object::builder(),
431 }
432 }
433
434 pub fn obey_child(self, obey_child: bool) -> Self {
435 Self {
436 builder: self.builder.property("obey-child", obey_child),
437 }
438 }
439
440 pub fn ratio(self, ratio: f32) -> Self {
441 Self {
442 builder: self.builder.property("ratio", ratio),
443 }
444 }
445
446 pub fn xalign(self, xalign: f32) -> Self {
447 Self {
448 builder: self.builder.property("xalign", xalign),
449 }
450 }
451
452 pub fn yalign(self, yalign: f32) -> Self {
453 Self {
454 builder: self.builder.property("yalign", yalign),
455 }
456 }
457
458 pub fn label(self, label: impl Into<glib::GString>) -> Self {
459 Self {
460 builder: self.builder.property("label", label.into()),
461 }
462 }
463
464 pub fn label_widget(self, label_widget: &impl IsA<Widget>) -> Self {
465 Self {
466 builder: self
467 .builder
468 .property("label-widget", label_widget.clone().upcast()),
469 }
470 }
471
472 pub fn label_xalign(self, label_xalign: f32) -> Self {
473 Self {
474 builder: self.builder.property("label-xalign", label_xalign),
475 }
476 }
477
478 pub fn label_yalign(self, label_yalign: f32) -> Self {
479 Self {
480 builder: self.builder.property("label-yalign", label_yalign),
481 }
482 }
483
484 pub fn shadow_type(self, shadow_type: ShadowType) -> Self {
485 Self {
486 builder: self.builder.property("shadow-type", shadow_type),
487 }
488 }
489
490 pub fn border_width(self, border_width: u32) -> Self {
491 Self {
492 builder: self.builder.property("border-width", border_width),
493 }
494 }
495
496 pub fn child(self, child: &impl IsA<Widget>) -> Self {
497 Self {
498 builder: self.builder.property("child", child.clone().upcast()),
499 }
500 }
501
502 pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
503 Self {
504 builder: self.builder.property("resize-mode", resize_mode),
505 }
506 }
507
508 pub fn app_paintable(self, app_paintable: bool) -> Self {
509 Self {
510 builder: self.builder.property("app-paintable", app_paintable),
511 }
512 }
513
514 pub fn can_default(self, can_default: bool) -> Self {
515 Self {
516 builder: self.builder.property("can-default", can_default),
517 }
518 }
519
520 pub fn can_focus(self, can_focus: bool) -> Self {
521 Self {
522 builder: self.builder.property("can-focus", can_focus),
523 }
524 }
525
526 pub fn events(self, events: gdk::EventMask) -> Self {
527 Self {
528 builder: self.builder.property("events", events),
529 }
530 }
531
532 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
533 pub fn expand(self, expand: bool) -> Self {
534 Self {
535 builder: self.builder.property("expand", expand),
536 }
537 }
538
539 /// Whether the widget should grab focus when it is clicked with the mouse.
540 ///
541 /// This property is only relevant for widgets that can take focus.
542 ///
543 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
544 /// GtkComboBox) implemented this property individually.
545 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
546 Self {
547 builder: self.builder.property("focus-on-click", focus_on_click),
548 }
549 }
550
551 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
552 pub fn halign(self, halign: Align) -> Self {
553 Self {
554 builder: self.builder.property("halign", halign),
555 }
556 }
557
558 pub fn has_default(self, has_default: bool) -> Self {
559 Self {
560 builder: self.builder.property("has-default", has_default),
561 }
562 }
563
564 pub fn has_focus(self, has_focus: bool) -> Self {
565 Self {
566 builder: self.builder.property("has-focus", has_focus),
567 }
568 }
569
570 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
571 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
572 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
573 /// whether it will provide a tooltip or not.
574 ///
575 /// Note that setting this property to [`true`] for the first time will change
576 /// the event masks of the GdkWindows of this widget to include leave-notify
577 /// and motion-notify events. This cannot and will not be undone when the
578 /// property is set to [`false`] again.
579 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
580 Self {
581 builder: self.builder.property("has-tooltip", has_tooltip),
582 }
583 }
584
585 pub fn height_request(self, height_request: i32) -> Self {
586 Self {
587 builder: self.builder.property("height-request", height_request),
588 }
589 }
590
591 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
592 pub fn hexpand(self, hexpand: bool) -> Self {
593 Self {
594 builder: self.builder.property("hexpand", hexpand),
595 }
596 }
597
598 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
599 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
600 Self {
601 builder: self.builder.property("hexpand-set", hexpand_set),
602 }
603 }
604
605 pub fn is_focus(self, is_focus: bool) -> Self {
606 Self {
607 builder: self.builder.property("is-focus", is_focus),
608 }
609 }
610
611 /// Sets all four sides' margin at once. If read, returns max
612 /// margin on any side.
613 pub fn margin(self, margin: i32) -> Self {
614 Self {
615 builder: self.builder.property("margin", margin),
616 }
617 }
618
619 /// Margin on bottom side of widget.
620 ///
621 /// This property adds margin outside of the widget's normal size
622 /// request, the margin will be added in addition to the size from
623 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
624 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
625 Self {
626 builder: self.builder.property("margin-bottom", margin_bottom),
627 }
628 }
629
630 /// Margin on end of widget, horizontally. This property supports
631 /// left-to-right and right-to-left text directions.
632 ///
633 /// This property adds margin outside of the widget's normal size
634 /// request, the margin will be added in addition to the size from
635 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
636 pub fn margin_end(self, margin_end: i32) -> Self {
637 Self {
638 builder: self.builder.property("margin-end", margin_end),
639 }
640 }
641
642 /// Margin on start of widget, horizontally. This property supports
643 /// left-to-right and right-to-left text directions.
644 ///
645 /// This property adds margin outside of the widget's normal size
646 /// request, the margin will be added in addition to the size from
647 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
648 pub fn margin_start(self, margin_start: i32) -> Self {
649 Self {
650 builder: self.builder.property("margin-start", margin_start),
651 }
652 }
653
654 /// Margin on top side of widget.
655 ///
656 /// This property adds margin outside of the widget's normal size
657 /// request, the margin will be added in addition to the size from
658 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
659 pub fn margin_top(self, margin_top: i32) -> Self {
660 Self {
661 builder: self.builder.property("margin-top", margin_top),
662 }
663 }
664
665 pub fn name(self, name: impl Into<glib::GString>) -> Self {
666 Self {
667 builder: self.builder.property("name", name.into()),
668 }
669 }
670
671 pub fn no_show_all(self, no_show_all: bool) -> Self {
672 Self {
673 builder: self.builder.property("no-show-all", no_show_all),
674 }
675 }
676
677 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
678 /// more details about window opacity.
679 ///
680 /// Before 3.8 this was only available in GtkWindow
681 pub fn opacity(self, opacity: f64) -> Self {
682 Self {
683 builder: self.builder.property("opacity", opacity),
684 }
685 }
686
687 pub fn parent(self, parent: &impl IsA<Container>) -> Self {
688 Self {
689 builder: self.builder.property("parent", parent.clone().upcast()),
690 }
691 }
692
693 pub fn receives_default(self, receives_default: bool) -> Self {
694 Self {
695 builder: self.builder.property("receives-default", receives_default),
696 }
697 }
698
699 pub fn sensitive(self, sensitive: bool) -> Self {
700 Self {
701 builder: self.builder.property("sensitive", sensitive),
702 }
703 }
704
705 /// Sets the text of tooltip to be the given string, which is marked up
706 /// with the [Pango text markup language][PangoMarkupFormat].
707 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
708 ///
709 /// This is a convenience property which will take care of getting the
710 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
711 /// will automatically be set to [`true`] and there will be taken care of
712 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
713 ///
714 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
715 /// are set, the last one wins.
716 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
717 Self {
718 builder: self
719 .builder
720 .property("tooltip-markup", tooltip_markup.into()),
721 }
722 }
723
724 /// Sets the text of tooltip to be the given string.
725 ///
726 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
727 ///
728 /// This is a convenience property which will take care of getting the
729 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
730 /// will automatically be set to [`true`] and there will be taken care of
731 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
732 ///
733 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
734 /// are set, the last one wins.
735 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
736 Self {
737 builder: self.builder.property("tooltip-text", tooltip_text.into()),
738 }
739 }
740
741 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
742 pub fn valign(self, valign: Align) -> Self {
743 Self {
744 builder: self.builder.property("valign", valign),
745 }
746 }
747
748 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
749 pub fn vexpand(self, vexpand: bool) -> Self {
750 Self {
751 builder: self.builder.property("vexpand", vexpand),
752 }
753 }
754
755 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
756 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
757 Self {
758 builder: self.builder.property("vexpand-set", vexpand_set),
759 }
760 }
761
762 pub fn visible(self, visible: bool) -> Self {
763 Self {
764 builder: self.builder.property("visible", visible),
765 }
766 }
767
768 pub fn width_request(self, width_request: i32) -> Self {
769 Self {
770 builder: self.builder.property("width-request", width_request),
771 }
772 }
773
774 // rustdoc-stripper-ignore-next
775 /// Build the [`AspectFrame`].
776 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
777 pub fn build(self) -> AspectFrame {
778 self.builder.build()
779 }
780}
781
782mod sealed {
783 pub trait Sealed {}
784 impl<T: super::IsA<super::AspectFrame>> Sealed for T {}
785}
786
787/// Trait containing all [`struct@AspectFrame`] methods.
788///
789/// # Implementors
790///
791/// [`AspectFrame`][struct@crate::AspectFrame]
792pub trait AspectFrameExt: IsA<AspectFrame> + sealed::Sealed + 'static {
793 /// Set parameters for an existing [`AspectFrame`][crate::AspectFrame].
794 /// ## `xalign`
795 /// Horizontal alignment of the child within the allocation of
796 /// the [`AspectFrame`][crate::AspectFrame]. This ranges from 0.0 (left aligned)
797 /// to 1.0 (right aligned)
798 /// ## `yalign`
799 /// Vertical alignment of the child within the allocation of
800 /// the [`AspectFrame`][crate::AspectFrame]. This ranges from 0.0 (top aligned)
801 /// to 1.0 (bottom aligned)
802 /// ## `ratio`
803 /// The desired aspect ratio.
804 /// ## `obey_child`
805 /// If [`true`], `ratio` is ignored, and the aspect
806 /// ratio is taken from the requistion of the child.
807 #[doc(alias = "gtk_aspect_frame_set")]
808 fn set(&self, xalign: f32, yalign: f32, ratio: f32, obey_child: bool) {
809 unsafe {
810 ffi::gtk_aspect_frame_set(
811 self.as_ref().to_glib_none().0,
812 xalign,
813 yalign,
814 ratio,
815 obey_child.into_glib(),
816 );
817 }
818 }
819
820 #[doc(alias = "obey-child")]
821 fn is_obey_child(&self) -> bool {
822 ObjectExt::property(self.as_ref(), "obey-child")
823 }
824
825 #[doc(alias = "obey-child")]
826 fn set_obey_child(&self, obey_child: bool) {
827 ObjectExt::set_property(self.as_ref(), "obey-child", obey_child)
828 }
829
830 fn ratio(&self) -> f32 {
831 ObjectExt::property(self.as_ref(), "ratio")
832 }
833
834 fn set_ratio(&self, ratio: f32) {
835 ObjectExt::set_property(self.as_ref(), "ratio", ratio)
836 }
837
838 fn xalign(&self) -> f32 {
839 ObjectExt::property(self.as_ref(), "xalign")
840 }
841
842 fn set_xalign(&self, xalign: f32) {
843 ObjectExt::set_property(self.as_ref(), "xalign", xalign)
844 }
845
846 fn yalign(&self) -> f32 {
847 ObjectExt::property(self.as_ref(), "yalign")
848 }
849
850 fn set_yalign(&self, yalign: f32) {
851 ObjectExt::set_property(self.as_ref(), "yalign", yalign)
852 }
853
854 #[doc(alias = "obey-child")]
855 fn connect_obey_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
856 unsafe extern "C" fn notify_obey_child_trampoline<
857 P: IsA<AspectFrame>,
858 F: Fn(&P) + 'static,
859 >(
860 this: *mut ffi::GtkAspectFrame,
861 _param_spec: glib::ffi::gpointer,
862 f: glib::ffi::gpointer,
863 ) {
864 let f: &F = &*(f as *const F);
865 f(AspectFrame::from_glib_borrow(this).unsafe_cast_ref())
866 }
867 unsafe {
868 let f: Box_<F> = Box_::new(f);
869 connect_raw(
870 self.as_ptr() as *mut _,
871 b"notify::obey-child\0".as_ptr() as *const _,
872 Some(transmute::<_, unsafe extern "C" fn()>(
873 notify_obey_child_trampoline::<Self, F> as *const (),
874 )),
875 Box_::into_raw(f),
876 )
877 }
878 }
879
880 #[doc(alias = "ratio")]
881 fn connect_ratio_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
882 unsafe extern "C" fn notify_ratio_trampoline<P: IsA<AspectFrame>, F: Fn(&P) + 'static>(
883 this: *mut ffi::GtkAspectFrame,
884 _param_spec: glib::ffi::gpointer,
885 f: glib::ffi::gpointer,
886 ) {
887 let f: &F = &*(f as *const F);
888 f(AspectFrame::from_glib_borrow(this).unsafe_cast_ref())
889 }
890 unsafe {
891 let f: Box_<F> = Box_::new(f);
892 connect_raw(
893 self.as_ptr() as *mut _,
894 b"notify::ratio\0".as_ptr() as *const _,
895 Some(transmute::<_, unsafe extern "C" fn()>(
896 notify_ratio_trampoline::<Self, F> as *const (),
897 )),
898 Box_::into_raw(f),
899 )
900 }
901 }
902
903 #[doc(alias = "xalign")]
904 fn connect_xalign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
905 unsafe extern "C" fn notify_xalign_trampoline<P: IsA<AspectFrame>, F: Fn(&P) + 'static>(
906 this: *mut ffi::GtkAspectFrame,
907 _param_spec: glib::ffi::gpointer,
908 f: glib::ffi::gpointer,
909 ) {
910 let f: &F = &*(f as *const F);
911 f(AspectFrame::from_glib_borrow(this).unsafe_cast_ref())
912 }
913 unsafe {
914 let f: Box_<F> = Box_::new(f);
915 connect_raw(
916 self.as_ptr() as *mut _,
917 b"notify::xalign\0".as_ptr() as *const _,
918 Some(transmute::<_, unsafe extern "C" fn()>(
919 notify_xalign_trampoline::<Self, F> as *const (),
920 )),
921 Box_::into_raw(f),
922 )
923 }
924 }
925
926 #[doc(alias = "yalign")]
927 fn connect_yalign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
928 unsafe extern "C" fn notify_yalign_trampoline<P: IsA<AspectFrame>, F: Fn(&P) + 'static>(
929 this: *mut ffi::GtkAspectFrame,
930 _param_spec: glib::ffi::gpointer,
931 f: glib::ffi::gpointer,
932 ) {
933 let f: &F = &*(f as *const F);
934 f(AspectFrame::from_glib_borrow(this).unsafe_cast_ref())
935 }
936 unsafe {
937 let f: Box_<F> = Box_::new(f);
938 connect_raw(
939 self.as_ptr() as *mut _,
940 b"notify::yalign\0".as_ptr() as *const _,
941 Some(transmute::<_, unsafe extern "C" fn()>(
942 notify_yalign_trampoline::<Self, F> as *const (),
943 )),
944 Box_::into_raw(f),
945 )
946 }
947 }
948}
949
950impl<O: IsA<AspectFrame>> AspectFrameExt for O {}
951
952impl fmt::Display for AspectFrame {
953 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
954 f.write_str("AspectFrame")
955 }
956}