From 6e69af89678a441c1145edc7210b545b1ea03ede Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 27 May 2019 00:08:16 +0200 Subject: [PATCH] refactor(custon): avoid useless logic --- src/modules/custom.cpp | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/modules/custom.cpp b/src/modules/custom.cpp index f134f980..cdf13d7a 100644 --- a/src/modules/custom.cpp +++ b/src/modules/custom.cpp @@ -102,30 +102,29 @@ auto waybar::modules::Custom::update() -> void { } else { parseOutputRaw(); } - - auto str = fmt::format(format_, - text_, - fmt::arg("alt", alt_), - fmt::arg("icon", getIcon(percentage_, alt_)), - fmt::arg("percentage", percentage_)); - label_.set_markup(str); - if (tooltipEnabled()) { - if (text_ == tooltip_) { - label_.set_tooltip_text(str); - } else { - label_.set_tooltip_text(tooltip_); - } - } - auto classes = label_.get_style_context()->list_classes(); - for (auto const& c : classes) { - label_.get_style_context()->remove_class(c); - } - for (auto const& c : class_) { - label_.get_style_context()->add_class(c); - } if (text_.empty()) { event_box_.hide(); } else { + auto str = fmt::format(format_, + text_, + fmt::arg("alt", alt_), + fmt::arg("icon", getIcon(percentage_, alt_)), + fmt::arg("percentage", percentage_)); + label_.set_markup(str); + if (tooltipEnabled()) { + if (text_ == tooltip_) { + label_.set_tooltip_text(str); + } else { + label_.set_tooltip_text(tooltip_); + } + } + auto classes = label_.get_style_context()->list_classes(); + for (auto const& c : classes) { + label_.get_style_context()->remove_class(c); + } + for (auto const& c : class_) { + label_.get_style_context()->add_class(c); + } event_box_.show(); } }