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