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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

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

glib::wrapper! {
    /// An opaque structure representing a path to a row in a model.
    ///
    /// # Deprecated since 4.10
    ///
    #[derive(Debug, Hash)]
    pub struct TreePath(Boxed<ffi::GtkTreePath>);

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

impl TreePath {
    /// Creates a new [`TreePath`][crate::TreePath]
    /// This refers to a row.
    ///
    /// # Deprecated since 4.10
    ///
    ///
    /// # Returns
    ///
    /// A newly created [`TreePath`][crate::TreePath].
    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[allow(deprecated)]
    #[doc(alias = "gtk_tree_path_new")]
    pub fn new() -> TreePath {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(ffi::gtk_tree_path_new()) }
    }

    /// Creates a new [`TreePath`][crate::TreePath].
    ///
    /// The string representation of this path is “0”.
    ///
    /// # Deprecated since 4.10
    ///
    ///
    /// # Returns
    ///
    /// A new [`TreePath`][crate::TreePath]
    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[allow(deprecated)]
    #[doc(alias = "gtk_tree_path_new_first")]
    pub fn new_first() -> TreePath {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(ffi::gtk_tree_path_new_first()) }
    }

    /// Creates a new path with the given @indices array of @length.
    ///
    /// # Deprecated since 4.10
    ///
    /// ## `indices`
    /// array of indices
    ///
    /// # Returns
    ///
    /// A newly created [`TreePath`][crate::TreePath]
    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[allow(deprecated)]
    #[doc(alias = "gtk_tree_path_new_from_indicesv")]
    #[doc(alias = "new_from_indicesv")]
    pub fn from_indices(indices: &[i32]) -> TreePath {
        assert_initialized_main_thread!();
        let length = indices.len() as _;
        unsafe {
            from_glib_full(ffi::gtk_tree_path_new_from_indicesv(
                indices.to_glib_none().0,
                length,
            ))
        }
    }

    /// Creates a new [`TreePath`][crate::TreePath] initialized to @path.
    ///
    /// @path is expected to be a colon separated list of numbers.
    /// For example, the string “10:4:0” would create a path of depth
    /// 3 pointing to the 11th child of the root node, the 5th
    /// child of that 11th child, and the 1st child of that 5th child.
    /// If an invalid path string is passed in, [`None`] is returned.
    ///
    /// # Deprecated since 4.10
    ///
    /// ## `path`
    /// The string representation of a path
    ///
    /// # Returns
    ///
    /// A newly-created [`TreePath`][crate::TreePath]
    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[allow(deprecated)]
    #[doc(alias = "gtk_tree_path_new_from_string")]
    #[doc(alias = "new_from_string")]
    pub fn from_string(path: &str) -> Option<TreePath> {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(ffi::gtk_tree_path_new_from_string(path.to_glib_none().0)) }
    }

    /// Appends a new index to a path.
    ///
    /// As a result, the depth of the path is increased.
    ///
    /// # Deprecated since 4.10
    ///
    /// ## `index_`
    /// the index
    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[allow(deprecated)]
    #[doc(alias = "gtk_tree_path_append_index")]
    pub fn append_index(&mut self, index_: i32) {
        unsafe {
            ffi::gtk_tree_path_append_index(self.to_glib_none_mut().0, index_);
        }
    }

    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[allow(deprecated)]
    #[doc(alias = "gtk_tree_path_compare")]
    fn compare(&self, b: &TreePath) -> i32 {
        unsafe { ffi::gtk_tree_path_compare(self.to_glib_none().0, b.to_glib_none().0) }
    }

    /// Moves @self to point to the first child of the current path.
    ///
    /// # Deprecated since 4.10
    ///
    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[allow(deprecated)]
    #[doc(alias = "gtk_tree_path_down")]
    pub fn down(&mut self) {
        unsafe {
            ffi::gtk_tree_path_down(self.to_glib_none_mut().0);
        }
    }

    /// Returns the current depth of @self.
    ///
    /// # Deprecated since 4.10
    ///
    ///
    /// # Returns
    ///
    /// The depth of @self
    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[allow(deprecated)]
    #[doc(alias = "gtk_tree_path_get_depth")]
    #[doc(alias = "get_depth")]
    pub fn depth(&self) -> i32 {
        unsafe { ffi::gtk_tree_path_get_depth(mut_override(self.to_glib_none().0)) }
    }

    /// Returns [`true`] if @descendant is a descendant of @self.
    ///
    /// # Deprecated since 4.10
    ///
    /// ## `descendant`
    /// another [`TreePath`][crate::TreePath]
    ///
    /// # Returns
    ///
    /// [`true`] if @descendant is contained inside @self
    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[allow(deprecated)]
    #[doc(alias = "gtk_tree_path_is_ancestor")]
    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),
            ))
        }
    }

    /// Returns [`true`] if @self is a descendant of @ancestor.
    ///
    /// # Deprecated since 4.10
    ///
    /// ## `ancestor`
    /// another [`TreePath`][crate::TreePath]
    ///
    /// # Returns
    ///
    /// [`true`] if @ancestor contains @self somewhere below it
    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[allow(deprecated)]
    #[doc(alias = "gtk_tree_path_is_descendant")]
    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),
            ))
        }
    }

    /// Moves the @self to point to the next node at the current depth.
    ///
    /// # Deprecated since 4.10
    ///
    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[allow(deprecated)]
    #[doc(alias = "gtk_tree_path_next")]
    pub fn next(&mut self) {
        unsafe {
            ffi::gtk_tree_path_next(self.to_glib_none_mut().0);
        }
    }

    /// Prepends a new index to a path.
    ///
    /// As a result, the depth of the path is increased.
    ///
    /// # Deprecated since 4.10
    ///
    /// ## `index_`
    /// the index
    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[allow(deprecated)]
    #[doc(alias = "gtk_tree_path_prepend_index")]
    pub fn prepend_index(&mut self, index_: i32) {
        unsafe {
            ffi::gtk_tree_path_prepend_index(self.to_glib_none_mut().0, index_);
        }
    }

    /// Moves the @self to point to the previous node at the
    /// current depth, if it exists.
    ///
    /// # Deprecated since 4.10
    ///
    ///
    /// # Returns
    ///
    /// [`true`] if @self has a previous node, and
    ///   the move was made
    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[allow(deprecated)]
    #[doc(alias = "gtk_tree_path_prev")]
    pub fn prev(&mut self) -> bool {
        unsafe { from_glib(ffi::gtk_tree_path_prev(self.to_glib_none_mut().0)) }
    }

    /// Generates a string representation of the path.
    ///
    /// This string is a “:” separated list of numbers.
    /// For example, “4:10:0:3” would be an acceptable
    /// return value for this string. If the path has
    /// depth 0, [`None`] is returned.
    ///
    /// # Deprecated since 4.10
    ///
    ///
    /// # Returns
    ///
    /// A newly-allocated string
    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[allow(deprecated)]
    #[doc(alias = "gtk_tree_path_to_string")]
    #[doc(alias = "to_string")]
    pub fn to_str(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_full(ffi::gtk_tree_path_to_string(mut_override(
                self.to_glib_none().0,
            )))
        }
    }

    /// Moves the @self to point to its parent node, if it has a parent.
    ///
    /// # Deprecated since 4.10
    ///
    ///
    /// # Returns
    ///
    /// [`true`] if @self has a parent, and the move was made
    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
    #[allow(deprecated)]
    #[doc(alias = "gtk_tree_path_up")]
    pub fn up(&mut self) -> bool {
        unsafe { from_glib(ffi::gtk_tree_path_up(self.to_glib_none_mut().0)) }
    }
}

impl Default for TreePath {
    fn default() -> Self {
        Self::new()
    }
}

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)
    }
}