libpanel/auto/
frame_header_bar.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, Frame, FrameHeader};
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "PanelFrameHeaderBar")]
16    pub struct FrameHeaderBar(Object<ffi::PanelFrameHeaderBar, ffi::PanelFrameHeaderBarClass>) @extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, FrameHeader;
17
18    match fn {
19        type_ => || ffi::panel_frame_header_bar_get_type(),
20    }
21}
22
23impl FrameHeaderBar {
24    #[doc(alias = "panel_frame_header_bar_new")]
25    pub fn new() -> FrameHeaderBar {
26        assert_initialized_main_thread!();
27        unsafe { gtk::Widget::from_glib_none(ffi::panel_frame_header_bar_new()).unsafe_cast() }
28    }
29
30    // rustdoc-stripper-ignore-next
31    /// Creates a new builder-pattern struct instance to construct [`FrameHeaderBar`] objects.
32    ///
33    /// This method returns an instance of [`FrameHeaderBarBuilder`](crate::builders::FrameHeaderBarBuilder) which can be used to create [`FrameHeaderBar`] objects.
34    pub fn builder() -> FrameHeaderBarBuilder {
35        FrameHeaderBarBuilder::new()
36    }
37
38    #[doc(alias = "panel_frame_header_bar_get_menu_popover")]
39    #[doc(alias = "get_menu_popover")]
40    pub fn menu_popover(&self) -> gtk::PopoverMenu {
41        unsafe {
42            from_glib_none(ffi::panel_frame_header_bar_get_menu_popover(
43                self.to_glib_none().0,
44            ))
45        }
46    }
47
48    #[doc(alias = "panel_frame_header_bar_get_show_icon")]
49    #[doc(alias = "get_show_icon")]
50    #[doc(alias = "show-icon")]
51    pub fn shows_icon(&self) -> bool {
52        unsafe {
53            from_glib(ffi::panel_frame_header_bar_get_show_icon(
54                self.to_glib_none().0,
55            ))
56        }
57    }
58
59    #[doc(alias = "panel_frame_header_bar_set_show_icon")]
60    #[doc(alias = "show-icon")]
61    pub fn set_show_icon(&self, show_icon: bool) {
62        unsafe {
63            ffi::panel_frame_header_bar_set_show_icon(self.to_glib_none().0, show_icon.into_glib());
64        }
65    }
66
67    #[doc(alias = "show-icon")]
68    pub fn connect_show_icon_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
69        unsafe extern "C" fn notify_show_icon_trampoline<F: Fn(&FrameHeaderBar) + 'static>(
70            this: *mut ffi::PanelFrameHeaderBar,
71            _param_spec: glib::ffi::gpointer,
72            f: glib::ffi::gpointer,
73        ) {
74            let f: &F = &*(f as *const F);
75            f(&from_glib_borrow(this))
76        }
77        unsafe {
78            let f: Box_<F> = Box_::new(f);
79            connect_raw(
80                self.as_ptr() as *mut _,
81                c"notify::show-icon".as_ptr() as *const _,
82                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
83                    notify_show_icon_trampoline::<F> as *const (),
84                )),
85                Box_::into_raw(f),
86            )
87        }
88    }
89}
90
91impl Default for FrameHeaderBar {
92    fn default() -> Self {
93        Self::new()
94    }
95}
96
97// rustdoc-stripper-ignore-next
98/// A [builder-pattern] type to construct [`FrameHeaderBar`] objects.
99///
100/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
101#[must_use = "The builder must be built to be used"]
102pub struct FrameHeaderBarBuilder {
103    builder: glib::object::ObjectBuilder<'static, FrameHeaderBar>,
104}
105
106impl FrameHeaderBarBuilder {
107    fn new() -> Self {
108        Self {
109            builder: glib::object::Object::builder(),
110        }
111    }
112
113    pub fn show_icon(self, show_icon: bool) -> Self {
114        Self {
115            builder: self.builder.property("show-icon", show_icon),
116        }
117    }
118
119    pub fn can_focus(self, can_focus: bool) -> Self {
120        Self {
121            builder: self.builder.property("can-focus", can_focus),
122        }
123    }
124
125    pub fn can_target(self, can_target: bool) -> Self {
126        Self {
127            builder: self.builder.property("can-target", can_target),
128        }
129    }
130
131    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
132        Self {
133            builder: self.builder.property("css-classes", css_classes.into()),
134        }
135    }
136
137    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
138        Self {
139            builder: self.builder.property("css-name", css_name.into()),
140        }
141    }
142
143    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
144        Self {
145            builder: self.builder.property("cursor", cursor.clone()),
146        }
147    }
148
149    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
150        Self {
151            builder: self.builder.property("focus-on-click", focus_on_click),
152        }
153    }
154
155    pub fn focusable(self, focusable: bool) -> Self {
156        Self {
157            builder: self.builder.property("focusable", focusable),
158        }
159    }
160
161    pub fn halign(self, halign: gtk::Align) -> Self {
162        Self {
163            builder: self.builder.property("halign", halign),
164        }
165    }
166
167    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
168        Self {
169            builder: self.builder.property("has-tooltip", has_tooltip),
170        }
171    }
172
173    pub fn height_request(self, height_request: i32) -> Self {
174        Self {
175            builder: self.builder.property("height-request", height_request),
176        }
177    }
178
179    pub fn hexpand(self, hexpand: bool) -> Self {
180        Self {
181            builder: self.builder.property("hexpand", hexpand),
182        }
183    }
184
185    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
186        Self {
187            builder: self.builder.property("hexpand-set", hexpand_set),
188        }
189    }
190
191    pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
192        Self {
193            builder: self
194                .builder
195                .property("layout-manager", layout_manager.clone().upcast()),
196        }
197    }
198
199    #[cfg(feature = "gtk_v4_18")]
200    #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
201    pub fn limit_events(self, limit_events: bool) -> Self {
202        Self {
203            builder: self.builder.property("limit-events", limit_events),
204        }
205    }
206
207    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
208        Self {
209            builder: self.builder.property("margin-bottom", margin_bottom),
210        }
211    }
212
213    pub fn margin_end(self, margin_end: i32) -> Self {
214        Self {
215            builder: self.builder.property("margin-end", margin_end),
216        }
217    }
218
219    pub fn margin_start(self, margin_start: i32) -> Self {
220        Self {
221            builder: self.builder.property("margin-start", margin_start),
222        }
223    }
224
225    pub fn margin_top(self, margin_top: i32) -> Self {
226        Self {
227            builder: self.builder.property("margin-top", margin_top),
228        }
229    }
230
231    pub fn name(self, name: impl Into<glib::GString>) -> Self {
232        Self {
233            builder: self.builder.property("name", name.into()),
234        }
235    }
236
237    pub fn opacity(self, opacity: f64) -> Self {
238        Self {
239            builder: self.builder.property("opacity", opacity),
240        }
241    }
242
243    pub fn overflow(self, overflow: gtk::Overflow) -> Self {
244        Self {
245            builder: self.builder.property("overflow", overflow),
246        }
247    }
248
249    pub fn receives_default(self, receives_default: bool) -> Self {
250        Self {
251            builder: self.builder.property("receives-default", receives_default),
252        }
253    }
254
255    pub fn sensitive(self, sensitive: bool) -> Self {
256        Self {
257            builder: self.builder.property("sensitive", sensitive),
258        }
259    }
260
261    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
262        Self {
263            builder: self
264                .builder
265                .property("tooltip-markup", tooltip_markup.into()),
266        }
267    }
268
269    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
270        Self {
271            builder: self.builder.property("tooltip-text", tooltip_text.into()),
272        }
273    }
274
275    pub fn valign(self, valign: gtk::Align) -> Self {
276        Self {
277            builder: self.builder.property("valign", valign),
278        }
279    }
280
281    pub fn vexpand(self, vexpand: bool) -> Self {
282        Self {
283            builder: self.builder.property("vexpand", vexpand),
284        }
285    }
286
287    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
288        Self {
289            builder: self.builder.property("vexpand-set", vexpand_set),
290        }
291    }
292
293    pub fn visible(self, visible: bool) -> Self {
294        Self {
295            builder: self.builder.property("visible", visible),
296        }
297    }
298
299    pub fn width_request(self, width_request: i32) -> Self {
300        Self {
301            builder: self.builder.property("width-request", width_request),
302        }
303    }
304
305    pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
306        Self {
307            builder: self.builder.property("accessible-role", accessible_role),
308        }
309    }
310
311    pub fn frame(self, frame: &impl IsA<Frame>) -> Self {
312        Self {
313            builder: self.builder.property("frame", frame.clone().upcast()),
314        }
315    }
316
317    // rustdoc-stripper-ignore-next
318    /// Build the [`FrameHeaderBar`].
319    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
320    pub fn build(self) -> FrameHeaderBar {
321        assert_initialized_main_thread!();
322        self.builder.build()
323    }
324}