1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// This file was generated by gir (4b09025) from gir-files (71d73f0)
// DO NOT EDIT

use Error;
use ffi;
#[cfg(feature = "v2_38")]
use glib;
use glib::object::IsA;
use glib::translate::*;
use gobject_ffi;
use std::ptr;

glib_wrapper! {
    pub struct Icon(Object<ffi::GIcon>);

    match fn {
        get_type => || ffi::g_icon_get_type(),
    }
}

impl Icon {
    #[cfg(feature = "v2_38")]
    pub fn deserialize(value: &glib::Variant) -> Option<Icon> {
        unsafe {
            from_glib_full(ffi::g_icon_deserialize(value.to_glib_none().0))
        }
    }

    //pub fn hash(icon: /*Unimplemented*/Fundamental: Pointer) -> u32 {
    //    unsafe { TODO: call ffi::g_icon_hash() }
    //}

    pub fn new_for_string(str: &str) -> Result<Icon, Error> {
        unsafe {
            let mut error = ptr::null_mut();
            let ret = ffi::g_icon_new_for_string(str.to_glib_none().0, &mut error);
            if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
        }
    }
}

pub trait IconExt {
    fn equal<'a, P: IsA<Icon> + 'a, Q: Into<Option<&'a P>>>(&self, icon2: Q) -> bool;

    #[cfg(feature = "v2_38")]
    fn serialize(&self) -> Option<glib::Variant>;

    fn to_string(&self) -> Option<String>;
}

impl<O: IsA<Icon>> IconExt for O {
    fn equal<'a, P: IsA<Icon> + 'a, Q: Into<Option<&'a P>>>(&self, icon2: Q) -> bool {
        let icon2 = icon2.into();
        let icon2 = icon2.to_glib_none();
        unsafe {
            from_glib(ffi::g_icon_equal(self.to_glib_none().0, icon2.0))
        }
    }

    #[cfg(feature = "v2_38")]
    fn serialize(&self) -> Option<glib::Variant> {
        unsafe {
            from_glib_full(ffi::g_icon_serialize(self.to_glib_none().0))
        }
    }

    fn to_string(&self) -> Option<String> {
        unsafe {
            from_glib_full(ffi::g_icon_to_string(self.to_glib_none().0))
        }
    }
}