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