From bc1b86c584fe51b4e8ce94c48b940dd61e35b429 Mon Sep 17 00:00:00 2001
From: patrick96
Date: Sun, 24 May 2020 00:36:16 +0200
Subject: [PATCH] actions: Separate data from action string
Modules now no longer need to manually parse the action string and
extract data from it.
---
include/components/builder.hpp | 4 +--
include/modules/alsa.hpp | 2 +-
include/modules/backlight.hpp | 2 +-
include/modules/bspwm.hpp | 2 +-
include/modules/date.hpp | 2 +-
include/modules/i3.hpp | 2 +-
include/modules/menu.hpp | 2 +-
include/modules/meta/base.hpp | 2 +-
include/modules/meta/base.inl | 2 +-
include/modules/meta/input_handler.hpp | 7 +++--
include/modules/mpd.hpp | 2 +-
include/modules/pulseaudio.hpp | 2 +-
include/modules/systray.hpp | 2 +-
include/modules/unsupported.hpp | 2 +-
include/modules/xbacklight.hpp | 2 +-
include/modules/xkeyboard.hpp | 2 +-
include/modules/xworkspaces.hpp | 2 +-
include/utils/actions.hpp | 25 +----------------
src/components/builder.cpp | 8 +++---
src/components/controller.cpp | 32 +++++++++++++++------
src/modules/alsa.cpp | 8 +++---
src/modules/backlight.cpp | 6 ++--
src/modules/bspwm.cpp | 20 ++++++-------
src/modules/date.cpp | 4 +--
src/modules/i3.cpp | 13 ++++-----
src/modules/menu.cpp | 12 ++++----
src/modules/mpd.cpp | 39 +++++++++++++-------------
src/modules/pulseaudio.cpp | 8 +++---
src/modules/systray.cpp | 4 +--
src/modules/xbacklight.cpp | 6 ++--
src/modules/xkeyboard.cpp | 4 +--
src/modules/xworkspaces.cpp | 18 ++++++------
src/utils/actions.cpp | 18 ++++--------
33 files changed, 124 insertions(+), 142 deletions(-)
diff --git a/include/components/builder.hpp b/include/components/builder.hpp
index 36782dbc..c847d2ec 100644
--- a/include/components/builder.hpp
+++ b/include/components/builder.hpp
@@ -49,9 +49,9 @@ class builder {
void underline_close();
void control(controltag tag);
void action(mousebtn index, string action);
- void action(mousebtn btn, const modules::input_handler& handler, string action);
+ void action(mousebtn btn, const modules::input_handler& handler, string action, string data);
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(mousebtn btn, const modules::input_handler& handler, string action, string data, const label_t& label);
void action_close();
protected:
diff --git a/include/modules/alsa.hpp b/include/modules/alsa.hpp
index f96dd44b..da97c7bb 100644
--- a/include/modules/alsa.hpp
+++ b/include/modules/alsa.hpp
@@ -36,7 +36,7 @@ namespace modules {
static constexpr auto EVENT_TOGGLE = "toggle";
protected:
- bool input(string&& action);
+ bool input(string&& action, string&& data);
private:
static constexpr auto FORMAT_VOLUME = "format-volume";
diff --git a/include/modules/backlight.hpp b/include/modules/backlight.hpp
index 54fbd914..4bec7501 100644
--- a/include/modules/backlight.hpp
+++ b/include/modules/backlight.hpp
@@ -32,7 +32,7 @@ namespace modules {
static constexpr const char* EVENT_DEC = "dec";
protected:
- bool input(string&& cmd);
+ bool input(string&& cmd, string&& data);
private:
static constexpr auto TAG_LABEL = "