button: Hardcode min-width property set to zero

Buttons come with an intrinsic min-width but lack a method to alter this
property. Setting the requested size to zero has also no effect on it.
The only way found to work is to hard code the CSS into the button.
pull/1738/head
Simon Plakolb 2022-10-20 10:27:41 +02:00
parent c18c6b080a
commit 1f591e36f1
2 changed files with 7 additions and 0 deletions

View File

@ -2,6 +2,7 @@
#include <glibmm/markup.h> #include <glibmm/markup.h>
#include <gtkmm/button.h> #include <gtkmm/button.h>
#include <gtkmm/cssprovider.h>
#include <gtkmm/label.h> #include <gtkmm/label.h>
#include <json/json.h> #include <json/json.h>

View File

@ -18,6 +18,12 @@ AButton::AButton(const Json::Value& config, const std::string& name, const std::
default_format_(format_) { default_format_(format_) {
button_.set_name(name); button_.set_name(name);
button_.set_relief(Gtk::RELIEF_NONE); button_.set_relief(Gtk::RELIEF_NONE);
/* https://github.com/Alexays/Waybar/issues/1731 */
auto css = Gtk::CssProvider::create();
css->load_from_data("button { min-width: 0; }");
button_.get_style_context()->add_provider(css, GTK_STYLE_PROVIDER_PRIORITY_USER);
if (!id.empty()) { if (!id.empty()) {
button_.get_style_context()->add_class(id); button_.get_style_context()->add_class(id);
} }