mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
feat(modules): generic label module to allow max-length on all labels
This commit is contained in:
@ -2,21 +2,17 @@
|
||||
#include <iostream>
|
||||
|
||||
waybar::modules::Custom::Custom(const std::string &name, Json::Value config)
|
||||
: name_(name), config_(std::move(config))
|
||||
: ALabel(std::move(config)), name_(name)
|
||||
{
|
||||
if (!config_["exec"]) {
|
||||
throw std::runtime_error(name_ + " has no exec path.");
|
||||
}
|
||||
if (config_["max-length"]) {
|
||||
label_.set_max_width_chars(config_["max-length"].asUInt());
|
||||
label_.set_ellipsize(Pango::EllipsizeMode::ELLIPSIZE_END);
|
||||
}
|
||||
uint32_t interval = config_["interval"] ? config_["inveral"].asUInt() : 30;
|
||||
thread_ = [this, interval] {
|
||||
Glib::signal_idle().connect_once(sigc::mem_fun(*this, &Custom::update));
|
||||
thread_.sleep_for(chrono::seconds(interval));
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
auto waybar::modules::Custom::update() -> void
|
||||
{
|
||||
@ -52,7 +48,3 @@ auto waybar::modules::Custom::update() -> void
|
||||
label_.show();
|
||||
}
|
||||
}
|
||||
|
||||
waybar::modules::Custom::operator Gtk::Widget &() {
|
||||
return label_;
|
||||
}
|
||||
|
Reference in New Issue
Block a user