libadwaita/auto/
sidebar.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, SidebarItem, SidebarMode, SidebarSection};
7use glib::{
8    object::ObjectType as _,
9    prelude::*,
10    signal::{connect_raw, SignalHandlerId},
11    translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16    #[doc(alias = "AdwSidebar")]
17    pub struct Sidebar(Object<ffi::AdwSidebar, ffi::AdwSidebarClass>) @extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget;
18
19    match fn {
20        type_ => || ffi::adw_sidebar_get_type(),
21    }
22}
23
24impl Sidebar {
25    #[doc(alias = "adw_sidebar_new")]
26    pub fn new() -> Sidebar {
27        assert_initialized_main_thread!();
28        unsafe { gtk::Widget::from_glib_none(ffi::adw_sidebar_new()).unsafe_cast() }
29    }
30
31    // rustdoc-stripper-ignore-next
32    /// Creates a new builder-pattern struct instance to construct [`Sidebar`] objects.
33    ///
34    /// This method returns an instance of [`SidebarBuilder`](crate::builders::SidebarBuilder) which can be used to create [`Sidebar`] objects.
35    pub fn builder() -> SidebarBuilder {
36        SidebarBuilder::new()
37    }
38
39    #[doc(alias = "adw_sidebar_append")]
40    pub fn append(&self, section: SidebarSection) {
41        unsafe {
42            ffi::adw_sidebar_append(self.to_glib_none().0, section.into_glib_ptr());
43        }
44    }
45
46    #[doc(alias = "adw_sidebar_get_drop_preload")]
47    #[doc(alias = "get_drop_preload")]
48    #[doc(alias = "drop-preload")]
49    pub fn is_drop_preload(&self) -> bool {
50        unsafe { from_glib(ffi::adw_sidebar_get_drop_preload(self.to_glib_none().0)) }
51    }
52
53    #[doc(alias = "adw_sidebar_get_filter")]
54    #[doc(alias = "get_filter")]
55    pub fn filter(&self) -> Option<gtk::Filter> {
56        unsafe { from_glib_none(ffi::adw_sidebar_get_filter(self.to_glib_none().0)) }
57    }
58
59    #[doc(alias = "adw_sidebar_get_item")]
60    #[doc(alias = "get_item")]
61    pub fn item(&self, index: u32) -> Option<SidebarItem> {
62        unsafe { from_glib_none(ffi::adw_sidebar_get_item(self.to_glib_none().0, index)) }
63    }
64
65    #[doc(alias = "adw_sidebar_get_items")]
66    #[doc(alias = "get_items")]
67    pub fn items(&self) -> gtk::SelectionModel {
68        unsafe { from_glib_full(ffi::adw_sidebar_get_items(self.to_glib_none().0)) }
69    }
70
71    #[doc(alias = "adw_sidebar_get_menu_model")]
72    #[doc(alias = "get_menu_model")]
73    #[doc(alias = "menu-model")]
74    pub fn menu_model(&self) -> Option<gio::MenuModel> {
75        unsafe { from_glib_none(ffi::adw_sidebar_get_menu_model(self.to_glib_none().0)) }
76    }
77
78    #[doc(alias = "adw_sidebar_get_mode")]
79    #[doc(alias = "get_mode")]
80    pub fn mode(&self) -> SidebarMode {
81        unsafe { from_glib(ffi::adw_sidebar_get_mode(self.to_glib_none().0)) }
82    }
83
84    #[doc(alias = "adw_sidebar_get_placeholder")]
85    #[doc(alias = "get_placeholder")]
86    pub fn placeholder(&self) -> Option<gtk::Widget> {
87        unsafe { from_glib_none(ffi::adw_sidebar_get_placeholder(self.to_glib_none().0)) }
88    }
89
90    #[doc(alias = "adw_sidebar_get_section")]
91    #[doc(alias = "get_section")]
92    pub fn section(&self, index: u32) -> Option<SidebarSection> {
93        unsafe { from_glib_none(ffi::adw_sidebar_get_section(self.to_glib_none().0, index)) }
94    }
95
96    #[doc(alias = "adw_sidebar_get_sections")]
97    #[doc(alias = "get_sections")]
98    pub fn sections(&self) -> gio::ListModel {
99        unsafe { from_glib_full(ffi::adw_sidebar_get_sections(self.to_glib_none().0)) }
100    }
101
102    #[doc(alias = "adw_sidebar_get_selected")]
103    #[doc(alias = "get_selected")]
104    pub fn selected(&self) -> u32 {
105        unsafe { ffi::adw_sidebar_get_selected(self.to_glib_none().0) }
106    }
107
108    #[doc(alias = "adw_sidebar_get_selected_item")]
109    #[doc(alias = "get_selected_item")]
110    #[doc(alias = "selected-item")]
111    pub fn selected_item(&self) -> Option<SidebarItem> {
112        unsafe { from_glib_none(ffi::adw_sidebar_get_selected_item(self.to_glib_none().0)) }
113    }
114
115    #[doc(alias = "adw_sidebar_insert")]
116    pub fn insert(&self, section: SidebarSection, position: i32) {
117        unsafe {
118            ffi::adw_sidebar_insert(self.to_glib_none().0, section.into_glib_ptr(), position);
119        }
120    }
121
122    #[doc(alias = "adw_sidebar_prepend")]
123    pub fn prepend(&self, section: SidebarSection) {
124        unsafe {
125            ffi::adw_sidebar_prepend(self.to_glib_none().0, section.into_glib_ptr());
126        }
127    }
128
129    #[doc(alias = "adw_sidebar_remove")]
130    pub fn remove(&self, section: &SidebarSection) {
131        unsafe {
132            ffi::adw_sidebar_remove(self.to_glib_none().0, section.to_glib_none().0);
133        }
134    }
135
136    #[doc(alias = "adw_sidebar_remove_all")]
137    pub fn remove_all(&self) {
138        unsafe {
139            ffi::adw_sidebar_remove_all(self.to_glib_none().0);
140        }
141    }
142
143    #[doc(alias = "adw_sidebar_set_drop_preload")]
144    #[doc(alias = "drop-preload")]
145    pub fn set_drop_preload(&self, preload: bool) {
146        unsafe {
147            ffi::adw_sidebar_set_drop_preload(self.to_glib_none().0, preload.into_glib());
148        }
149    }
150
151    #[doc(alias = "adw_sidebar_set_filter")]
152    #[doc(alias = "filter")]
153    pub fn set_filter(&self, filter: Option<&impl IsA<gtk::Filter>>) {
154        unsafe {
155            ffi::adw_sidebar_set_filter(
156                self.to_glib_none().0,
157                filter.map(|p| p.as_ref()).to_glib_none().0,
158            );
159        }
160    }
161
162    #[doc(alias = "adw_sidebar_set_menu_model")]
163    #[doc(alias = "menu-model")]
164    pub fn set_menu_model(&self, menu_model: Option<&impl IsA<gio::MenuModel>>) {
165        unsafe {
166            ffi::adw_sidebar_set_menu_model(
167                self.to_glib_none().0,
168                menu_model.map(|p| p.as_ref()).to_glib_none().0,
169            );
170        }
171    }
172
173    #[doc(alias = "adw_sidebar_set_mode")]
174    #[doc(alias = "mode")]
175    pub fn set_mode(&self, mode: SidebarMode) {
176        unsafe {
177            ffi::adw_sidebar_set_mode(self.to_glib_none().0, mode.into_glib());
178        }
179    }
180
181    #[doc(alias = "adw_sidebar_set_placeholder")]
182    #[doc(alias = "placeholder")]
183    pub fn set_placeholder(&self, placeholder: Option<&impl IsA<gtk::Widget>>) {
184        unsafe {
185            ffi::adw_sidebar_set_placeholder(
186                self.to_glib_none().0,
187                placeholder.map(|p| p.as_ref()).to_glib_none().0,
188            );
189        }
190    }
191
192    #[doc(alias = "adw_sidebar_set_selected")]
193    #[doc(alias = "selected")]
194    pub fn set_selected(&self, selected: u32) {
195        unsafe {
196            ffi::adw_sidebar_set_selected(self.to_glib_none().0, selected);
197        }
198    }
199
200    #[cfg(feature = "v1_9")]
201    #[cfg_attr(docsrs, doc(cfg(feature = "v1_9")))]
202    #[doc(alias = "activated")]
203    pub fn connect_activated<F: Fn(&Self, u32) + 'static>(&self, f: F) -> SignalHandlerId {
204        unsafe extern "C" fn activated_trampoline<F: Fn(&Sidebar, u32) + 'static>(
205            this: *mut ffi::AdwSidebar,
206            index: std::ffi::c_uint,
207            f: glib::ffi::gpointer,
208        ) {
209            let f: &F = &*(f as *const F);
210            f(&from_glib_borrow(this), index)
211        }
212        unsafe {
213            let f: Box_<F> = Box_::new(f);
214            connect_raw(
215                self.as_ptr() as *mut _,
216                c"activated".as_ptr() as *const _,
217                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
218                    activated_trampoline::<F> as *const (),
219                )),
220                Box_::into_raw(f),
221            )
222        }
223    }
224
225    #[doc(alias = "drop")]
226    pub fn connect_drop<F: Fn(&Self, u32, &glib::Value, gdk::DragAction) -> bool + 'static>(
227        &self,
228        f: F,
229    ) -> SignalHandlerId {
230        unsafe extern "C" fn drop_trampoline<
231            F: Fn(&Sidebar, u32, &glib::Value, gdk::DragAction) -> bool + 'static,
232        >(
233            this: *mut ffi::AdwSidebar,
234            index: std::ffi::c_uint,
235            value: *mut glib::gobject_ffi::GValue,
236            preferred_action: gdk::ffi::GdkDragAction,
237            f: glib::ffi::gpointer,
238        ) -> glib::ffi::gboolean {
239            let f: &F = &*(f as *const F);
240            f(
241                &from_glib_borrow(this),
242                index,
243                &from_glib_borrow(value),
244                from_glib(preferred_action),
245            )
246            .into_glib()
247        }
248        unsafe {
249            let f: Box_<F> = Box_::new(f);
250            connect_raw(
251                self.as_ptr() as *mut _,
252                c"drop".as_ptr() as *const _,
253                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
254                    drop_trampoline::<F> as *const (),
255                )),
256                Box_::into_raw(f),
257            )
258        }
259    }
260
261    #[cfg(feature = "v1_9")]
262    #[cfg_attr(docsrs, doc(cfg(feature = "v1_9")))]
263    #[doc(alias = "drop-enter")]
264    pub fn connect_drop_enter<F: Fn(&Self, u32) -> gdk::DragAction + 'static>(
265        &self,
266        f: F,
267    ) -> SignalHandlerId {
268        unsafe extern "C" fn drop_enter_trampoline<
269            F: Fn(&Sidebar, u32) -> gdk::DragAction + 'static,
270        >(
271            this: *mut ffi::AdwSidebar,
272            index: std::ffi::c_uint,
273            f: glib::ffi::gpointer,
274        ) -> gdk::ffi::GdkDragAction {
275            let f: &F = &*(f as *const F);
276            f(&from_glib_borrow(this), index).into_glib()
277        }
278        unsafe {
279            let f: Box_<F> = Box_::new(f);
280            connect_raw(
281                self.as_ptr() as *mut _,
282                c"drop-enter".as_ptr() as *const _,
283                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
284                    drop_enter_trampoline::<F> as *const (),
285                )),
286                Box_::into_raw(f),
287            )
288        }
289    }
290
291    #[cfg(feature = "v1_9")]
292    #[cfg_attr(docsrs, doc(cfg(feature = "v1_9")))]
293    #[doc(alias = "drop-value-loaded")]
294    pub fn connect_drop_value_loaded<
295        F: Fn(&Self, u32, &glib::Value) -> gdk::DragAction + 'static,
296    >(
297        &self,
298        f: F,
299    ) -> SignalHandlerId {
300        unsafe extern "C" fn drop_value_loaded_trampoline<
301            F: Fn(&Sidebar, u32, &glib::Value) -> gdk::DragAction + 'static,
302        >(
303            this: *mut ffi::AdwSidebar,
304            index: std::ffi::c_uint,
305            value: *mut glib::gobject_ffi::GValue,
306            f: glib::ffi::gpointer,
307        ) -> gdk::ffi::GdkDragAction {
308            let f: &F = &*(f as *const F);
309            f(&from_glib_borrow(this), index, &from_glib_borrow(value)).into_glib()
310        }
311        unsafe {
312            let f: Box_<F> = Box_::new(f);
313            connect_raw(
314                self.as_ptr() as *mut _,
315                c"drop-value-loaded".as_ptr() as *const _,
316                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
317                    drop_value_loaded_trampoline::<F> as *const (),
318                )),
319                Box_::into_raw(f),
320            )
321        }
322    }
323
324    #[doc(alias = "setup-menu")]
325    pub fn connect_setup_menu<F: Fn(&Self, Option<&SidebarItem>) + 'static>(
326        &self,
327        f: F,
328    ) -> SignalHandlerId {
329        unsafe extern "C" fn setup_menu_trampoline<
330            F: Fn(&Sidebar, Option<&SidebarItem>) + 'static,
331        >(
332            this: *mut ffi::AdwSidebar,
333            item: *mut ffi::AdwSidebarItem,
334            f: glib::ffi::gpointer,
335        ) {
336            let f: &F = &*(f as *const F);
337            f(
338                &from_glib_borrow(this),
339                Option::<SidebarItem>::from_glib_borrow(item)
340                    .as_ref()
341                    .as_ref(),
342            )
343        }
344        unsafe {
345            let f: Box_<F> = Box_::new(f);
346            connect_raw(
347                self.as_ptr() as *mut _,
348                c"setup-menu".as_ptr() as *const _,
349                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
350                    setup_menu_trampoline::<F> as *const (),
351                )),
352                Box_::into_raw(f),
353            )
354        }
355    }
356
357    #[cfg(feature = "v1_9")]
358    #[cfg_attr(docsrs, doc(cfg(feature = "v1_9")))]
359    #[doc(alias = "drop-preload")]
360    pub fn connect_drop_preload_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
361        unsafe extern "C" fn notify_drop_preload_trampoline<F: Fn(&Sidebar) + 'static>(
362            this: *mut ffi::AdwSidebar,
363            _param_spec: glib::ffi::gpointer,
364            f: glib::ffi::gpointer,
365        ) {
366            let f: &F = &*(f as *const F);
367            f(&from_glib_borrow(this))
368        }
369        unsafe {
370            let f: Box_<F> = Box_::new(f);
371            connect_raw(
372                self.as_ptr() as *mut _,
373                c"notify::drop-preload".as_ptr() as *const _,
374                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
375                    notify_drop_preload_trampoline::<F> as *const (),
376                )),
377                Box_::into_raw(f),
378            )
379        }
380    }
381
382    #[cfg(feature = "v1_9")]
383    #[cfg_attr(docsrs, doc(cfg(feature = "v1_9")))]
384    #[doc(alias = "filter")]
385    pub fn connect_filter_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
386        unsafe extern "C" fn notify_filter_trampoline<F: Fn(&Sidebar) + 'static>(
387            this: *mut ffi::AdwSidebar,
388            _param_spec: glib::ffi::gpointer,
389            f: glib::ffi::gpointer,
390        ) {
391            let f: &F = &*(f as *const F);
392            f(&from_glib_borrow(this))
393        }
394        unsafe {
395            let f: Box_<F> = Box_::new(f);
396            connect_raw(
397                self.as_ptr() as *mut _,
398                c"notify::filter".as_ptr() as *const _,
399                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
400                    notify_filter_trampoline::<F> as *const (),
401                )),
402                Box_::into_raw(f),
403            )
404        }
405    }
406
407    #[cfg(feature = "v1_9")]
408    #[cfg_attr(docsrs, doc(cfg(feature = "v1_9")))]
409    #[doc(alias = "items")]
410    pub fn connect_items_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
411        unsafe extern "C" fn notify_items_trampoline<F: Fn(&Sidebar) + 'static>(
412            this: *mut ffi::AdwSidebar,
413            _param_spec: glib::ffi::gpointer,
414            f: glib::ffi::gpointer,
415        ) {
416            let f: &F = &*(f as *const F);
417            f(&from_glib_borrow(this))
418        }
419        unsafe {
420            let f: Box_<F> = Box_::new(f);
421            connect_raw(
422                self.as_ptr() as *mut _,
423                c"notify::items".as_ptr() as *const _,
424                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
425                    notify_items_trampoline::<F> as *const (),
426                )),
427                Box_::into_raw(f),
428            )
429        }
430    }
431
432    #[cfg(feature = "v1_9")]
433    #[cfg_attr(docsrs, doc(cfg(feature = "v1_9")))]
434    #[doc(alias = "menu-model")]
435    pub fn connect_menu_model_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
436        unsafe extern "C" fn notify_menu_model_trampoline<F: Fn(&Sidebar) + 'static>(
437            this: *mut ffi::AdwSidebar,
438            _param_spec: glib::ffi::gpointer,
439            f: glib::ffi::gpointer,
440        ) {
441            let f: &F = &*(f as *const F);
442            f(&from_glib_borrow(this))
443        }
444        unsafe {
445            let f: Box_<F> = Box_::new(f);
446            connect_raw(
447                self.as_ptr() as *mut _,
448                c"notify::menu-model".as_ptr() as *const _,
449                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
450                    notify_menu_model_trampoline::<F> as *const (),
451                )),
452                Box_::into_raw(f),
453            )
454        }
455    }
456
457    #[cfg(feature = "v1_9")]
458    #[cfg_attr(docsrs, doc(cfg(feature = "v1_9")))]
459    #[doc(alias = "mode")]
460    pub fn connect_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
461        unsafe extern "C" fn notify_mode_trampoline<F: Fn(&Sidebar) + 'static>(
462            this: *mut ffi::AdwSidebar,
463            _param_spec: glib::ffi::gpointer,
464            f: glib::ffi::gpointer,
465        ) {
466            let f: &F = &*(f as *const F);
467            f(&from_glib_borrow(this))
468        }
469        unsafe {
470            let f: Box_<F> = Box_::new(f);
471            connect_raw(
472                self.as_ptr() as *mut _,
473                c"notify::mode".as_ptr() as *const _,
474                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
475                    notify_mode_trampoline::<F> as *const (),
476                )),
477                Box_::into_raw(f),
478            )
479        }
480    }
481
482    #[cfg(feature = "v1_9")]
483    #[cfg_attr(docsrs, doc(cfg(feature = "v1_9")))]
484    #[doc(alias = "placeholder")]
485    pub fn connect_placeholder_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
486        unsafe extern "C" fn notify_placeholder_trampoline<F: Fn(&Sidebar) + 'static>(
487            this: *mut ffi::AdwSidebar,
488            _param_spec: glib::ffi::gpointer,
489            f: glib::ffi::gpointer,
490        ) {
491            let f: &F = &*(f as *const F);
492            f(&from_glib_borrow(this))
493        }
494        unsafe {
495            let f: Box_<F> = Box_::new(f);
496            connect_raw(
497                self.as_ptr() as *mut _,
498                c"notify::placeholder".as_ptr() as *const _,
499                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
500                    notify_placeholder_trampoline::<F> as *const (),
501                )),
502                Box_::into_raw(f),
503            )
504        }
505    }
506
507    #[cfg(feature = "v1_9")]
508    #[cfg_attr(docsrs, doc(cfg(feature = "v1_9")))]
509    #[doc(alias = "sections")]
510    pub fn connect_sections_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
511        unsafe extern "C" fn notify_sections_trampoline<F: Fn(&Sidebar) + 'static>(
512            this: *mut ffi::AdwSidebar,
513            _param_spec: glib::ffi::gpointer,
514            f: glib::ffi::gpointer,
515        ) {
516            let f: &F = &*(f as *const F);
517            f(&from_glib_borrow(this))
518        }
519        unsafe {
520            let f: Box_<F> = Box_::new(f);
521            connect_raw(
522                self.as_ptr() as *mut _,
523                c"notify::sections".as_ptr() as *const _,
524                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
525                    notify_sections_trampoline::<F> as *const (),
526                )),
527                Box_::into_raw(f),
528            )
529        }
530    }
531
532    #[cfg(feature = "v1_9")]
533    #[cfg_attr(docsrs, doc(cfg(feature = "v1_9")))]
534    #[doc(alias = "selected")]
535    pub fn connect_selected_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
536        unsafe extern "C" fn notify_selected_trampoline<F: Fn(&Sidebar) + 'static>(
537            this: *mut ffi::AdwSidebar,
538            _param_spec: glib::ffi::gpointer,
539            f: glib::ffi::gpointer,
540        ) {
541            let f: &F = &*(f as *const F);
542            f(&from_glib_borrow(this))
543        }
544        unsafe {
545            let f: Box_<F> = Box_::new(f);
546            connect_raw(
547                self.as_ptr() as *mut _,
548                c"notify::selected".as_ptr() as *const _,
549                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
550                    notify_selected_trampoline::<F> as *const (),
551                )),
552                Box_::into_raw(f),
553            )
554        }
555    }
556
557    #[cfg(feature = "v1_9")]
558    #[cfg_attr(docsrs, doc(cfg(feature = "v1_9")))]
559    #[doc(alias = "selected-item")]
560    pub fn connect_selected_item_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
561        unsafe extern "C" fn notify_selected_item_trampoline<F: Fn(&Sidebar) + 'static>(
562            this: *mut ffi::AdwSidebar,
563            _param_spec: glib::ffi::gpointer,
564            f: glib::ffi::gpointer,
565        ) {
566            let f: &F = &*(f as *const F);
567            f(&from_glib_borrow(this))
568        }
569        unsafe {
570            let f: Box_<F> = Box_::new(f);
571            connect_raw(
572                self.as_ptr() as *mut _,
573                c"notify::selected-item".as_ptr() as *const _,
574                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
575                    notify_selected_item_trampoline::<F> as *const (),
576                )),
577                Box_::into_raw(f),
578            )
579        }
580    }
581}
582
583#[cfg(feature = "v1_9")]
584#[cfg_attr(docsrs, doc(cfg(feature = "v1_9")))]
585impl Default for Sidebar {
586    fn default() -> Self {
587        Self::new()
588    }
589}
590
591// rustdoc-stripper-ignore-next
592/// A [builder-pattern] type to construct [`Sidebar`] objects.
593///
594/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
595#[must_use = "The builder must be built to be used"]
596pub struct SidebarBuilder {
597    builder: glib::object::ObjectBuilder<'static, Sidebar>,
598}
599
600impl SidebarBuilder {
601    fn new() -> Self {
602        Self {
603            builder: glib::object::Object::builder(),
604        }
605    }
606
607    #[cfg(feature = "v1_9")]
608    #[cfg_attr(docsrs, doc(cfg(feature = "v1_9")))]
609    pub fn drop_preload(self, drop_preload: bool) -> Self {
610        Self {
611            builder: self.builder.property("drop-preload", drop_preload),
612        }
613    }
614
615    #[cfg(feature = "v1_9")]
616    #[cfg_attr(docsrs, doc(cfg(feature = "v1_9")))]
617    pub fn filter(self, filter: &impl IsA<gtk::Filter>) -> Self {
618        Self {
619            builder: self.builder.property("filter", filter.clone().upcast()),
620        }
621    }
622
623    #[cfg(feature = "v1_9")]
624    #[cfg_attr(docsrs, doc(cfg(feature = "v1_9")))]
625    pub fn menu_model(self, menu_model: &impl IsA<gio::MenuModel>) -> Self {
626        Self {
627            builder: self
628                .builder
629                .property("menu-model", menu_model.clone().upcast()),
630        }
631    }
632
633    #[cfg(feature = "v1_9")]
634    #[cfg_attr(docsrs, doc(cfg(feature = "v1_9")))]
635    pub fn mode(self, mode: SidebarMode) -> Self {
636        Self {
637            builder: self.builder.property("mode", mode),
638        }
639    }
640
641    #[cfg(feature = "v1_9")]
642    #[cfg_attr(docsrs, doc(cfg(feature = "v1_9")))]
643    pub fn placeholder(self, placeholder: &impl IsA<gtk::Widget>) -> Self {
644        Self {
645            builder: self
646                .builder
647                .property("placeholder", placeholder.clone().upcast()),
648        }
649    }
650
651    #[cfg(feature = "v1_9")]
652    #[cfg_attr(docsrs, doc(cfg(feature = "v1_9")))]
653    pub fn selected(self, selected: u32) -> Self {
654        Self {
655            builder: self.builder.property("selected", selected),
656        }
657    }
658
659    pub fn can_focus(self, can_focus: bool) -> Self {
660        Self {
661            builder: self.builder.property("can-focus", can_focus),
662        }
663    }
664
665    pub fn can_target(self, can_target: bool) -> Self {
666        Self {
667            builder: self.builder.property("can-target", can_target),
668        }
669    }
670
671    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
672        Self {
673            builder: self.builder.property("css-classes", css_classes.into()),
674        }
675    }
676
677    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
678        Self {
679            builder: self.builder.property("css-name", css_name.into()),
680        }
681    }
682
683    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
684        Self {
685            builder: self.builder.property("cursor", cursor.clone()),
686        }
687    }
688
689    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
690        Self {
691            builder: self.builder.property("focus-on-click", focus_on_click),
692        }
693    }
694
695    pub fn focusable(self, focusable: bool) -> Self {
696        Self {
697            builder: self.builder.property("focusable", focusable),
698        }
699    }
700
701    pub fn halign(self, halign: gtk::Align) -> Self {
702        Self {
703            builder: self.builder.property("halign", halign),
704        }
705    }
706
707    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
708        Self {
709            builder: self.builder.property("has-tooltip", has_tooltip),
710        }
711    }
712
713    pub fn height_request(self, height_request: i32) -> Self {
714        Self {
715            builder: self.builder.property("height-request", height_request),
716        }
717    }
718
719    pub fn hexpand(self, hexpand: bool) -> Self {
720        Self {
721            builder: self.builder.property("hexpand", hexpand),
722        }
723    }
724
725    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
726        Self {
727            builder: self.builder.property("hexpand-set", hexpand_set),
728        }
729    }
730
731    pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
732        Self {
733            builder: self
734                .builder
735                .property("layout-manager", layout_manager.clone().upcast()),
736        }
737    }
738
739    #[cfg(feature = "gtk_v4_18")]
740    #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
741    pub fn limit_events(self, limit_events: bool) -> Self {
742        Self {
743            builder: self.builder.property("limit-events", limit_events),
744        }
745    }
746
747    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
748        Self {
749            builder: self.builder.property("margin-bottom", margin_bottom),
750        }
751    }
752
753    pub fn margin_end(self, margin_end: i32) -> Self {
754        Self {
755            builder: self.builder.property("margin-end", margin_end),
756        }
757    }
758
759    pub fn margin_start(self, margin_start: i32) -> Self {
760        Self {
761            builder: self.builder.property("margin-start", margin_start),
762        }
763    }
764
765    pub fn margin_top(self, margin_top: i32) -> Self {
766        Self {
767            builder: self.builder.property("margin-top", margin_top),
768        }
769    }
770
771    pub fn name(self, name: impl Into<glib::GString>) -> Self {
772        Self {
773            builder: self.builder.property("name", name.into()),
774        }
775    }
776
777    pub fn opacity(self, opacity: f64) -> Self {
778        Self {
779            builder: self.builder.property("opacity", opacity),
780        }
781    }
782
783    pub fn overflow(self, overflow: gtk::Overflow) -> Self {
784        Self {
785            builder: self.builder.property("overflow", overflow),
786        }
787    }
788
789    pub fn receives_default(self, receives_default: bool) -> Self {
790        Self {
791            builder: self.builder.property("receives-default", receives_default),
792        }
793    }
794
795    pub fn sensitive(self, sensitive: bool) -> Self {
796        Self {
797            builder: self.builder.property("sensitive", sensitive),
798        }
799    }
800
801    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
802        Self {
803            builder: self
804                .builder
805                .property("tooltip-markup", tooltip_markup.into()),
806        }
807    }
808
809    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
810        Self {
811            builder: self.builder.property("tooltip-text", tooltip_text.into()),
812        }
813    }
814
815    pub fn valign(self, valign: gtk::Align) -> Self {
816        Self {
817            builder: self.builder.property("valign", valign),
818        }
819    }
820
821    pub fn vexpand(self, vexpand: bool) -> Self {
822        Self {
823            builder: self.builder.property("vexpand", vexpand),
824        }
825    }
826
827    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
828        Self {
829            builder: self.builder.property("vexpand-set", vexpand_set),
830        }
831    }
832
833    pub fn visible(self, visible: bool) -> Self {
834        Self {
835            builder: self.builder.property("visible", visible),
836        }
837    }
838
839    pub fn width_request(self, width_request: i32) -> Self {
840        Self {
841            builder: self.builder.property("width-request", width_request),
842        }
843    }
844
845    pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
846        Self {
847            builder: self.builder.property("accessible-role", accessible_role),
848        }
849    }
850
851    // rustdoc-stripper-ignore-next
852    /// Build the [`Sidebar`].
853    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
854    pub fn build(self) -> Sidebar {
855        assert_initialized_main_thread!();
856        self.builder.build()
857    }
858}