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