mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
refactor: format code
This commit is contained in:
@ -44,7 +44,7 @@ auto waybar::modules::sway::Workspaces::update() -> void {
|
||||
});
|
||||
if (ws == workspaces_.end() ||
|
||||
(!config_["all-outputs"].asBool() && (*ws)["output"].asString() != bar_.output->name)) {
|
||||
it = buttons_.erase(it);
|
||||
it = buttons_.erase(it);
|
||||
needReorder = true;
|
||||
} else {
|
||||
++it;
|
||||
@ -78,11 +78,11 @@ auto waybar::modules::sway::Workspaces::update() -> void {
|
||||
if (needReorder) {
|
||||
box_.reorder_child(button, getWorkspaceIndex(node["name"].asString()));
|
||||
}
|
||||
auto icon = getIcon(node["name"].asString(), node);
|
||||
auto icon = getIcon(node["name"].asString(), node);
|
||||
std::string output = icon;
|
||||
if (config_["format"].isString()) {
|
||||
auto format = config_["format"].asString();
|
||||
output = fmt::format(format,
|
||||
output = fmt::format(format,
|
||||
fmt::arg("icon", icon),
|
||||
fmt::arg("name", trimWorkspaceName(node["name"].asString())),
|
||||
fmt::arg("index", node["num"].asString()));
|
||||
@ -101,14 +101,14 @@ auto waybar::modules::sway::Workspaces::update() -> void {
|
||||
}
|
||||
|
||||
void waybar::modules::sway::Workspaces::addWorkspace(const Json::Value &node) {
|
||||
auto icon = getIcon(node["name"].asString(), node);
|
||||
auto icon = getIcon(node["name"].asString(), node);
|
||||
auto format = config_["format"].isString()
|
||||
? fmt::format(config_["format"].asString(),
|
||||
fmt::arg("icon", icon),
|
||||
fmt::arg("name", trimWorkspaceName(node["name"].asString())),
|
||||
fmt::arg("index", node["num"].asString()))
|
||||
: icon;
|
||||
auto pair = buttons_.emplace(node["name"].asString(), format);
|
||||
auto pair = buttons_.emplace(node["name"].asString(), format);
|
||||
auto &button = pair.first->second;
|
||||
if (!config_["disable-markup"].asBool()) {
|
||||
static_cast<Gtk::Label *>(button.get_children()[0])->set_markup(format);
|
||||
@ -201,9 +201,9 @@ bool waybar::modules::sway::Workspaces::handleScroll(GdkEventScroll *e) {
|
||||
|
||||
const std::string waybar::modules::sway::Workspaces::getCycleWorkspace(uint8_t focused_workspace,
|
||||
bool prev) const {
|
||||
auto inc = prev ? -1 : 1;
|
||||
auto inc = prev ? -1 : 1;
|
||||
int size = workspaces_.size();
|
||||
uint8_t idx = 0;
|
||||
uint8_t idx = 0;
|
||||
for (int i = focused_workspace; i < size && i >= 0; i += inc) {
|
||||
bool same_output = (workspaces_[i]["output"].asString() == bar_.output->name &&
|
||||
!config_["all-outputs"].asBool()) ||
|
||||
|
Reference in New Issue
Block a user