feat: can disable tooltip
parent
331b28393a
commit
83a6475510
|
@ -17,6 +17,8 @@ public:
|
|||
virtual operator Gtk::Widget &();
|
||||
|
||||
protected:
|
||||
bool tooltipEnabled();
|
||||
|
||||
Gtk::EventBox event_box_;
|
||||
Gtk::Label label_;
|
||||
const Json::Value &config_;
|
||||
|
|
|
@ -86,8 +86,8 @@ bool waybar::ALabel::handleScroll(GdkEventScroll* e) {
|
|||
return true;
|
||||
}
|
||||
|
||||
std::string waybar::ALabel::getIcon(uint16_t percentage,
|
||||
const std::string& alt) {
|
||||
std::string waybar::ALabel::getIcon(uint16_t percentage, const std::string& alt)
|
||||
{
|
||||
auto format_icons = config_["format-icons"];
|
||||
if (format_icons.isObject()) {
|
||||
if (!alt.empty() && (format_icons[alt].isString() || format_icons[alt].isArray())) {
|
||||
|
@ -107,4 +107,10 @@ std::string waybar::ALabel::getIcon(uint16_t percentage,
|
|||
return "";
|
||||
}
|
||||
|
||||
bool waybar::ALabel::tooltipEnabled()
|
||||
{
|
||||
return !config_["tooltip"].isBool() ||
|
||||
(config_["tooltip"].isBool() && config_["tooltip"].asBool());
|
||||
}
|
||||
|
||||
waybar::ALabel::operator Gtk::Widget&() { return event_box_; }
|
||||
|
|
|
@ -148,7 +148,9 @@ auto waybar::modules::Battery::update() -> void
|
|||
if (status == "Unknown") {
|
||||
status = getAdapterStatus(capacity);
|
||||
}
|
||||
if (tooltipEnabled()) {
|
||||
label_.set_tooltip_text(status);
|
||||
}
|
||||
std::transform(status.begin(), status.end(), status.begin(), ::tolower);
|
||||
auto format = format_;
|
||||
auto state = getState(capacity);
|
||||
|
|
|
@ -18,7 +18,9 @@ auto waybar::modules::Cpu::update() -> void
|
|||
// TODO: as creating dynamic fmt::arg arrays is buggy we have to calc both
|
||||
auto cpu_load = getCpuLoad();
|
||||
auto [cpu_usage, tooltip] = getCpuUsage();
|
||||
if (tooltipEnabled()) {
|
||||
label_.set_tooltip_text(tooltip);
|
||||
}
|
||||
label_.set_markup(fmt::format(format_,
|
||||
fmt::arg("load", cpu_load), fmt::arg("usage", cpu_usage)));
|
||||
}
|
||||
|
|
|
@ -94,11 +94,13 @@ auto waybar::modules::Custom::update() -> void
|
|||
fmt::arg("icon", getIcon(percentage_)),
|
||||
fmt::arg("percentage", percentage_));
|
||||
label_.set_markup(str);
|
||||
if (tooltipEnabled()) {
|
||||
if (text_ == tooltip_) {
|
||||
label_.set_tooltip_text(str);
|
||||
} else {
|
||||
label_.set_tooltip_text(tooltip_);
|
||||
}
|
||||
}
|
||||
if (class_ != "") {
|
||||
if (prevclass_ != "") {
|
||||
label_.get_style_context()->remove_class(prevclass_);
|
||||
|
|
|
@ -20,7 +20,9 @@ auto waybar::modules::Memory::update() -> void
|
|||
int used_ram_percentage = 100 * (memtotal_ - memfree_) / memtotal_;
|
||||
label_.set_markup(fmt::format(format_, used_ram_percentage));
|
||||
auto used_ram_gigabytes = (memtotal_ - memfree_) / std::pow(1024, 2);
|
||||
if (tooltipEnabled()) {
|
||||
label_.set_tooltip_text(fmt::format("{:.{}f}Gb used", used_ram_gigabytes, 1));
|
||||
}
|
||||
event_box_.show();
|
||||
} else {
|
||||
event_box_.hide();
|
||||
|
|
|
@ -215,7 +215,9 @@ auto waybar::modules::Pulseaudio::update() -> void
|
|||
label_.set_markup(
|
||||
fmt::format(format, fmt::arg("volume", volume_),
|
||||
fmt::arg("icon", getIcon(volume_, getPortIcon()))));
|
||||
if (tooltipEnabled()) {
|
||||
label_.set_tooltip_text(desc_);
|
||||
}
|
||||
if (scrolling_) {
|
||||
scrolling_ = false;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,9 @@ auto waybar::modules::sway::Mode::update() -> void
|
|||
event_box_.hide();
|
||||
} else {
|
||||
label_.set_markup(fmt::format(format_, mode_));
|
||||
if (tooltipEnabled()) {
|
||||
label_.set_tooltip_text(mode_);
|
||||
}
|
||||
event_box_.show();
|
||||
}
|
||||
}
|
|
@ -48,8 +48,10 @@ void waybar::modules::sway::Window::worker()
|
|||
auto waybar::modules::sway::Window::update() -> void
|
||||
{
|
||||
label_.set_markup(fmt::format(format_, window_));
|
||||
if (tooltipEnabled()) {
|
||||
label_.set_tooltip_text(window_);
|
||||
}
|
||||
}
|
||||
|
||||
std::tuple<int, std::string> waybar::modules::sway::Window::getFocusedNode(
|
||||
Json::Value nodes)
|
||||
|
|
Loading…
Reference in New Issue