Skip to main content

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