Skip to main content

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
5#[cfg(feature = "v4_10")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
7use crate::Accessible;
8use crate::{
9    AccessibleRole, Align, Buildable, ConstraintTarget, LayoutManager, Overflow, Widget, ffi,
10};
11use glib::{
12    prelude::*,
13    signal::{SignalHandlerId, connect_raw},
14    translate::*,
15};
16use std::boxed::Box as Box_;
17
18#[cfg(feature = "v4_10")]
19#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
20glib::wrapper! {
21    /// Surrounds its child with a decorative frame and an optional label.
22    ///
23    /// <picture>
24    ///   <source srcset="frame-dark.png" media="(prefers-color-scheme: dark)">
25    ///   <img alt="An example GtkFrame" src="frame.png">
26    /// </picture>
27    ///
28    /// If present, the label is drawn inside the top edge of the frame.
29    /// The horizontal position of the label can be controlled with
30    /// [`FrameExt::set_label_align()`][crate::prelude::FrameExt::set_label_align()].
31    ///
32    /// [`Frame`][crate::Frame] clips its child. You can use this to add rounded corners
33    /// to widgets, but be aware that it also cuts off shadows.
34    ///
35    /// # GtkFrame as GtkBuildable
36    ///
37    /// An example of a UI definition fragment with GtkFrame:
38    ///
39    /// ```xml
40    /// <object class="GtkFrame">
41    ///   <property name="label-widget">
42    ///     <object class="GtkLabel" id="frame_label"/>
43    ///   </property>
44    ///   <property name="child">
45    ///     <object class="GtkEntry" id="frame_content"/>
46    ///   </property>
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 | Writable
73    ///
74    ///
75    /// #### `label`
76    ///  Text of the frame's label.
77    ///
78    /// Readable | Writable
79    ///
80    ///
81    /// #### `label-widget`
82    ///  Widget to display in place of the usual frame label.
83    ///
84    /// Readable | Writable
85    ///
86    ///
87    /// #### `label-xalign`
88    ///  The horizontal alignment of the label.
89    ///
90    /// Readable | Writable
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 | Writable
102    ///
103    ///
104    /// #### `can-target`
105    ///  Whether the widget can receive pointer events.
106    ///
107    /// Readable | Writable
108    ///
109    ///
110    /// #### `css-classes`
111    ///  A list of css classes applied to this widget.
112    ///
113    /// Readable | Writable
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 | Writable | Construct Only
123    ///
124    ///
125    /// #### `cursor`
126    ///  The cursor used by @widget.
127    ///
128    /// Readable | Writable
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 | Writable
137    ///
138    ///
139    /// #### `focusable`
140    ///  Whether this widget itself will accept the input focus.
141    ///
142    /// Readable | Writable
143    ///
144    ///
145    /// #### `halign`
146    ///  How to distribute horizontal space if widget gets extra space.
147    ///
148    /// Readable | Writable
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 | Writable
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 | Writable
180    ///
181    ///
182    /// #### `hexpand`
183    ///  Whether to expand horizontally.
184    ///
185    /// Readable | Writable
186    ///
187    ///
188    /// #### `hexpand-set`
189    ///  Whether to use the `hexpand` property.
190    ///
191    /// Readable | Writable
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 | Writable
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 | Writable
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 | Writable
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 | Writable
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 | Writable
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 | Writable
259    ///
260    ///
261    /// #### `name`
262    ///  The name of the widget.
263    ///
264    /// Readable | Writable
265    ///
266    ///
267    /// #### `opacity`
268    ///  The requested opacity of the widget.
269    ///
270    /// Readable | Writable
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 | Writable
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 | Writable
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 | Writable
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 | Writable
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 | Writable
347    ///
348    ///
349    /// #### `valign`
350    ///  How to distribute vertical space if widget gets extra space.
351    ///
352    /// Readable | Writable
353    ///
354    ///
355    /// #### `vexpand`
356    ///  Whether to expand vertically.
357    ///
358    /// Readable | Writable
359    ///
360    ///
361    /// #### `vexpand-set`
362    ///  Whether to use the `vexpand` property.
363    ///
364    /// Readable | Writable
365    ///
366    ///
367    /// #### `visible`
368    ///  Whether the widget is visible.
369    ///
370    /// Readable | Writable
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 | Writable
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 | Writable
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
402#[cfg(not(feature = "v4_10"))]
403glib::wrapper! {
404    #[doc(alias = "GtkFrame")]
405    pub struct Frame(Object<ffi::GtkFrame, ffi::GtkFrameClass>) @extends Widget, @implements Buildable, ConstraintTarget;
406
407    match fn {
408        type_ => || ffi::gtk_frame_get_type(),
409    }
410}
411
412impl Frame {
413    pub const NONE: Option<&'static Frame> = None;
414
415    /// Creates a new [`Frame`][crate::Frame], with optional label @label.
416    ///
417    /// If @label is [`None`], the label is omitted.
418    /// ## `label`
419    /// the text to use as the label of the frame
420    ///
421    /// # Returns
422    ///
423    /// a new [`Frame`][crate::Frame] widget
424    #[doc(alias = "gtk_frame_new")]
425    pub fn new(label: Option<&str>) -> Frame {
426        assert_initialized_main_thread!();
427        unsafe { Widget::from_glib_none(ffi::gtk_frame_new(label.to_glib_none().0)).unsafe_cast() }
428    }
429
430    // rustdoc-stripper-ignore-next
431    /// Creates a new builder-pattern struct instance to construct [`Frame`] objects.
432    ///
433    /// This method returns an instance of [`FrameBuilder`](crate::builders::FrameBuilder) which can be used to create [`Frame`] objects.
434    pub fn builder() -> FrameBuilder {
435        FrameBuilder::new()
436    }
437}
438
439impl Default for Frame {
440    fn default() -> Self {
441        glib::object::Object::new::<Self>()
442    }
443}
444
445// rustdoc-stripper-ignore-next
446/// A [builder-pattern] type to construct [`Frame`] objects.
447///
448/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
449#[must_use = "The builder must be built to be used"]
450pub struct FrameBuilder {
451    builder: glib::object::ObjectBuilder<'static, Frame>,
452}
453
454impl FrameBuilder {
455    fn new() -> Self {
456        Self {
457            builder: glib::object::Object::builder(),
458        }
459    }
460
461    /// The child widget.
462    pub fn child(self, child: &impl IsA<Widget>) -> Self {
463        Self {
464            builder: self.builder.property("child", child.clone().upcast()),
465        }
466    }
467
468    /// Text of the frame's label.
469    pub fn label(self, label: impl Into<glib::GString>) -> Self {
470        Self {
471            builder: self.builder.property("label", label.into()),
472        }
473    }
474
475    /// Widget to display in place of the usual frame label.
476    pub fn label_widget(self, label_widget: &impl IsA<Widget>) -> Self {
477        Self {
478            builder: self
479                .builder
480                .property("label-widget", label_widget.clone().upcast()),
481        }
482    }
483
484    /// The horizontal alignment of the label.
485    pub fn label_xalign(self, label_xalign: f32) -> Self {
486        Self {
487            builder: self.builder.property("label-xalign", label_xalign),
488        }
489    }
490
491    /// Whether the widget or any of its descendents can accept
492    /// the input focus.
493    ///
494    /// This property is meant to be set by widget implementations,
495    /// typically in their instance init function.
496    pub fn can_focus(self, can_focus: bool) -> Self {
497        Self {
498            builder: self.builder.property("can-focus", can_focus),
499        }
500    }
501
502    /// Whether the widget can receive pointer events.
503    pub fn can_target(self, can_target: bool) -> Self {
504        Self {
505            builder: self.builder.property("can-target", can_target),
506        }
507    }
508
509    /// A list of css classes applied to this widget.
510    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
511        Self {
512            builder: self.builder.property("css-classes", css_classes.into()),
513        }
514    }
515
516    /// The name of this widget in the CSS tree.
517    ///
518    /// This property is meant to be set by widget implementations,
519    /// typically in their instance init function.
520    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
521        Self {
522            builder: self.builder.property("css-name", css_name.into()),
523        }
524    }
525
526    /// The cursor used by @widget.
527    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
528        Self {
529            builder: self.builder.property("cursor", cursor.clone()),
530        }
531    }
532
533    /// Whether the widget should grab focus when it is clicked with the mouse.
534    ///
535    /// This property is only relevant for widgets that can take focus.
536    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
537        Self {
538            builder: self.builder.property("focus-on-click", focus_on_click),
539        }
540    }
541
542    /// Whether this widget itself will accept the input focus.
543    pub fn focusable(self, focusable: bool) -> Self {
544        Self {
545            builder: self.builder.property("focusable", focusable),
546        }
547    }
548
549    /// How to distribute horizontal space if widget gets extra space.
550    pub fn halign(self, halign: Align) -> Self {
551        Self {
552            builder: self.builder.property("halign", halign),
553        }
554    }
555
556    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
557    /// signal on @widget.
558    ///
559    /// A true value indicates that @widget can have a tooltip, in this case
560    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
561    /// determine whether it will provide a tooltip or not.
562    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
563        Self {
564            builder: self.builder.property("has-tooltip", has_tooltip),
565        }
566    }
567
568    /// Overrides for height request of the widget.
569    ///
570    /// If this is -1, the natural request will be used.
571    pub fn height_request(self, height_request: i32) -> Self {
572        Self {
573            builder: self.builder.property("height-request", height_request),
574        }
575    }
576
577    /// Whether to expand horizontally.
578    pub fn hexpand(self, hexpand: bool) -> Self {
579        Self {
580            builder: self.builder.property("hexpand", hexpand),
581        }
582    }
583
584    /// Whether to use the `hexpand` property.
585    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
586        Self {
587            builder: self.builder.property("hexpand-set", hexpand_set),
588        }
589    }
590
591    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
592    /// the preferred size of the widget, and allocate its children.
593    ///
594    /// This property is meant to be set by widget implementations,
595    /// typically in their instance init function.
596    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
597        Self {
598            builder: self
599                .builder
600                .property("layout-manager", layout_manager.clone().upcast()),
601        }
602    }
603
604    /// Makes this widget act like a modal dialog, with respect to
605    /// event delivery.
606    ///
607    /// Global event controllers will not handle events with targets
608    /// inside the widget, unless they are set up to ignore propagation
609    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
610    #[cfg(feature = "v4_18")]
611    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
612    pub fn limit_events(self, limit_events: bool) -> Self {
613        Self {
614            builder: self.builder.property("limit-events", limit_events),
615        }
616    }
617
618    /// Margin on bottom side of widget.
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_bottom(self, margin_bottom: i32) -> Self {
624        Self {
625            builder: self.builder.property("margin-bottom", margin_bottom),
626        }
627    }
628
629    /// Margin on end 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_end(self, margin_end: i32) -> Self {
638        Self {
639            builder: self.builder.property("margin-end", margin_end),
640        }
641    }
642
643    /// Margin on start of widget, horizontally.
644    ///
645    /// This property supports left-to-right and right-to-left text
646    /// directions.
647    ///
648    /// This property adds margin outside of the widget's normal size
649    /// request, the margin will be added in addition to the size from
650    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
651    pub fn margin_start(self, margin_start: i32) -> Self {
652        Self {
653            builder: self.builder.property("margin-start", margin_start),
654        }
655    }
656
657    /// Margin on top side of widget.
658    ///
659    /// This property adds margin outside of the widget's normal size
660    /// request, the margin will be added in addition to the size from
661    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
662    pub fn margin_top(self, margin_top: i32) -> Self {
663        Self {
664            builder: self.builder.property("margin-top", margin_top),
665        }
666    }
667
668    /// The name of the widget.
669    pub fn name(self, name: impl Into<glib::GString>) -> Self {
670        Self {
671            builder: self.builder.property("name", name.into()),
672        }
673    }
674
675    /// The requested opacity of the widget.
676    pub fn opacity(self, opacity: f64) -> Self {
677        Self {
678            builder: self.builder.property("opacity", opacity),
679        }
680    }
681
682    /// How content outside the widget's content area is treated.
683    ///
684    /// This property is meant to be set by widget implementations,
685    /// typically in their instance init function.
686    pub fn overflow(self, overflow: Overflow) -> Self {
687        Self {
688            builder: self.builder.property("overflow", overflow),
689        }
690    }
691
692    /// Whether the widget will receive the default action when it is focused.
693    pub fn receives_default(self, receives_default: bool) -> Self {
694        Self {
695            builder: self.builder.property("receives-default", receives_default),
696        }
697    }
698
699    /// Whether the widget responds to input.
700    pub fn sensitive(self, sensitive: bool) -> Self {
701        Self {
702            builder: self.builder.property("sensitive", sensitive),
703        }
704    }
705
706    /// Sets the text of tooltip to be the given string, which is marked up
707    /// with Pango markup.
708    ///
709    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
710    ///
711    /// This is a convenience property which will take care of getting the
712    /// tooltip shown if the given string is not `NULL`:
713    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
714    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
715    /// the default signal handler.
716    ///
717    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
718    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
719    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
720        Self {
721            builder: self
722                .builder
723                .property("tooltip-markup", tooltip_markup.into()),
724        }
725    }
726
727    /// Sets the text of tooltip to be the given string.
728    ///
729    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
730    ///
731    /// This is a convenience property which will take care of getting the
732    /// tooltip shown if the given string is not `NULL`:
733    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
734    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
735    /// the default signal handler.
736    ///
737    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
738    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
739    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
740        Self {
741            builder: self.builder.property("tooltip-text", tooltip_text.into()),
742        }
743    }
744
745    /// How to distribute vertical space if widget gets extra space.
746    pub fn valign(self, valign: Align) -> Self {
747        Self {
748            builder: self.builder.property("valign", valign),
749        }
750    }
751
752    /// Whether to expand vertically.
753    pub fn vexpand(self, vexpand: bool) -> Self {
754        Self {
755            builder: self.builder.property("vexpand", vexpand),
756        }
757    }
758
759    /// Whether to use the `vexpand` property.
760    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
761        Self {
762            builder: self.builder.property("vexpand-set", vexpand_set),
763        }
764    }
765
766    /// Whether the widget is visible.
767    pub fn visible(self, visible: bool) -> Self {
768        Self {
769            builder: self.builder.property("visible", visible),
770        }
771    }
772
773    /// Overrides for width request of the widget.
774    ///
775    /// If this is -1, the natural request will be used.
776    pub fn width_request(self, width_request: i32) -> Self {
777        Self {
778            builder: self.builder.property("width-request", width_request),
779        }
780    }
781
782    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
783    ///
784    /// The accessible role cannot be changed once set.
785    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
786        Self {
787            builder: self.builder.property("accessible-role", accessible_role),
788        }
789    }
790
791    // rustdoc-stripper-ignore-next
792    /// Build the [`Frame`].
793    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
794    pub fn build(self) -> Frame {
795        assert_initialized_main_thread!();
796        self.builder.build()
797    }
798}
799
800/// Trait containing all [`struct@Frame`] methods.
801///
802/// # Implementors
803///
804/// [`Frame`][struct@crate::Frame]
805pub trait FrameExt: IsA<Frame> + 'static {
806    /// Gets the child widget of @self.
807    ///
808    /// # Returns
809    ///
810    /// the child widget of @self
811    #[doc(alias = "gtk_frame_get_child")]
812    #[doc(alias = "get_child")]
813    fn child(&self) -> Option<Widget> {
814        unsafe { from_glib_none(ffi::gtk_frame_get_child(self.as_ref().to_glib_none().0)) }
815    }
816
817    /// Returns the frame labels text.
818    ///
819    /// If the frame's label widget is not a [`Label`][crate::Label], [`None`]
820    /// is returned.
821    ///
822    /// # Returns
823    ///
824    /// the text in the label, or [`None`] if there
825    ///    was no label widget or the label widget was not a [`Label`][crate::Label].
826    ///    This string is owned by GTK and must not be modified or freed.
827    #[doc(alias = "gtk_frame_get_label")]
828    #[doc(alias = "get_label")]
829    fn label(&self) -> Option<glib::GString> {
830        unsafe { from_glib_none(ffi::gtk_frame_get_label(self.as_ref().to_glib_none().0)) }
831    }
832
833    /// Retrieves the X alignment of the frame’s label.
834    ///
835    /// # Returns
836    ///
837    /// the frames X alignment
838    #[doc(alias = "gtk_frame_get_label_align")]
839    #[doc(alias = "get_label_align")]
840    #[doc(alias = "label-xalign")]
841    fn label_align(&self) -> f32 {
842        unsafe { ffi::gtk_frame_get_label_align(self.as_ref().to_glib_none().0) }
843    }
844
845    /// Retrieves the label widget for the frame.
846    ///
847    /// # Returns
848    ///
849    /// the label widget
850    #[doc(alias = "gtk_frame_get_label_widget")]
851    #[doc(alias = "get_label_widget")]
852    #[doc(alias = "label-widget")]
853    fn label_widget(&self) -> Option<Widget> {
854        unsafe {
855            from_glib_none(ffi::gtk_frame_get_label_widget(
856                self.as_ref().to_glib_none().0,
857            ))
858        }
859    }
860
861    /// Sets the child widget of @self.
862    /// ## `child`
863    /// the child widget
864    #[doc(alias = "gtk_frame_set_child")]
865    #[doc(alias = "child")]
866    fn set_child(&self, child: Option<&impl IsA<Widget>>) {
867        unsafe {
868            ffi::gtk_frame_set_child(
869                self.as_ref().to_glib_none().0,
870                child.map(|p| p.as_ref()).to_glib_none().0,
871            );
872        }
873    }
874
875    /// Creates a new [`Label`][crate::Label] with the @label and sets it as the frame's
876    /// label widget.
877    /// ## `label`
878    /// the text to use as the label of the frame
879    #[doc(alias = "gtk_frame_set_label")]
880    #[doc(alias = "label")]
881    fn set_label(&self, label: Option<&str>) {
882        unsafe {
883            ffi::gtk_frame_set_label(self.as_ref().to_glib_none().0, label.to_glib_none().0);
884        }
885    }
886
887    /// Sets the X alignment of the frame widget’s label.
888    ///
889    /// The default value for a newly created frame is 0.0.
890    /// ## `xalign`
891    /// The position of the label along the top edge
892    ///   of the widget. A value of 0.0 represents left alignment;
893    ///   1.0 represents right alignment.
894    #[doc(alias = "gtk_frame_set_label_align")]
895    #[doc(alias = "label-xalign")]
896    fn set_label_align(&self, xalign: f32) {
897        unsafe {
898            ffi::gtk_frame_set_label_align(self.as_ref().to_glib_none().0, xalign);
899        }
900    }
901
902    /// Sets the label widget for the frame.
903    ///
904    /// This is the widget that will appear embedded in the top edge
905    /// of the frame as a title.
906    /// ## `label_widget`
907    /// the new label widget
908    #[doc(alias = "gtk_frame_set_label_widget")]
909    #[doc(alias = "label-widget")]
910    fn set_label_widget(&self, label_widget: Option<&impl IsA<Widget>>) {
911        unsafe {
912            ffi::gtk_frame_set_label_widget(
913                self.as_ref().to_glib_none().0,
914                label_widget.map(|p| p.as_ref()).to_glib_none().0,
915            );
916        }
917    }
918
919    #[doc(alias = "child")]
920    fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
921        unsafe extern "C" fn notify_child_trampoline<P: IsA<Frame>, F: Fn(&P) + 'static>(
922            this: *mut ffi::GtkFrame,
923            _param_spec: glib::ffi::gpointer,
924            f: glib::ffi::gpointer,
925        ) {
926            unsafe {
927                let f: &F = &*(f as *const F);
928                f(Frame::from_glib_borrow(this).unsafe_cast_ref())
929            }
930        }
931        unsafe {
932            let f: Box_<F> = Box_::new(f);
933            connect_raw(
934                self.as_ptr() as *mut _,
935                c"notify::child".as_ptr(),
936                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
937                    notify_child_trampoline::<Self, F> as *const (),
938                )),
939                Box_::into_raw(f),
940            )
941        }
942    }
943
944    #[doc(alias = "label")]
945    fn connect_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
946        unsafe extern "C" fn notify_label_trampoline<P: IsA<Frame>, F: Fn(&P) + 'static>(
947            this: *mut ffi::GtkFrame,
948            _param_spec: glib::ffi::gpointer,
949            f: glib::ffi::gpointer,
950        ) {
951            unsafe {
952                let f: &F = &*(f as *const F);
953                f(Frame::from_glib_borrow(this).unsafe_cast_ref())
954            }
955        }
956        unsafe {
957            let f: Box_<F> = Box_::new(f);
958            connect_raw(
959                self.as_ptr() as *mut _,
960                c"notify::label".as_ptr(),
961                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
962                    notify_label_trampoline::<Self, F> as *const (),
963                )),
964                Box_::into_raw(f),
965            )
966        }
967    }
968
969    #[doc(alias = "label-widget")]
970    fn connect_label_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
971        unsafe extern "C" fn notify_label_widget_trampoline<P: IsA<Frame>, F: Fn(&P) + 'static>(
972            this: *mut ffi::GtkFrame,
973            _param_spec: glib::ffi::gpointer,
974            f: glib::ffi::gpointer,
975        ) {
976            unsafe {
977                let f: &F = &*(f as *const F);
978                f(Frame::from_glib_borrow(this).unsafe_cast_ref())
979            }
980        }
981        unsafe {
982            let f: Box_<F> = Box_::new(f);
983            connect_raw(
984                self.as_ptr() as *mut _,
985                c"notify::label-widget".as_ptr(),
986                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
987                    notify_label_widget_trampoline::<Self, F> as *const (),
988                )),
989                Box_::into_raw(f),
990            )
991        }
992    }
993
994    #[doc(alias = "label-xalign")]
995    fn connect_label_xalign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
996        unsafe extern "C" fn notify_label_xalign_trampoline<P: IsA<Frame>, F: Fn(&P) + 'static>(
997            this: *mut ffi::GtkFrame,
998            _param_spec: glib::ffi::gpointer,
999            f: glib::ffi::gpointer,
1000        ) {
1001            unsafe {
1002                let f: &F = &*(f as *const F);
1003                f(Frame::from_glib_borrow(this).unsafe_cast_ref())
1004            }
1005        }
1006        unsafe {
1007            let f: Box_<F> = Box_::new(f);
1008            connect_raw(
1009                self.as_ptr() as *mut _,
1010                c"notify::label-xalign".as_ptr(),
1011                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1012                    notify_label_xalign_trampoline::<Self, F> as *const (),
1013                )),
1014                Box_::into_raw(f),
1015            )
1016        }
1017    }
1018}
1019
1020impl<O: IsA<Frame>> FrameExt for O {}