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
// Take a look at the license at the top of the repository in the LICENSE file.

use crate::{CssParserWarning, Ordering};
use glib::{error::ErrorDomain, translate::*, Quark};
use std::cmp;

impl From<cmp::Ordering> for Ordering {
    #[inline]
    fn from(o: cmp::Ordering) -> Self {
        skip_assert_initialized!();
        match o {
            cmp::Ordering::Equal => Self::Equal,
            cmp::Ordering::Greater => Self::Larger,
            cmp::Ordering::Less => Self::Smaller,
        }
    }
}

impl From<Ordering> for cmp::Ordering {
    #[inline]
    fn from(o: Ordering) -> Self {
        skip_assert_initialized!();
        match o {
            Ordering::Equal => Self::Equal,
            Ordering::Larger => Self::Greater,
            Ordering::Smaller => Self::Less,
            Ordering::__Unknown(_) => unreachable!(),
        }
    }
}

impl ErrorDomain for CssParserWarning {
    #[inline]
    fn domain() -> Quark {
        skip_assert_initialized!();
        unsafe { from_glib(ffi::gtk_css_parser_warning_quark()) }
    }

    #[inline]
    fn code(self) -> i32 {
        self.into_glib()
    }

    #[inline]
    fn from(code: i32) -> Option<Self> {
        skip_assert_initialized!();
        match code {
            ffi::GTK_CSS_PARSER_WARNING_DEPRECATED => Some(Self::Deprecated),
            ffi::GTK_CSS_PARSER_WARNING_SYNTAX => Some(Self::Syntax),
            ffi::GTK_CSS_PARSER_WARNING_UNIMPLEMENTED => Some(Self::Unimplemented),
            value => Some(Self::__Unknown(value)),
        }
    }
}