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