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:
Simon Plakolb
2021-05-29 19:40:50 +02:00
parent 0012bcbd74
commit 8fa5d9b838
12 changed files with 49 additions and 47 deletions

View File

@ -117,10 +117,10 @@ auto Inhibitor::activated() -> bool { return handle_ != -1; }
auto Inhibitor::update() -> void {
std::string status_text = activated() ? "activated" : "deactivated";
label_->get_style_context()->remove_class(activated() ? "deactivated" : "activated");
button_.get_style_context()->remove_class(activated() ? "deactivated" : "activated");
label_->set_markup(fmt::format(format_, fmt::arg("status", status_text),
fmt::arg("icon", getIcon(0, status_text))));
label_->get_style_context()->add_class(status_text);
button_.get_style_context()->add_class(status_text);
if (tooltipEnabled()) {
label_->set_tooltip_text(status_text);