mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-07-01 18:51:04 +02:00
parent
8fc516a85d
commit
f24b21d242
1 changed files with 39 additions and 20 deletions
|
@ -49,7 +49,7 @@ const fn default_icon_size() -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Module<gtk::Box> for FocusedModule {
|
impl Module<gtk::Box> for FocusedModule {
|
||||||
type SendMessage = (String, String);
|
type SendMessage = Option<(String, String)>;
|
||||||
type ReceiveMessage = ();
|
type ReceiveMessage = ();
|
||||||
|
|
||||||
fn name() -> &'static str {
|
fn name() -> &'static str {
|
||||||
|
@ -78,22 +78,35 @@ impl Module<gtk::Box> for FocusedModule {
|
||||||
if let Some(focused) = focused {
|
if let Some(focused) = focused {
|
||||||
try_send!(
|
try_send!(
|
||||||
tx,
|
tx,
|
||||||
ModuleUpdateEvent::Update((focused.title.clone(), focused.app_id))
|
ModuleUpdateEvent::Update(Some((focused.title.clone(), focused.app_id)))
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
while let Ok(event) = wlrx.recv().await {
|
while let Ok(event) = wlrx.recv().await {
|
||||||
if let ToplevelEvent::Update(handle) = event {
|
match event {
|
||||||
|
ToplevelEvent::Update(handle) => {
|
||||||
let info = handle.info().unwrap_or_default();
|
let info = handle.info().unwrap_or_default();
|
||||||
|
|
||||||
if info.focused {
|
if info.focused {
|
||||||
debug!("Changing focus");
|
debug!("Changing focus");
|
||||||
send_async!(
|
send_async!(
|
||||||
tx,
|
tx,
|
||||||
ModuleUpdateEvent::Update((info.title.clone(), info.app_id.clone()))
|
ModuleUpdateEvent::Update(Some((
|
||||||
|
info.title.clone(),
|
||||||
|
info.app_id.clone()
|
||||||
|
)))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ToplevelEvent::Remove(handle) => {
|
||||||
|
let info = handle.info().unwrap_or_default();
|
||||||
|
if info.focused {
|
||||||
|
debug!("Clearing focus");
|
||||||
|
send_async!(tx, ModuleUpdateEvent::Update(None));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ToplevelEvent::New(_) => {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -126,19 +139,25 @@ impl Module<gtk::Box> for FocusedModule {
|
||||||
|
|
||||||
{
|
{
|
||||||
let icon_theme = icon_theme.clone();
|
let icon_theme = icon_theme.clone();
|
||||||
context.widget_rx.attach(None, move |(name, id)| {
|
context.widget_rx.attach(None, move |data| {
|
||||||
|
if let Some((name, id)) = data {
|
||||||
if self.show_icon {
|
if self.show_icon {
|
||||||
match ImageProvider::parse(&id, &icon_theme, true, self.icon_size)
|
match ImageProvider::parse(&id, &icon_theme, true, self.icon_size)
|
||||||
.map(|image| image.load_into_image(icon.clone()))
|
.map(|image| image.load_into_image(icon.clone()))
|
||||||
{
|
{
|
||||||
Some(Ok(_)) => icon.show(),
|
Some(Ok(())) => icon.show(),
|
||||||
_ => icon.hide(),
|
_ => icon.hide(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.show_title {
|
if self.show_title {
|
||||||
|
label.show();
|
||||||
label.set_label(&name);
|
label.set_label(&name);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
icon.hide();
|
||||||
|
label.hide();
|
||||||
|
}
|
||||||
|
|
||||||
Continue(true)
|
Continue(true)
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue