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>
|
|
|
|
#include "IModule.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-04-18 17:52:00 +02:00
|
|
|
#include "util/json.hpp"
|
|
|
|
#include "util/sleeper_thread.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
|
|
|
|
2018-08-16 14:29:41 +02:00
|
|
|
class Workspaces : public IModule {
|
2019-04-18 17:52:00 +02:00
|
|
|
public:
|
|
|
|
Workspaces(const std::string&, const waybar::Bar&, const Json::Value&);
|
|
|
|
~Workspaces() = default;
|
|
|
|
auto update() -> void;
|
|
|
|
operator Gtk::Widget&();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void worker();
|
|
|
|
void addWorkspace(const Json::Value&);
|
|
|
|
void onButtonReady(const Json::Value&, Gtk::Button&);
|
|
|
|
std::string getIcon(const std::string&, const Json::Value&);
|
|
|
|
bool handleScroll(GdkEventScroll*);
|
|
|
|
const std::string getCycleWorkspace(uint8_t current, bool prev) const;
|
|
|
|
uint16_t getWorkspaceIndex(const std::string& name) const;
|
|
|
|
std::string trimWorkspaceName(std::string);
|
2018-08-16 14:29:41 +02:00
|
|
|
|
2019-04-18 17:52:00 +02:00
|
|
|
const Bar& bar_;
|
|
|
|
const Json::Value& config_;
|
|
|
|
Json::Value workspaces_;
|
|
|
|
waybar::util::SleeperThread thread_;
|
|
|
|
Gtk::Box box_;
|
|
|
|
util::JsonParser parser_;
|
|
|
|
Ipc ipc_;
|
|
|
|
std::mutex mutex_;
|
|
|
|
bool scrolling_;
|
|
|
|
std::unordered_map<std::string, Gtk::Button> buttons_;
|
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
|