1use atk_sys;
6use glib::object::Cast;
7use glib::object::IsA;
8use glib::signal::connect_raw;
9use glib::signal::SignalHandlerId;
10use glib::translate::*;
11use glib::GString;
12use glib_sys;
13use libc;
14use std::boxed::Box as Box_;
15use std::fmt;
16use std::mem::transmute;
17use Object;
18
19glib_wrapper! {
20 pub struct Table(Interface<atk_sys::AtkTable>);
21
22 match fn {
23 get_type => || atk_sys::atk_table_get_type(),
24 }
25}
26
27pub const NONE_TABLE: Option<&Table> = None;
28
29pub trait TableExt: 'static {
30 fn add_column_selection(&self, column: i32) -> bool;
31
32 fn add_row_selection(&self, row: i32) -> bool;
33
34 fn get_caption(&self) -> Option<Object>;
35
36 fn get_column_at_index(&self, index_: i32) -> i32;
37
38 fn get_column_description(&self, column: i32) -> Option<GString>;
39
40 fn get_column_extent_at(&self, row: i32, column: i32) -> i32;
41
42 fn get_column_header(&self, column: i32) -> Option<Object>;
43
44 fn get_index_at(&self, row: i32, column: i32) -> i32;
45
46 fn get_n_columns(&self) -> i32;
47
48 fn get_n_rows(&self) -> i32;
49
50 fn get_row_at_index(&self, index_: i32) -> i32;
51
52 fn get_row_description(&self, row: i32) -> Option<GString>;
53
54 fn get_row_extent_at(&self, row: i32, column: i32) -> i32;
55
56 fn get_row_header(&self, row: i32) -> Option<Object>;
57
58 fn get_summary(&self) -> Option<Object>;
59
60 fn is_column_selected(&self, column: i32) -> bool;
61
62 fn is_row_selected(&self, row: i32) -> bool;
63
64 fn is_selected(&self, row: i32, column: i32) -> bool;
65
66 fn ref_at(&self, row: i32, column: i32) -> Option<Object>;
67
68 fn remove_column_selection(&self, column: i32) -> bool;
69
70 fn remove_row_selection(&self, row: i32) -> bool;
71
72 fn set_caption<P: IsA<Object>>(&self, caption: &P);
73
74 fn set_column_description(&self, column: i32, description: &str);
75
76 fn set_column_header<P: IsA<Object>>(&self, column: i32, header: &P);
77
78 fn set_row_description(&self, row: i32, description: &str);
79
80 fn set_row_header<P: IsA<Object>>(&self, row: i32, header: &P);
81
82 fn set_summary<P: IsA<Object>>(&self, accessible: &P);
83
84 fn connect_column_deleted<F: Fn(&Self, i32, i32) + 'static>(&self, f: F) -> SignalHandlerId;
85
86 fn connect_column_inserted<F: Fn(&Self, i32, i32) + 'static>(&self, f: F) -> SignalHandlerId;
87
88 fn connect_column_reordered<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
89
90 fn connect_model_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
91
92 fn connect_row_deleted<F: Fn(&Self, i32, i32) + 'static>(&self, f: F) -> SignalHandlerId;
93
94 fn connect_row_inserted<F: Fn(&Self, i32, i32) + 'static>(&self, f: F) -> SignalHandlerId;
95
96 fn connect_row_reordered<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
97}
98
99impl<O: IsA<Table>> TableExt for O {
100 fn add_column_selection(&self, column: i32) -> bool {
101 unsafe {
102 from_glib(atk_sys::atk_table_add_column_selection(
103 self.as_ref().to_glib_none().0,
104 column,
105 ))
106 }
107 }
108
109 fn add_row_selection(&self, row: i32) -> bool {
110 unsafe {
111 from_glib(atk_sys::atk_table_add_row_selection(
112 self.as_ref().to_glib_none().0,
113 row,
114 ))
115 }
116 }
117
118 fn get_caption(&self) -> Option<Object> {
119 unsafe {
120 from_glib_none(atk_sys::atk_table_get_caption(
121 self.as_ref().to_glib_none().0,
122 ))
123 }
124 }
125
126 fn get_column_at_index(&self, index_: i32) -> i32 {
127 unsafe { atk_sys::atk_table_get_column_at_index(self.as_ref().to_glib_none().0, index_) }
128 }
129
130 fn get_column_description(&self, column: i32) -> Option<GString> {
131 unsafe {
132 from_glib_none(atk_sys::atk_table_get_column_description(
133 self.as_ref().to_glib_none().0,
134 column,
135 ))
136 }
137 }
138
139 fn get_column_extent_at(&self, row: i32, column: i32) -> i32 {
140 unsafe {
141 atk_sys::atk_table_get_column_extent_at(self.as_ref().to_glib_none().0, row, column)
142 }
143 }
144
145 fn get_column_header(&self, column: i32) -> Option<Object> {
146 unsafe {
147 from_glib_none(atk_sys::atk_table_get_column_header(
148 self.as_ref().to_glib_none().0,
149 column,
150 ))
151 }
152 }
153
154 fn get_index_at(&self, row: i32, column: i32) -> i32 {
155 unsafe { atk_sys::atk_table_get_index_at(self.as_ref().to_glib_none().0, row, column) }
156 }
157
158 fn get_n_columns(&self) -> i32 {
159 unsafe { atk_sys::atk_table_get_n_columns(self.as_ref().to_glib_none().0) }
160 }
161
162 fn get_n_rows(&self) -> i32 {
163 unsafe { atk_sys::atk_table_get_n_rows(self.as_ref().to_glib_none().0) }
164 }
165
166 fn get_row_at_index(&self, index_: i32) -> i32 {
167 unsafe { atk_sys::atk_table_get_row_at_index(self.as_ref().to_glib_none().0, index_) }
168 }
169
170 fn get_row_description(&self, row: i32) -> Option<GString> {
171 unsafe {
172 from_glib_none(atk_sys::atk_table_get_row_description(
173 self.as_ref().to_glib_none().0,
174 row,
175 ))
176 }
177 }
178
179 fn get_row_extent_at(&self, row: i32, column: i32) -> i32 {
180 unsafe { atk_sys::atk_table_get_row_extent_at(self.as_ref().to_glib_none().0, row, column) }
181 }
182
183 fn get_row_header(&self, row: i32) -> Option<Object> {
184 unsafe {
185 from_glib_none(atk_sys::atk_table_get_row_header(
186 self.as_ref().to_glib_none().0,
187 row,
188 ))
189 }
190 }
191
192 fn get_summary(&self) -> Option<Object> {
193 unsafe {
194 from_glib_full(atk_sys::atk_table_get_summary(
195 self.as_ref().to_glib_none().0,
196 ))
197 }
198 }
199
200 fn is_column_selected(&self, column: i32) -> bool {
201 unsafe {
202 from_glib(atk_sys::atk_table_is_column_selected(
203 self.as_ref().to_glib_none().0,
204 column,
205 ))
206 }
207 }
208
209 fn is_row_selected(&self, row: i32) -> bool {
210 unsafe {
211 from_glib(atk_sys::atk_table_is_row_selected(
212 self.as_ref().to_glib_none().0,
213 row,
214 ))
215 }
216 }
217
218 fn is_selected(&self, row: i32, column: i32) -> bool {
219 unsafe {
220 from_glib(atk_sys::atk_table_is_selected(
221 self.as_ref().to_glib_none().0,
222 row,
223 column,
224 ))
225 }
226 }
227
228 fn ref_at(&self, row: i32, column: i32) -> Option<Object> {
229 unsafe {
230 from_glib_full(atk_sys::atk_table_ref_at(
231 self.as_ref().to_glib_none().0,
232 row,
233 column,
234 ))
235 }
236 }
237
238 fn remove_column_selection(&self, column: i32) -> bool {
239 unsafe {
240 from_glib(atk_sys::atk_table_remove_column_selection(
241 self.as_ref().to_glib_none().0,
242 column,
243 ))
244 }
245 }
246
247 fn remove_row_selection(&self, row: i32) -> bool {
248 unsafe {
249 from_glib(atk_sys::atk_table_remove_row_selection(
250 self.as_ref().to_glib_none().0,
251 row,
252 ))
253 }
254 }
255
256 fn set_caption<P: IsA<Object>>(&self, caption: &P) {
257 unsafe {
258 atk_sys::atk_table_set_caption(
259 self.as_ref().to_glib_none().0,
260 caption.as_ref().to_glib_none().0,
261 );
262 }
263 }
264
265 fn set_column_description(&self, column: i32, description: &str) {
266 unsafe {
267 atk_sys::atk_table_set_column_description(
268 self.as_ref().to_glib_none().0,
269 column,
270 description.to_glib_none().0,
271 );
272 }
273 }
274
275 fn set_column_header<P: IsA<Object>>(&self, column: i32, header: &P) {
276 unsafe {
277 atk_sys::atk_table_set_column_header(
278 self.as_ref().to_glib_none().0,
279 column,
280 header.as_ref().to_glib_none().0,
281 );
282 }
283 }
284
285 fn set_row_description(&self, row: i32, description: &str) {
286 unsafe {
287 atk_sys::atk_table_set_row_description(
288 self.as_ref().to_glib_none().0,
289 row,
290 description.to_glib_none().0,
291 );
292 }
293 }
294
295 fn set_row_header<P: IsA<Object>>(&self, row: i32, header: &P) {
296 unsafe {
297 atk_sys::atk_table_set_row_header(
298 self.as_ref().to_glib_none().0,
299 row,
300 header.as_ref().to_glib_none().0,
301 );
302 }
303 }
304
305 fn set_summary<P: IsA<Object>>(&self, accessible: &P) {
306 unsafe {
307 atk_sys::atk_table_set_summary(
308 self.as_ref().to_glib_none().0,
309 accessible.as_ref().to_glib_none().0,
310 );
311 }
312 }
313
314 fn connect_column_deleted<F: Fn(&Self, i32, i32) + 'static>(&self, f: F) -> SignalHandlerId {
315 unsafe extern "C" fn column_deleted_trampoline<P, F: Fn(&P, i32, i32) + 'static>(
316 this: *mut atk_sys::AtkTable,
317 arg1: libc::c_int,
318 arg2: libc::c_int,
319 f: glib_sys::gpointer,
320 ) where
321 P: IsA<Table>,
322 {
323 let f: &F = &*(f as *const F);
324 f(&Table::from_glib_borrow(this).unsafe_cast(), arg1, arg2)
325 }
326 unsafe {
327 let f: Box_<F> = Box_::new(f);
328 connect_raw(
329 self.as_ptr() as *mut _,
330 b"column-deleted\0".as_ptr() as *const _,
331 Some(transmute(column_deleted_trampoline::<Self, F> as usize)),
332 Box_::into_raw(f),
333 )
334 }
335 }
336
337 fn connect_column_inserted<F: Fn(&Self, i32, i32) + 'static>(&self, f: F) -> SignalHandlerId {
338 unsafe extern "C" fn column_inserted_trampoline<P, F: Fn(&P, i32, i32) + 'static>(
339 this: *mut atk_sys::AtkTable,
340 arg1: libc::c_int,
341 arg2: libc::c_int,
342 f: glib_sys::gpointer,
343 ) where
344 P: IsA<Table>,
345 {
346 let f: &F = &*(f as *const F);
347 f(&Table::from_glib_borrow(this).unsafe_cast(), arg1, arg2)
348 }
349 unsafe {
350 let f: Box_<F> = Box_::new(f);
351 connect_raw(
352 self.as_ptr() as *mut _,
353 b"column-inserted\0".as_ptr() as *const _,
354 Some(transmute(column_inserted_trampoline::<Self, F> as usize)),
355 Box_::into_raw(f),
356 )
357 }
358 }
359
360 fn connect_column_reordered<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
361 unsafe extern "C" fn column_reordered_trampoline<P, F: Fn(&P) + 'static>(
362 this: *mut atk_sys::AtkTable,
363 f: glib_sys::gpointer,
364 ) where
365 P: IsA<Table>,
366 {
367 let f: &F = &*(f as *const F);
368 f(&Table::from_glib_borrow(this).unsafe_cast())
369 }
370 unsafe {
371 let f: Box_<F> = Box_::new(f);
372 connect_raw(
373 self.as_ptr() as *mut _,
374 b"column-reordered\0".as_ptr() as *const _,
375 Some(transmute(column_reordered_trampoline::<Self, F> as usize)),
376 Box_::into_raw(f),
377 )
378 }
379 }
380
381 fn connect_model_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
382 unsafe extern "C" fn model_changed_trampoline<P, F: Fn(&P) + 'static>(
383 this: *mut atk_sys::AtkTable,
384 f: glib_sys::gpointer,
385 ) where
386 P: IsA<Table>,
387 {
388 let f: &F = &*(f as *const F);
389 f(&Table::from_glib_borrow(this).unsafe_cast())
390 }
391 unsafe {
392 let f: Box_<F> = Box_::new(f);
393 connect_raw(
394 self.as_ptr() as *mut _,
395 b"model-changed\0".as_ptr() as *const _,
396 Some(transmute(model_changed_trampoline::<Self, F> as usize)),
397 Box_::into_raw(f),
398 )
399 }
400 }
401
402 fn connect_row_deleted<F: Fn(&Self, i32, i32) + 'static>(&self, f: F) -> SignalHandlerId {
403 unsafe extern "C" fn row_deleted_trampoline<P, F: Fn(&P, i32, i32) + 'static>(
404 this: *mut atk_sys::AtkTable,
405 arg1: libc::c_int,
406 arg2: libc::c_int,
407 f: glib_sys::gpointer,
408 ) where
409 P: IsA<Table>,
410 {
411 let f: &F = &*(f as *const F);
412 f(&Table::from_glib_borrow(this).unsafe_cast(), arg1, arg2)
413 }
414 unsafe {
415 let f: Box_<F> = Box_::new(f);
416 connect_raw(
417 self.as_ptr() as *mut _,
418 b"row-deleted\0".as_ptr() as *const _,
419 Some(transmute(row_deleted_trampoline::<Self, F> as usize)),
420 Box_::into_raw(f),
421 )
422 }
423 }
424
425 fn connect_row_inserted<F: Fn(&Self, i32, i32) + 'static>(&self, f: F) -> SignalHandlerId {
426 unsafe extern "C" fn row_inserted_trampoline<P, F: Fn(&P, i32, i32) + 'static>(
427 this: *mut atk_sys::AtkTable,
428 arg1: libc::c_int,
429 arg2: libc::c_int,
430 f: glib_sys::gpointer,
431 ) where
432 P: IsA<Table>,
433 {
434 let f: &F = &*(f as *const F);
435 f(&Table::from_glib_borrow(this).unsafe_cast(), arg1, arg2)
436 }
437 unsafe {
438 let f: Box_<F> = Box_::new(f);
439 connect_raw(
440 self.as_ptr() as *mut _,
441 b"row-inserted\0".as_ptr() as *const _,
442 Some(transmute(row_inserted_trampoline::<Self, F> as usize)),
443 Box_::into_raw(f),
444 )
445 }
446 }
447
448 fn connect_row_reordered<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
449 unsafe extern "C" fn row_reordered_trampoline<P, F: Fn(&P) + 'static>(
450 this: *mut atk_sys::AtkTable,
451 f: glib_sys::gpointer,
452 ) where
453 P: IsA<Table>,
454 {
455 let f: &F = &*(f as *const F);
456 f(&Table::from_glib_borrow(this).unsafe_cast())
457 }
458 unsafe {
459 let f: Box_<F> = Box_::new(f);
460 connect_raw(
461 self.as_ptr() as *mut _,
462 b"row-reordered\0".as_ptr() as *const _,
463 Some(transmute(row_reordered_trampoline::<Self, F> as usize)),
464 Box_::into_raw(f),
465 )
466 }
467 }
468}
469
470impl fmt::Display for Table {
471 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
472 write!(f, "Table")
473 }
474}