1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-07-04 04:01:03 +02:00

feat: new focused window module

This commit is contained in:
Jake Stanger 2022-08-14 20:40:11 +01:00
parent e416e03b0a
commit dc14cb003f
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
13 changed files with 222 additions and 88 deletions

View file

@ -1,4 +1,5 @@
use crate::modules::{Module, ModuleInfo};
use crate::sway::{Workspace, WorkspaceEvent};
use gtk::prelude::*;
use gtk::{Button, Orientation};
use ksway::client::Client;
@ -13,22 +14,10 @@ use tokio::task::spawn_blocking;
pub struct WorkspacesModule {
name_map: Option<HashMap<String, String>>,
#[serde(default = "default_false")]
#[serde(default = "crate::config::default_false")]
all_monitors: bool,
}
const fn default_false() -> bool {
false
}
#[derive(Deserialize, Debug)]
struct Workspace {
name: String,
focused: bool,
// num: i32,
output: String,
}
impl Workspace {
fn as_button(&self, name_map: &HashMap<String, String>, tx: &mpsc::Sender<String>) -> Button {
let button = Button::builder()
@ -52,13 +41,6 @@ impl Workspace {
}
}
#[derive(Deserialize, Debug)]
struct WorkspaceEvent {
change: String,
old: Option<Workspace>,
current: Option<Workspace>,
}
impl Module<gtk::Box> for WorkspacesModule {
fn into_widget(self, info: &ModuleInfo) -> gtk::Box {
let mut sway = Client::connect().unwrap();