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