atk/
attribute.rs

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
5use atk_sys;
6use glib::translate::*;
7use glib::GString;
8use std::fmt;
9
10pub struct Attribute {
11    pub name: GString,
12    pub value: GString,
13}
14
15impl fmt::Display for Attribute {
16    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
17        f.debug_struct("Attribute")
18            .field("name", &self.name)
19            .field("value", &self.value)
20            .finish()
21    }
22}
23
24#[doc(hidden)]
25impl FromGlib<atk_sys::AtkAttribute> for Attribute {
26    fn from_glib(value: atk_sys::AtkAttribute) -> Self {
27        skip_assert_initialized!();
28        unsafe {
29            Attribute {
30                name: from_glib_full(value.name),
31                value: from_glib_full(value.value),
32            }
33        }
34    }
35}
36
37#[doc(hidden)]
38impl ToGlib for Attribute {
39    type GlibType = atk_sys::AtkAttribute;
40
41    fn to_glib(&self) -> atk_sys::AtkAttribute {
42        atk_sys::AtkAttribute {
43            name: self.name.to_glib_none().0,
44            value: self.value.to_glib_none().0,
45        }
46    }
47}