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

fix(music): correctly show/hide popup elements based on player capabilities

This commit is contained in:
Jake Stanger 2023-06-30 17:59:40 +01:00
parent 12053f111a
commit 1759945912
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
2 changed files with 37 additions and 19 deletions

View file

@ -423,15 +423,9 @@ impl Module<Button> for MusicModule {
}
}
title_label
.label
.set_text(&update.song.title.unwrap_or_default());
album_label
.label
.set_text(&update.song.album.unwrap_or_default());
artist_label
.label
.set_text(&update.song.artist.unwrap_or_default());
update_popup_metadata_label(update.song.title, &title_label);
update_popup_metadata_label(update.song.album, &album_label);
update_popup_metadata_label(update.song.artist, &artist_label);
match update.status.state {
PlayerState::Stopped => {
@ -500,6 +494,18 @@ impl Module<Button> for MusicModule {
}
}
fn update_popup_metadata_label(text: Option<String>, label: &IconLabel) {
match text {
Some(value) => {
label.label.set_text(&value);
label.container.show_all();
}
None => {
label.container.hide();
}
}
}
/// Replaces each of the formatting tokens in the formatting string
/// with actual data pulled from the music player
fn replace_tokens(format_string: &str, tokens: &Vec<String>, song: &Track) -> String {