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, ffi};
6use glib::{
7 prelude::*,
8 signal::{SignalHandlerId, connect_raw},
9 translate::*,
10};
11use std::boxed::Box as Box_;
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 | Writable
31 ///
32 ///
33 /// #### `ratio`
34 /// Readable | Writable
35 ///
36 ///
37 /// #### `xalign`
38 /// Readable | Writable
39 ///
40 ///
41 /// #### `yalign`
42 /// Readable | Writable
43 /// <details><summary><h4>Frame</h4></summary>
44 ///
45 ///
46 /// #### `label`
47 /// Readable | Writable
48 ///
49 ///
50 /// #### `label-widget`
51 /// Readable | Writable
52 ///
53 ///
54 /// #### `label-xalign`
55 /// Readable | Writable
56 ///
57 ///
58 /// #### `label-yalign`
59 /// Readable | Writable
60 ///
61 ///
62 /// #### `shadow-type`
63 /// Readable | Writable
64 /// </details>
65 /// <details><summary><h4>Container</h4></summary>
66 ///
67 ///
68 /// #### `border-width`
69 /// Readable | Writable
70 ///
71 ///
72 /// #### `child`
73 /// Writable
74 ///
75 ///
76 /// #### `resize-mode`
77 /// Readable | Writable
78 /// </details>
79 /// <details><summary><h4>Widget</h4></summary>
80 ///
81 ///
82 /// #### `app-paintable`
83 /// Readable | Writable
84 ///
85 ///
86 /// #### `can-default`
87 /// Readable | Writable
88 ///
89 ///
90 /// #### `can-focus`
91 /// Readable | Writable
92 ///
93 ///
94 /// #### `composite-child`
95 /// Readable
96 ///
97 ///
98 /// #### `double-buffered`
99 /// Whether the widget is double buffered.
100 ///
101 /// Readable | Writable
102 ///
103 ///
104 /// #### `events`
105 /// Readable | Writable
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 | Writable
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 | Writable
123 ///
124 ///
125 /// #### `halign`
126 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
127 ///
128 /// Readable | Writable
129 ///
130 ///
131 /// #### `has-default`
132 /// Readable | Writable
133 ///
134 ///
135 /// #### `has-focus`
136 /// Readable | Writable
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 | Writable
151 ///
152 ///
153 /// #### `height-request`
154 /// Readable | Writable
155 ///
156 ///
157 /// #### `hexpand`
158 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
159 ///
160 /// Readable | Writable
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 | Writable
167 ///
168 ///
169 /// #### `is-focus`
170 /// Readable | Writable
171 ///
172 ///
173 /// #### `margin`
174 /// Sets all four sides' margin at once. If read, returns max
175 /// margin on any side.
176 ///
177 /// Readable | Writable
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 | Writable
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 | Writable
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 | Writable
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 | Writable
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 | Writable
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 | Writable
240 ///
241 ///
242 /// #### `name`
243 /// Readable | Writable
244 ///
245 ///
246 /// #### `no-show-all`
247 /// Readable | Writable
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 | Writable
257 ///
258 ///
259 /// #### `parent`
260 /// Readable | Writable
261 ///
262 ///
263 /// #### `receives-default`
264 /// Readable | Writable
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 | Writable
276 ///
277 ///
278 /// #### `style`
279 /// The style of the widget, which contains information about how it will look (colors, etc).
280 ///
281 /// Readable | Writable
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 | Writable
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 | Writable
314 ///
315 ///
316 /// #### `valign`
317 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
318 ///
319 /// Readable | Writable
320 ///
321 ///
322 /// #### `vexpand`
323 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
324 ///
325 /// Readable | Writable
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 | Writable
332 ///
333 ///
334 /// #### `visible`
335 /// Readable | Writable
336 ///
337 ///
338 /// #### `width-request`
339 /// Readable | Writable
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 assert_initialized_main_thread!();
779 self.builder.build()
780 }
781}
782
783/// Trait containing all [`struct@AspectFrame`] methods.
784///
785/// # Implementors
786///
787/// [`AspectFrame`][struct@crate::AspectFrame]
788pub trait AspectFrameExt: IsA<AspectFrame> + 'static {
789 /// Set parameters for an existing [`AspectFrame`][crate::AspectFrame].
790 /// ## `xalign`
791 /// Horizontal alignment of the child within the allocation of
792 /// the [`AspectFrame`][crate::AspectFrame]. This ranges from 0.0 (left aligned)
793 /// to 1.0 (right aligned)
794 /// ## `yalign`
795 /// Vertical alignment of the child within the allocation of
796 /// the [`AspectFrame`][crate::AspectFrame]. This ranges from 0.0 (top aligned)
797 /// to 1.0 (bottom aligned)
798 /// ## `ratio`
799 /// The desired aspect ratio.
800 /// ## `obey_child`
801 /// If [`true`], `ratio` is ignored, and the aspect
802 /// ratio is taken from the requistion of the child.
803 #[doc(alias = "gtk_aspect_frame_set")]
804 fn set(&self, xalign: f32, yalign: f32, ratio: f32, obey_child: bool) {
805 unsafe {
806 ffi::gtk_aspect_frame_set(
807 self.as_ref().to_glib_none().0,
808 xalign,
809 yalign,
810 ratio,
811 obey_child.into_glib(),
812 );
813 }
814 }
815
816 #[doc(alias = "obey-child")]
817 fn is_obey_child(&self) -> bool {
818 ObjectExt::property(self.as_ref(), "obey-child")
819 }
820
821 #[doc(alias = "obey-child")]
822 fn set_obey_child(&self, obey_child: bool) {
823 ObjectExt::set_property(self.as_ref(), "obey-child", obey_child)
824 }
825
826 fn ratio(&self) -> f32 {
827 ObjectExt::property(self.as_ref(), "ratio")
828 }
829
830 fn set_ratio(&self, ratio: f32) {
831 ObjectExt::set_property(self.as_ref(), "ratio", ratio)
832 }
833
834 fn xalign(&self) -> f32 {
835 ObjectExt::property(self.as_ref(), "xalign")
836 }
837
838 fn set_xalign(&self, xalign: f32) {
839 ObjectExt::set_property(self.as_ref(), "xalign", xalign)
840 }
841
842 fn yalign(&self) -> f32 {
843 ObjectExt::property(self.as_ref(), "yalign")
844 }
845
846 fn set_yalign(&self, yalign: f32) {
847 ObjectExt::set_property(self.as_ref(), "yalign", yalign)
848 }
849
850 #[doc(alias = "obey-child")]
851 fn connect_obey_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
852 unsafe extern "C" fn notify_obey_child_trampoline<
853 P: IsA<AspectFrame>,
854 F: Fn(&P) + 'static,
855 >(
856 this: *mut ffi::GtkAspectFrame,
857 _param_spec: glib::ffi::gpointer,
858 f: glib::ffi::gpointer,
859 ) {
860 unsafe {
861 let f: &F = &*(f as *const F);
862 f(AspectFrame::from_glib_borrow(this).unsafe_cast_ref())
863 }
864 }
865 unsafe {
866 let f: Box_<F> = Box_::new(f);
867 connect_raw(
868 self.as_ptr() as *mut _,
869 c"notify::obey-child".as_ptr(),
870 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
871 notify_obey_child_trampoline::<Self, F> as *const (),
872 )),
873 Box_::into_raw(f),
874 )
875 }
876 }
877
878 #[doc(alias = "ratio")]
879 fn connect_ratio_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
880 unsafe extern "C" fn notify_ratio_trampoline<P: IsA<AspectFrame>, F: Fn(&P) + 'static>(
881 this: *mut ffi::GtkAspectFrame,
882 _param_spec: glib::ffi::gpointer,
883 f: glib::ffi::gpointer,
884 ) {
885 unsafe {
886 let f: &F = &*(f as *const F);
887 f(AspectFrame::from_glib_borrow(this).unsafe_cast_ref())
888 }
889 }
890 unsafe {
891 let f: Box_<F> = Box_::new(f);
892 connect_raw(
893 self.as_ptr() as *mut _,
894 c"notify::ratio".as_ptr(),
895 Some(std::mem::transmute::<*const (), 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 unsafe {
911 let f: &F = &*(f as *const F);
912 f(AspectFrame::from_glib_borrow(this).unsafe_cast_ref())
913 }
914 }
915 unsafe {
916 let f: Box_<F> = Box_::new(f);
917 connect_raw(
918 self.as_ptr() as *mut _,
919 c"notify::xalign".as_ptr(),
920 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
921 notify_xalign_trampoline::<Self, F> as *const (),
922 )),
923 Box_::into_raw(f),
924 )
925 }
926 }
927
928 #[doc(alias = "yalign")]
929 fn connect_yalign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
930 unsafe extern "C" fn notify_yalign_trampoline<P: IsA<AspectFrame>, F: Fn(&P) + 'static>(
931 this: *mut ffi::GtkAspectFrame,
932 _param_spec: glib::ffi::gpointer,
933 f: glib::ffi::gpointer,
934 ) {
935 unsafe {
936 let f: &F = &*(f as *const F);
937 f(AspectFrame::from_glib_borrow(this).unsafe_cast_ref())
938 }
939 }
940 unsafe {
941 let f: Box_<F> = Box_::new(f);
942 connect_raw(
943 self.as_ptr() as *mut _,
944 c"notify::yalign".as_ptr(),
945 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
946 notify_yalign_trampoline::<Self, F> as *const (),
947 )),
948 Box_::into_raw(f),
949 )
950 }
951 }
952}
953
954impl<O: IsA<AspectFrame>> AspectFrameExt for O {}