refactor: avoid useless has_class check

This commit is contained in:
Alexis
2018-08-10 17:05:12 +02:00
parent 9e85c68fc8
commit 4d3879f26f
4 changed files with 9 additions and 9 deletions

View File

@ -4,7 +4,6 @@
waybar::modules::Custom::Custom(std::string name, Json::Value config)
: _name(name), _config(config)
{
_label.get_style_context()->add_class("custom-" + name);
if (!_config["exec"]) {
std::cerr << name + " has no exec path." << std::endl;
return;
@ -36,9 +35,11 @@ auto waybar::modules::Custom::update() -> void
}
// Hide label if output is empty
if (output.empty())
if (output.empty()) {
_label.get_style_context()->remove_class("custom-" + _name);
_label.hide();
else {
} else {
_label.get_style_context()->add_class("custom-" + _name);
auto format = _config["format"] ? _config["format"].asString() : "{}";
_label.set_text(fmt::format(format, output));
_label.show();