gtk4/auto/
tree_path.rs
1use crate::ffi;
6use glib::translate::*;
7
8glib::wrapper! {
9 #[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 #[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 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
52 #[allow(deprecated)]
53 #[doc(alias = "gtk_tree_path_new_first")]
54 pub fn new_first() -> TreePath {
55 assert_initialized_main_thread!();
56 unsafe { from_glib_full(ffi::gtk_tree_path_new_first()) }
57 }
58
59 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
70 #[allow(deprecated)]
71 #[doc(alias = "gtk_tree_path_new_from_indicesv")]
72 #[doc(alias = "new_from_indicesv")]
73 pub fn from_indices(indices: &[i32]) -> TreePath {
74 assert_initialized_main_thread!();
75 let length = indices.len() as _;
76 unsafe {
77 from_glib_full(ffi::gtk_tree_path_new_from_indicesv(
78 indices.to_glib_none().0,
79 length,
80 ))
81 }
82 }
83
84 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
101 #[allow(deprecated)]
102 #[doc(alias = "gtk_tree_path_new_from_string")]
103 #[doc(alias = "new_from_string")]
104 pub fn from_string(path: &str) -> Option<TreePath> {
105 assert_initialized_main_thread!();
106 unsafe { from_glib_full(ffi::gtk_tree_path_new_from_string(path.to_glib_none().0)) }
107 }
108
109 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
118 #[allow(deprecated)]
119 #[doc(alias = "gtk_tree_path_append_index")]
120 pub fn append_index(&mut self, index_: i32) {
121 unsafe {
122 ffi::gtk_tree_path_append_index(self.to_glib_none_mut().0, index_);
123 }
124 }
125
126 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
127 #[allow(deprecated)]
128 #[doc(alias = "gtk_tree_path_compare")]
129 fn compare(&self, b: &TreePath) -> i32 {
130 unsafe { ffi::gtk_tree_path_compare(self.to_glib_none().0, b.to_glib_none().0) }
131 }
132
133 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
138 #[allow(deprecated)]
139 #[doc(alias = "gtk_tree_path_down")]
140 pub fn down(&mut self) {
141 unsafe {
142 ffi::gtk_tree_path_down(self.to_glib_none_mut().0);
143 }
144 }
145
146 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
155 #[allow(deprecated)]
156 #[doc(alias = "gtk_tree_path_get_depth")]
157 #[doc(alias = "get_depth")]
158 pub fn depth(&self) -> i32 {
159 unsafe { ffi::gtk_tree_path_get_depth(mut_override(self.to_glib_none().0)) }
160 }
161
162 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
173 #[allow(deprecated)]
174 #[doc(alias = "gtk_tree_path_is_ancestor")]
175 pub fn is_ancestor(&self, descendant: &TreePath) -> bool {
176 unsafe {
177 from_glib(ffi::gtk_tree_path_is_ancestor(
178 mut_override(self.to_glib_none().0),
179 mut_override(descendant.to_glib_none().0),
180 ))
181 }
182 }
183
184 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
195 #[allow(deprecated)]
196 #[doc(alias = "gtk_tree_path_is_descendant")]
197 pub fn is_descendant(&self, ancestor: &TreePath) -> bool {
198 unsafe {
199 from_glib(ffi::gtk_tree_path_is_descendant(
200 mut_override(self.to_glib_none().0),
201 mut_override(ancestor.to_glib_none().0),
202 ))
203 }
204 }
205
206 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
211 #[allow(deprecated)]
212 #[doc(alias = "gtk_tree_path_next")]
213 pub fn next(&mut self) {
214 unsafe {
215 ffi::gtk_tree_path_next(self.to_glib_none_mut().0);
216 }
217 }
218
219 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
228 #[allow(deprecated)]
229 #[doc(alias = "gtk_tree_path_prepend_index")]
230 pub fn prepend_index(&mut self, index_: i32) {
231 unsafe {
232 ffi::gtk_tree_path_prepend_index(self.to_glib_none_mut().0, index_);
233 }
234 }
235
236 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
247 #[allow(deprecated)]
248 #[doc(alias = "gtk_tree_path_prev")]
249 pub fn prev(&mut self) -> bool {
250 unsafe { from_glib(ffi::gtk_tree_path_prev(self.to_glib_none_mut().0)) }
251 }
252
253 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
267 #[allow(deprecated)]
268 #[doc(alias = "gtk_tree_path_to_string")]
269 #[doc(alias = "to_string")]
270 pub fn to_str(&self) -> Option<glib::GString> {
271 unsafe {
272 from_glib_full(ffi::gtk_tree_path_to_string(mut_override(
273 self.to_glib_none().0,
274 )))
275 }
276 }
277
278 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
287 #[allow(deprecated)]
288 #[doc(alias = "gtk_tree_path_up")]
289 pub fn up(&mut self) -> bool {
290 unsafe { from_glib(ffi::gtk_tree_path_up(self.to_glib_none_mut().0)) }
291 }
292}
293
294impl Default for TreePath {
295 fn default() -> Self {
296 Self::new()
297 }
298}
299
300impl PartialEq for TreePath {
301 #[inline]
302 fn eq(&self, other: &Self) -> bool {
303 self.compare(other) == 0
304 }
305}
306
307impl Eq for TreePath {}
308
309impl PartialOrd for TreePath {
310 #[inline]
311 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
312 Some(self.cmp(other))
313 }
314}
315
316impl Ord for TreePath {
317 #[inline]
318 fn cmp(&self, other: &Self) -> std::cmp::Ordering {
319 self.compare(other).cmp(&0)
320 }
321}