1 // Copyright 2013-2018, The Gtk-rs Project Developers.
2 // See the COPYRIGHT file at the top-level directory of this distribution.
3 // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
4 
5 use atk_sys;
6 use glib::object::IsA;
7 use glib::translate::*;
8 use Table;
9 
10 pub trait TableExtManual: 'static {
get_selected_columns(&self) -> Vec<i32>11     fn get_selected_columns(&self) -> Vec<i32>;
get_selected_rows(&self) -> Vec<i32>12     fn get_selected_rows(&self) -> Vec<i32>;
13 }
14 
15 impl<O: IsA<Table>> TableExtManual for O {
get_selected_columns(&self) -> Vec<i32>16     fn get_selected_columns(&self) -> Vec<i32> {
17         unsafe {
18             let mut selected = ::std::ptr::null_mut();
19             let nb = atk_sys::atk_table_get_selected_columns(
20                 self.as_ref().to_glib_none().0,
21                 &mut selected,
22             );
23             if nb <= 0 {
24                 Vec::new()
25             } else {
26                 Vec::from_raw_parts(selected, nb as usize, nb as usize)
27             }
28         }
29     }
30 
get_selected_rows(&self) -> Vec<i32>31     fn get_selected_rows(&self) -> Vec<i32> {
32         unsafe {
33             let mut selected = ::std::ptr::null_mut();
34             let nb =
35                 atk_sys::atk_table_get_selected_rows(self.as_ref().to_glib_none().0, &mut selected);
36             if nb <= 0 {
37                 Vec::new()
38             } else {
39                 Vec::from_raw_parts(selected, nb as usize, nb as usize)
40             }
41         }
42     }
43 }
44