1use atk_sys;
6use glib::object::IsA;
7use glib::translate::*;
8use glib::GString;
9use std::fmt;
10use std::mem;
11use CoordType;
12
13glib_wrapper! {
14 pub struct Image(Interface<atk_sys::AtkImage>);
15
16 match fn {
17 get_type => || atk_sys::atk_image_get_type(),
18 }
19}
20
21pub const NONE_IMAGE: Option<&Image> = None;
22
23pub trait AtkImageExt: 'static {
24 fn get_image_description(&self) -> Option<GString>;
25
26 fn get_image_locale(&self) -> Option<GString>;
27
28 fn get_image_position(&self, coord_type: CoordType) -> (i32, i32);
29
30 fn get_image_size(&self) -> (i32, i32);
31
32 fn set_image_description(&self, description: &str) -> bool;
33}
34
35impl<O: IsA<Image>> AtkImageExt for O {
36 fn get_image_description(&self) -> Option<GString> {
37 unsafe {
38 from_glib_none(atk_sys::atk_image_get_image_description(
39 self.as_ref().to_glib_none().0,
40 ))
41 }
42 }
43
44 fn get_image_locale(&self) -> Option<GString> {
45 unsafe {
46 from_glib_none(atk_sys::atk_image_get_image_locale(
47 self.as_ref().to_glib_none().0,
48 ))
49 }
50 }
51
52 fn get_image_position(&self, coord_type: CoordType) -> (i32, i32) {
53 unsafe {
54 let mut x = mem::uninitialized();
55 let mut y = mem::uninitialized();
56 atk_sys::atk_image_get_image_position(
57 self.as_ref().to_glib_none().0,
58 &mut x,
59 &mut y,
60 coord_type.to_glib(),
61 );
62 (x, y)
63 }
64 }
65
66 fn get_image_size(&self) -> (i32, i32) {
67 unsafe {
68 let mut width = mem::uninitialized();
69 let mut height = mem::uninitialized();
70 atk_sys::atk_image_get_image_size(
71 self.as_ref().to_glib_none().0,
72 &mut width,
73 &mut height,
74 );
75 (width, height)
76 }
77 }
78
79 fn set_image_description(&self, description: &str) -> bool {
80 unsafe {
81 from_glib(atk_sys::atk_image_set_image_description(
82 self.as_ref().to_glib_none().0,
83 description.to_glib_none().0,
84 ))
85 }
86 }
87}
88
89impl fmt::Display for Image {
90 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
91 write!(f, "Image")
92 }
93}