Merge branch 'master' into custom-multiple-classes

pull/265/head
Alex 2019-04-15 10:58:27 +02:00 committed by GitHub
commit 5828d34fa0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -8,6 +8,7 @@
#include "IModule.hpp" #include "IModule.hpp"
#include "modules/sway/ipc/client.hpp" #include "modules/sway/ipc/client.hpp"
#include <gtkmm/button.h> #include <gtkmm/button.h>
#include <gtkmm/label.h>
namespace waybar::modules::sway { namespace waybar::modules::sway {

View File

@ -81,13 +81,17 @@ auto waybar::modules::sway::Workspaces::update() -> void
box_.reorder_child(button, getWorkspaceIndex(node["name"].asString())); 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()) { if (config_["format"].isString()) {
auto format = config_["format"].asString(); auto format = config_["format"].asString();
button.set_label(fmt::format(format, fmt::arg("icon", icon), output = fmt::format(format, fmt::arg("icon", icon),
fmt::arg("name", trimWorkspaceName(node["name"].asString())), fmt::arg("name", trimWorkspaceName(node["name"].asString())),
fmt::arg("index", node["num"].asString()))); fmt::arg("index", node["num"].asString()));
}
if (!config_["disable-markup"].asBool()) {
static_cast<Gtk::Label*>(button.get_children()[0])->set_markup(output);
} else { } else {
button.set_label(icon); button.set_label(output);
} }
onButtonReady(node, button); onButtonReady(node, button);
} }
@ -107,6 +111,9 @@ void waybar::modules::sway::Workspaces::addWorkspace(const Json::Value &node)
: icon; : icon;
auto pair = buttons_.emplace(node["name"].asString(), format); auto pair = buttons_.emplace(node["name"].asString(), format);
auto &button = pair.first->second; auto &button = pair.first->second;
if (!config_["disable-markup"].asBool()) {
static_cast<Gtk::Label*>(button.get_children()[0])->set_markup(format);
}
box_.pack_start(button, false, false, 0); box_.pack_start(button, false, false, 0);
button.set_relief(Gtk::RELIEF_NONE); button.set_relief(Gtk::RELIEF_NONE);
button.signal_clicked().connect([this, pair] { button.signal_clicked().connect([this, pair] {