summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2013-07-07 15:54:23 +0200
committerLars-Dominik Braun <lars@6xq.net>2013-07-07 15:54:23 +0200
commit02b89aa2d2e0df87cb51bae8ffcbfb6439e474dc (patch)
tree7baec4fcdb02ee926af4947513ae9dad2697d503 /src
parentf6df7d7e510f2d8879ec54dce32fee2b691dc32d (diff)
downloadpianobar-windows-02b89aa2d2e0df87cb51bae8ffcbfb6439e474dc.tar.gz
pianobar-windows-02b89aa2d2e0df87cb51bae8ffcbfb6439e474dc.tar.bz2
pianobar-windows-02b89aa2d2e0df87cb51bae8ffcbfb6439e474dc.zip
Add keyboard shortcut to reset volume
Closes #377.
Diffstat (limited to 'src')
-rw-r--r--src/settings.h7
-rw-r--r--src/ui_act.c18
-rw-r--r--src/ui_act.h1
-rw-r--r--src/ui_dispatch.h2
4 files changed, 21 insertions, 7 deletions
diff --git a/src/settings.h b/src/settings.h
index 819f8cb..aad1fc4 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -57,10 +57,11 @@ typedef enum {
BAR_KS_MANAGESTATION = 23,
BAR_KS_PLAYPAUSE2 = 24,
BAR_KS_CREATESTATIONFROMSONG = 25,
- BAR_KS_PLAY = 26,
- BAR_KS_PAUSE = 27,
+ BAR_KS_PLAY = 26,
+ BAR_KS_PAUSE = 27,
+ BAR_KS_VOLRESET = 28,
/* insert new shortcuts _before_ this element and increase its value */
- BAR_KS_COUNT = 28,
+ BAR_KS_COUNT = 29,
} BarKeyShortcutId_t;
#define BAR_KS_DISABLED '\x00'
diff --git a/src/ui_act.c b/src/ui_act.c
index 0f73018..270c1f5 100644
--- a/src/ui_act.c
+++ b/src/ui_act.c
@@ -647,20 +647,30 @@ BarUiActCallback(BarUiActBookmark) {
}
}
+static void BarUiActUpdateScale (BarApp_t *app) {
+ /* FIXME: assuming unsigned integer store is atomic operation */
+ app->player.scale = BarPlayerCalcScale (app->player.gain + app->settings.volume);
+}
+
/* decrease volume
*/
BarUiActCallback(BarUiActVolDown) {
--app->settings.volume;
- /* FIXME: assuming unsigned integer store is atomic operation */
- app->player.scale = BarPlayerCalcScale (app->player.gain + app->settings.volume);
+ BarUiActUpdateScale (app);
}
/* increase volume
*/
BarUiActCallback(BarUiActVolUp) {
++app->settings.volume;
- /* FIXME: assuming unsigned integer store is atomic operation */
- app->player.scale = BarPlayerCalcScale (app->player.gain + app->settings.volume);
+ BarUiActUpdateScale (app);
+}
+
+/* reset volume
+ */
+BarUiActCallback(BarUiActVolReset) {
+ app->settings.volume = 0;
+ BarUiActUpdateScale (app);
}
/* manage station (remove seeds or feedback)
diff --git a/src/ui_act.h b/src/ui_act.h
index 3e6c4c5..bd2cf88 100644
--- a/src/ui_act.h
+++ b/src/ui_act.h
@@ -60,5 +60,6 @@ BarUiActCallback(BarUiActBookmark);
BarUiActCallback(BarUiActVolDown);
BarUiActCallback(BarUiActVolUp);
BarUiActCallback(BarUiActManageStation);
+BarUiActCallback(BarUiActVolReset);
#endif /* _UI_ACT_H */
diff --git a/src/ui_dispatch.h b/src/ui_dispatch.h
index 6b96ae3..ca8a292 100644
--- a/src/ui_dispatch.h
+++ b/src/ui_dispatch.h
@@ -101,6 +101,8 @@ static const BarUiDispatchAction_t dispatchActions[BAR_KS_COUNT] = {
"act_songplay"},
{'S', BAR_DC_GLOBAL | BAR_DC_STATION, BarUiActPause, "pause playback",
"act_songpause"},
+ {'^', BAR_DC_GLOBAL, BarUiActVolReset, "reset volume",
+ "act_volreset"},
};
#include <piano.h>