[go: up one dir, main page]

gtk4/auto/
list_box.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
5#[cfg(feature = "v4_18")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
7use crate::ListTabBehavior;
8use crate::{
9    ffi, Accessible, AccessibleRole, Adjustment, Align, Buildable, ConstraintTarget, LayoutManager,
10    ListBoxRow, MovementStep, Overflow, SelectionMode, Widget,
11};
12use glib::{
13    object::ObjectType as _,
14    prelude::*,
15    signal::{connect_raw, SignalHandlerId},
16    translate::*,
17};
18use std::boxed::Box as Box_;
19
20glib::wrapper! {
21    #[doc(alias = "GtkListBox")]
22    pub struct ListBox(Object<ffi::GtkListBox>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget;
23
24    match fn {
25        type_ => || ffi::gtk_list_box_get_type(),
26    }
27}
28
29impl ListBox {
30    #[doc(alias = "gtk_list_box_new")]
31    pub fn new() -> ListBox {
32        assert_initialized_main_thread!();
33        unsafe { Widget::from_glib_none(ffi::gtk_list_box_new()).unsafe_cast() }
34    }
35
36    // rustdoc-stripper-ignore-next
37    /// Creates a new builder-pattern struct instance to construct [`ListBox`] objects.
38    ///
39    /// This method returns an instance of [`ListBoxBuilder`](crate::builders::ListBoxBuilder) which can be used to create [`ListBox`] objects.
40    pub fn builder() -> ListBoxBuilder {
41        ListBoxBuilder::new()
42    }
43
44    #[doc(alias = "gtk_list_box_append")]
45    pub fn append(&self, child: &impl IsA<Widget>) {
46        unsafe {
47            ffi::gtk_list_box_append(self.to_glib_none().0, child.as_ref().to_glib_none().0);
48        }
49    }
50
51    #[doc(alias = "gtk_list_box_bind_model")]
52    pub fn bind_model<P: Fn(&glib::Object) -> Widget + 'static>(
53        &self,
54        model: Option<&impl IsA<gio::ListModel>>,
55        create_widget_func: P,
56    ) {
57        let create_widget_func_data: Box_<P> = Box_::new(create_widget_func);
58        unsafe extern "C" fn create_widget_func_func<P: Fn(&glib::Object) -> Widget + 'static>(
59            item: *mut glib::gobject_ffi::GObject,
60            user_data: glib::ffi::gpointer,
61        ) -> *mut ffi::GtkWidget {
62            let item = from_glib_borrow(item);
63            let callback = &*(user_data as *mut P);
64            (*callback)(&item).to_glib_full()
65        }
66        let create_widget_func = Some(create_widget_func_func::<P> as _);
67        unsafe extern "C" fn user_data_free_func_func<P: Fn(&glib::Object) -> Widget + 'static>(
68            data: glib::ffi::gpointer,
69        ) {
70            let _callback = Box_::from_raw(data as *mut P);
71        }
72        let destroy_call4 = Some(user_data_free_func_func::<P> as _);
73        let super_callback0: Box_<P> = create_widget_func_data;
74        unsafe {
75            ffi::gtk_list_box_bind_model(
76                self.to_glib_none().0,
77                model.map(|p| p.as_ref()).to_glib_none().0,
78                create_widget_func,
79                Box_::into_raw(super_callback0) as *mut _,
80                destroy_call4,
81            );
82        }
83    }
84
85    #[doc(alias = "gtk_list_box_drag_highlight_row")]
86    pub fn drag_highlight_row(&self, row: &impl IsA<ListBoxRow>) {
87        unsafe {
88            ffi::gtk_list_box_drag_highlight_row(
89                self.to_glib_none().0,
90                row.as_ref().to_glib_none().0,
91            );
92        }
93    }
94
95    #[doc(alias = "gtk_list_box_drag_unhighlight_row")]
96    pub fn drag_unhighlight_row(&self) {
97        unsafe {
98            ffi::gtk_list_box_drag_unhighlight_row(self.to_glib_none().0);
99        }
100    }
101
102    #[doc(alias = "gtk_list_box_get_activate_on_single_click")]
103    #[doc(alias = "get_activate_on_single_click")]
104    #[doc(alias = "activate-on-single-click")]
105    pub fn activates_on_single_click(&self) -> bool {
106        unsafe {
107            from_glib(ffi::gtk_list_box_get_activate_on_single_click(
108                self.to_glib_none().0,
109            ))
110        }
111    }
112
113    #[doc(alias = "gtk_list_box_get_adjustment")]
114    #[doc(alias = "get_adjustment")]
115    pub fn adjustment(&self) -> Option<Adjustment> {
116        unsafe { from_glib_none(ffi::gtk_list_box_get_adjustment(self.to_glib_none().0)) }
117    }
118
119    #[doc(alias = "gtk_list_box_get_row_at_index")]
120    #[doc(alias = "get_row_at_index")]
121    pub fn row_at_index(&self, index_: i32) -> Option<ListBoxRow> {
122        unsafe {
123            from_glib_none(ffi::gtk_list_box_get_row_at_index(
124                self.to_glib_none().0,
125                index_,
126            ))
127        }
128    }
129
130    #[doc(alias = "gtk_list_box_get_row_at_y")]
131    #[doc(alias = "get_row_at_y")]
132    pub fn row_at_y(&self, y: i32) -> Option<ListBoxRow> {
133        unsafe { from_glib_none(ffi::gtk_list_box_get_row_at_y(self.to_glib_none().0, y)) }
134    }
135
136    #[doc(alias = "gtk_list_box_get_selected_row")]
137    #[doc(alias = "get_selected_row")]
138    pub fn selected_row(&self) -> Option<ListBoxRow> {
139        unsafe { from_glib_none(ffi::gtk_list_box_get_selected_row(self.to_glib_none().0)) }
140    }
141
142    #[doc(alias = "gtk_list_box_get_selected_rows")]
143    #[doc(alias = "get_selected_rows")]
144    pub fn selected_rows(&self) -> Vec<ListBoxRow> {
145        unsafe {
146            FromGlibPtrContainer::from_glib_container(ffi::gtk_list_box_get_selected_rows(
147                self.to_glib_none().0,
148            ))
149        }
150    }
151
152    #[doc(alias = "gtk_list_box_get_selection_mode")]
153    #[doc(alias = "get_selection_mode")]
154    #[doc(alias = "selection-mode")]
155    pub fn selection_mode(&self) -> SelectionMode {
156        unsafe { from_glib(ffi::gtk_list_box_get_selection_mode(self.to_glib_none().0)) }
157    }
158
159    #[doc(alias = "gtk_list_box_get_show_separators")]
160    #[doc(alias = "get_show_separators")]
161    #[doc(alias = "show-separators")]
162    pub fn shows_separators(&self) -> bool {
163        unsafe { from_glib(ffi::gtk_list_box_get_show_separators(self.to_glib_none().0)) }
164    }
165
166    #[cfg(feature = "v4_18")]
167    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
168    #[doc(alias = "gtk_list_box_get_tab_behavior")]
169    #[doc(alias = "get_tab_behavior")]
170    #[doc(alias = "tab-behavior")]
171    pub fn tab_behavior(&self) -> ListTabBehavior {
172        unsafe { from_glib(ffi::gtk_list_box_get_tab_behavior(self.to_glib_none().0)) }
173    }
174
175    #[doc(alias = "gtk_list_box_insert")]
176    pub fn insert(&self, child: &impl IsA<Widget>, position: i32) {
177        unsafe {
178            ffi::gtk_list_box_insert(
179                self.to_glib_none().0,
180                child.as_ref().to_glib_none().0,
181                position,
182            );
183        }
184    }
185
186    #[doc(alias = "gtk_list_box_invalidate_filter")]
187    pub fn invalidate_filter(&self) {
188        unsafe {
189            ffi::gtk_list_box_invalidate_filter(self.to_glib_none().0);
190        }
191    }
192
193    #[doc(alias = "gtk_list_box_invalidate_headers")]
194    pub fn invalidate_headers(&self) {
195        unsafe {
196            ffi::gtk_list_box_invalidate_headers(self.to_glib_none().0);
197        }
198    }
199
200    #[doc(alias = "gtk_list_box_invalidate_sort")]
201    pub fn invalidate_sort(&self) {
202        unsafe {
203            ffi::gtk_list_box_invalidate_sort(self.to_glib_none().0);
204        }
205    }
206
207    #[doc(alias = "gtk_list_box_prepend")]
208    pub fn prepend(&self, child: &impl IsA<Widget>) {
209        unsafe {
210            ffi::gtk_list_box_prepend(self.to_glib_none().0, child.as_ref().to_glib_none().0);
211        }
212    }
213
214    #[doc(alias = "gtk_list_box_remove")]
215    pub fn remove(&self, child: &impl IsA<Widget>) {
216        unsafe {
217            ffi::gtk_list_box_remove(self.to_glib_none().0, child.as_ref().to_glib_none().0);
218        }
219    }
220
221    #[cfg(feature = "v4_12")]
222    #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
223    #[doc(alias = "gtk_list_box_remove_all")]
224    pub fn remove_all(&self) {
225        unsafe {
226            ffi::gtk_list_box_remove_all(self.to_glib_none().0);
227        }
228    }
229
230    #[doc(alias = "gtk_list_box_select_all")]
231    pub fn select_all(&self) {
232        unsafe {
233            ffi::gtk_list_box_select_all(self.to_glib_none().0);
234        }
235    }
236
237    #[doc(alias = "gtk_list_box_select_row")]
238    pub fn select_row(&self, row: Option<&impl IsA<ListBoxRow>>) {
239        unsafe {
240            ffi::gtk_list_box_select_row(
241                self.to_glib_none().0,
242                row.map(|p| p.as_ref()).to_glib_none().0,
243            );
244        }
245    }
246
247    #[doc(alias = "gtk_list_box_selected_foreach")]
248    pub fn selected_foreach<P: FnMut(&ListBox, &ListBoxRow)>(&self, func: P) {
249        let mut func_data: P = func;
250        unsafe extern "C" fn func_func<P: FnMut(&ListBox, &ListBoxRow)>(
251            box_: *mut ffi::GtkListBox,
252            row: *mut ffi::GtkListBoxRow,
253            user_data: glib::ffi::gpointer,
254        ) {
255            let box_ = from_glib_borrow(box_);
256            let row = from_glib_borrow(row);
257            let callback = user_data as *mut P;
258            (*callback)(&box_, &row)
259        }
260        let func = Some(func_func::<P> as _);
261        let super_callback0: &mut P = &mut func_data;
262        unsafe {
263            ffi::gtk_list_box_selected_foreach(
264                self.to_glib_none().0,
265                func,
266                super_callback0 as *mut _ as *mut _,
267            );
268        }
269    }
270
271    #[doc(alias = "gtk_list_box_set_activate_on_single_click")]
272    #[doc(alias = "activate-on-single-click")]
273    pub fn set_activate_on_single_click(&self, single: bool) {
274        unsafe {
275            ffi::gtk_list_box_set_activate_on_single_click(
276                self.to_glib_none().0,
277                single.into_glib(),
278            );
279        }
280    }
281
282    #[doc(alias = "gtk_list_box_set_adjustment")]
283    pub fn set_adjustment(&self, adjustment: Option<&impl IsA<Adjustment>>) {
284        unsafe {
285            ffi::gtk_list_box_set_adjustment(
286                self.to_glib_none().0,
287                adjustment.map(|p| p.as_ref()).to_glib_none().0,
288            );
289        }
290    }
291
292    #[doc(alias = "gtk_list_box_set_filter_func")]
293    pub fn set_filter_func<P: Fn(&ListBoxRow) -> bool + 'static>(&self, filter_func: P) {
294        let filter_func_data: Box_<P> = Box_::new(filter_func);
295        unsafe extern "C" fn filter_func_func<P: Fn(&ListBoxRow) -> bool + 'static>(
296            row: *mut ffi::GtkListBoxRow,
297            user_data: glib::ffi::gpointer,
298        ) -> glib::ffi::gboolean {
299            let row = from_glib_borrow(row);
300            let callback = &*(user_data as *mut P);
301            (*callback)(&row).into_glib()
302        }
303        let filter_func = Some(filter_func_func::<P> as _);
304        unsafe extern "C" fn destroy_func<P: Fn(&ListBoxRow) -> bool + 'static>(
305            data: glib::ffi::gpointer,
306        ) {
307            let _callback = Box_::from_raw(data as *mut P);
308        }
309        let destroy_call3 = Some(destroy_func::<P> as _);
310        let super_callback0: Box_<P> = filter_func_data;
311        unsafe {
312            ffi::gtk_list_box_set_filter_func(
313                self.to_glib_none().0,
314                filter_func,
315                Box_::into_raw(super_callback0) as *mut _,
316                destroy_call3,
317            );
318        }
319    }
320
321    #[doc(alias = "gtk_list_box_set_header_func")]
322    pub fn set_header_func<P: Fn(&ListBoxRow, Option<&ListBoxRow>) + 'static>(
323        &self,
324        update_header: P,
325    ) {
326        let update_header_data: Box_<P> = Box_::new(update_header);
327        unsafe extern "C" fn update_header_func<
328            P: Fn(&ListBoxRow, Option<&ListBoxRow>) + 'static,
329        >(
330            row: *mut ffi::GtkListBoxRow,
331            before: *mut ffi::GtkListBoxRow,
332            user_data: glib::ffi::gpointer,
333        ) {
334            let row = from_glib_borrow(row);
335            let before: Borrowed<Option<ListBoxRow>> = from_glib_borrow(before);
336            let callback = &*(user_data as *mut P);
337            (*callback)(&row, before.as_ref().as_ref())
338        }
339        let update_header = Some(update_header_func::<P> as _);
340        unsafe extern "C" fn destroy_func<P: Fn(&ListBoxRow, Option<&ListBoxRow>) + 'static>(
341            data: glib::ffi::gpointer,
342        ) {
343            let _callback = Box_::from_raw(data as *mut P);
344        }
345        let destroy_call3 = Some(destroy_func::<P> as _);
346        let super_callback0: Box_<P> = update_header_data;
347        unsafe {
348            ffi::gtk_list_box_set_header_func(
349                self.to_glib_none().0,
350                update_header,
351                Box_::into_raw(super_callback0) as *mut _,
352                destroy_call3,
353            );
354        }
355    }
356
357    #[doc(alias = "gtk_list_box_set_placeholder")]
358    pub fn set_placeholder(&self, placeholder: Option<&impl IsA<Widget>>) {
359        unsafe {
360            ffi::gtk_list_box_set_placeholder(
361                self.to_glib_none().0,
362                placeholder.map(|p| p.as_ref()).to_glib_none().0,
363            );
364        }
365    }
366
367    #[doc(alias = "gtk_list_box_set_selection_mode")]
368    #[doc(alias = "selection-mode")]
369    pub fn set_selection_mode(&self, mode: SelectionMode) {
370        unsafe {
371            ffi::gtk_list_box_set_selection_mode(self.to_glib_none().0, mode.into_glib());
372        }
373    }
374
375    #[doc(alias = "gtk_list_box_set_show_separators")]
376    #[doc(alias = "show-separators")]
377    pub fn set_show_separators(&self, show_separators: bool) {
378        unsafe {
379            ffi::gtk_list_box_set_show_separators(
380                self.to_glib_none().0,
381                show_separators.into_glib(),
382            );
383        }
384    }
385
386    #[cfg(feature = "v4_18")]
387    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
388    #[doc(alias = "gtk_list_box_set_tab_behavior")]
389    #[doc(alias = "tab-behavior")]
390    pub fn set_tab_behavior(&self, behavior: ListTabBehavior) {
391        unsafe {
392            ffi::gtk_list_box_set_tab_behavior(self.to_glib_none().0, behavior.into_glib());
393        }
394    }
395
396    #[doc(alias = "gtk_list_box_unselect_all")]
397    pub fn unselect_all(&self) {
398        unsafe {
399            ffi::gtk_list_box_unselect_all(self.to_glib_none().0);
400        }
401    }
402
403    #[doc(alias = "gtk_list_box_unselect_row")]
404    pub fn unselect_row(&self, row: &impl IsA<ListBoxRow>) {
405        unsafe {
406            ffi::gtk_list_box_unselect_row(self.to_glib_none().0, row.as_ref().to_glib_none().0);
407        }
408    }
409
410    #[doc(alias = "accept-unpaired-release")]
411    pub fn accepts_unpaired_release(&self) -> bool {
412        ObjectExt::property(self, "accept-unpaired-release")
413    }
414
415    #[doc(alias = "accept-unpaired-release")]
416    pub fn set_accept_unpaired_release(&self, accept_unpaired_release: bool) {
417        ObjectExt::set_property(self, "accept-unpaired-release", accept_unpaired_release)
418    }
419
420    #[doc(alias = "activate-cursor-row")]
421    pub fn connect_activate_cursor_row<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
422        unsafe extern "C" fn activate_cursor_row_trampoline<F: Fn(&ListBox) + 'static>(
423            this: *mut ffi::GtkListBox,
424            f: glib::ffi::gpointer,
425        ) {
426            let f: &F = &*(f as *const F);
427            f(&from_glib_borrow(this))
428        }
429        unsafe {
430            let f: Box_<F> = Box_::new(f);
431            connect_raw(
432                self.as_ptr() as *mut _,
433                c"activate-cursor-row".as_ptr() as *const _,
434                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
435                    activate_cursor_row_trampoline::<F> as *const (),
436                )),
437                Box_::into_raw(f),
438            )
439        }
440    }
441
442    pub fn emit_activate_cursor_row(&self) {
443        self.emit_by_name::<()>("activate-cursor-row", &[]);
444    }
445
446    #[doc(alias = "move-cursor")]
447    pub fn connect_move_cursor<F: Fn(&Self, MovementStep, i32, bool, bool) + 'static>(
448        &self,
449        f: F,
450    ) -> SignalHandlerId {
451        unsafe extern "C" fn move_cursor_trampoline<
452            F: Fn(&ListBox, MovementStep, i32, bool, bool) + 'static,
453        >(
454            this: *mut ffi::GtkListBox,
455            step: ffi::GtkMovementStep,
456            count: std::ffi::c_int,
457            extend: glib::ffi::gboolean,
458            modify: glib::ffi::gboolean,
459            f: glib::ffi::gpointer,
460        ) {
461            let f: &F = &*(f as *const F);
462            f(
463                &from_glib_borrow(this),
464                from_glib(step),
465                count,
466                from_glib(extend),
467                from_glib(modify),
468            )
469        }
470        unsafe {
471            let f: Box_<F> = Box_::new(f);
472            connect_raw(
473                self.as_ptr() as *mut _,
474                c"move-cursor".as_ptr() as *const _,
475                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
476                    move_cursor_trampoline::<F> as *const (),
477                )),
478                Box_::into_raw(f),
479            )
480        }
481    }
482
483    pub fn emit_move_cursor(&self, step: MovementStep, count: i32, extend: bool, modify: bool) {
484        self.emit_by_name::<()>("move-cursor", &[&step, &count, &extend, &modify]);
485    }
486
487    #[doc(alias = "row-activated")]
488    pub fn connect_row_activated<F: Fn(&Self, &ListBoxRow) + 'static>(
489        &self,
490        f: F,
491    ) -> SignalHandlerId {
492        unsafe extern "C" fn row_activated_trampoline<F: Fn(&ListBox, &ListBoxRow) + 'static>(
493            this: *mut ffi::GtkListBox,
494            row: *mut ffi::GtkListBoxRow,
495            f: glib::ffi::gpointer,
496        ) {
497            let f: &F = &*(f as *const F);
498            f(&from_glib_borrow(this), &from_glib_borrow(row))
499        }
500        unsafe {
501            let f: Box_<F> = Box_::new(f);
502            connect_raw(
503                self.as_ptr() as *mut _,
504                c"row-activated".as_ptr() as *const _,
505                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
506                    row_activated_trampoline::<F> as *const (),
507                )),
508                Box_::into_raw(f),
509            )
510        }
511    }
512
513    #[doc(alias = "row-selected")]
514    pub fn connect_row_selected<F: Fn(&Self, Option<&ListBoxRow>) + 'static>(
515        &self,
516        f: F,
517    ) -> SignalHandlerId {
518        unsafe extern "C" fn row_selected_trampoline<
519            F: Fn(&ListBox, Option<&ListBoxRow>) + 'static,
520        >(
521            this: *mut ffi::GtkListBox,
522            row: *mut ffi::GtkListBoxRow,
523            f: glib::ffi::gpointer,
524        ) {
525            let f: &F = &*(f as *const F);
526            f(
527                &from_glib_borrow(this),
528                Option::<ListBoxRow>::from_glib_borrow(row)
529                    .as_ref()
530                    .as_ref(),
531            )
532        }
533        unsafe {
534            let f: Box_<F> = Box_::new(f);
535            connect_raw(
536                self.as_ptr() as *mut _,
537                c"row-selected".as_ptr() as *const _,
538                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
539                    row_selected_trampoline::<F> as *const (),
540                )),
541                Box_::into_raw(f),
542            )
543        }
544    }
545
546    #[doc(alias = "select-all")]
547    pub fn connect_select_all<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
548        unsafe extern "C" fn select_all_trampoline<F: Fn(&ListBox) + 'static>(
549            this: *mut ffi::GtkListBox,
550            f: glib::ffi::gpointer,
551        ) {
552            let f: &F = &*(f as *const F);
553            f(&from_glib_borrow(this))
554        }
555        unsafe {
556            let f: Box_<F> = Box_::new(f);
557            connect_raw(
558                self.as_ptr() as *mut _,
559                c"select-all".as_ptr() as *const _,
560                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
561                    select_all_trampoline::<F> as *const (),
562                )),
563                Box_::into_raw(f),
564            )
565        }
566    }
567
568    pub fn emit_select_all(&self) {
569        self.emit_by_name::<()>("select-all", &[]);
570    }
571
572    #[doc(alias = "selected-rows-changed")]
573    pub fn connect_selected_rows_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
574        unsafe extern "C" fn selected_rows_changed_trampoline<F: Fn(&ListBox) + 'static>(
575            this: *mut ffi::GtkListBox,
576            f: glib::ffi::gpointer,
577        ) {
578            let f: &F = &*(f as *const F);
579            f(&from_glib_borrow(this))
580        }
581        unsafe {
582            let f: Box_<F> = Box_::new(f);
583            connect_raw(
584                self.as_ptr() as *mut _,
585                c"selected-rows-changed".as_ptr() as *const _,
586                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
587                    selected_rows_changed_trampoline::<F> as *const (),
588                )),
589                Box_::into_raw(f),
590            )
591        }
592    }
593
594    #[doc(alias = "toggle-cursor-row")]
595    pub fn connect_toggle_cursor_row<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
596        unsafe extern "C" fn toggle_cursor_row_trampoline<F: Fn(&ListBox) + 'static>(
597            this: *mut ffi::GtkListBox,
598            f: glib::ffi::gpointer,
599        ) {
600            let f: &F = &*(f as *const F);
601            f(&from_glib_borrow(this))
602        }
603        unsafe {
604            let f: Box_<F> = Box_::new(f);
605            connect_raw(
606                self.as_ptr() as *mut _,
607                c"toggle-cursor-row".as_ptr() as *const _,
608                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
609                    toggle_cursor_row_trampoline::<F> as *const (),
610                )),
611                Box_::into_raw(f),
612            )
613        }
614    }
615
616    pub fn emit_toggle_cursor_row(&self) {
617        self.emit_by_name::<()>("toggle-cursor-row", &[]);
618    }
619
620    #[doc(alias = "unselect-all")]
621    pub fn connect_unselect_all<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
622        unsafe extern "C" fn unselect_all_trampoline<F: Fn(&ListBox) + 'static>(
623            this: *mut ffi::GtkListBox,
624            f: glib::ffi::gpointer,
625        ) {
626            let f: &F = &*(f as *const F);
627            f(&from_glib_borrow(this))
628        }
629        unsafe {
630            let f: Box_<F> = Box_::new(f);
631            connect_raw(
632                self.as_ptr() as *mut _,
633                c"unselect-all".as_ptr() as *const _,
634                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
635                    unselect_all_trampoline::<F> as *const (),
636                )),
637                Box_::into_raw(f),
638            )
639        }
640    }
641
642    pub fn emit_unselect_all(&self) {
643        self.emit_by_name::<()>("unselect-all", &[]);
644    }
645
646    #[doc(alias = "accept-unpaired-release")]
647    pub fn connect_accept_unpaired_release_notify<F: Fn(&Self) + 'static>(
648        &self,
649        f: F,
650    ) -> SignalHandlerId {
651        unsafe extern "C" fn notify_accept_unpaired_release_trampoline<
652            F: Fn(&ListBox) + 'static,
653        >(
654            this: *mut ffi::GtkListBox,
655            _param_spec: glib::ffi::gpointer,
656            f: glib::ffi::gpointer,
657        ) {
658            let f: &F = &*(f as *const F);
659            f(&from_glib_borrow(this))
660        }
661        unsafe {
662            let f: Box_<F> = Box_::new(f);
663            connect_raw(
664                self.as_ptr() as *mut _,
665                c"notify::accept-unpaired-release".as_ptr() as *const _,
666                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
667                    notify_accept_unpaired_release_trampoline::<F> as *const (),
668                )),
669                Box_::into_raw(f),
670            )
671        }
672    }
673
674    #[doc(alias = "activate-on-single-click")]
675    pub fn connect_activate_on_single_click_notify<F: Fn(&Self) + 'static>(
676        &self,
677        f: F,
678    ) -> SignalHandlerId {
679        unsafe extern "C" fn notify_activate_on_single_click_trampoline<
680            F: Fn(&ListBox) + 'static,
681        >(
682            this: *mut ffi::GtkListBox,
683            _param_spec: glib::ffi::gpointer,
684            f: glib::ffi::gpointer,
685        ) {
686            let f: &F = &*(f as *const F);
687            f(&from_glib_borrow(this))
688        }
689        unsafe {
690            let f: Box_<F> = Box_::new(f);
691            connect_raw(
692                self.as_ptr() as *mut _,
693                c"notify::activate-on-single-click".as_ptr() as *const _,
694                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
695                    notify_activate_on_single_click_trampoline::<F> as *const (),
696                )),
697                Box_::into_raw(f),
698            )
699        }
700    }
701
702    #[doc(alias = "selection-mode")]
703    pub fn connect_selection_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
704        unsafe extern "C" fn notify_selection_mode_trampoline<F: Fn(&ListBox) + 'static>(
705            this: *mut ffi::GtkListBox,
706            _param_spec: glib::ffi::gpointer,
707            f: glib::ffi::gpointer,
708        ) {
709            let f: &F = &*(f as *const F);
710            f(&from_glib_borrow(this))
711        }
712        unsafe {
713            let f: Box_<F> = Box_::new(f);
714            connect_raw(
715                self.as_ptr() as *mut _,
716                c"notify::selection-mode".as_ptr() as *const _,
717                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
718                    notify_selection_mode_trampoline::<F> as *const (),
719                )),
720                Box_::into_raw(f),
721            )
722        }
723    }
724
725    #[doc(alias = "show-separators")]
726    pub fn connect_show_separators_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
727        unsafe extern "C" fn notify_show_separators_trampoline<F: Fn(&ListBox) + 'static>(
728            this: *mut ffi::GtkListBox,
729            _param_spec: glib::ffi::gpointer,
730            f: glib::ffi::gpointer,
731        ) {
732            let f: &F = &*(f as *const F);
733            f(&from_glib_borrow(this))
734        }
735        unsafe {
736            let f: Box_<F> = Box_::new(f);
737            connect_raw(
738                self.as_ptr() as *mut _,
739                c"notify::show-separators".as_ptr() as *const _,
740                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
741                    notify_show_separators_trampoline::<F> as *const (),
742                )),
743                Box_::into_raw(f),
744            )
745        }
746    }
747
748    #[cfg(feature = "v4_18")]
749    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
750    #[doc(alias = "tab-behavior")]
751    pub fn connect_tab_behavior_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
752        unsafe extern "C" fn notify_tab_behavior_trampoline<F: Fn(&ListBox) + 'static>(
753            this: *mut ffi::GtkListBox,
754            _param_spec: glib::ffi::gpointer,
755            f: glib::ffi::gpointer,
756        ) {
757            let f: &F = &*(f as *const F);
758            f(&from_glib_borrow(this))
759        }
760        unsafe {
761            let f: Box_<F> = Box_::new(f);
762            connect_raw(
763                self.as_ptr() as *mut _,
764                c"notify::tab-behavior".as_ptr() as *const _,
765                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
766                    notify_tab_behavior_trampoline::<F> as *const (),
767                )),
768                Box_::into_raw(f),
769            )
770        }
771    }
772}
773
774impl Default for ListBox {
775    fn default() -> Self {
776        Self::new()
777    }
778}
779
780// rustdoc-stripper-ignore-next
781/// A [builder-pattern] type to construct [`ListBox`] objects.
782///
783/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
784#[must_use = "The builder must be built to be used"]
785pub struct ListBoxBuilder {
786    builder: glib::object::ObjectBuilder<'static, ListBox>,
787}
788
789impl ListBoxBuilder {
790    fn new() -> Self {
791        Self {
792            builder: glib::object::Object::builder(),
793        }
794    }
795
796    pub fn accept_unpaired_release(self, accept_unpaired_release: bool) -> Self {
797        Self {
798            builder: self
799                .builder
800                .property("accept-unpaired-release", accept_unpaired_release),
801        }
802    }
803
804    pub fn activate_on_single_click(self, activate_on_single_click: bool) -> Self {
805        Self {
806            builder: self
807                .builder
808                .property("activate-on-single-click", activate_on_single_click),
809        }
810    }
811
812    pub fn selection_mode(self, selection_mode: SelectionMode) -> Self {
813        Self {
814            builder: self.builder.property("selection-mode", selection_mode),
815        }
816    }
817
818    pub fn show_separators(self, show_separators: bool) -> Self {
819        Self {
820            builder: self.builder.property("show-separators", show_separators),
821        }
822    }
823
824    #[cfg(feature = "v4_18")]
825    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
826    pub fn tab_behavior(self, tab_behavior: ListTabBehavior) -> Self {
827        Self {
828            builder: self.builder.property("tab-behavior", tab_behavior),
829        }
830    }
831
832    pub fn can_focus(self, can_focus: bool) -> Self {
833        Self {
834            builder: self.builder.property("can-focus", can_focus),
835        }
836    }
837
838    pub fn can_target(self, can_target: bool) -> Self {
839        Self {
840            builder: self.builder.property("can-target", can_target),
841        }
842    }
843
844    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
845        Self {
846            builder: self.builder.property("css-classes", css_classes.into()),
847        }
848    }
849
850    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
851        Self {
852            builder: self.builder.property("css-name", css_name.into()),
853        }
854    }
855
856    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
857        Self {
858            builder: self.builder.property("cursor", cursor.clone()),
859        }
860    }
861
862    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
863        Self {
864            builder: self.builder.property("focus-on-click", focus_on_click),
865        }
866    }
867
868    pub fn focusable(self, focusable: bool) -> Self {
869        Self {
870            builder: self.builder.property("focusable", focusable),
871        }
872    }
873
874    pub fn halign(self, halign: Align) -> Self {
875        Self {
876            builder: self.builder.property("halign", halign),
877        }
878    }
879
880    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
881        Self {
882            builder: self.builder.property("has-tooltip", has_tooltip),
883        }
884    }
885
886    pub fn height_request(self, height_request: i32) -> Self {
887        Self {
888            builder: self.builder.property("height-request", height_request),
889        }
890    }
891
892    pub fn hexpand(self, hexpand: bool) -> Self {
893        Self {
894            builder: self.builder.property("hexpand", hexpand),
895        }
896    }
897
898    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
899        Self {
900            builder: self.builder.property("hexpand-set", hexpand_set),
901        }
902    }
903
904    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
905        Self {
906            builder: self
907                .builder
908                .property("layout-manager", layout_manager.clone().upcast()),
909        }
910    }
911
912    #[cfg(feature = "v4_18")]
913    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
914    pub fn limit_events(self, limit_events: bool) -> Self {
915        Self {
916            builder: self.builder.property("limit-events", limit_events),
917        }
918    }
919
920    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
921        Self {
922            builder: self.builder.property("margin-bottom", margin_bottom),
923        }
924    }
925
926    pub fn margin_end(self, margin_end: i32) -> Self {
927        Self {
928            builder: self.builder.property("margin-end", margin_end),
929        }
930    }
931
932    pub fn margin_start(self, margin_start: i32) -> Self {
933        Self {
934            builder: self.builder.property("margin-start", margin_start),
935        }
936    }
937
938    pub fn margin_top(self, margin_top: i32) -> Self {
939        Self {
940            builder: self.builder.property("margin-top", margin_top),
941        }
942    }
943
944    pub fn name(self, name: impl Into<glib::GString>) -> Self {
945        Self {
946            builder: self.builder.property("name", name.into()),
947        }
948    }
949
950    pub fn opacity(self, opacity: f64) -> Self {
951        Self {
952            builder: self.builder.property("opacity", opacity),
953        }
954    }
955
956    pub fn overflow(self, overflow: Overflow) -> Self {
957        Self {
958            builder: self.builder.property("overflow", overflow),
959        }
960    }
961
962    pub fn receives_default(self, receives_default: bool) -> Self {
963        Self {
964            builder: self.builder.property("receives-default", receives_default),
965        }
966    }
967
968    pub fn sensitive(self, sensitive: bool) -> Self {
969        Self {
970            builder: self.builder.property("sensitive", sensitive),
971        }
972    }
973
974    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
975        Self {
976            builder: self
977                .builder
978                .property("tooltip-markup", tooltip_markup.into()),
979        }
980    }
981
982    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
983        Self {
984            builder: self.builder.property("tooltip-text", tooltip_text.into()),
985        }
986    }
987
988    pub fn valign(self, valign: Align) -> Self {
989        Self {
990            builder: self.builder.property("valign", valign),
991        }
992    }
993
994    pub fn vexpand(self, vexpand: bool) -> Self {
995        Self {
996            builder: self.builder.property("vexpand", vexpand),
997        }
998    }
999
1000    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1001        Self {
1002            builder: self.builder.property("vexpand-set", vexpand_set),
1003        }
1004    }
1005
1006    pub fn visible(self, visible: bool) -> Self {
1007        Self {
1008            builder: self.builder.property("visible", visible),
1009        }
1010    }
1011
1012    pub fn width_request(self, width_request: i32) -> Self {
1013        Self {
1014            builder: self.builder.property("width-request", width_request),
1015        }
1016    }
1017
1018    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1019        Self {
1020            builder: self.builder.property("accessible-role", accessible_role),
1021        }
1022    }
1023
1024    // rustdoc-stripper-ignore-next
1025    /// Build the [`ListBox`].
1026    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1027    pub fn build(self) -> ListBox {
1028        assert_initialized_main_thread!();
1029        self.builder.build()
1030    }
1031}