use snake_case for variable name

This commit is contained in:
Rio Sanjaya
2025-12-27 17:57:20 +07:00
parent eb2090688c
commit 8e9ebb8bb1
2 changed files with 14 additions and 14 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ class AIconLabel : public ALabel {
Gtk::Box box_; Gtk::Box box_;
unsigned app_icon_size_{24}; unsigned app_icon_size_{24};
bool labelContainsIcon; bool label_contains_icon;
bool iconEnabled() const; bool iconEnabled() const;
}; };
+13 -13
View File
@@ -62,31 +62,31 @@ AIconLabel::AIconLabel(const Json::Value &config, const std::string &name, const
} }
std::tuple<std::string, std::string> AIconLabel::extractIcon(const std::string& input) { std::tuple<std::string, std::string> AIconLabel::extractIcon(const std::string& input) {
std::string iconResult = ""; std::string icon_result = "";
std::string labelResult = input; std::string label_result = input;
try { try {
const std::regex iconSearch(R"((?=\\0icon\\1f).+?(?=\\n))"); const std::regex icon_search(R"((?=\\0icon\\1f).+?(?=\\n))");
std::smatch iconMatch; std::smatch icon_match;
if (std::regex_search(input, iconMatch, iconSearch)) { if (std::regex_search(input, icon_match, icon_search)) {
iconResult = iconMatch[0].str().substr(9); icon_result = icon_match[0].str().substr(9);
const std::regex cleanLabelPattern(R"(\\0icon\\1f.+?\\n)"); const std::regex clean_label_pattern(R"(\\0icon\\1f.+?\\n)");
labelResult = std::regex_replace(input, cleanLabelPattern, ""); label_result = std::regex_replace(input, clean_label_pattern, "");
} }
} catch (const std::exception& e) { } catch (const std::exception& e) {
spdlog::warn("Error while parsing icon from label. {}", e.what()); spdlog::warn("Error while parsing icon from label. {}", e.what());
} }
return std::make_tuple(iconResult, labelResult); return std::make_tuple(icon_result, label_result);
} }
auto AIconLabel::update() -> void { auto AIconLabel::update() -> void {
labelContainsIcon = false; label_contains_icon = false;
auto [iconLabel, cleanLabel] = extractIcon(label_.get_label().c_str()); auto [iconLabel, cleanLabel] = extractIcon(label_.get_label().c_str());
labelContainsIcon = iconLabel.length() > 0; label_contains_icon = iconLabel.length() > 0;
if (labelContainsIcon) { if (label_contains_icon) {
label_.set_markup(cleanLabel); label_.set_markup(cleanLabel);
if (iconLabel.front() == '/') { if (iconLabel.front() == '/') {
@@ -108,7 +108,7 @@ auto AIconLabel::update() -> void {
} }
bool AIconLabel::iconEnabled() const { bool AIconLabel::iconEnabled() const {
return labelContainsIcon || (config_["icon"].isBool() ? config_["icon"].asBool() : false); return label_contains_icon || (config_["icon"].isBool() ? config_["icon"].asBool() : false);
} }
} // namespace waybar } // namespace waybar