♻️ move GMenu to ALabel class
This commit is contained in:
@ -27,24 +27,6 @@ AModule::AModule(const Json::Value& config, const std::string& name, const std::
|
||||
else
|
||||
spdlog::warn("Wrong actions section configuration. See config by index: {}", it.index());
|
||||
}
|
||||
// If a GTKMenu is requested in the config
|
||||
if (config_["menu"].isString()) {
|
||||
// Create the GTKMenu widget
|
||||
GtkBuilder* builder = gtk_builder_new_from_file(config_["menu-file"].asString().c_str());
|
||||
menu_ = gtk_builder_get_object(builder, "menu");
|
||||
submenus_ = std::map<std::string, GtkMenuItem*>();
|
||||
menuActionsMap_ = std::map<std::string, std::string>();
|
||||
// Linking actions to the GTKMenu based on
|
||||
for (Json::Value::const_iterator it = config_["menu-actions"].begin(); it != config_["menu-actions"].end(); ++it) {
|
||||
std::string key = it.key().asString();
|
||||
submenus_[key] = GTK_MENU_ITEM(gtk_builder_get_object(builder, key.c_str()));
|
||||
menuActionsMap_[key] = it->asString();
|
||||
g_signal_connect(submenus_[key], "activate", G_CALLBACK(handleGtkMenuEvent), (gpointer) menuActionsMap_[key].c_str());
|
||||
|
||||
}
|
||||
// Enable click
|
||||
enable_click = true;
|
||||
}
|
||||
|
||||
event_box_.signal_enter_notify_event().connect(sigc::mem_fun(*this, &AModule::handleMouseEnter));
|
||||
event_box_.signal_leave_notify_event().connect(sigc::mem_fun(*this, &AModule::handleMouseLeave));
|
||||
@ -84,10 +66,6 @@ AModule::AModule(const Json::Value& config, const std::string& name, const std::
|
||||
}
|
||||
}
|
||||
|
||||
void AModule::handleGtkMenuEvent(GtkMenuItem* menuitem, gpointer data) {
|
||||
waybar::util::command::res res = waybar::util::command::exec((char*) data, "TLP");
|
||||
}
|
||||
|
||||
AModule::~AModule() {
|
||||
for (const auto& pid : pid_) {
|
||||
if (pid != -1) {
|
||||
|
Reference in New Issue
Block a user