From ae2350167b2ba879685bebd29bf44a7971ad16c3 Mon Sep 17 00:00:00 2001 From: patrick96 Date: Sun, 24 May 2020 18:35:12 +0200 Subject: [PATCH] actions: Switch all modules over to new system All modules now expose their actions as public static constants Issues: The menu module no longer closes when an item is clicked (before it would intercept any executed command and look if it matches one of its exec commands) --- include/components/builder.hpp | 10 ++--- include/modules/alsa.hpp | 11 +++--- include/modules/backlight.hpp | 6 +-- include/modules/bspwm.hpp | 11 +++--- include/modules/date.hpp | 5 ++- include/modules/i3.hpp | 11 +++--- include/modules/menu.hpp | 8 ++-- include/modules/meta/base.hpp | 2 +- include/modules/meta/input_handler.hpp | 2 - include/modules/mpd.hpp | 24 ++++++------ include/modules/pulseaudio.hpp | 11 +++--- include/modules/systray.hpp | 5 ++- include/modules/xbacklight.hpp | 8 ++-- include/modules/xkeyboard.hpp | 6 +-- include/modules/xworkspaces.hpp | 11 +++--- src/components/builder.cpp | 28 +++++++------- src/modules/alsa.cpp | 16 ++++---- src/modules/backlight.cpp | 12 +++--- src/modules/bspwm.cpp | 32 +++++++--------- src/modules/date.cpp | 8 ++-- src/modules/i3.cpp | 28 ++++++-------- src/modules/ipc.cpp | 2 +- src/modules/menu.cpp | 28 ++++++-------- src/modules/mpd.cpp | 52 ++++++++++++-------------- src/modules/pulseaudio.cpp | 20 +++++----- src/modules/script.cpp | 2 +- src/modules/systray.cpp | 8 ++-- src/modules/text.cpp | 10 ++--- src/modules/xbacklight.cpp | 14 +++---- src/modules/xkeyboard.cpp | 8 ++-- src/modules/xworkspaces.cpp | 30 ++++++--------- 31 files changed, 197 insertions(+), 232 deletions(-) diff --git a/include/components/builder.hpp b/include/components/builder.hpp index c8e62447..36782dbc 100644 --- a/include/components/builder.hpp +++ b/include/components/builder.hpp @@ -48,11 +48,11 @@ class builder { void underline(const string& color = ""); void underline_close(); void control(controltag tag); - void cmd(mousebtn index, string action); - void cmd(mousebtn btn, const modules::input_handler& handler, string action); - void cmd(mousebtn index, string action, const label_t& label); - void cmd(mousebtn btn, const modules::input_handler& handler, string action, const label_t& label); - void cmd_close(); + void action(mousebtn index, string action); + void action(mousebtn btn, const modules::input_handler& handler, string action); + void action(mousebtn index, string action, const label_t& label); + void action(mousebtn btn, const modules::input_handler& handler, string action, const label_t& label); + void action_close(); protected: string background_hex(); diff --git a/include/modules/alsa.hpp b/include/modules/alsa.hpp index 2b3f52ca..f96dd44b 100644 --- a/include/modules/alsa.hpp +++ b/include/modules/alsa.hpp @@ -31,8 +31,12 @@ namespace modules { static constexpr auto TYPE = "internal/alsa"; + static constexpr auto EVENT_INC = "inc"; + static constexpr auto EVENT_DEC = "dec"; + static constexpr auto EVENT_TOGGLE = "toggle"; + protected: - bool input(string&& cmd); + bool input(string&& action); private: static constexpr auto FORMAT_VOLUME = "format-volume"; @@ -44,11 +48,6 @@ namespace modules { static constexpr auto TAG_LABEL_VOLUME = ""; static constexpr auto TAG_LABEL_MUTED = ""; - static constexpr auto EVENT_PREFIX = "vol"; - static constexpr auto EVENT_VOLUME_UP = "volup"; - static constexpr auto EVENT_VOLUME_DOWN = "voldown"; - static constexpr auto EVENT_TOGGLE_MUTE = "volmute"; - progressbar_t m_bar_volume; ramp_t m_ramp_volume; ramp_t m_ramp_headphones; diff --git a/include/modules/backlight.hpp b/include/modules/backlight.hpp index 751735c8..54fbd914 100644 --- a/include/modules/backlight.hpp +++ b/include/modules/backlight.hpp @@ -28,6 +28,9 @@ namespace modules { static constexpr auto TYPE = "internal/backlight"; + static constexpr const char* EVENT_INC = "inc"; + static constexpr const char* EVENT_DEC = "dec"; + protected: bool input(string&& cmd); @@ -36,9 +39,6 @@ namespace modules { static constexpr auto TAG_BAR = ""; static constexpr auto TAG_RAMP = ""; - static constexpr const char* EVENT_SCROLLUP{"backlight+"}; - static constexpr const char* EVENT_SCROLLDOWN{"backlight-"}; - ramp_t m_ramp; label_t m_label; progressbar_t m_progressbar; diff --git a/include/modules/bspwm.hpp b/include/modules/bspwm.hpp index be97cf8b..602d0940 100644 --- a/include/modules/bspwm.hpp +++ b/include/modules/bspwm.hpp @@ -49,8 +49,12 @@ namespace modules { static constexpr auto TYPE = "internal/bspwm"; + static constexpr auto EVENT_FOCUS = "focus"; + static constexpr auto EVENT_NEXT = "next"; + static constexpr auto EVENT_PREV = "prev"; + protected: - bool input(string&& cmd); + bool input(string&& action); private: bool handle_status(string& data); @@ -63,11 +67,6 @@ namespace modules { static constexpr auto TAG_LABEL_STATE = ""; static constexpr auto TAG_LABEL_MODE = ""; - static constexpr const char* EVENT_PREFIX{"bspwm-desk"}; - static constexpr const char* EVENT_CLICK{"bspwm-deskfocus"}; - static constexpr const char* EVENT_SCROLL_UP{"bspwm-desknext"}; - static constexpr const char* EVENT_SCROLL_DOWN{"bspwm-deskprev"}; - bspwm_util::connection_t m_subscriber; vector> m_monitors; diff --git a/include/modules/date.hpp b/include/modules/date.hpp index 6639b759..9b4fd224 100644 --- a/include/modules/date.hpp +++ b/include/modules/date.hpp @@ -18,12 +18,13 @@ namespace modules { static constexpr auto TYPE = "internal/date"; + static constexpr auto EVENT_TOGGLE = "toggle"; + protected: - bool input(string&& cmd); + bool input(string&& action); private: static constexpr auto TAG_LABEL = "