libpanel/auto/
frame.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files.git)
4// DO NOT EDIT
5
6use crate::{ffi, FrameHeader, Position, Widget};
7#[cfg(feature = "v1_2")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
9use glib::object::ObjectType as _;
10use glib::{
11    prelude::*,
12    signal::{connect_raw, SignalHandlerId},
13    translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18    #[doc(alias = "PanelFrame")]
19    pub struct Frame(Object<ffi::PanelFrame, ffi::PanelFrameClass>) @extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
20
21    match fn {
22        type_ => || ffi::panel_frame_get_type(),
23    }
24}
25
26impl Frame {
27    pub const NONE: Option<&'static Frame> = None;
28
29    #[doc(alias = "panel_frame_new")]
30    pub fn new() -> Frame {
31        assert_initialized_main_thread!();
32        unsafe { gtk::Widget::from_glib_none(ffi::panel_frame_new()).unsafe_cast() }
33    }
34
35    // rustdoc-stripper-ignore-next
36    /// Creates a new builder-pattern struct instance to construct [`Frame`] objects.
37    ///
38    /// This method returns an instance of [`FrameBuilder`](crate::builders::FrameBuilder) which can be used to create [`Frame`] objects.
39    pub fn builder() -> FrameBuilder {
40        FrameBuilder::new()
41    }
42}
43
44impl Default for Frame {
45    fn default() -> Self {
46        Self::new()
47    }
48}
49
50// rustdoc-stripper-ignore-next
51/// A [builder-pattern] type to construct [`Frame`] objects.
52///
53/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
54#[must_use = "The builder must be built to be used"]
55pub struct FrameBuilder {
56    builder: glib::object::ObjectBuilder<'static, Frame>,
57}
58
59impl FrameBuilder {
60    fn new() -> Self {
61        Self {
62            builder: glib::object::Object::builder(),
63        }
64    }
65
66    pub fn placeholder(self, placeholder: &impl IsA<gtk::Widget>) -> Self {
67        Self {
68            builder: self
69                .builder
70                .property("placeholder", placeholder.clone().upcast()),
71        }
72    }
73
74    pub fn visible_child(self, visible_child: &impl IsA<Widget>) -> Self {
75        Self {
76            builder: self
77                .builder
78                .property("visible-child", visible_child.clone().upcast()),
79        }
80    }
81
82    pub fn can_focus(self, can_focus: bool) -> Self {
83        Self {
84            builder: self.builder.property("can-focus", can_focus),
85        }
86    }
87
88    pub fn can_target(self, can_target: bool) -> Self {
89        Self {
90            builder: self.builder.property("can-target", can_target),
91        }
92    }
93
94    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
95        Self {
96            builder: self.builder.property("css-classes", css_classes.into()),
97        }
98    }
99
100    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
101        Self {
102            builder: self.builder.property("css-name", css_name.into()),
103        }
104    }
105
106    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
107        Self {
108            builder: self.builder.property("cursor", cursor.clone()),
109        }
110    }
111
112    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
113        Self {
114            builder: self.builder.property("focus-on-click", focus_on_click),
115        }
116    }
117
118    pub fn focusable(self, focusable: bool) -> Self {
119        Self {
120            builder: self.builder.property("focusable", focusable),
121        }
122    }
123
124    pub fn halign(self, halign: gtk::Align) -> Self {
125        Self {
126            builder: self.builder.property("halign", halign),
127        }
128    }
129
130    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
131        Self {
132            builder: self.builder.property("has-tooltip", has_tooltip),
133        }
134    }
135
136    pub fn height_request(self, height_request: i32) -> Self {
137        Self {
138            builder: self.builder.property("height-request", height_request),
139        }
140    }
141
142    pub fn hexpand(self, hexpand: bool) -> Self {
143        Self {
144            builder: self.builder.property("hexpand", hexpand),
145        }
146    }
147
148    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
149        Self {
150            builder: self.builder.property("hexpand-set", hexpand_set),
151        }
152    }
153
154    pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
155        Self {
156            builder: self
157                .builder
158                .property("layout-manager", layout_manager.clone().upcast()),
159        }
160    }
161
162    #[cfg(feature = "gtk_v4_18")]
163    #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
164    pub fn limit_events(self, limit_events: bool) -> Self {
165        Self {
166            builder: self.builder.property("limit-events", limit_events),
167        }
168    }
169
170    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
171        Self {
172            builder: self.builder.property("margin-bottom", margin_bottom),
173        }
174    }
175
176    pub fn margin_end(self, margin_end: i32) -> Self {
177        Self {
178            builder: self.builder.property("margin-end", margin_end),
179        }
180    }
181
182    pub fn margin_start(self, margin_start: i32) -> Self {
183        Self {
184            builder: self.builder.property("margin-start", margin_start),
185        }
186    }
187
188    pub fn margin_top(self, margin_top: i32) -> Self {
189        Self {
190            builder: self.builder.property("margin-top", margin_top),
191        }
192    }
193
194    pub fn name(self, name: impl Into<glib::GString>) -> Self {
195        Self {
196            builder: self.builder.property("name", name.into()),
197        }
198    }
199
200    pub fn opacity(self, opacity: f64) -> Self {
201        Self {
202            builder: self.builder.property("opacity", opacity),
203        }
204    }
205
206    pub fn overflow(self, overflow: gtk::Overflow) -> Self {
207        Self {
208            builder: self.builder.property("overflow", overflow),
209        }
210    }
211
212    pub fn receives_default(self, receives_default: bool) -> Self {
213        Self {
214            builder: self.builder.property("receives-default", receives_default),
215        }
216    }
217
218    pub fn sensitive(self, sensitive: bool) -> Self {
219        Self {
220            builder: self.builder.property("sensitive", sensitive),
221        }
222    }
223
224    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
225        Self {
226            builder: self
227                .builder
228                .property("tooltip-markup", tooltip_markup.into()),
229        }
230    }
231
232    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
233        Self {
234            builder: self.builder.property("tooltip-text", tooltip_text.into()),
235        }
236    }
237
238    pub fn valign(self, valign: gtk::Align) -> Self {
239        Self {
240            builder: self.builder.property("valign", valign),
241        }
242    }
243
244    pub fn vexpand(self, vexpand: bool) -> Self {
245        Self {
246            builder: self.builder.property("vexpand", vexpand),
247        }
248    }
249
250    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
251        Self {
252            builder: self.builder.property("vexpand-set", vexpand_set),
253        }
254    }
255
256    pub fn visible(self, visible: bool) -> Self {
257        Self {
258            builder: self.builder.property("visible", visible),
259        }
260    }
261
262    pub fn width_request(self, width_request: i32) -> Self {
263        Self {
264            builder: self.builder.property("width-request", width_request),
265        }
266    }
267
268    pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
269        Self {
270            builder: self.builder.property("accessible-role", accessible_role),
271        }
272    }
273
274    pub fn orientation(self, orientation: gtk::Orientation) -> Self {
275        Self {
276            builder: self.builder.property("orientation", orientation),
277        }
278    }
279
280    // rustdoc-stripper-ignore-next
281    /// Build the [`Frame`].
282    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
283    pub fn build(self) -> Frame {
284        assert_initialized_main_thread!();
285        self.builder.build()
286    }
287}
288
289pub trait PanelFrameExt: IsA<Frame> + 'static {
290    #[doc(alias = "panel_frame_add")]
291    fn add(&self, panel: &impl IsA<Widget>) {
292        unsafe {
293            ffi::panel_frame_add(
294                self.as_ref().to_glib_none().0,
295                panel.as_ref().to_glib_none().0,
296            );
297        }
298    }
299
300    #[doc(alias = "panel_frame_add_before")]
301    fn add_before(&self, panel: &impl IsA<Widget>, sibling: &impl IsA<Widget>) {
302        unsafe {
303            ffi::panel_frame_add_before(
304                self.as_ref().to_glib_none().0,
305                panel.as_ref().to_glib_none().0,
306                sibling.as_ref().to_glib_none().0,
307            );
308        }
309    }
310
311    #[doc(alias = "panel_frame_get_closeable")]
312    #[doc(alias = "get_closeable")]
313    #[doc(alias = "closeable")]
314    fn is_closeable(&self) -> bool {
315        unsafe {
316            from_glib(ffi::panel_frame_get_closeable(
317                self.as_ref().to_glib_none().0,
318            ))
319        }
320    }
321
322    #[doc(alias = "panel_frame_get_empty")]
323    #[doc(alias = "get_empty")]
324    #[doc(alias = "empty")]
325    fn is_empty(&self) -> bool {
326        unsafe { from_glib(ffi::panel_frame_get_empty(self.as_ref().to_glib_none().0)) }
327    }
328
329    #[doc(alias = "panel_frame_get_header")]
330    #[doc(alias = "get_header")]
331    fn header(&self) -> Option<FrameHeader> {
332        unsafe { from_glib_none(ffi::panel_frame_get_header(self.as_ref().to_glib_none().0)) }
333    }
334
335    #[doc(alias = "panel_frame_get_n_pages")]
336    #[doc(alias = "get_n_pages")]
337    fn n_pages(&self) -> u32 {
338        unsafe { ffi::panel_frame_get_n_pages(self.as_ref().to_glib_none().0) }
339    }
340
341    #[doc(alias = "panel_frame_get_page")]
342    #[doc(alias = "get_page")]
343    fn page(&self, n: u32) -> Option<Widget> {
344        unsafe { from_glib_none(ffi::panel_frame_get_page(self.as_ref().to_glib_none().0, n)) }
345    }
346
347    #[doc(alias = "panel_frame_get_pages")]
348    #[doc(alias = "get_pages")]
349    fn pages(&self) -> gtk::SelectionModel {
350        unsafe { from_glib_full(ffi::panel_frame_get_pages(self.as_ref().to_glib_none().0)) }
351    }
352
353    #[doc(alias = "panel_frame_get_placeholder")]
354    #[doc(alias = "get_placeholder")]
355    fn placeholder(&self) -> Option<gtk::Widget> {
356        unsafe {
357            from_glib_none(ffi::panel_frame_get_placeholder(
358                self.as_ref().to_glib_none().0,
359            ))
360        }
361    }
362
363    #[doc(alias = "panel_frame_get_position")]
364    #[doc(alias = "get_position")]
365    fn position(&self) -> Position {
366        unsafe {
367            from_glib_full(ffi::panel_frame_get_position(
368                self.as_ref().to_glib_none().0,
369            ))
370        }
371    }
372
373    #[doc(alias = "panel_frame_get_requested_size")]
374    #[doc(alias = "get_requested_size")]
375    fn requested_size(&self) -> i32 {
376        unsafe { ffi::panel_frame_get_requested_size(self.as_ref().to_glib_none().0) }
377    }
378
379    #[doc(alias = "panel_frame_get_visible_child")]
380    #[doc(alias = "get_visible_child")]
381    #[doc(alias = "visible-child")]
382    fn visible_child(&self) -> Option<Widget> {
383        unsafe {
384            from_glib_none(ffi::panel_frame_get_visible_child(
385                self.as_ref().to_glib_none().0,
386            ))
387        }
388    }
389
390    #[doc(alias = "panel_frame_remove")]
391    fn remove(&self, panel: &impl IsA<Widget>) {
392        unsafe {
393            ffi::panel_frame_remove(
394                self.as_ref().to_glib_none().0,
395                panel.as_ref().to_glib_none().0,
396            );
397        }
398    }
399
400    #[cfg(feature = "v1_2")]
401    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
402    #[doc(alias = "panel_frame_set_child_pinned")]
403    fn set_child_pinned(&self, child: &impl IsA<Widget>, pinned: bool) {
404        unsafe {
405            ffi::panel_frame_set_child_pinned(
406                self.as_ref().to_glib_none().0,
407                child.as_ref().to_glib_none().0,
408                pinned.into_glib(),
409            );
410        }
411    }
412
413    #[doc(alias = "panel_frame_set_header")]
414    fn set_header(&self, header: Option<&impl IsA<FrameHeader>>) {
415        unsafe {
416            ffi::panel_frame_set_header(
417                self.as_ref().to_glib_none().0,
418                header.map(|p| p.as_ref()).to_glib_none().0,
419            );
420        }
421    }
422
423    #[doc(alias = "panel_frame_set_placeholder")]
424    #[doc(alias = "placeholder")]
425    fn set_placeholder(&self, placeholder: Option<&impl IsA<gtk::Widget>>) {
426        unsafe {
427            ffi::panel_frame_set_placeholder(
428                self.as_ref().to_glib_none().0,
429                placeholder.map(|p| p.as_ref()).to_glib_none().0,
430            );
431        }
432    }
433
434    #[doc(alias = "panel_frame_set_requested_size")]
435    fn set_requested_size(&self, requested_size: i32) {
436        unsafe {
437            ffi::panel_frame_set_requested_size(self.as_ref().to_glib_none().0, requested_size);
438        }
439    }
440
441    #[doc(alias = "panel_frame_set_visible_child")]
442    #[doc(alias = "visible-child")]
443    fn set_visible_child(&self, widget: &impl IsA<Widget>) {
444        unsafe {
445            ffi::panel_frame_set_visible_child(
446                self.as_ref().to_glib_none().0,
447                widget.as_ref().to_glib_none().0,
448            );
449        }
450    }
451
452    #[cfg(feature = "v1_2")]
453    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
454    #[doc(alias = "adopt-widget")]
455    fn connect_adopt_widget<F: Fn(&Self, &Widget) -> bool + 'static>(
456        &self,
457        f: F,
458    ) -> SignalHandlerId {
459        unsafe extern "C" fn adopt_widget_trampoline<
460            P: IsA<Frame>,
461            F: Fn(&P, &Widget) -> bool + 'static,
462        >(
463            this: *mut ffi::PanelFrame,
464            widget: *mut ffi::PanelWidget,
465            f: glib::ffi::gpointer,
466        ) -> glib::ffi::gboolean {
467            let f: &F = &*(f as *const F);
468            f(
469                Frame::from_glib_borrow(this).unsafe_cast_ref(),
470                &from_glib_borrow(widget),
471            )
472            .into_glib()
473        }
474        unsafe {
475            let f: Box_<F> = Box_::new(f);
476            connect_raw(
477                self.as_ptr() as *mut _,
478                c"adopt-widget".as_ptr() as *const _,
479                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
480                    adopt_widget_trampoline::<Self, F> as *const (),
481                )),
482                Box_::into_raw(f),
483            )
484        }
485    }
486
487    #[cfg(feature = "v1_2")]
488    #[cfg_attr(docsrs, doc(cfg(feature = "v1_2")))]
489    #[doc(alias = "page-closed")]
490    fn connect_page_closed<F: Fn(&Self, &Widget) + 'static>(&self, f: F) -> SignalHandlerId {
491        unsafe extern "C" fn page_closed_trampoline<P: IsA<Frame>, F: Fn(&P, &Widget) + 'static>(
492            this: *mut ffi::PanelFrame,
493            widget: *mut ffi::PanelWidget,
494            f: glib::ffi::gpointer,
495        ) {
496            let f: &F = &*(f as *const F);
497            f(
498                Frame::from_glib_borrow(this).unsafe_cast_ref(),
499                &from_glib_borrow(widget),
500            )
501        }
502        unsafe {
503            let f: Box_<F> = Box_::new(f);
504            connect_raw(
505                self.as_ptr() as *mut _,
506                c"page-closed".as_ptr() as *const _,
507                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
508                    page_closed_trampoline::<Self, F> as *const (),
509                )),
510                Box_::into_raw(f),
511            )
512        }
513    }
514
515    #[doc(alias = "closeable")]
516    fn connect_closeable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
517        unsafe extern "C" fn notify_closeable_trampoline<P: IsA<Frame>, F: Fn(&P) + 'static>(
518            this: *mut ffi::PanelFrame,
519            _param_spec: glib::ffi::gpointer,
520            f: glib::ffi::gpointer,
521        ) {
522            let f: &F = &*(f as *const F);
523            f(Frame::from_glib_borrow(this).unsafe_cast_ref())
524        }
525        unsafe {
526            let f: Box_<F> = Box_::new(f);
527            connect_raw(
528                self.as_ptr() as *mut _,
529                c"notify::closeable".as_ptr() as *const _,
530                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
531                    notify_closeable_trampoline::<Self, F> as *const (),
532                )),
533                Box_::into_raw(f),
534            )
535        }
536    }
537
538    #[doc(alias = "empty")]
539    fn connect_empty_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
540        unsafe extern "C" fn notify_empty_trampoline<P: IsA<Frame>, F: Fn(&P) + 'static>(
541            this: *mut ffi::PanelFrame,
542            _param_spec: glib::ffi::gpointer,
543            f: glib::ffi::gpointer,
544        ) {
545            let f: &F = &*(f as *const F);
546            f(Frame::from_glib_borrow(this).unsafe_cast_ref())
547        }
548        unsafe {
549            let f: Box_<F> = Box_::new(f);
550            connect_raw(
551                self.as_ptr() as *mut _,
552                c"notify::empty".as_ptr() as *const _,
553                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
554                    notify_empty_trampoline::<Self, F> as *const (),
555                )),
556                Box_::into_raw(f),
557            )
558        }
559    }
560
561    #[doc(alias = "placeholder")]
562    fn connect_placeholder_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
563        unsafe extern "C" fn notify_placeholder_trampoline<P: IsA<Frame>, F: Fn(&P) + 'static>(
564            this: *mut ffi::PanelFrame,
565            _param_spec: glib::ffi::gpointer,
566            f: glib::ffi::gpointer,
567        ) {
568            let f: &F = &*(f as *const F);
569            f(Frame::from_glib_borrow(this).unsafe_cast_ref())
570        }
571        unsafe {
572            let f: Box_<F> = Box_::new(f);
573            connect_raw(
574                self.as_ptr() as *mut _,
575                c"notify::placeholder".as_ptr() as *const _,
576                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
577                    notify_placeholder_trampoline::<Self, F> as *const (),
578                )),
579                Box_::into_raw(f),
580            )
581        }
582    }
583
584    #[doc(alias = "visible-child")]
585    fn connect_visible_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
586        unsafe extern "C" fn notify_visible_child_trampoline<P: IsA<Frame>, F: Fn(&P) + 'static>(
587            this: *mut ffi::PanelFrame,
588            _param_spec: glib::ffi::gpointer,
589            f: glib::ffi::gpointer,
590        ) {
591            let f: &F = &*(f as *const F);
592            f(Frame::from_glib_borrow(this).unsafe_cast_ref())
593        }
594        unsafe {
595            let f: Box_<F> = Box_::new(f);
596            connect_raw(
597                self.as_ptr() as *mut _,
598                c"notify::visible-child".as_ptr() as *const _,
599                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
600                    notify_visible_child_trampoline::<Self, F> as *const (),
601                )),
602                Box_::into_raw(f),
603            )
604        }
605    }
606}
607
608impl<O: IsA<Frame>> PanelFrameExt for O {}