gtk4/auto/tree_sortable.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#![allow(deprecated)]
5
6use crate::{ffi, TreeModel};
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 /// There is no replacement for this interface. You should
17 /// use [`SortListModel`][crate::SortListModel] to wrap your list model instead
18 /// The interface for sortable models used by GtkTreeView
19 ///
20 /// [`TreeSortable`][crate::TreeSortable] is an interface to be implemented by tree models which
21 /// support sorting. The [`TreeView`][crate::TreeView] uses the methods provided by this interface
22 /// to sort the model.
23 ///
24 /// ## Signals
25 ///
26 ///
27 /// #### `sort-column-changed`
28 /// The ::sort-column-changed signal is emitted when the sort column
29 /// or sort order of @sortable is changed. The signal is emitted before
30 /// the contents of @sortable are resorted.
31 ///
32 ///
33 /// <details><summary><h4>TreeModel</h4></summary>
34 ///
35 ///
36 /// #### `row-changed`
37 /// This signal is emitted when a row in the model has changed.
38 ///
39 ///
40 ///
41 ///
42 /// #### `row-deleted`
43 /// This signal is emitted when a row has been deleted.
44 ///
45 /// Note that no iterator is passed to the signal handler,
46 /// since the row is already deleted.
47 ///
48 /// This should be called by models after a row has been removed.
49 /// The location pointed to by @path should be the location that
50 /// the row previously was at. It may not be a valid location anymore.
51 ///
52 ///
53 ///
54 ///
55 /// #### `row-has-child-toggled`
56 /// This signal is emitted when a row has gotten the first child
57 /// row or lost its last child row.
58 ///
59 ///
60 ///
61 ///
62 /// #### `row-inserted`
63 /// This signal is emitted when a new row has been inserted in
64 /// the model.
65 ///
66 /// Note that the row may still be empty at this point, since
67 /// it is a common pattern to first insert an empty row, and
68 /// then fill it with the desired values.
69 ///
70 ///
71 ///
72 ///
73 /// #### `rows-reordered`
74 /// This signal is emitted when the children of a node in the
75 /// [`TreeModel`][crate::TreeModel] have been reordered.
76 ///
77 /// Note that this signal is not emitted
78 /// when rows are reordered by DND, since this is implemented
79 /// by removing and then reinserting the row.
80 ///
81 ///
82 /// </details>
83 ///
84 /// # Implements
85 ///
86 /// [`TreeSortableExt`][trait@crate::prelude::TreeSortableExt], [`TreeModelExt`][trait@crate::prelude::TreeModelExt], [`TreeSortableExtManual`][trait@crate::prelude::TreeSortableExtManual], [`TreeModelExtManual`][trait@crate::prelude::TreeModelExtManual]
87 #[doc(alias = "GtkTreeSortable")]
88 pub struct TreeSortable(Interface<ffi::GtkTreeSortable, ffi::GtkTreeSortableIface>) @requires TreeModel;
89
90 match fn {
91 type_ => || ffi::gtk_tree_sortable_get_type(),
92 }
93}
94
95impl TreeSortable {
96 pub const NONE: Option<&'static TreeSortable> = None;
97}
98
99mod sealed {
100 pub trait Sealed {}
101 impl<T: super::IsA<super::TreeSortable>> Sealed for T {}
102}
103
104/// Trait containing all [`struct@TreeSortable`] methods.
105///
106/// # Implementors
107///
108/// [`ListStore`][struct@crate::ListStore], [`TreeModelSort`][struct@crate::TreeModelSort], [`TreeSortable`][struct@crate::TreeSortable], [`TreeStore`][struct@crate::TreeStore]
109pub trait TreeSortableExt: IsA<TreeSortable> + sealed::Sealed + 'static {
110 /// Returns [`true`] if the model has a default sort function. This is used
111 /// primarily by GtkTreeViewColumns in order to determine if a model can
112 /// go back to the default state, or not.
113 ///
114 /// # Deprecated since 4.10
115 ///
116 ///
117 /// # Returns
118 ///
119 /// [`true`], if the model has a default sort function
120 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
121 #[allow(deprecated)]
122 #[doc(alias = "gtk_tree_sortable_has_default_sort_func")]
123 fn has_default_sort_func(&self) -> bool {
124 unsafe {
125 from_glib(ffi::gtk_tree_sortable_has_default_sort_func(
126 self.as_ref().to_glib_none().0,
127 ))
128 }
129 }
130
131 /// Emits a `GtkTreeSortable::sort-column-changed` signal on @self.
132 ///
133 /// # Deprecated since 4.10
134 ///
135 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
136 #[allow(deprecated)]
137 #[doc(alias = "gtk_tree_sortable_sort_column_changed")]
138 fn sort_column_changed(&self) {
139 unsafe {
140 ffi::gtk_tree_sortable_sort_column_changed(self.as_ref().to_glib_none().0);
141 }
142 }
143
144 /// The ::sort-column-changed signal is emitted when the sort column
145 /// or sort order of @sortable is changed. The signal is emitted before
146 /// the contents of @sortable are resorted.
147 #[doc(alias = "sort-column-changed")]
148 fn connect_sort_column_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
149 unsafe extern "C" fn sort_column_changed_trampoline<
150 P: IsA<TreeSortable>,
151 F: Fn(&P) + 'static,
152 >(
153 this: *mut ffi::GtkTreeSortable,
154 f: glib::ffi::gpointer,
155 ) {
156 let f: &F = &*(f as *const F);
157 f(TreeSortable::from_glib_borrow(this).unsafe_cast_ref())
158 }
159 unsafe {
160 let f: Box_<F> = Box_::new(f);
161 connect_raw(
162 self.as_ptr() as *mut _,
163 b"sort-column-changed\0".as_ptr() as *const _,
164 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
165 sort_column_changed_trampoline::<Self, F> as *const (),
166 )),
167 Box_::into_raw(f),
168 )
169 }
170 }
171}
172
173impl<O: IsA<TreeSortable>> TreeSortableExt for O {}