[go: up one dir, main page]

gtk4/auto/
frame.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{
6    ffi, Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, LayoutManager, Overflow,
7    Widget,
8};
9use glib::{
10    prelude::*,
11    signal::{connect_raw, SignalHandlerId},
12    translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17    #[doc(alias = "GtkFrame")]
18    pub struct Frame(Object<ffi::GtkFrame, ffi::GtkFrameClass>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
19
20    match fn {
21        type_ => || ffi::gtk_frame_get_type(),
22    }
23}
24
25impl Frame {
26    pub const NONE: Option<&'static Frame> = None;
27
28    #[doc(alias = "gtk_frame_new")]
29    pub fn new(label: Option<&str>) -> Frame {
30        assert_initialized_main_thread!();
31        unsafe { Widget::from_glib_none(ffi::gtk_frame_new(label.to_glib_none().0)).unsafe_cast() }
32    }
33
34    // rustdoc-stripper-ignore-next
35    /// Creates a new builder-pattern struct instance to construct [`Frame`] objects.
36    ///
37    /// This method returns an instance of [`FrameBuilder`](crate::builders::FrameBuilder) which can be used to create [`Frame`] objects.
38    pub fn builder() -> FrameBuilder {
39        FrameBuilder::new()
40    }
41}
42
43impl Default for Frame {
44    fn default() -> Self {
45        glib::object::Object::new::<Self>()
46    }
47}
48
49// rustdoc-stripper-ignore-next
50/// A [builder-pattern] type to construct [`Frame`] objects.
51///
52/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
53#[must_use = "The builder must be built to be used"]
54pub struct FrameBuilder {
55    builder: glib::object::ObjectBuilder<'static, Frame>,
56}
57
58impl FrameBuilder {
59    fn new() -> Self {
60        Self {
61            builder: glib::object::Object::builder(),
62        }
63    }
64
65    pub fn child(self, child: &impl IsA<Widget>) -> Self {
66        Self {
67            builder: self.builder.property("child", child.clone().upcast()),
68        }
69    }
70
71    pub fn label(self, label: impl Into<glib::GString>) -> Self {
72        Self {
73            builder: self.builder.property("label", label.into()),
74        }
75    }
76
77    pub fn label_widget(self, label_widget: &impl IsA<Widget>) -> Self {
78        Self {
79            builder: self
80                .builder
81                .property("label-widget", label_widget.clone().upcast()),
82        }
83    }
84
85    pub fn label_xalign(self, label_xalign: f32) -> Self {
86        Self {
87            builder: self.builder.property("label-xalign", label_xalign),
88        }
89    }
90
91    pub fn can_focus(self, can_focus: bool) -> Self {
92        Self {
93            builder: self.builder.property("can-focus", can_focus),
94        }
95    }
96
97    pub fn can_target(self, can_target: bool) -> Self {
98        Self {
99            builder: self.builder.property("can-target", can_target),
100        }
101    }
102
103    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
104        Self {
105            builder: self.builder.property("css-classes", css_classes.into()),
106        }
107    }
108
109    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
110        Self {
111            builder: self.builder.property("css-name", css_name.into()),
112        }
113    }
114
115    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
116        Self {
117            builder: self.builder.property("cursor", cursor.clone()),
118        }
119    }
120
121    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
122        Self {
123            builder: self.builder.property("focus-on-click", focus_on_click),
124        }
125    }
126
127    pub fn focusable(self, focusable: bool) -> Self {
128        Self {
129            builder: self.builder.property("focusable", focusable),
130        }
131    }
132
133    pub fn halign(self, halign: Align) -> Self {
134        Self {
135            builder: self.builder.property("halign", halign),
136        }
137    }
138
139    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
140        Self {
141            builder: self.builder.property("has-tooltip", has_tooltip),
142        }
143    }
144
145    pub fn height_request(self, height_request: i32) -> Self {
146        Self {
147            builder: self.builder.property("height-request", height_request),
148        }
149    }
150
151    pub fn hexpand(self, hexpand: bool) -> Self {
152        Self {
153            builder: self.builder.property("hexpand", hexpand),
154        }
155    }
156
157    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
158        Self {
159            builder: self.builder.property("hexpand-set", hexpand_set),
160        }
161    }
162
163    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
164        Self {
165            builder: self
166                .builder
167                .property("layout-manager", layout_manager.clone().upcast()),
168        }
169    }
170
171    #[cfg(feature = "v4_18")]
172    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
173    pub fn limit_events(self, limit_events: bool) -> Self {
174        Self {
175            builder: self.builder.property("limit-events", limit_events),
176        }
177    }
178
179    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
180        Self {
181            builder: self.builder.property("margin-bottom", margin_bottom),
182        }
183    }
184
185    pub fn margin_end(self, margin_end: i32) -> Self {
186        Self {
187            builder: self.builder.property("margin-end", margin_end),
188        }
189    }
190
191    pub fn margin_start(self, margin_start: i32) -> Self {
192        Self {
193            builder: self.builder.property("margin-start", margin_start),
194        }
195    }
196
197    pub fn margin_top(self, margin_top: i32) -> Self {
198        Self {
199            builder: self.builder.property("margin-top", margin_top),
200        }
201    }
202
203    pub fn name(self, name: impl Into<glib::GString>) -> Self {
204        Self {
205            builder: self.builder.property("name", name.into()),
206        }
207    }
208
209    pub fn opacity(self, opacity: f64) -> Self {
210        Self {
211            builder: self.builder.property("opacity", opacity),
212        }
213    }
214
215    pub fn overflow(self, overflow: Overflow) -> Self {
216        Self {
217            builder: self.builder.property("overflow", overflow),
218        }
219    }
220
221    pub fn receives_default(self, receives_default: bool) -> Self {
222        Self {
223            builder: self.builder.property("receives-default", receives_default),
224        }
225    }
226
227    pub fn sensitive(self, sensitive: bool) -> Self {
228        Self {
229            builder: self.builder.property("sensitive", sensitive),
230        }
231    }
232
233    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
234        Self {
235            builder: self
236                .builder
237                .property("tooltip-markup", tooltip_markup.into()),
238        }
239    }
240
241    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
242        Self {
243            builder: self.builder.property("tooltip-text", tooltip_text.into()),
244        }
245    }
246
247    pub fn valign(self, valign: Align) -> Self {
248        Self {
249            builder: self.builder.property("valign", valign),
250        }
251    }
252
253    pub fn vexpand(self, vexpand: bool) -> Self {
254        Self {
255            builder: self.builder.property("vexpand", vexpand),
256        }
257    }
258
259    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
260        Self {
261            builder: self.builder.property("vexpand-set", vexpand_set),
262        }
263    }
264
265    pub fn visible(self, visible: bool) -> Self {
266        Self {
267            builder: self.builder.property("visible", visible),
268        }
269    }
270
271    pub fn width_request(self, width_request: i32) -> Self {
272        Self {
273            builder: self.builder.property("width-request", width_request),
274        }
275    }
276
277    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
278        Self {
279            builder: self.builder.property("accessible-role", accessible_role),
280        }
281    }
282
283    // rustdoc-stripper-ignore-next
284    /// Build the [`Frame`].
285    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
286    pub fn build(self) -> Frame {
287        assert_initialized_main_thread!();
288        self.builder.build()
289    }
290}
291
292pub trait FrameExt: IsA<Frame> + 'static {
293    #[doc(alias = "gtk_frame_get_child")]
294    #[doc(alias = "get_child")]
295    fn child(&self) -> Option<Widget> {
296        unsafe { from_glib_none(ffi::gtk_frame_get_child(self.as_ref().to_glib_none().0)) }
297    }
298
299    #[doc(alias = "gtk_frame_get_label")]
300    #[doc(alias = "get_label")]
301    fn label(&self) -> Option<glib::GString> {
302        unsafe { from_glib_none(ffi::gtk_frame_get_label(self.as_ref().to_glib_none().0)) }
303    }
304
305    #[doc(alias = "gtk_frame_get_label_align")]
306    #[doc(alias = "get_label_align")]
307    #[doc(alias = "label-xalign")]
308    fn label_align(&self) -> f32 {
309        unsafe { ffi::gtk_frame_get_label_align(self.as_ref().to_glib_none().0) }
310    }
311
312    #[doc(alias = "gtk_frame_get_label_widget")]
313    #[doc(alias = "get_label_widget")]
314    #[doc(alias = "label-widget")]
315    fn label_widget(&self) -> Option<Widget> {
316        unsafe {
317            from_glib_none(ffi::gtk_frame_get_label_widget(
318                self.as_ref().to_glib_none().0,
319            ))
320        }
321    }
322
323    #[doc(alias = "gtk_frame_set_child")]
324    #[doc(alias = "child")]
325    fn set_child(&self, child: Option<&impl IsA<Widget>>) {
326        unsafe {
327            ffi::gtk_frame_set_child(
328                self.as_ref().to_glib_none().0,
329                child.map(|p| p.as_ref()).to_glib_none().0,
330            );
331        }
332    }
333
334    #[doc(alias = "gtk_frame_set_label")]
335    #[doc(alias = "label")]
336    fn set_label(&self, label: Option<&str>) {
337        unsafe {
338            ffi::gtk_frame_set_label(self.as_ref().to_glib_none().0, label.to_glib_none().0);
339        }
340    }
341
342    #[doc(alias = "gtk_frame_set_label_align")]
343    #[doc(alias = "label-xalign")]
344    fn set_label_align(&self, xalign: f32) {
345        unsafe {
346            ffi::gtk_frame_set_label_align(self.as_ref().to_glib_none().0, xalign);
347        }
348    }
349
350    #[doc(alias = "gtk_frame_set_label_widget")]
351    #[doc(alias = "label-widget")]
352    fn set_label_widget(&self, label_widget: Option<&impl IsA<Widget>>) {
353        unsafe {
354            ffi::gtk_frame_set_label_widget(
355                self.as_ref().to_glib_none().0,
356                label_widget.map(|p| p.as_ref()).to_glib_none().0,
357            );
358        }
359    }
360
361    #[doc(alias = "child")]
362    fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
363        unsafe extern "C" fn notify_child_trampoline<P: IsA<Frame>, F: Fn(&P) + 'static>(
364            this: *mut ffi::GtkFrame,
365            _param_spec: glib::ffi::gpointer,
366            f: glib::ffi::gpointer,
367        ) {
368            let f: &F = &*(f as *const F);
369            f(Frame::from_glib_borrow(this).unsafe_cast_ref())
370        }
371        unsafe {
372            let f: Box_<F> = Box_::new(f);
373            connect_raw(
374                self.as_ptr() as *mut _,
375                c"notify::child".as_ptr() as *const _,
376                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
377                    notify_child_trampoline::<Self, F> as *const (),
378                )),
379                Box_::into_raw(f),
380            )
381        }
382    }
383
384    #[doc(alias = "label")]
385    fn connect_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
386        unsafe extern "C" fn notify_label_trampoline<P: IsA<Frame>, F: Fn(&P) + 'static>(
387            this: *mut ffi::GtkFrame,
388            _param_spec: glib::ffi::gpointer,
389            f: glib::ffi::gpointer,
390        ) {
391            let f: &F = &*(f as *const F);
392            f(Frame::from_glib_borrow(this).unsafe_cast_ref())
393        }
394        unsafe {
395            let f: Box_<F> = Box_::new(f);
396            connect_raw(
397                self.as_ptr() as *mut _,
398                c"notify::label".as_ptr() as *const _,
399                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
400                    notify_label_trampoline::<Self, F> as *const (),
401                )),
402                Box_::into_raw(f),
403            )
404        }
405    }
406
407    #[doc(alias = "label-widget")]
408    fn connect_label_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
409        unsafe extern "C" fn notify_label_widget_trampoline<P: IsA<Frame>, F: Fn(&P) + 'static>(
410            this: *mut ffi::GtkFrame,
411            _param_spec: glib::ffi::gpointer,
412            f: glib::ffi::gpointer,
413        ) {
414            let f: &F = &*(f as *const F);
415            f(Frame::from_glib_borrow(this).unsafe_cast_ref())
416        }
417        unsafe {
418            let f: Box_<F> = Box_::new(f);
419            connect_raw(
420                self.as_ptr() as *mut _,
421                c"notify::label-widget".as_ptr() as *const _,
422                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
423                    notify_label_widget_trampoline::<Self, F> as *const (),
424                )),
425                Box_::into_raw(f),
426            )
427        }
428    }
429
430    #[doc(alias = "label-xalign")]
431    fn connect_label_xalign_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
432        unsafe extern "C" fn notify_label_xalign_trampoline<P: IsA<Frame>, F: Fn(&P) + 'static>(
433            this: *mut ffi::GtkFrame,
434            _param_spec: glib::ffi::gpointer,
435            f: glib::ffi::gpointer,
436        ) {
437            let f: &F = &*(f as *const F);
438            f(Frame::from_glib_borrow(this).unsafe_cast_ref())
439        }
440        unsafe {
441            let f: Box_<F> = Box_::new(f);
442            connect_raw(
443                self.as_ptr() as *mut _,
444                c"notify::label-xalign".as_ptr() as *const _,
445                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
446                    notify_label_xalign_trampoline::<Self, F> as *const (),
447                )),
448                Box_::into_raw(f),
449            )
450        }
451    }
452}
453
454impl<O: IsA<Frame>> FrameExt for O {}