gtk4/auto/tree_model_sort.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::{TreeDragSource, TreeIter, TreeModel, TreePath, TreeSortable, ffi};
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10 /// Use [`SortListModel`][crate::SortListModel] instead
11 /// modified_data,
12 /// -1);
13 /// g_free (modified_data);
14 /// }
15 /// ```text
16 ///
17 ///
18 /// ## Properties
19 ///
20 ///
21 /// #### `model`
22 /// The model of the tree model sort.
23 ///
24 /// Readable | Writable | Construct Only
25 ///
26 /// # Implements
27 ///
28 /// [`TreeModelSortExt`][trait@crate::prelude::TreeModelSortExt], [`trait@glib::ObjectExt`], [`TreeDragSourceExt`][trait@crate::prelude::TreeDragSourceExt], [`TreeModelExt`][trait@crate::prelude::TreeModelExt], [`TreeSortableExt`][trait@crate::prelude::TreeSortableExt], [`TreeModelExtManual`][trait@crate::prelude::TreeModelExtManual], [`TreeSortableExtManual`][trait@crate::prelude::TreeSortableExtManual]
29 #[doc(alias = "GtkTreeModelSort")]
30 pub struct TreeModelSort(Object<ffi::GtkTreeModelSort, ffi::GtkTreeModelSortClass>) @implements TreeDragSource, TreeModel, TreeSortable;
31
32 match fn {
33 type_ => || ffi::gtk_tree_model_sort_get_type(),
34 }
35}
36
37impl TreeModelSort {
38 pub const NONE: Option<&'static TreeModelSort> = None;
39
40 /// Creates a new [`TreeModelSort`][crate::TreeModelSort], with @child_model as the child model.
41 ///
42 /// # Deprecated since 4.10
43 ///
44 /// ## `child_model`
45 /// A [`TreeModel`][crate::TreeModel]
46 ///
47 /// # Returns
48 ///
49 /// A new [`TreeModelSort`][crate::TreeModelSort].
50 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
51 #[allow(deprecated)]
52 #[doc(alias = "gtk_tree_model_sort_new_with_model")]
53 #[doc(alias = "new_with_model")]
54 pub fn with_model(child_model: &impl IsA<TreeModel>) -> TreeModelSort {
55 skip_assert_initialized!();
56 unsafe {
57 from_glib_full(ffi::gtk_tree_model_sort_new_with_model(
58 child_model.as_ref().to_glib_none().0,
59 ))
60 }
61 }
62}
63
64/// Trait containing all [`struct@TreeModelSort`] methods.
65///
66/// # Implementors
67///
68/// [`TreeModelSort`][struct@crate::TreeModelSort]
69pub trait TreeModelSortExt: IsA<TreeModelSort> + 'static {
70 /// This function should almost never be called. It clears the @self
71 /// of any cached iterators that haven’t been reffed with
72 /// gtk_tree_model_ref_node(). This might be useful if the child model being
73 /// sorted is static (and doesn’t change often) and there has been a lot of
74 /// unreffed access to nodes. As a side effect of this function, all unreffed
75 /// iters will be invalid.
76 ///
77 /// # Deprecated since 4.10
78 ///
79 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
80 #[allow(deprecated)]
81 #[doc(alias = "gtk_tree_model_sort_clear_cache")]
82 fn clear_cache(&self) {
83 unsafe {
84 ffi::gtk_tree_model_sort_clear_cache(self.as_ref().to_glib_none().0);
85 }
86 }
87
88 /// Sets @sort_iter to point to the row in @self that corresponds to
89 /// the row pointed at by @child_iter. If @sort_iter was not set, [`false`]
90 /// is returned. Note: a boolean is only returned since 2.14.
91 ///
92 /// # Deprecated since 4.10
93 ///
94 /// ## `child_iter`
95 /// A valid [`TreeIter`][crate::TreeIter] pointing to a row on the child model
96 ///
97 /// # Returns
98 ///
99 /// [`true`], if @sort_iter was set, i.e. if @sort_iter is a
100 /// valid iterator pointer to a visible row in the child model.
101 ///
102 /// ## `sort_iter`
103 /// An uninitialized [`TreeIter`][crate::TreeIter]
104 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
105 #[allow(deprecated)]
106 #[doc(alias = "gtk_tree_model_sort_convert_child_iter_to_iter")]
107 fn convert_child_iter_to_iter(&self, child_iter: &TreeIter) -> Option<TreeIter> {
108 unsafe {
109 let mut sort_iter = TreeIter::uninitialized();
110 let ret = from_glib(ffi::gtk_tree_model_sort_convert_child_iter_to_iter(
111 self.as_ref().to_glib_none().0,
112 sort_iter.to_glib_none_mut().0,
113 mut_override(child_iter.to_glib_none().0),
114 ));
115 if ret { Some(sort_iter) } else { None }
116 }
117 }
118
119 /// Converts @child_path to a path relative to @self. That is,
120 /// @child_path points to a path in the child model. The returned path will
121 /// point to the same row in the sorted model. If @child_path isn’t a valid
122 /// path on the child model, then [`None`] is returned.
123 ///
124 /// # Deprecated since 4.10
125 ///
126 /// ## `child_path`
127 /// A [`TreePath`][crate::TreePath] to convert
128 ///
129 /// # Returns
130 ///
131 /// A newly allocated [`TreePath`][crate::TreePath]
132 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
133 #[allow(deprecated)]
134 #[doc(alias = "gtk_tree_model_sort_convert_child_path_to_path")]
135 fn convert_child_path_to_path(&self, child_path: &TreePath) -> Option<TreePath> {
136 unsafe {
137 from_glib_full(ffi::gtk_tree_model_sort_convert_child_path_to_path(
138 self.as_ref().to_glib_none().0,
139 mut_override(child_path.to_glib_none().0),
140 ))
141 }
142 }
143
144 /// Sets @child_iter to point to the row pointed to by @sorted_iter.
145 ///
146 /// # Deprecated since 4.10
147 ///
148 /// ## `sorted_iter`
149 /// A valid [`TreeIter`][crate::TreeIter] pointing to a row on @self.
150 ///
151 /// # Returns
152 ///
153 ///
154 /// ## `child_iter`
155 /// An uninitialized [`TreeIter`][crate::TreeIter]
156 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
157 #[allow(deprecated)]
158 #[doc(alias = "gtk_tree_model_sort_convert_iter_to_child_iter")]
159 fn convert_iter_to_child_iter(&self, sorted_iter: &TreeIter) -> TreeIter {
160 unsafe {
161 let mut child_iter = TreeIter::uninitialized();
162 ffi::gtk_tree_model_sort_convert_iter_to_child_iter(
163 self.as_ref().to_glib_none().0,
164 child_iter.to_glib_none_mut().0,
165 mut_override(sorted_iter.to_glib_none().0),
166 );
167 child_iter
168 }
169 }
170
171 /// Converts @sorted_path to a path on the child model of @self.
172 /// That is, @sorted_path points to a location in @self. The
173 /// returned path will point to the same location in the model not being
174 /// sorted. If @sorted_path does not point to a location in the child model,
175 /// [`None`] is returned.
176 ///
177 /// # Deprecated since 4.10
178 ///
179 /// ## `sorted_path`
180 /// A [`TreePath`][crate::TreePath] to convert
181 ///
182 /// # Returns
183 ///
184 /// A newly allocated [`TreePath`][crate::TreePath]
185 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
186 #[allow(deprecated)]
187 #[doc(alias = "gtk_tree_model_sort_convert_path_to_child_path")]
188 fn convert_path_to_child_path(&self, sorted_path: &TreePath) -> Option<TreePath> {
189 unsafe {
190 from_glib_full(ffi::gtk_tree_model_sort_convert_path_to_child_path(
191 self.as_ref().to_glib_none().0,
192 mut_override(sorted_path.to_glib_none().0),
193 ))
194 }
195 }
196
197 /// Returns the model the [`TreeModelSort`][crate::TreeModelSort] is sorting.
198 ///
199 /// # Deprecated since 4.10
200 ///
201 ///
202 /// # Returns
203 ///
204 /// the "child model" being sorted
205 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
206 #[allow(deprecated)]
207 #[doc(alias = "gtk_tree_model_sort_get_model")]
208 #[doc(alias = "get_model")]
209 fn model(&self) -> TreeModel {
210 unsafe {
211 from_glib_none(ffi::gtk_tree_model_sort_get_model(
212 self.as_ref().to_glib_none().0,
213 ))
214 }
215 }
216
217 /// purposes.
218 ///
219 /// Checks if the given iter is a valid iter for this [`TreeModelSort`][crate::TreeModelSort].
220 ///
221 /// # Deprecated since 4.10
222 ///
223 /// ## `iter`
224 /// A [`TreeIter`][crate::TreeIter]
225 ///
226 /// # Returns
227 ///
228 /// [`true`] if the iter is valid, [`false`] if the iter is invalid.
229 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
230 #[allow(deprecated)]
231 #[doc(alias = "gtk_tree_model_sort_iter_is_valid")]
232 fn iter_is_valid(&self, iter: &TreeIter) -> bool {
233 unsafe {
234 from_glib(ffi::gtk_tree_model_sort_iter_is_valid(
235 self.as_ref().to_glib_none().0,
236 mut_override(iter.to_glib_none().0),
237 ))
238 }
239 }
240
241 /// This resets the default sort function to be in the “unsorted” state. That
242 /// is, it is in the same order as the child model. It will re-sort the model
243 /// to be in the same order as the child model only if the [`TreeModelSort`][crate::TreeModelSort]
244 /// is in “unsorted” state.
245 ///
246 /// # Deprecated since 4.10
247 ///
248 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
249 #[allow(deprecated)]
250 #[doc(alias = "gtk_tree_model_sort_reset_default_sort_func")]
251 fn reset_default_sort_func(&self) {
252 unsafe {
253 ffi::gtk_tree_model_sort_reset_default_sort_func(self.as_ref().to_glib_none().0);
254 }
255 }
256}
257
258impl<O: IsA<TreeModelSort>> TreeModelSortExt for O {}