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