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