diff --git a/src/property/imp.rs b/src/property/imp.rs index 6a8fa33..cd5394e 100644 --- a/src/property/imp.rs +++ b/src/property/imp.rs @@ -1,7 +1,6 @@ -// SPDX-FileCopyrightText: 2022 Deren Vural +// SPDX-FileCopyrightText: 2024 Deren Vural // SPDX-License-Identifier: GPL-3.0-or-later -use adwaita::glib; /** * Name: * imp.rs @@ -19,9 +18,16 @@ use adwaita::glib; * */ // Imports -use glib::{once_cell::sync::Lazy, ParamSpec, ToValue, Value}; -use gtk::subclass::prelude::*; +// std +use std::sync::OnceLock; use std::cell::Cell; +// gtk-rs +use gtk::subclass::prelude::*; +use adwaita::glib; +use glib::{ + ParamSpec, + value::ToValue, value::Value +}; // Modules use crate::formatter::Formatter; @@ -81,18 +87,17 @@ impl ObjectImpl for Property { * beware that you need to use kebab-case () */ fn properties() -> &'static [ParamSpec] { - static PROPERTIES: Lazy> = Lazy::new(|| { + static PROPERTIES: OnceLock> = OnceLock::new(); + PROPERTIES.get_or_init(|| { vec![ glib::ParamSpecString::builder("id").build(), - glib::ParamSpecObject::builder("processor", glib::Type::OBJECT).build(), - glib::ParamSpecObject::builder("formatter", glib::Type::OBJECT).build(), + glib::ParamSpecObject::builder::("processor").build(), + glib::ParamSpecObject::builder::("formatter").build(), ] - }); + }) //println!("PROPERTIES: {:?}", PROPERTIES);//TEST //println!("trying to add `base_call`: {:?}", glib::ParamSpecString::builder("base_call").build());//TEST - - PROPERTIES.as_ref() } /** @@ -111,7 +116,12 @@ impl ObjectImpl for Property { * Notes: * */ - fn set_property(&self, _obj: &Self::Type, _id: usize, value: &Value, pspec: &ParamSpec) { + fn set_property( + &self, + _id: usize, + value: &Value, + pspec: &ParamSpec + ) { //println!("setting: {:?}", pspec.name());//TEST match pspec.name() { @@ -153,7 +163,11 @@ impl ObjectImpl for Property { * Notes: * */ - fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value { + fn property( + &self, + _id: usize, + pspec: &ParamSpec + ) -> Value { //println!("getting: {:?}", pspec.name());//TEST match pspec.name() { diff --git a/src/property/mod.rs b/src/property/mod.rs index 375ab00..6e3fb20 100644 --- a/src/property/mod.rs +++ b/src/property/mod.rs @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2022 Deren Vural +// SPDX-FileCopyrightText: 2024 Deren Vural // SPDX-License-Identifier: GPL-3.0-or-later /** @@ -20,10 +20,18 @@ // Custom GObjects mod imp; -use gdk::glib::value::FromValue; // Imports -use glib::Object; -use gtk::{glib, prelude::*}; +// std +// +// gtk-rs +use gtk::{ + prelude::*, + glib +}; +use glib::{ + value::FromValue, + Object +}; // Modules use crate::formatter::Formatter; @@ -72,8 +80,13 @@ impl Property { * * given proc and gpuCount */ - pub fn new(processor: &Processor, formatter: &Formatter, id: &str) -> Self { - let obj: Property = Object::new(&[]).expect("Failed to create `Property`."); + pub fn new( + processor: &Processor, + formatter: &Formatter, + id: &str + ) -> Self { + // Create Object + let obj: Property = Object::builder::().build(); // Set properties obj.set_property("processor", processor); @@ -100,7 +113,10 @@ impl Property { * Notes: * */ - pub fn parse(self, uuid: &str) -> Option { + pub fn parse( + self, + uuid: &str + ) -> Option { // println!("UUID: `{}`", uuid); //TEST // Grab formatter & processor let formatter: Formatter = self.property("formatter"); @@ -159,31 +175,38 @@ impl Property { * Notes: * */ - pub fn get_value FromValue<'a> + 'static>(&self, name: &str) -> T { + pub fn get_value FromValue<'a> + 'static>( + &self, + name: &str + ) -> T { // Return the value of the property self.property::(name) } - /** - * Name: - * update_value - * - * Description: - * Update a property with a new value - * - * Made: - * 29/10/2022 - * - * Made by: - * Deren Vural - * - * Notes: - * - */ - pub fn update_value(&self, property_name: &str, value: T) { - // Update the property with new value - self.set_property(property_name, value); - } + // /** + // * Name: + // * update_value + // * + // * Description: + // * Update a property with a new value + // * + // * Made: + // * 29/10/2022 + // * + // * Made by: + // * Deren Vural + // * + // * Notes: + // * + // */ + // pub fn update_value>( + // &self, + // property_name: &str, + // value: T + // ) { + // // Update the property with new value + // self.set_property(property_name, value); + // } } /**