[go: up one dir, main page]

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    #[derive(Debug, Hash)]
10    pub struct TreePath(Boxed<ffi::GtkTreePath>);
11
12    match fn {
13        copy => |ptr| ffi::gtk_tree_path_copy(ptr),
14        free => |ptr| ffi::gtk_tree_path_free(ptr),
15        type_ => || ffi::gtk_tree_path_get_type(),
16    }
17}
18
19impl TreePath {
20    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
21    #[allow(deprecated)]
22    #[doc(alias = "gtk_tree_path_new")]
23    pub fn new() -> TreePath {
24        assert_initialized_main_thread!();
25        unsafe { from_glib_full(ffi::gtk_tree_path_new()) }
26    }
27
28    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
29    #[allow(deprecated)]
30    #[doc(alias = "gtk_tree_path_new_first")]
31    pub fn new_first() -> TreePath {
32        assert_initialized_main_thread!();
33        unsafe { from_glib_full(ffi::gtk_tree_path_new_first()) }
34    }
35
36    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
37    #[allow(deprecated)]
38    #[doc(alias = "gtk_tree_path_new_from_indicesv")]
39    #[doc(alias = "new_from_indicesv")]
40    pub fn from_indices(indices: &[i32]) -> TreePath {
41        assert_initialized_main_thread!();
42        let length = indices.len() as _;
43        unsafe {
44            from_glib_full(ffi::gtk_tree_path_new_from_indicesv(
45                indices.to_glib_none().0,
46                length,
47            ))
48        }
49    }
50
51    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
52    #[allow(deprecated)]
53    #[doc(alias = "gtk_tree_path_new_from_string")]
54    #[doc(alias = "new_from_string")]
55    pub fn from_string(path: &str) -> Option<TreePath> {
56        assert_initialized_main_thread!();
57        unsafe { from_glib_full(ffi::gtk_tree_path_new_from_string(path.to_glib_none().0)) }
58    }
59
60    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
61    #[allow(deprecated)]
62    #[doc(alias = "gtk_tree_path_append_index")]
63    pub fn append_index(&mut self, index_: i32) {
64        unsafe {
65            ffi::gtk_tree_path_append_index(self.to_glib_none_mut().0, index_);
66        }
67    }
68
69    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
70    #[allow(deprecated)]
71    #[doc(alias = "gtk_tree_path_compare")]
72    fn compare(&self, b: &TreePath) -> i32 {
73        unsafe { ffi::gtk_tree_path_compare(self.to_glib_none().0, b.to_glib_none().0) }
74    }
75
76    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
77    #[allow(deprecated)]
78    #[doc(alias = "gtk_tree_path_down")]
79    pub fn down(&mut self) {
80        unsafe {
81            ffi::gtk_tree_path_down(self.to_glib_none_mut().0);
82        }
83    }
84
85    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
86    #[allow(deprecated)]
87    #[doc(alias = "gtk_tree_path_get_depth")]
88    #[doc(alias = "get_depth")]
89    pub fn depth(&self) -> i32 {
90        unsafe { ffi::gtk_tree_path_get_depth(mut_override(self.to_glib_none().0)) }
91    }
92
93    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
94    #[allow(deprecated)]
95    #[doc(alias = "gtk_tree_path_is_ancestor")]
96    pub fn is_ancestor(&self, descendant: &TreePath) -> bool {
97        unsafe {
98            from_glib(ffi::gtk_tree_path_is_ancestor(
99                mut_override(self.to_glib_none().0),
100                mut_override(descendant.to_glib_none().0),
101            ))
102        }
103    }
104
105    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
106    #[allow(deprecated)]
107    #[doc(alias = "gtk_tree_path_is_descendant")]
108    pub fn is_descendant(&self, ancestor: &TreePath) -> bool {
109        unsafe {
110            from_glib(ffi::gtk_tree_path_is_descendant(
111                mut_override(self.to_glib_none().0),
112                mut_override(ancestor.to_glib_none().0),
113            ))
114        }
115    }
116
117    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
118    #[allow(deprecated)]
119    #[doc(alias = "gtk_tree_path_next")]
120    pub fn next(&mut self) {
121        unsafe {
122            ffi::gtk_tree_path_next(self.to_glib_none_mut().0);
123        }
124    }
125
126    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
127    #[allow(deprecated)]
128    #[doc(alias = "gtk_tree_path_prepend_index")]
129    pub fn prepend_index(&mut self, index_: i32) {
130        unsafe {
131            ffi::gtk_tree_path_prepend_index(self.to_glib_none_mut().0, index_);
132        }
133    }
134
135    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
136    #[allow(deprecated)]
137    #[doc(alias = "gtk_tree_path_prev")]
138    pub fn prev(&mut self) -> bool {
139        unsafe { from_glib(ffi::gtk_tree_path_prev(self.to_glib_none_mut().0)) }
140    }
141
142    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
143    #[allow(deprecated)]
144    #[doc(alias = "gtk_tree_path_to_string")]
145    #[doc(alias = "to_string")]
146    pub fn to_str(&self) -> Option<glib::GString> {
147        unsafe {
148            from_glib_full(ffi::gtk_tree_path_to_string(mut_override(
149                self.to_glib_none().0,
150            )))
151        }
152    }
153
154    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
155    #[allow(deprecated)]
156    #[doc(alias = "gtk_tree_path_up")]
157    pub fn up(&mut self) -> bool {
158        unsafe { from_glib(ffi::gtk_tree_path_up(self.to_glib_none_mut().0)) }
159    }
160}
161
162impl Default for TreePath {
163    fn default() -> Self {
164        Self::new()
165    }
166}
167
168impl PartialEq for TreePath {
169    #[inline]
170    fn eq(&self, other: &Self) -> bool {
171        self.compare(other) == 0
172    }
173}
174
175impl Eq for TreePath {}
176
177impl PartialOrd for TreePath {
178    #[inline]
179    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
180        Some(self.cmp(other))
181    }
182}
183
184impl Ord for TreePath {
185    #[inline]
186    fn cmp(&self, other: &Self) -> std::cmp::Ordering {
187        self.compare(other).cmp(&0)
188    }
189}