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 glib::GString; 7 use gtk_sys; 8 use std::cmp; 9 use std::fmt; 10 use std::mem; 11 12 glib_wrapper! { 13 #[derive(Debug, Hash)] 14 pub struct TreePath(Boxed<gtk_sys::GtkTreePath>); 15 16 match fn { 17 copy => |ptr| gtk_sys::gtk_tree_path_copy(mut_override(ptr)), 18 free => |ptr| gtk_sys::gtk_tree_path_free(ptr), 19 get_type => || gtk_sys::gtk_tree_path_get_type(), 20 } 21 } 22 23 impl TreePath { new() -> TreePath24 pub fn new() -> TreePath { 25 assert_initialized_main_thread!(); 26 unsafe { from_glib_full(gtk_sys::gtk_tree_path_new()) } 27 } 28 new_first() -> TreePath29 pub fn new_first() -> TreePath { 30 assert_initialized_main_thread!(); 31 unsafe { from_glib_full(gtk_sys::gtk_tree_path_new_first()) } 32 } 33 34 //pub fn new_from_indices(first_index: i32, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> TreePath { 35 // unsafe { TODO: call gtk_sys:gtk_tree_path_new_from_indices() } 36 //} 37 new_from_indicesv(indices: &[i32]) -> TreePath38 pub fn new_from_indicesv(indices: &[i32]) -> TreePath { 39 assert_initialized_main_thread!(); 40 let length = indices.len() as usize; 41 unsafe { 42 from_glib_full(gtk_sys::gtk_tree_path_new_from_indicesv( 43 indices.to_glib_none().0, 44 length, 45 )) 46 } 47 } 48 new_from_string(path: &str) -> TreePath49 pub fn new_from_string(path: &str) -> TreePath { 50 assert_initialized_main_thread!(); 51 unsafe { 52 from_glib_full(gtk_sys::gtk_tree_path_new_from_string( 53 path.to_glib_none().0, 54 )) 55 } 56 } 57 append_index(&mut self, index_: i32)58 pub fn append_index(&mut self, index_: i32) { 59 unsafe { 60 gtk_sys::gtk_tree_path_append_index(self.to_glib_none_mut().0, index_); 61 } 62 } 63 compare(&self, b: &TreePath) -> i3264 fn compare(&self, b: &TreePath) -> i32 { 65 unsafe { gtk_sys::gtk_tree_path_compare(self.to_glib_none().0, b.to_glib_none().0) } 66 } 67 down(&mut self)68 pub fn down(&mut self) { 69 unsafe { 70 gtk_sys::gtk_tree_path_down(self.to_glib_none_mut().0); 71 } 72 } 73 get_depth(&self) -> i3274 pub fn get_depth(&self) -> i32 { 75 unsafe { gtk_sys::gtk_tree_path_get_depth(mut_override(self.to_glib_none().0)) } 76 } 77 get_indices_with_depth(&mut self) -> Vec<i32>78 pub fn get_indices_with_depth(&mut self) -> Vec<i32> { 79 unsafe { 80 let mut depth = mem::MaybeUninit::uninit(); 81 let ret = FromGlibContainer::from_glib_none_num( 82 gtk_sys::gtk_tree_path_get_indices_with_depth( 83 self.to_glib_none_mut().0, 84 depth.as_mut_ptr(), 85 ), 86 depth.assume_init() as usize, 87 ); 88 ret 89 } 90 } 91 is_ancestor(&self, descendant: &TreePath) -> bool92 pub fn is_ancestor(&self, descendant: &TreePath) -> bool { 93 unsafe { 94 from_glib(gtk_sys::gtk_tree_path_is_ancestor( 95 mut_override(self.to_glib_none().0), 96 mut_override(descendant.to_glib_none().0), 97 )) 98 } 99 } 100 is_descendant(&self, ancestor: &TreePath) -> bool101 pub fn is_descendant(&self, ancestor: &TreePath) -> bool { 102 unsafe { 103 from_glib(gtk_sys::gtk_tree_path_is_descendant( 104 mut_override(self.to_glib_none().0), 105 mut_override(ancestor.to_glib_none().0), 106 )) 107 } 108 } 109 next(&mut self)110 pub fn next(&mut self) { 111 unsafe { 112 gtk_sys::gtk_tree_path_next(self.to_glib_none_mut().0); 113 } 114 } 115 prepend_index(&mut self, index_: i32)116 pub fn prepend_index(&mut self, index_: i32) { 117 unsafe { 118 gtk_sys::gtk_tree_path_prepend_index(self.to_glib_none_mut().0, index_); 119 } 120 } 121 prev(&mut self) -> bool122 pub fn prev(&mut self) -> bool { 123 unsafe { from_glib(gtk_sys::gtk_tree_path_prev(self.to_glib_none_mut().0)) } 124 } 125 to_string(&self) -> GString126 fn to_string(&self) -> GString { 127 unsafe { 128 from_glib_full(gtk_sys::gtk_tree_path_to_string(mut_override( 129 self.to_glib_none().0, 130 ))) 131 } 132 } 133 up(&mut self) -> bool134 pub fn up(&mut self) -> bool { 135 unsafe { from_glib(gtk_sys::gtk_tree_path_up(self.to_glib_none_mut().0)) } 136 } 137 } 138 139 impl Default for TreePath { default() -> Self140 fn default() -> Self { 141 Self::new() 142 } 143 } 144 145 impl PartialEq for TreePath { 146 #[inline] eq(&self, other: &Self) -> bool147 fn eq(&self, other: &Self) -> bool { 148 self.compare(other) == 0 149 } 150 } 151 152 impl Eq for TreePath {} 153 154 impl PartialOrd for TreePath { 155 #[inline] partial_cmp(&self, other: &Self) -> Option<cmp::Ordering>156 fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> { 157 self.compare(other).partial_cmp(&0) 158 } 159 } 160 161 impl Ord for TreePath { 162 #[inline] cmp(&self, other: &Self) -> cmp::Ordering163 fn cmp(&self, other: &Self) -> cmp::Ordering { 164 self.compare(other).cmp(&0) 165 } 166 } 167 168 impl fmt::Display for TreePath { 169 #[inline] fmt(&self, f: &mut fmt::Formatter) -> fmt::Result170 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 171 write!(f, "{}", self.to_string()) 172 } 173 } 174