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