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
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use glib::translate::*;
use std::fmt;

#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "GdkX11DeviceType")]
pub enum X11DeviceType {
    #[doc(alias = "GDK_X11_DEVICE_TYPE_LOGICAL")]
    Logical,
    #[doc(alias = "GDK_X11_DEVICE_TYPE_PHYSICAL")]
    Physical,
    #[doc(alias = "GDK_X11_DEVICE_TYPE_FLOATING")]
    Floating,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for X11DeviceType {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "X11DeviceType::{}",
            match *self {
                Self::Logical => "Logical",
                Self::Physical => "Physical",
                Self::Floating => "Floating",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl IntoGlib for X11DeviceType {
    type GlibType = ffi::GdkX11DeviceType;

    #[inline]
    fn into_glib(self) -> ffi::GdkX11DeviceType {
        match self {
            Self::Logical => ffi::GDK_X11_DEVICE_TYPE_LOGICAL,
            Self::Physical => ffi::GDK_X11_DEVICE_TYPE_PHYSICAL,
            Self::Floating => ffi::GDK_X11_DEVICE_TYPE_FLOATING,
            Self::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::GdkX11DeviceType> for X11DeviceType {
    #[inline]
    unsafe fn from_glib(value: ffi::GdkX11DeviceType) -> Self {
        skip_assert_initialized!();

        match value {
            ffi::GDK_X11_DEVICE_TYPE_LOGICAL => Self::Logical,
            ffi::GDK_X11_DEVICE_TYPE_PHYSICAL => Self::Physical,
            ffi::GDK_X11_DEVICE_TYPE_FLOATING => Self::Floating,
            value => Self::__Unknown(value),
        }
    }
}