2021-10-17 18:08:16 +00:00
|
|
|
#include "AIconLabel.hpp"
|
|
|
|
|
|
|
|
#include <gdkmm/pixbuf.h>
|
|
|
|
|
|
|
|
namespace waybar {
|
|
|
|
|
|
|
|
AIconLabel::AIconLabel(const Json::Value &config, const std::string &name, const std::string &id,
|
|
|
|
const std::string &format, uint16_t interval, bool ellipsize,
|
|
|
|
bool enable_click, bool enable_scroll)
|
|
|
|
: ALabel(config, name, id, format, interval, ellipsize, enable_click, enable_scroll) {
|
|
|
|
event_box_.remove();
|
2024-02-26 04:07:03 +00:00
|
|
|
label_.unset_name();
|
|
|
|
label_.get_style_context()->remove_class(MODULE_CLASS);
|
|
|
|
box_.get_style_context()->add_class(MODULE_CLASS);
|
|
|
|
if (!id.empty()) {
|
|
|
|
label_.get_style_context()->remove_class(id);
|
|
|
|
box_.get_style_context()->add_class(id);
|
|
|
|
}
|
2024-02-25 22:56:52 +00:00
|
|
|
|
2024-02-26 04:07:03 +00:00
|
|
|
box_.set_orientation(Gtk::Orientation::ORIENTATION_HORIZONTAL);
|
|
|
|
box_.set_name(name);
|
2024-02-25 22:56:52 +00:00
|
|
|
|
2024-02-28 00:24:58 +00:00
|
|
|
int spacing = config_["icon-spacing"].isInt() ? config_["icon-spacing"].asInt() : 8;
|
2024-02-26 20:58:38 +00:00
|
|
|
box_.set_spacing(spacing);
|
|
|
|
|
2021-10-17 18:08:16 +00:00
|
|
|
box_.add(image_);
|
|
|
|
box_.add(label_);
|
2024-02-26 04:07:03 +00:00
|
|
|
|
2021-10-17 18:08:16 +00:00
|
|
|
event_box_.add(box_);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto AIconLabel::update() -> void {
|
|
|
|
image_.set_visible(image_.get_visible() && iconEnabled());
|
|
|
|
ALabel::update();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AIconLabel::iconEnabled() const {
|
2022-03-10 08:48:50 +00:00
|
|
|
return config_["icon"].isBool() ? config_["icon"].asBool() : false;
|
2021-10-17 18:08:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace waybar
|