adding spacer

This commit is contained in:
Chris Cochrun 2025-06-19 06:26:17 -05:00
parent eb83bb3c38
commit aaa21aff21

View file

@ -13,7 +13,7 @@ use iced::font::Weight;
use iced::futures::SinkExt; use iced::futures::SinkExt;
use iced::stream; use iced::stream;
use iced::widget::image::Handle; use iced::widget::image::Handle;
use iced::widget::{container, horizontal_space, image, row, svg, text}; use iced::widget::{button, container, horizontal_space, image, row, svg, text};
use iced::{ use iced::{
time, Background, Border, Color, Element, Event, Font, Length, Shadow, Subscription, Task, time, Background, Border, Color, Element, Event, Font, Length, Shadow, Subscription, Task,
Vector, Vector,
@ -92,7 +92,7 @@ struct Panel {
} }
#[to_layer_message] #[to_layer_message]
#[derive(Debug, Clone)] #[derive(Debug)]
enum Message { enum Message {
Launch(usize), Launch(usize),
Time(DateTime<Local>), Time(DateTime<Local>),
@ -100,6 +100,8 @@ enum Message {
WorkspaceChange(Vec<Workspace>), WorkspaceChange(Vec<Workspace>),
ActiveWorkspaceChange(event_listener::WorkspaceEventData), ActiveWorkspaceChange(event_listener::WorkspaceEventData),
ActiveWindowChange((String, String)), ActiveWindowChange((String, String)),
AddSystemTray(SystemTray),
None,
} }
impl Panel { impl Panel {
@ -143,9 +145,9 @@ impl Panel {
system_tray: None, system_tray: None,
}; };
// let sys_task = Task::perform(app.add_sys_tray(), |app| app = app ); let sys_task = Task::perform(add_sys_tray(), |m| m);
(app, Task::none()) (app, sys_task)
} }
fn namespace(&self) -> String { fn namespace(&self) -> String {
String::from("panel") String::from("panel")
@ -204,7 +206,9 @@ impl Panel {
} }
Message::ActiveWindowChange(w) => { Message::ActiveWindowChange(w) => {
debug!(?w); debug!(?w);
self.active_window = w.0; self.active_window =
w.0.trim_start_matches("\u{180e}\u{200b}\u{200c}")
.to_string();
let class; let class;
if &w.1 == "lw" { if &w.1 == "lw" {
class = "LibreWolf"; class = "LibreWolf";
@ -225,6 +229,11 @@ impl Panel {
debug!(?svg); debug!(?svg);
self.active_window_icon_svg = svg; self.active_window_icon_svg = svg;
} }
Message::AddSystemTray(system_tray) => {
debug!(?system_tray);
self.system_tray = Some(system_tray);
}
Message::None => {}
_ => unreachable!(), _ => unreachable!(),
} }
Task::none() Task::none()
@ -404,10 +413,15 @@ impl Panel {
) )
.color(Color::parse("#ff6ac1").unwrap()); .color(Color::parse("#ff6ac1").unwrap());
let spacer = text!(" | ");
// let sys_tray = vec![button()]
let row = row!( let row = row!(
container(row!(workspaces, icon, window, horizontal_space()).spacing(10)), container(row!(workspaces, icon, window, horizontal_space()).spacing(10)),
container(clock), container(clock),
container(row!(horizontal_space(), disk, cpu, mem, battery).spacing(5)) container(row!(horizontal_space(), disk, cpu, mem, battery).spacing(5)),
spacer,
) )
.spacing(5) .spacing(5)
.padding([0, 20]); .padding([0, 20]);
@ -444,18 +458,16 @@ impl Panel {
text_color: theme.palette().text, text_color: theme.palette().text,
} }
} }
}
async fn add_sys_tray(mut self) -> Self { async fn add_sys_tray() -> Message {
let sys_tray = SystemTray::new().await; let sys_tray = SystemTray::new().await;
match sys_tray { match sys_tray {
Ok(s) => { Ok(s) => Message::AddSystemTray(s),
self.system_tray = Some(s); Err(e) => {
} error!(?e, "Sys tray couldn't be initialized");
Err(e) => { Message::None
error!(?e, "Sys tray couldn't be initialized")
}
} }
self
} }
} }