mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Allow enabing pango markup in the taskbar string
The fix for taskbar tooltips in 6a2d214b55
was incomplete: it causes the label
to contain escaped titles. Use set_markup so that GTK decodes markup again,
but only if requested by the user (disabling markup is needed if using format
strings like "{title:.15}" to avoid terminating the string in the middle of an
XML entity).
This commit is contained in:
parent
447fad34c7
commit
ea722615c4
@ -32,6 +32,11 @@ Addressed by *wlr/taskbar*
|
||||
default: 16 ++
|
||||
The size of the icon.
|
||||
|
||||
*markup*: ++
|
||||
typeof: bool ++
|
||||
default: false ++
|
||||
If set to true, pango markup will be accepted in format and tooltip-format.
|
||||
|
||||
*tooltip*: ++
|
||||
typeof: bool ++
|
||||
default: true ++
|
||||
|
@ -306,7 +306,7 @@ std::string Task::state_string(bool shortened) const
|
||||
|
||||
void Task::handle_title(const char *title)
|
||||
{
|
||||
title_ = Glib::Markup::escape_text(title);
|
||||
title_ = title;
|
||||
}
|
||||
|
||||
void Task::handle_app_id(const char *app_id)
|
||||
@ -460,38 +460,51 @@ bool Task::operator!=(const Task &o) const
|
||||
|
||||
void Task::update()
|
||||
{
|
||||
bool markup = config_["markup"].isBool() ? config_["markup"].asBool() : false;
|
||||
std::string title = title_;
|
||||
std::string app_id = app_id_;
|
||||
if (markup) {
|
||||
title = Glib::Markup::escape_text(title);
|
||||
app_id = Glib::Markup::escape_text(app_id);
|
||||
}
|
||||
if (!format_before_.empty()) {
|
||||
text_before_.set_label(
|
||||
fmt::format(format_before_,
|
||||
fmt::arg("title", title_),
|
||||
fmt::arg("app_id", app_id_),
|
||||
auto txt = fmt::format(format_before_,
|
||||
fmt::arg("title", title),
|
||||
fmt::arg("app_id", app_id),
|
||||
fmt::arg("state", state_string()),
|
||||
fmt::arg("short_state", state_string(true))
|
||||
)
|
||||
);
|
||||
);
|
||||
if (markup)
|
||||
text_before_.set_markup(txt);
|
||||
else
|
||||
text_before_.set_label(txt);
|
||||
text_before_.show();
|
||||
}
|
||||
if (!format_after_.empty()) {
|
||||
text_after_.set_label(
|
||||
fmt::format(format_after_,
|
||||
fmt::arg("title", title_),
|
||||
fmt::arg("app_id", app_id_),
|
||||
auto txt = fmt::format(format_after_,
|
||||
fmt::arg("title", title),
|
||||
fmt::arg("app_id", app_id),
|
||||
fmt::arg("state", state_string()),
|
||||
fmt::arg("short_state", state_string(true))
|
||||
)
|
||||
);
|
||||
);
|
||||
if (markup)
|
||||
text_after_.set_markup(txt);
|
||||
else
|
||||
text_after_.set_label(txt);
|
||||
text_after_.show();
|
||||
}
|
||||
|
||||
if (!format_tooltip_.empty()) {
|
||||
button_.set_tooltip_markup(
|
||||
fmt::format(format_tooltip_,
|
||||
fmt::arg("title", title_),
|
||||
fmt::arg("app_id", app_id_),
|
||||
auto txt = fmt::format(format_tooltip_,
|
||||
fmt::arg("title", title),
|
||||
fmt::arg("app_id", app_id),
|
||||
fmt::arg("state", state_string()),
|
||||
fmt::arg("short_state", state_string(true))
|
||||
)
|
||||
);
|
||||
);
|
||||
if (markup)
|
||||
button_.set_tooltip_markup(txt);
|
||||
else
|
||||
button_.set_tooltip_text(txt);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user