feat(mpd): Add support for setting tooltip label when disconnected

This commit is contained in:
Minijackson 2019-04-17 10:46:08 +02:00
parent 06aff70e2e
commit 8c9dd94670
No known key found for this signature in database
GPG Key ID: FEA888C9F5D64F62

View File

@ -59,6 +59,14 @@ void waybar::modules::MPD::setLabel() {
auto format = config_["format-disconnected"].isString() ? auto format = config_["format-disconnected"].isString() ?
config_["format-disconnected"].asString() : "disconnected"; config_["format-disconnected"].asString() : "disconnected";
label_.set_markup(format); label_.set_markup(format);
if (tooltipEnabled()) {
std::string tooltip_format;
tooltip_format = config_["tooltip-format-disconnected"].isString() ?
config_["tooltip-format-disconnected"].asString() : "MPD (disconnected)";
// Nothing to format
label_.set_tooltip_text(tooltip_format);
}
return; return;
} else { } else {
label_.get_style_context()->remove_class("disconnected"); label_.get_style_context()->remove_class("disconnected");
@ -92,7 +100,7 @@ void waybar::modules::MPD::setLabel() {
if (tooltipEnabled()) { if (tooltipEnabled()) {
std::string tooltip_format; std::string tooltip_format;
tooltip_format = config_["tooltip-format"].isString() ? tooltip_format = config_["tooltip-format"].isString() ?
config_["tooltip-format"].asString() : "MPD"; config_["tooltip-format"].asString() : "MPD (connected)";
auto tooltip_text = fmt::format(tooltip_format, auto tooltip_text = fmt::format(tooltip_format,
fmt::arg("artist", artist), fmt::arg("artist", artist),
fmt::arg("album-artist", album_artist), fmt::arg("album-artist", album_artist),