feat: add module class to the root elements of the modules

Previously, the only way to select all the module labels was with the
following kind of selector:
```css
.modules-left > widget > label,
.modules-center > widget > label,
.modules-right > widget > label {
    /* ... */
}
```
(and a matching block for the `box` containers).

Now, this can be expressed as
```css
label.module, box.module {
    /* ... */
}
```
This commit is contained in:
Aleksei Bavshin
2024-02-14 22:04:42 -08:00
parent 2f555a6936
commit d590d508ca
13 changed files with 20 additions and 5 deletions

View File

@ -176,16 +176,18 @@ auto waybar::modules::Custom::update() -> void {
}
}
}
auto classes = label_.get_style_context()->list_classes();
auto style = label_.get_style_context();
auto classes = style->list_classes();
for (auto const& c : classes) {
if (c == id_) continue;
label_.get_style_context()->remove_class(c);
style->remove_class(c);
}
for (auto const& c : class_) {
label_.get_style_context()->add_class(c);
style->add_class(c);
}
label_.get_style_context()->add_class("flat");
label_.get_style_context()->add_class("text-button");
style->add_class("flat");
style->add_class("text-button");
style->add_class(MODULE_CLASS);
event_box_.show();
}
}