gtk4/auto/multi_sorter.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{ffi, Buildable, Sorter};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 /// Combines multiple sorters by trying them in turn.
10 ///
11 /// If the first sorter compares two items as equal,
12 /// the second is tried next, and so on.
13 ///
14 /// ## Properties
15 ///
16 ///
17 /// #### `item-type`
18 /// The type of items. See [`ListModelExtManual::item_type()`][crate::gio::prelude::ListModelExtManual::item_type()].
19 ///
20 /// Readable
21 ///
22 ///
23 /// #### `n-items`
24 /// The number of items. See [`ListModelExtManual::n_items()`][crate::gio::prelude::ListModelExtManual::n_items()].
25 ///
26 /// Readable
27 ///
28 /// # Implements
29 ///
30 /// [`SorterExt`][trait@crate::prelude::SorterExt], [`trait@glib::ObjectExt`], [`trait@gio::prelude::ListModelExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt]
31 #[doc(alias = "GtkMultiSorter")]
32 pub struct MultiSorter(Object<ffi::GtkMultiSorter, ffi::GtkMultiSorterClass>) @extends Sorter, @implements gio::ListModel, Buildable;
33
34 match fn {
35 type_ => || ffi::gtk_multi_sorter_get_type(),
36 }
37}
38
39impl MultiSorter {
40 /// Creates a new multi sorter.
41 ///
42 /// This sorter compares items by trying each of the sorters
43 /// in turn, until one returns non-zero. In particular, if
44 /// no sorter has been added to it, it will always compare
45 /// items as equal.
46 ///
47 /// # Returns
48 ///
49 /// a new [`MultiSorter`][crate::MultiSorter]
50 #[doc(alias = "gtk_multi_sorter_new")]
51 pub fn new() -> MultiSorter {
52 assert_initialized_main_thread!();
53 unsafe { from_glib_full(ffi::gtk_multi_sorter_new()) }
54 }
55
56 /// Add @sorter to @self to use for sorting at the end.
57 ///
58 /// @self will consult all existing sorters before it will
59 /// sort with the given @sorter.
60 /// ## `sorter`
61 /// a sorter to add
62 #[doc(alias = "gtk_multi_sorter_append")]
63 pub fn append(&self, sorter: impl IsA<Sorter>) {
64 unsafe {
65 ffi::gtk_multi_sorter_append(self.to_glib_none().0, sorter.upcast().into_glib_ptr());
66 }
67 }
68
69 /// Removes the sorter at the given @position from the list of sorter
70 /// used by @self.
71 ///
72 /// If @position is larger than the number of sorters, nothing happens.
73 /// ## `position`
74 /// position of sorter to remove
75 #[doc(alias = "gtk_multi_sorter_remove")]
76 pub fn remove(&self, position: u32) {
77 unsafe {
78 ffi::gtk_multi_sorter_remove(self.to_glib_none().0, position);
79 }
80 }
81}
82
83impl Default for MultiSorter {
84 fn default() -> Self {
85 Self::new()
86 }
87}