mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Merge branch 'master' into swaybar-ipc
This commit is contained in:
53
src/bar.cpp
53
src/bar.cpp
@ -9,6 +9,7 @@
|
||||
#include "bar.hpp"
|
||||
#include "client.hpp"
|
||||
#include "factory.hpp"
|
||||
#include "group.hpp"
|
||||
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
|
||||
|
||||
#ifdef HAVE_SWAY
|
||||
@ -710,19 +711,7 @@ void waybar::Bar::setupAltFormatKeyForModuleList(const char* module_list_name) {
|
||||
}
|
||||
|
||||
void waybar::Bar::handleSignal(int signal) {
|
||||
for (auto& module : modules_left_) {
|
||||
auto* custom = dynamic_cast<waybar::modules::Custom*>(module.get());
|
||||
if (custom != nullptr) {
|
||||
custom->refresh(signal);
|
||||
}
|
||||
}
|
||||
for (auto& module : modules_center_) {
|
||||
auto* custom = dynamic_cast<waybar::modules::Custom*>(module.get());
|
||||
if (custom != nullptr) {
|
||||
custom->refresh(signal);
|
||||
}
|
||||
}
|
||||
for (auto& module : modules_right_) {
|
||||
for (auto& module : modules_all_) {
|
||||
auto* custom = dynamic_cast<waybar::modules::Custom*>(module.get());
|
||||
if (custom != nullptr) {
|
||||
custom->refresh(signal);
|
||||
@ -730,19 +719,35 @@ void waybar::Bar::handleSignal(int signal) {
|
||||
}
|
||||
}
|
||||
|
||||
void waybar::Bar::getModules(const Factory& factory, const std::string& pos) {
|
||||
if (config[pos].isArray()) {
|
||||
for (const auto& name : config[pos]) {
|
||||
void waybar::Bar::getModules(const Factory& factory, const std::string& pos, Gtk::Box* group = nullptr) {
|
||||
auto module_list = group ? config[pos]["modules"] : config[pos];
|
||||
if (module_list.isArray()) {
|
||||
for (const auto& name : module_list) {
|
||||
try {
|
||||
auto module = factory.makeModule(name.asString());
|
||||
if (pos == "modules-left") {
|
||||
modules_left_.emplace_back(module);
|
||||
auto ref = name.asString();
|
||||
AModule* module;
|
||||
|
||||
if (ref.compare(0, 6, "group/") == 0 && ref.size() > 6) {
|
||||
auto group_module = new waybar::Group(ref, *this, config[ref]);
|
||||
getModules(factory, ref, &group_module->box);
|
||||
module = group_module;
|
||||
} else {
|
||||
module = factory.makeModule(ref);
|
||||
}
|
||||
if (pos == "modules-center") {
|
||||
modules_center_.emplace_back(module);
|
||||
}
|
||||
if (pos == "modules-right") {
|
||||
modules_right_.emplace_back(module);
|
||||
|
||||
modules_all_.emplace_back(module);
|
||||
if (group) {
|
||||
group->pack_start(*module, false, false);
|
||||
} else {
|
||||
if (pos == "modules-left") {
|
||||
modules_left_.emplace_back(module);
|
||||
}
|
||||
if (pos == "modules-center") {
|
||||
modules_center_.emplace_back(module);
|
||||
}
|
||||
if (pos == "modules-right") {
|
||||
modules_right_.emplace_back(module);
|
||||
}
|
||||
}
|
||||
module->dp.connect([module, &name] {
|
||||
try {
|
||||
|
19
src/group.cpp
Normal file
19
src/group.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include "group.hpp"
|
||||
#include <fmt/format.h>
|
||||
#include <util/command.hpp>
|
||||
|
||||
namespace waybar {
|
||||
|
||||
Group::Group(const std::string& name, const Bar& bar, const Json::Value& config)
|
||||
: AModule(config, name, "", false, false),
|
||||
box{bar.vertical ? Gtk::ORIENTATION_HORIZONTAL : Gtk::ORIENTATION_VERTICAL, 0}
|
||||
{
|
||||
}
|
||||
|
||||
auto Group::update() -> void {
|
||||
// noop
|
||||
}
|
||||
|
||||
Group::operator Gtk::Widget&() { return box; }
|
||||
|
||||
} // namespace waybar
|
@ -211,7 +211,7 @@ static const std::array<std::string, 9> ports = {
|
||||
};
|
||||
|
||||
const std::vector<std::string> waybar::modules::Pulseaudio::getPulseIcon() const {
|
||||
std::vector<std::string> res = {default_source_name_};
|
||||
std::vector<std::string> res = {current_sink_name_, default_source_name_};
|
||||
std::string nameLC = port_name_ + form_factor_;
|
||||
std::transform(nameLC.begin(), nameLC.end(), nameLC.begin(), ::tolower);
|
||||
for (auto const &port : ports) {
|
||||
|
Reference in New Issue
Block a user