From d3787b22839146fae174aa6cede45184f6e71fb5 Mon Sep 17 00:00:00 2001 From: doryan Date: Fri, 2 Aug 2024 01:09:26 +0400 Subject: [PATCH] feat(model): add model for ColumnView Added model that are GObject for generating values in tables. --- src/model/mod.rs | 13 +++++++++++++ src/model/models.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) 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 {}