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