mirror of
https://gitlab.com/marcandre.lureau/qemu-display.git
synced 2025-01-03 03:05:18 +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();
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -1,28 +1,8 @@
|
||||
use gtk::glib;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum AppError {
|
||||
GL = 1,
|
||||
Failed = 2,
|
||||
}
|
||||
|
||||
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),
|
||||
}
|
||||
}
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, glib::GErrorDomain)]
|
||||
#[gerror_domain(name = "QemuGtk")]
|
||||
pub enum QemuGtkError {
|
||||
GL,
|
||||
Failed,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user