2018-08-08 23:54:58 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <fmt/format.h>
|
2019-04-18 17:52:00 +02:00
|
|
|
#include <gtkmm/button.h>
|
|
|
|
#include <gtkmm/label.h>
|
2019-06-15 14:57:52 +02:00
|
|
|
#include "AModule.hpp"
|
2018-08-08 23:54:58 +02:00
|
|
|
#include "bar.hpp"
|
|
|
|
#include "client.hpp"
|
2018-08-20 14:50:45 +02:00
|
|
|
#include "modules/sway/ipc/client.hpp"
|
2019-05-07 13:43:48 +02:00
|
|
|
#include "util/json.hpp"
|
2018-08-08 23:54:58 +02:00
|
|
|
|
2018-08-15 20:17:17 +02:00
|
|
|
namespace waybar::modules::sway {
|
2018-08-08 23:54:58 +02:00
|
|
|
|
2019-06-15 14:57:52 +02:00
|
|
|
class Workspaces : public AModule, public sigc::trackable {
|
2019-04-18 17:52:00 +02:00
|
|
|
public:
|
|
|
|
Workspaces(const std::string&, const waybar::Bar&, const Json::Value&);
|
|
|
|
~Workspaces() = default;
|
|
|
|
auto update() -> void;
|
|
|
|
|
|
|
|
private:
|
2019-04-24 12:37:24 +02:00
|
|
|
void onCmd(const struct Ipc::ipc_response&);
|
|
|
|
void onEvent(const struct Ipc::ipc_response&);
|
2019-04-19 16:48:02 +02:00
|
|
|
bool filterButtons();
|
|
|
|
Gtk::Button& addButton(const Json::Value&);
|
2019-04-18 17:52:00 +02:00
|
|
|
void onButtonReady(const Json::Value&, Gtk::Button&);
|
|
|
|
std::string getIcon(const std::string&, const Json::Value&);
|
2019-04-19 16:48:02 +02:00
|
|
|
const std::string getCycleWorkspace(std::vector<Json::Value>::iterator, bool prev) const;
|
|
|
|
uint16_t getWorkspaceIndex(const std::string& name) const;
|
2019-04-18 17:52:00 +02:00
|
|
|
std::string trimWorkspaceName(std::string);
|
2019-05-17 09:59:37 +02:00
|
|
|
bool handleScroll(GdkEventScroll*);
|
2018-08-16 14:29:41 +02:00
|
|
|
|
2019-04-18 17:52:00 +02:00
|
|
|
const Bar& bar_;
|
2019-04-19 16:48:02 +02:00
|
|
|
std::vector<Json::Value> workspaces_;
|
2019-05-18 17:58:01 +02:00
|
|
|
std::vector<std::string> workspaces_order_;
|
2019-04-18 17:52:00 +02:00
|
|
|
Gtk::Box box_;
|
2019-05-07 13:43:48 +02:00
|
|
|
util::JsonParser parser_;
|
2019-04-18 17:52:00 +02:00
|
|
|
std::unordered_map<std::string, Gtk::Button> buttons_;
|
2019-06-17 11:39:45 +02:00
|
|
|
std::mutex mutex_;
|
2019-08-28 04:43:03 +02:00
|
|
|
Ipc ipc_;
|
2018-08-16 14:29:41 +02:00
|
|
|
};
|
2018-08-08 23:54:58 +02:00
|
|
|
|
2019-04-18 17:52:00 +02:00
|
|
|
} // namespace waybar::modules::sway
|