gtk/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 glib::translate::*;
6use std::{cmp, fmt, mem};
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    #[doc(alias = "gtk_tree_path_new")]
21    pub fn new() -> TreePath {
22        assert_initialized_main_thread!();
23        unsafe { from_glib_full(ffi::gtk_tree_path_new()) }
24    }
25
26    #[doc(alias = "gtk_tree_path_new_first")]
27    pub fn new_first() -> TreePath {
28        assert_initialized_main_thread!();
29        unsafe { from_glib_full(ffi::gtk_tree_path_new_first()) }
30    }
31
32    //#[doc(alias = "gtk_tree_path_new_from_indices")]
33    //#[doc(alias = "new_from_indices")]
34    //pub fn from_indices(first_index: i32, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> TreePath {
35    //    unsafe { TODO: call ffi:gtk_tree_path_new_from_indices() }
36    //}
37
38    #[doc(alias = "gtk_tree_path_new_from_indicesv")]
39    #[doc(alias = "new_from_indicesv")]
40    pub fn from_indicesv(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    #[doc(alias = "gtk_tree_path_new_from_string")]
52    #[doc(alias = "new_from_string")]
53    pub fn from_string(path: &str) -> TreePath {
54        assert_initialized_main_thread!();
55        unsafe { from_glib_full(ffi::gtk_tree_path_new_from_string(path.to_glib_none().0)) }
56    }
57
58    #[doc(alias = "gtk_tree_path_append_index")]
59    pub fn append_index(&mut self, index_: i32) {
60        unsafe {
61            ffi::gtk_tree_path_append_index(self.to_glib_none_mut().0, index_);
62        }
63    }
64
65    #[doc(alias = "gtk_tree_path_compare")]
66    fn compare(&self, b: &TreePath) -> i32 {
67        unsafe { ffi::gtk_tree_path_compare(self.to_glib_none().0, b.to_glib_none().0) }
68    }
69
70    #[doc(alias = "gtk_tree_path_down")]
71    pub fn down(&mut self) {
72        unsafe {
73            ffi::gtk_tree_path_down(self.to_glib_none_mut().0);
74        }
75    }
76
77    #[doc(alias = "gtk_tree_path_get_depth")]
78    #[doc(alias = "get_depth")]
79    pub fn depth(&self) -> i32 {
80        unsafe { ffi::gtk_tree_path_get_depth(mut_override(self.to_glib_none().0)) }
81    }
82
83    #[doc(alias = "gtk_tree_path_get_indices_with_depth")]
84    #[doc(alias = "get_indices_with_depth")]
85    pub fn indices_with_depth(&mut self) -> Vec<i32> {
86        unsafe {
87            let mut depth = mem::MaybeUninit::uninit();
88            let ret = FromGlibContainer::from_glib_none_num(
89                ffi::gtk_tree_path_get_indices_with_depth(
90                    self.to_glib_none_mut().0,
91                    depth.as_mut_ptr(),
92                ),
93                depth.assume_init() as _,
94            );
95            ret
96        }
97    }
98
99    #[doc(alias = "gtk_tree_path_is_ancestor")]
100    pub fn is_ancestor(&self, descendant: &TreePath) -> bool {
101        unsafe {
102            from_glib(ffi::gtk_tree_path_is_ancestor(
103                mut_override(self.to_glib_none().0),
104                mut_override(descendant.to_glib_none().0),
105            ))
106        }
107    }
108
109    #[doc(alias = "gtk_tree_path_is_descendant")]
110    pub fn is_descendant(&self, ancestor: &TreePath) -> bool {
111        unsafe {
112            from_glib(ffi::gtk_tree_path_is_descendant(
113                mut_override(self.to_glib_none().0),
114                mut_override(ancestor.to_glib_none().0),
115            ))
116        }
117    }
118
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    #[doc(alias = "gtk_tree_path_prepend_index")]
127    pub fn prepend_index(&mut self, index_: i32) {
128        unsafe {
129            ffi::gtk_tree_path_prepend_index(self.to_glib_none_mut().0, index_);
130        }
131    }
132
133    #[doc(alias = "gtk_tree_path_prev")]
134    pub fn prev(&mut self) -> bool {
135        unsafe { from_glib(ffi::gtk_tree_path_prev(self.to_glib_none_mut().0)) }
136    }
137
138    #[doc(alias = "gtk_tree_path_to_string")]
139    #[doc(alias = "to_string")]
140    pub fn to_str(&self) -> glib::GString {
141        unsafe {
142            from_glib_full(ffi::gtk_tree_path_to_string(mut_override(
143                self.to_glib_none().0,
144            )))
145        }
146    }
147
148    #[doc(alias = "gtk_tree_path_up")]
149    pub fn up(&mut self) -> bool {
150        unsafe { from_glib(ffi::gtk_tree_path_up(self.to_glib_none_mut().0)) }
151    }
152}
153
154impl Default for TreePath {
155    fn default() -> Self {
156        Self::new()
157    }
158}
159
160impl PartialEq for TreePath {
161    #[inline]
162    fn eq(&self, other: &Self) -> bool {
163        self.compare(other) == 0
164    }
165}
166
167impl Eq for TreePath {}
168
169impl PartialOrd for TreePath {
170    #[inline]
171    fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
172        self.compare(other).partial_cmp(&0)
173    }
174}
175
176impl Ord for TreePath {
177    #[inline]
178    fn cmp(&self, other: &Self) -> cmp::Ordering {
179        self.compare(other).cmp(&0)
180    }
181}
182
183impl fmt::Display for TreePath {
184    #[inline]
185    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
186        f.write_str(&self.to_str())
187    }
188}