workspace state handling

This commit is contained in:
Ashley Wulber 2022-06-16 14:33:26 -04:00
parent dba44d579f
commit 2417ff6e31
7 changed files with 50 additions and 17 deletions

View file

@ -4,7 +4,7 @@ use std::cell::{RefCell, Cell};
use glib::{ParamFlags, ParamSpec, Value};
use gtk4::gdk::glib::ParamSpecBoolean;
use gtk4::glib::{self, ParamSpecString};
use gtk4::glib::{self, ParamSpecString, ParamSpecUInt};
use gtk4::prelude::*;
use gtk4::subclass::prelude::*;
use once_cell::sync::Lazy;
@ -13,7 +13,7 @@ use once_cell::sync::Lazy;
#[derive(Default)]
pub struct WorkspaceObject {
pub(crate) id: RefCell<String>,
pub(crate) active: Cell<bool>,
pub(crate) active: Cell<u32>,
}
// The central trait for subclassing a GObject
@ -41,11 +41,13 @@ impl ObjectImpl for WorkspaceObject {
// The property can be read and written to
ParamFlags::READWRITE,
),
ParamSpecBoolean::new(
ParamSpecUInt::new(
"active",
"active",
"Indicates whether workspace is active",
false,
0,
4,
0,
ParamFlags::READWRITE,
),
]

View file

@ -13,7 +13,7 @@ impl WorkspaceObject {
glib::Object::new(&[]).unwrap()
}
pub fn from_id_active(id: String, active: bool) -> Self {
pub fn from_id_active(id: String, active: u32) -> Self {
glib::Object::new(&[("id", &id), ("active", &active)]).unwrap()
}
@ -21,7 +21,7 @@ impl WorkspaceObject {
imp::WorkspaceObject::from_instance(&self).id.borrow().clone()
}
pub fn active(&self) -> bool {
pub fn active(&self) -> u32 {
imp::WorkspaceObject::from_instance(&self).active.get()
}
}