Skip to main content

gtk4/auto/
tree_path.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;
6use glib::translate::*;
7
8glib::wrapper! {
9    /// An opaque structure representing a path to a row in a model.
10    ///
11    /// # Deprecated since 4.10
12    ///
13    #[derive(Debug, Hash)]
14    pub struct TreePath(Boxed<ffi::GtkTreePath>);
15
16    match fn {
17        copy => |ptr| ffi::gtk_tree_path_copy(ptr),
18        free => |ptr| ffi::gtk_tree_path_free(ptr),
19        type_ => || ffi::gtk_tree_path_get_type(),
20    }
21}
22
23impl TreePath {
24    /// Creates a new [`TreePath`][crate::TreePath]
25    /// This refers to a row.
26    ///
27    /// # Deprecated since 4.10
28    ///
29    ///
30    /// # Returns
31    ///
32    /// A newly created [`TreePath`][crate::TreePath].
33    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
34    #[allow(deprecated)]
35    #[doc(alias = "gtk_tree_path_new")]
36    pub fn new() -> TreePath {
37        assert_initialized_main_thread!();
38        unsafe { from_glib_full(ffi::gtk_tree_path_new()) }
39    }
40
41    /// .
42    ///
43    /// # Deprecated since 4.10
44    ///
45    ///
46    /// # Returns
47    ///
48    /// A new [`TreePath`][crate::TreePath]
49    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
50    #[allow(deprecated)]
51    #[doc(alias = "gtk_tree_path_new_first")]
52    pub fn new_first() -> TreePath {
53        assert_initialized_main_thread!();
54        unsafe { from_glib_full(ffi::gtk_tree_path_new_first()) }
55    }
56
57    /// Creates a new path with the given @indices array of @length.
58    ///
59    /// # Deprecated since 4.10
60    ///
61    /// ## `indices`
62    /// array of indices
63    ///
64    /// # Returns
65    ///
66    /// A newly created [`TreePath`][crate::TreePath]
67    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
68    #[allow(deprecated)]
69    #[doc(alias = "gtk_tree_path_new_from_indicesv")]
70    #[doc(alias = "new_from_indicesv")]
71    pub fn from_indices(indices: &[i32]) -> TreePath {
72        assert_initialized_main_thread!();
73        let length = indices.len() as _;
74        unsafe {
75            from_glib_full(ffi::gtk_tree_path_new_from_indicesv(
76                indices.to_glib_none().0,
77                length,
78            ))
79        }
80    }
81
82    ///  would create a path of depth
83    /// 3 pointing to the 11th child of the root node, the 5th
84    /// child of that 11th child, and the 1st child of that 5th child.
85    /// If an invalid path string is passed in, [`None`] is returned.
86    ///
87    /// # Deprecated since 4.10
88    ///
89    /// ## `path`
90    /// The string representation of a path
91    ///
92    /// # Returns
93    ///
94    /// A newly-created [`TreePath`][crate::TreePath]
95    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
96    #[allow(deprecated)]
97    #[doc(alias = "gtk_tree_path_new_from_string")]
98    #[doc(alias = "new_from_string")]
99    pub fn from_string(path: &str) -> Option<TreePath> {
100        assert_initialized_main_thread!();
101        unsafe { from_glib_full(ffi::gtk_tree_path_new_from_string(path.to_glib_none().0)) }
102    }
103
104    /// Appends a new index to a path.
105    ///
106    /// As a result, the depth of the path is increased.
107    ///
108    /// # Deprecated since 4.10
109    ///
110    /// ## `index_`
111    /// the index
112    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
113    #[allow(deprecated)]
114    #[doc(alias = "gtk_tree_path_append_index")]
115    pub fn append_index(&mut self, index_: i32) {
116        unsafe {
117            ffi::gtk_tree_path_append_index(self.to_glib_none_mut().0, index_);
118        }
119    }
120
121    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
122    #[allow(deprecated)]
123    #[doc(alias = "gtk_tree_path_compare")]
124    fn compare(&self, b: &TreePath) -> i32 {
125        unsafe { ffi::gtk_tree_path_compare(self.to_glib_none().0, b.to_glib_none().0) }
126    }
127
128    /// Moves @self to point to the first child of the current path.
129    ///
130    /// # Deprecated since 4.10
131    ///
132    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
133    #[allow(deprecated)]
134    #[doc(alias = "gtk_tree_path_down")]
135    pub fn down(&mut self) {
136        unsafe {
137            ffi::gtk_tree_path_down(self.to_glib_none_mut().0);
138        }
139    }
140
141    /// Returns the current depth of @self.
142    ///
143    /// # Deprecated since 4.10
144    ///
145    ///
146    /// # Returns
147    ///
148    /// The depth of @self
149    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
150    #[allow(deprecated)]
151    #[doc(alias = "gtk_tree_path_get_depth")]
152    #[doc(alias = "get_depth")]
153    pub fn depth(&self) -> i32 {
154        unsafe { ffi::gtk_tree_path_get_depth(mut_override(self.to_glib_none().0)) }
155    }
156
157    /// Returns [`true`] if @descendant is a descendant of @self.
158    ///
159    /// # Deprecated since 4.10
160    ///
161    /// ## `descendant`
162    /// another [`TreePath`][crate::TreePath]
163    ///
164    /// # Returns
165    ///
166    /// [`true`] if @descendant is contained inside @self
167    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
168    #[allow(deprecated)]
169    #[doc(alias = "gtk_tree_path_is_ancestor")]
170    pub fn is_ancestor(&self, descendant: &TreePath) -> bool {
171        unsafe {
172            from_glib(ffi::gtk_tree_path_is_ancestor(
173                mut_override(self.to_glib_none().0),
174                mut_override(descendant.to_glib_none().0),
175            ))
176        }
177    }
178
179    /// Returns [`true`] if @self is a descendant of @ancestor.
180    ///
181    /// # Deprecated since 4.10
182    ///
183    /// ## `ancestor`
184    /// another [`TreePath`][crate::TreePath]
185    ///
186    /// # Returns
187    ///
188    /// [`true`] if @ancestor contains @self somewhere below it
189    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
190    #[allow(deprecated)]
191    #[doc(alias = "gtk_tree_path_is_descendant")]
192    pub fn is_descendant(&self, ancestor: &TreePath) -> bool {
193        unsafe {
194            from_glib(ffi::gtk_tree_path_is_descendant(
195                mut_override(self.to_glib_none().0),
196                mut_override(ancestor.to_glib_none().0),
197            ))
198        }
199    }
200
201    /// Moves the @self to point to the next node at the current depth.
202    ///
203    /// # Deprecated since 4.10
204    ///
205    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
206    #[allow(deprecated)]
207    #[doc(alias = "gtk_tree_path_next")]
208    pub fn next(&mut self) {
209        unsafe {
210            ffi::gtk_tree_path_next(self.to_glib_none_mut().0);
211        }
212    }
213
214    /// Prepends a new index to a path.
215    ///
216    /// As a result, the depth of the path is increased.
217    ///
218    /// # Deprecated since 4.10
219    ///
220    /// ## `index_`
221    /// the index
222    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
223    #[allow(deprecated)]
224    #[doc(alias = "gtk_tree_path_prepend_index")]
225    pub fn prepend_index(&mut self, index_: i32) {
226        unsafe {
227            ffi::gtk_tree_path_prepend_index(self.to_glib_none_mut().0, index_);
228        }
229    }
230
231    /// Moves the @self to point to the previous node at the
232    /// current depth, if it exists.
233    ///
234    /// # Deprecated since 4.10
235    ///
236    ///
237    /// # Returns
238    ///
239    /// [`true`] if @self has a previous node, and
240    ///   the move was made
241    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
242    #[allow(deprecated)]
243    #[doc(alias = "gtk_tree_path_prev")]
244    pub fn prev(&mut self) -> bool {
245        unsafe { from_glib(ffi::gtk_tree_path_prev(self.to_glib_none_mut().0)) }
246    }
247
248    ///  would be an acceptable
249    /// return value for this string. If the path has
250    /// depth 0, [`None`] is returned.
251    ///
252    /// # Deprecated since 4.10
253    ///
254    ///
255    /// # Returns
256    ///
257    /// A newly-allocated string
258    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
259    #[allow(deprecated)]
260    #[doc(alias = "gtk_tree_path_to_string")]
261    #[doc(alias = "to_string")]
262    pub fn to_str(&self) -> Option<glib::GString> {
263        unsafe {
264            from_glib_full(ffi::gtk_tree_path_to_string(mut_override(
265                self.to_glib_none().0,
266            )))
267        }
268    }
269
270    /// Moves the @self to point to its parent node, if it has a parent.
271    ///
272    /// # Deprecated since 4.10
273    ///
274    ///
275    /// # Returns
276    ///
277    /// [`true`] if @self has a parent, and the move was made
278    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
279    #[allow(deprecated)]
280    #[doc(alias = "gtk_tree_path_up")]
281    pub fn up(&mut self) -> bool {
282        unsafe { from_glib(ffi::gtk_tree_path_up(self.to_glib_none_mut().0)) }
283    }
284}
285
286impl Default for TreePath {
287    fn default() -> Self {
288        Self::new()
289    }
290}
291
292impl PartialEq for TreePath {
293    #[inline]
294    fn eq(&self, other: &Self) -> bool {
295        self.compare(other) == 0
296    }
297}
298
299impl Eq for TreePath {}
300
301impl PartialOrd for TreePath {
302    #[inline]
303    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
304        Some(self.cmp(other))
305    }
306}
307
308impl Ord for TreePath {
309    #[inline]
310    fn cmp(&self, other: &Self) -> std::cmp::Ordering {
311        self.compare(other).cmp(&0)
312    }
313}