mirror of
https://github.com/rad4day/Waybar.git
synced 2025-07-12 06:02:30 +02:00
modules: Set style-context on button
Fixes issue where the class parameters in style.css would have no effect. The CSS now references the GtkButton instead of the GtkLabel. Removing all style-classes from the custom module GtkButton however removes any properties set via style.css. Thus, the default classes 'flat' and 'text-button' are added on every update of these modules.
This commit is contained in:
@ -189,10 +189,10 @@ auto waybar::modules::Bluetooth::update() -> void {
|
||||
format_.empty() ? event_box_.hide() : event_box_.show();
|
||||
|
||||
auto update_style_context = [this](const std::string& style_class, bool in_next_state) {
|
||||
if (in_next_state && !label_->get_style_context()->has_class(style_class)) {
|
||||
label_->get_style_context()->add_class(style_class);
|
||||
} else if (!in_next_state && label_->get_style_context()->has_class(style_class)) {
|
||||
label_->get_style_context()->remove_class(style_class);
|
||||
if (in_next_state && !button_.get_style_context()->has_class(style_class)) {
|
||||
button_.get_style_context()->add_class(style_class);
|
||||
} else if (!in_next_state && button_.get_style_context()->has_class(style_class)) {
|
||||
button_.get_style_context()->remove_class(style_class);
|
||||
}
|
||||
};
|
||||
update_style_context("discoverable", cur_controller_.discoverable);
|
||||
|
Reference in New Issue
Block a user