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 
5 use glib::translate::*;
6 use std::cmp;
7 use std::fmt;
8 use std::mem;
9 
10 glib::wrapper! {
11     #[derive(Debug, Hash)]
12     pub struct TreePath(Boxed<ffi::GtkTreePath>);
13 
14     match fn {
15         copy => |ptr| ffi::gtk_tree_path_copy(ptr),
16         free => |ptr| ffi::gtk_tree_path_free(ptr),
17         type_ => || ffi::gtk_tree_path_get_type(),
18     }
19 }
20 
21 impl TreePath {
22     #[doc(alias = "gtk_tree_path_new")]
new() -> TreePath23     pub fn new() -> TreePath {
24         assert_initialized_main_thread!();
25         unsafe { from_glib_full(ffi::gtk_tree_path_new()) }
26     }
27 
28     #[doc(alias = "gtk_tree_path_new_first")]
new_first() -> TreePath29     pub fn new_first() -> TreePath {
30         assert_initialized_main_thread!();
31         unsafe { from_glib_full(ffi::gtk_tree_path_new_first()) }
32     }
33 
34     //#[doc(alias = "gtk_tree_path_new_from_indices")]
35     //#[doc(alias = "new_from_indices")]
36     //pub fn from_indices(first_index: i32, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> TreePath {
37     //    unsafe { TODO: call ffi:gtk_tree_path_new_from_indices() }
38     //}
39 
40     #[doc(alias = "gtk_tree_path_new_from_indicesv")]
41     #[doc(alias = "new_from_indicesv")]
from_indicesv(indices: &[i32]) -> TreePath42     pub fn from_indicesv(indices: &[i32]) -> TreePath {
43         assert_initialized_main_thread!();
44         let length = indices.len() as usize;
45         unsafe {
46             from_glib_full(ffi::gtk_tree_path_new_from_indicesv(
47                 indices.to_glib_none().0,
48                 length,
49             ))
50         }
51     }
52 
53     #[doc(alias = "gtk_tree_path_new_from_string")]
54     #[doc(alias = "new_from_string")]
from_string(path: &str) -> TreePath55     pub fn from_string(path: &str) -> 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     #[doc(alias = "gtk_tree_path_append_index")]
append_index(&mut self, index_: i32)61     pub fn append_index(&mut self, index_: i32) {
62         unsafe {
63             ffi::gtk_tree_path_append_index(self.to_glib_none_mut().0, index_);
64         }
65     }
66 
67     #[doc(alias = "gtk_tree_path_compare")]
compare(&self, b: &TreePath) -> i3268     fn compare(&self, b: &TreePath) -> i32 {
69         unsafe { ffi::gtk_tree_path_compare(self.to_glib_none().0, b.to_glib_none().0) }
70     }
71 
72     #[doc(alias = "gtk_tree_path_down")]
down(&mut self)73     pub fn down(&mut self) {
74         unsafe {
75             ffi::gtk_tree_path_down(self.to_glib_none_mut().0);
76         }
77     }
78 
79     #[doc(alias = "gtk_tree_path_get_depth")]
80     #[doc(alias = "get_depth")]
depth(&self) -> i3281     pub fn depth(&self) -> i32 {
82         unsafe { ffi::gtk_tree_path_get_depth(mut_override(self.to_glib_none().0)) }
83     }
84 
85     #[doc(alias = "gtk_tree_path_get_indices_with_depth")]
86     #[doc(alias = "get_indices_with_depth")]
indices_with_depth(&mut self) -> Vec<i32>87     pub fn indices_with_depth(&mut self) -> Vec<i32> {
88         unsafe {
89             let mut depth = mem::MaybeUninit::uninit();
90             let ret = FromGlibContainer::from_glib_none_num(
91                 ffi::gtk_tree_path_get_indices_with_depth(
92                     self.to_glib_none_mut().0,
93                     depth.as_mut_ptr(),
94                 ),
95                 depth.assume_init() as usize,
96             );
97             ret
98         }
99     }
100 
101     #[doc(alias = "gtk_tree_path_is_ancestor")]
is_ancestor(&self, descendant: &TreePath) -> bool102     pub fn is_ancestor(&self, descendant: &TreePath) -> bool {
103         unsafe {
104             from_glib(ffi::gtk_tree_path_is_ancestor(
105                 mut_override(self.to_glib_none().0),
106                 mut_override(descendant.to_glib_none().0),
107             ))
108         }
109     }
110 
111     #[doc(alias = "gtk_tree_path_is_descendant")]
is_descendant(&self, ancestor: &TreePath) -> bool112     pub fn is_descendant(&self, ancestor: &TreePath) -> bool {
113         unsafe {
114             from_glib(ffi::gtk_tree_path_is_descendant(
115                 mut_override(self.to_glib_none().0),
116                 mut_override(ancestor.to_glib_none().0),
117             ))
118         }
119     }
120 
121     #[doc(alias = "gtk_tree_path_next")]
next(&mut self)122     pub fn next(&mut self) {
123         unsafe {
124             ffi::gtk_tree_path_next(self.to_glib_none_mut().0);
125         }
126     }
127 
128     #[doc(alias = "gtk_tree_path_prepend_index")]
prepend_index(&mut self, index_: i32)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     #[doc(alias = "gtk_tree_path_prev")]
prev(&mut self) -> bool136     pub fn prev(&mut self) -> bool {
137         unsafe { from_glib(ffi::gtk_tree_path_prev(self.to_glib_none_mut().0)) }
138     }
139 
140     #[doc(alias = "gtk_tree_path_to_string")]
141     #[doc(alias = "to_string")]
to_str(&self) -> glib::GString142     pub fn to_str(&self) -> glib::GString {
143         unsafe {
144             from_glib_full(ffi::gtk_tree_path_to_string(mut_override(
145                 self.to_glib_none().0,
146             )))
147         }
148     }
149 
150     #[doc(alias = "gtk_tree_path_up")]
up(&mut self) -> bool151     pub fn up(&mut self) -> bool {
152         unsafe { from_glib(ffi::gtk_tree_path_up(self.to_glib_none_mut().0)) }
153     }
154 }
155 
156 impl Default for TreePath {
default() -> Self157     fn default() -> Self {
158         Self::new()
159     }
160 }
161 
162 impl PartialEq for TreePath {
163     #[inline]
eq(&self, other: &Self) -> bool164     fn eq(&self, other: &Self) -> bool {
165         self.compare(other) == 0
166     }
167 }
168 
169 impl Eq for TreePath {}
170 
171 impl PartialOrd for TreePath {
172     #[inline]
partial_cmp(&self, other: &Self) -> Option<cmp::Ordering>173     fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
174         self.compare(other).partial_cmp(&0)
175     }
176 }
177 
178 impl Ord for TreePath {
179     #[inline]
cmp(&self, other: &Self) -> cmp::Ordering180     fn cmp(&self, other: &Self) -> cmp::Ordering {
181         self.compare(other).cmp(&0)
182     }
183 }
184 
185 impl fmt::Display for TreePath {
186     #[inline]
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result187     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
188         f.write_str(&self.to_str())
189     }
190 }
191