fix
This commit is contained in:
parent
c67f6fdb2d
commit
554bdfe19b
5 changed files with 30 additions and 19 deletions
|
|
@ -1,10 +1,10 @@
|
|||
// SPDX-License-Identifier: MPL-2.0-only
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::cell::{RefCell, Cell};
|
||||
|
||||
use glib::{ParamFlags, ParamSpec, Value};
|
||||
use gtk4::gdk::glib::ParamSpecBoolean;
|
||||
use gtk4::glib;
|
||||
use gtk4::glib::{self, ParamSpecString};
|
||||
use gtk4::glib::ParamSpecUInt;
|
||||
use gtk4::prelude::*;
|
||||
use gtk4::subclass::prelude::*;
|
||||
|
|
@ -13,7 +13,7 @@ use once_cell::sync::Lazy;
|
|||
// Object holding the state
|
||||
#[derive(Default)]
|
||||
pub struct WorkspaceObject {
|
||||
pub(crate) id: Cell<u32>,
|
||||
pub(crate) id: RefCell<String>,
|
||||
pub(crate) active: Cell<bool>,
|
||||
}
|
||||
|
||||
|
|
@ -30,19 +30,15 @@ impl ObjectImpl for WorkspaceObject {
|
|||
fn properties() -> &'static [ParamSpec] {
|
||||
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
|
||||
vec![
|
||||
ParamSpecUInt::new(
|
||||
ParamSpecString::new(
|
||||
// Name
|
||||
"id",
|
||||
// Nickname
|
||||
"id",
|
||||
// Short description
|
||||
"id",
|
||||
// Minimum value
|
||||
u32::MIN,
|
||||
// Maximum value
|
||||
u32::MAX,
|
||||
// Default value
|
||||
0,
|
||||
None,
|
||||
// The property can be read and written to
|
||||
ParamFlags::READWRITE,
|
||||
),
|
||||
|
|
@ -74,7 +70,7 @@ impl ObjectImpl for WorkspaceObject {
|
|||
|
||||
fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value {
|
||||
match pspec.name() {
|
||||
"id" => self.id.get().to_value(),
|
||||
"id" => self.id.borrow().to_value(),
|
||||
"active" => self.active.get().to_value(),
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@ impl WorkspaceObject {
|
|||
glib::Object::new(&[]).unwrap()
|
||||
}
|
||||
|
||||
pub fn from_id_active(id: u32, active: bool) -> Self {
|
||||
pub fn from_id_active(id: String, active: bool) -> Self {
|
||||
glib::Object::new(&[("id", &id), ("active", &active)]).unwrap()
|
||||
}
|
||||
|
||||
pub fn id(&self) -> u32 {
|
||||
imp::WorkspaceObject::from_instance(&self).id.get()
|
||||
pub fn id(&self) -> String {
|
||||
imp::WorkspaceObject::from_instance(&self).id.borrow().clone()
|
||||
}
|
||||
|
||||
pub fn active(&self) -> bool {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue