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:
parent
12053f111a
commit
1759945912
2 changed files with 37 additions and 19 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue