From 33fa97503181642c68c9bba80efc13cda0033cce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Mon, 22 Mar 2021 17:36:36 +0400 Subject: [PATCH] Use the new GErrorDomain macro --- qemu-gtk4/src/console_area.rs | 2 +- qemu-gtk4/src/error.rs | 30 +++++------------------------- 2 files changed, 6 insertions(+), 26 deletions(-) diff --git a/qemu-gtk4/src/console_area.rs b/qemu-gtk4/src/console_area.rs index 3eaa116..db3afcb 100644 --- a/qemu-gtk4/src/console_area.rs +++ b/qemu-gtk4/src/console_area.rs @@ -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)); } } diff --git a/qemu-gtk4/src/error.rs b/qemu-gtk4/src/error.rs index 1febdc6..1190d8d 100644 --- a/qemu-gtk4/src/error.rs +++ b/qemu-gtk4/src/error.rs @@ -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 - 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, }