🎨 clang-tidy

This commit is contained in:
Benjamin Voisin 2024-05-09 20:59:25 +02:00
parent 3b87b83076
commit 21751b2faa
No known key found for this signature in database
GPG Key ID: C5C8EDD125FBFD78
4 changed files with 13 additions and 10 deletions

View File

@ -28,9 +28,9 @@ class ALabel : public AModule {
bool handleToggle(GdkEventButton *const &e) override; bool handleToggle(GdkEventButton *const &e) override;
virtual std::string getState(uint8_t value, bool lesser = false); virtual std::string getState(uint8_t value, bool lesser = false);
std::map<std::string, GtkMenuItem*> submenus_; std::map<std::string, GtkMenuItem *> submenus_;
std::map<std::string, std::string> menuActionsMap_; std::map<std::string, std::string> menuActionsMap_;
static void handleGtkMenuEvent(GtkMenuItem* menuitem, gpointer data); static void handleGtkMenuEvent(GtkMenuItem *menuitem, gpointer data);
}; };
} // namespace waybar } // namespace waybar

View File

@ -2,9 +2,9 @@
#include <glibmm/dispatcher.h> #include <glibmm/dispatcher.h>
#include <glibmm/markup.h> #include <glibmm/markup.h>
#include <gtkmm.h>
#include <gtkmm/eventbox.h> #include <gtkmm/eventbox.h>
#include <json/json.h> #include <json/json.h>
#include <gtkmm.h>
#include "IModule.hpp" #include "IModule.hpp"
@ -45,7 +45,7 @@ class AModule : public IModule {
virtual bool handleMouseLeave(GdkEventCrossing *const &ev); virtual bool handleMouseLeave(GdkEventCrossing *const &ev);
virtual bool handleScroll(GdkEventScroll *); virtual bool handleScroll(GdkEventScroll *);
virtual bool handleRelease(GdkEventButton *const &ev); virtual bool handleRelease(GdkEventButton *const &ev);
GObject* menu_; GObject *menu_;
private: private:
bool handleUserEvent(GdkEventButton *const &ev); bool handleUserEvent(GdkEventButton *const &ev);

View File

@ -9,7 +9,9 @@ namespace waybar {
ALabel::ALabel(const Json::Value& config, const std::string& name, const std::string& id, ALabel::ALabel(const Json::Value& config, const std::string& name, const std::string& id,
const std::string& format, uint16_t interval, bool ellipsize, bool enable_click, const std::string& format, uint16_t interval, bool ellipsize, bool enable_click,
bool enable_scroll) bool enable_scroll)
: AModule(config, name, id, config["format-alt"].isString() || config["menu"].isString() || enable_click, enable_scroll), : AModule(config, name, id,
config["format-alt"].isString() || config["menu"].isString() || enable_click,
enable_scroll),
format_(config_["format"].isString() ? config_["format"].asString() : format), format_(config_["format"].isString() ? config_["format"].asString() : format),
interval_(config_["interval"] == "once" interval_(config_["interval"] == "once"
? std::chrono::seconds::max() ? std::chrono::seconds::max()
@ -59,11 +61,13 @@ ALabel::ALabel(const Json::Value& config, const std::string& name, const std::st
submenus_ = std::map<std::string, GtkMenuItem*>(); submenus_ = std::map<std::string, GtkMenuItem*>();
menuActionsMap_ = std::map<std::string, std::string>(); menuActionsMap_ = std::map<std::string, std::string>();
// Linking actions to the GTKMenu based on // Linking actions to the GTKMenu based on
for (Json::Value::const_iterator it = config_["menu-actions"].begin(); it != config_["menu-actions"].end(); ++it) { for (Json::Value::const_iterator it = config_["menu-actions"].begin();
it != config_["menu-actions"].end(); ++it) {
std::string key = it.key().asString(); std::string key = it.key().asString();
submenus_[key] = GTK_MENU_ITEM(gtk_builder_get_object(builder, key.c_str())); submenus_[key] = GTK_MENU_ITEM(gtk_builder_get_object(builder, key.c_str()));
menuActionsMap_[key] = it->asString(); menuActionsMap_[key] = it->asString();
g_signal_connect(submenus_[key], "activate", G_CALLBACK(handleGtkMenuEvent), (gpointer) menuActionsMap_[key].c_str()); g_signal_connect(submenus_[key], "activate", G_CALLBACK(handleGtkMenuEvent),
(gpointer)menuActionsMap_[key].c_str());
} }
} }
@ -142,7 +146,7 @@ bool waybar::ALabel::handleToggle(GdkEventButton* const& e) {
} }
void ALabel::handleGtkMenuEvent(GtkMenuItem* menuitem, gpointer data) { void ALabel::handleGtkMenuEvent(GtkMenuItem* menuitem, gpointer data) {
waybar::util::command::res res = waybar::util::command::exec((char*) data, "GtkMenu"); waybar::util::command::res res = waybar::util::command::exec((char*)data, "GtkMenu");
} }
std::string ALabel::getState(uint8_t value, bool lesser) { std::string ALabel::getState(uint8_t value, bool lesser) {

View File

@ -138,8 +138,7 @@ bool AModule::handleUserEvent(GdkEventButton* const& e) {
if (rec->second == config_["menu"].asString()) { if (rec->second == config_["menu"].asString()) {
// Popup the menu // Popup the menu
gtk_widget_show_all(GTK_WIDGET(menu_)); gtk_widget_show_all(GTK_WIDGET(menu_));
gtk_menu_popup_at_pointer (GTK_MENU(menu_), reinterpret_cast<GdkEvent*>(e)); gtk_menu_popup_at_pointer(GTK_MENU(menu_), reinterpret_cast<GdkEvent*>(e));
} }
// Second call user scripts // Second call user scripts
if (!format.empty()) { if (!format.empty()) {