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