1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-03 04:33:30 -05:00
polybar/include/modules/menu.hpp

45 lines
983 B
C++
Raw Normal View History

#pragma once
2016-05-19 10:41:06 -04:00
#include <mutex>
#include "modules/base.hpp"
namespace modules
{
struct MenuTreeItem {
std::string exec;
std::unique_ptr<drawtypes::Label> label;
};
struct MenuTree {
std::vector<std::unique_ptr<MenuTreeItem>> items;
};
DefineModule(MenuModule, StaticModule)
{
static constexpr auto TAG_LABEL_TOGGLE = "<label:toggle>";
static constexpr auto TAG_MENU = "<menu>";
2016-05-19 10:41:06 -04:00
static constexpr auto EVENT_MENU_OPEN = "menu_open:";
static constexpr auto EVENT_MENU_CLOSE = "menu_close";
2016-05-19 10:41:06 -04:00
std::mutex output_mtx;
std::mutex cmd_mtx;
int current_level = -1;
std::vector<std::unique_ptr<MenuTree>> levels;
std::unique_ptr<drawtypes::Label> label_open;
std::unique_ptr<drawtypes::Label> label_close;
public:
explicit MenuModule(const std::string& name);
2016-05-19 10:41:06 -04:00
std::string get_output();
2016-05-19 10:41:06 -04:00
bool build(Builder *builder, const std::string& tag);
bool handle_command(const std::string& cmd);
};
}