1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
// This file was generated by gir (9e3f4cc) from gir-files (71d73f0)
// DO NOT EDIT

use ffi;
use glib::translate::*;
use std::cmp;
use std::fmt;

glib_wrapper! {
    pub struct TreePath(Boxed<ffi::GtkTreePath>);

    match fn {
        copy => |ptr| ffi::gtk_tree_path_copy(mut_override(ptr)),
        free => |ptr| ffi::gtk_tree_path_free(ptr),
    }
}

impl TreePath {
    pub fn new() -> TreePath {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::gtk_tree_path_new())
        }
    }

    pub fn new_first() -> TreePath {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::gtk_tree_path_new_first())
        }
    }

    //pub fn new_from_indices(first_index: i32, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> TreePath {
    //    unsafe { TODO: call ffi::gtk_tree_path_new_from_indices() }
    //}

    //#[cfg(feature = "v3_12")]
    //pub fn new_from_indicesv(indices: /*Unimplemented*/&CArray TypeId { ns_id: 0, id: 14 }) -> TreePath {
    //    unsafe { TODO: call ffi::gtk_tree_path_new_from_indicesv() }
    //}

    pub fn new_from_string(path: &str) -> TreePath {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::gtk_tree_path_new_from_string(path.to_glib_none().0))
        }
    }

    pub fn append_index(&mut self, index_: i32) {
        unsafe {
            ffi::gtk_tree_path_append_index(self.to_glib_none_mut().0, index_);
        }
    }

    fn compare(&self, b: &TreePath) -> i32 {
        unsafe {
            ffi::gtk_tree_path_compare(self.to_glib_none().0, b.to_glib_none().0)
        }
    }

    pub fn down(&mut self) {
        unsafe {
            ffi::gtk_tree_path_down(self.to_glib_none_mut().0);
        }
    }

    pub fn get_depth(&self) -> i32 {
        unsafe {
            ffi::gtk_tree_path_get_depth(mut_override(self.to_glib_none().0))
        }
    }

    //pub fn get_indices_with_depth(&mut self) -> /*Unimplemented*/CArray TypeId { ns_id: 0, id: 14 } {
    //    unsafe { TODO: call ffi::gtk_tree_path_get_indices_with_depth() }
    //}

    pub fn is_ancestor(&self, descendant: &TreePath) -> bool {
        unsafe {
            from_glib(ffi::gtk_tree_path_is_ancestor(mut_override(self.to_glib_none().0), mut_override(descendant.to_glib_none().0)))
        }
    }

    pub fn is_descendant(&self, ancestor: &TreePath) -> bool {
        unsafe {
            from_glib(ffi::gtk_tree_path_is_descendant(mut_override(self.to_glib_none().0), mut_override(ancestor.to_glib_none().0)))
        }
    }

    pub fn next(&mut self) {
        unsafe {
            ffi::gtk_tree_path_next(self.to_glib_none_mut().0);
        }
    }

    pub fn prepend_index(&mut self, index_: i32) {
        unsafe {
            ffi::gtk_tree_path_prepend_index(self.to_glib_none_mut().0, index_);
        }
    }

    pub fn prev(&mut self) -> bool {
        unsafe {
            from_glib(ffi::gtk_tree_path_prev(self.to_glib_none_mut().0))
        }
    }

    fn to_string(&self) -> String {
        unsafe {
            from_glib_full(ffi::gtk_tree_path_to_string(mut_override(self.to_glib_none().0)))
        }
    }

    pub fn up(&mut self) -> bool {
        unsafe {
            from_glib(ffi::gtk_tree_path_up(self.to_glib_none_mut().0))
        }
    }
}

impl PartialEq for TreePath {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        self.compare(other) == 0
    }
}

impl Eq for TreePath {}

impl PartialOrd for TreePath {
    #[inline]
    fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
        self.compare(other).partial_cmp(&0)
    }
}

impl Ord for TreePath {
    #[inline]
    fn cmp(&self, other: &Self) -> cmp::Ordering {
        self.compare(other).cmp(&0)
    }
}

impl fmt::Display for TreePath {
    #[inline]
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "{}", self.to_string())
    }
}