gtk/tree_path.rs
1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use crate::{TreePath, ffi};
4use glib::translate::*;
5use std::slice;
6
7impl TreePath {
8 /// Returns the current indices of `self`.
9 ///
10 /// This is an array of integers, each representing a node in a tree.
11 /// This value should not be freed.
12 ///
13 /// The length of the array can be obtained with [`depth()`][Self::depth()].
14 ///
15 /// # Returns
16 ///
17 /// The current indices, or [`None`]
18 #[doc(alias = "gtk_tree_path_get_indices_with_depth")]
19 #[doc(alias = "get_indices")]
20 pub fn indices(&self) -> Vec<i32> {
21 unsafe {
22 let mut count = 0;
23 let ptr = ffi::gtk_tree_path_get_indices_with_depth(
24 mut_override(self.to_glib_none().0),
25 &mut count,
26 );
27 if ptr.is_null() || count == 0 {
28 vec![]
29 } else {
30 slice::from_raw_parts(ptr, count as usize).to_owned()
31 }
32 }
33 }
34}