mirror of
https://github.com/rustdesk/qemu-display.git
synced 2025-07-01 23:35:36 +00:00
Use the new GErrorDomain macro
This commit is contained in:
parent
9580a40c04
commit
33fa975031
@ -82,7 +82,7 @@ mod imp {
|
|||||||
widget.make_current();
|
widget.make_current();
|
||||||
|
|
||||||
if let Err(e) = unsafe { self.realize_gl() } {
|
if let Err(e) = unsafe { self.realize_gl() } {
|
||||||
let e = glib::Error::new(AppError::GL, &e);
|
let e = glib::Error::new(QemuGtkError::GL, &e);
|
||||||
widget.set_error(Some(&e));
|
widget.set_error(Some(&e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,8 @@
|
|||||||
use gtk::glib;
|
use gtk::glib;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, glib::GErrorDomain)]
|
||||||
pub enum AppError {
|
#[gerror_domain(name = "QemuGtk")]
|
||||||
GL = 1,
|
pub enum QemuGtkError {
|
||||||
Failed = 2,
|
GL,
|
||||||
}
|
Failed,
|
||||||
|
|
||||||
impl glib::error::ErrorDomain for AppError {
|
|
||||||
fn domain() -> glib::Quark {
|
|
||||||
glib::Quark::from_string("qemu-gtk4")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn code(self) -> i32 {
|
|
||||||
self as _
|
|
||||||
}
|
|
||||||
|
|
||||||
fn from(code: i32) -> Option<Self>
|
|
||||||
where
|
|
||||||
Self: Sized,
|
|
||||||
{
|
|
||||||
use self::AppError::*;
|
|
||||||
match code {
|
|
||||||
x if x == GL as i32 => Some(GL),
|
|
||||||
_ => Some(Failed),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user