Skip to main content

atk/
table.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use crate::Table;
4use glib::object::IsA;
5use glib::translate::*;
6
7mod sealed {
8    pub trait Sealed {}
9    impl<T: glib::IsA<crate::Table>> Sealed for T {}
10}
11
12pub trait TableExtManual: IsA<Table> + sealed::Sealed + 'static {
13    /// Gets the selected columns of the table by initializing **selected with
14    /// the selected column numbers. This array should be freed by the caller.
15    /// ## `selected`
16    /// a `gint`** that is to contain the selected columns numbers
17    ///
18    /// # Returns
19    ///
20    /// a gint representing the number of selected columns,
21    /// or `0` if value does not implement this interface.
22    #[doc(alias = "atk_table_get_selected_columns")]
23    #[doc(alias = "get_selected_columns")]
24    fn selected_columns(&self) -> Vec<i32> {
25        unsafe {
26            let mut selected = ::std::ptr::null_mut();
27            let nb =
28                ffi::atk_table_get_selected_columns(self.as_ref().to_glib_none().0, &mut selected);
29            if nb <= 0 {
30                Vec::new()
31            } else {
32                Vec::from_raw_parts(selected, nb as usize, nb as usize)
33            }
34        }
35    }
36
37    /// Gets the selected rows of the table by initializing **selected with
38    /// the selected row numbers. This array should be freed by the caller.
39    /// ## `selected`
40    /// a `gint`** that is to contain the selected row numbers
41    ///
42    /// # Returns
43    ///
44    /// a gint representing the number of selected rows,
45    /// or zero if value does not implement this interface.
46    #[doc(alias = "atk_table_get_selected_rows")]
47    #[doc(alias = "get_selected_rows")]
48    fn selected_rows(&self) -> Vec<i32> {
49        unsafe {
50            let mut selected = ::std::ptr::null_mut();
51            let nb =
52                ffi::atk_table_get_selected_rows(self.as_ref().to_glib_none().0, &mut selected);
53            if nb <= 0 {
54                Vec::new()
55            } else {
56                Vec::from_raw_parts(selected, nb as usize, nb as usize)
57            }
58        }
59    }
60}
61
62impl<O: IsA<Table>> TableExtManual for O {}