diff --git a/src/model/mod.rs b/src/model/mod.rs index cf7a1c1..8530639 100644 --- a/src/model/mod.rs +++ b/src/model/mod.rs @@ -1,2 +1,15 @@ pub mod builder_traits; pub mod models; + +use crate::gtk::glib; +use glib::Object; + +glib::wrapper! { + pub struct ResultValue(ObjectSubclass); +} + +impl ResultValue { + pub fn new(val: f64) -> Self { + Object::builder().property("value", val).build() + } +} diff --git a/src/model/models.rs b/src/model/models.rs index c9fd331..f1fb011 100644 --- a/src/model/models.rs +++ b/src/model/models.rs @@ -1,3 +1,12 @@ +use std::cell::Cell; + +use crate::gtk; + +use glib::Properties; +use gtk::glib; +use gtk::prelude::*; +use gtk::subclass::prelude::*; + #[repr(usize)] #[derive(Clone)] pub enum HammingMode { @@ -11,3 +20,20 @@ pub struct EventHandler { } pub type SchemeCharacteristics = (f64, f64, f64, f64, f64, f64); + +#[derive(Properties, Default)] +#[properties(wrapper_type = super::ResultValue)] +pub struct ResultValue { + #[property(get, set)] + value: Cell, +} + +// The central trait for subclassing a GObject +#[glib::object_subclass] +impl ObjectSubclass for ResultValue { + const NAME: &'static str = "MyGtkAppCustomButton"; + type Type = super::ResultValue; +} + +#[glib::derived_properties] +impl ObjectImpl for ResultValue {}