summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p@janouch.name>2018-10-29 09:58:11 +0100
committerPřemysl Janouch <p@janouch.name>2018-10-29 09:58:43 +0100
commit6298235e227bf98e5869d555747cb055963a2658 (patch)
treeed57fa770d355abbdb1c74ee95c7918246ee60d2
parent841e2f79c094381661183a7ce3f4307050070fb4 (diff)
downloadnncmpp-6298235e227bf98e5869d555747cb055963a2658.tar.gz
nncmpp-6298235e227bf98e5869d555747cb055963a2658.tar.xz
nncmpp-6298235e227bf98e5869d555747cb055963a2658.zip
Add actions for repeat/random/single/consume
Now the user can at least toggle them from the help tab, or even bind them as necessary.
-rw-r--r--nncmpp.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/nncmpp.c b/nncmpp.c
index 53f447b..5272b04 100644
--- a/nncmpp.c
+++ b/nncmpp.c
@@ -1548,6 +1548,10 @@ app_goto_tab (int tab_index)
XX( MPD_SEARCH, "Global search" ) \
XX( MPD_ADD, "Add selection to playlist" ) \
XX( MPD_REPLACE, "Replace playlist" ) \
+ XX( MPD_REPEAT, "Toggle repeat" ) \
+ XX( MPD_RANDOM, "Toggle random playback" ) \
+ XX( MPD_SINGLE, "Toggle single song playback" ) \
+ XX( MPD_CONSUME, "Toggle consume" ) \
XX( MPD_UPDATE_DB, "Update MPD database" ) \
XX( MPD_COMMAND, "Send raw command to MPD" ) \
\
@@ -1699,6 +1703,14 @@ app_on_editor_end (bool confirmed)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
static bool
+app_mpd_toggle (const char *name)
+{
+ const char *s = str_map_find (&g.playback_info, name);
+ bool value = s && strcmp (s, "0");
+ return MPD_SIMPLE (name, value ? "0" : "1");
+}
+
+static bool
app_process_action (enum action action)
{
// First let the tab try to handle this
@@ -1767,6 +1779,10 @@ app_process_action (enum action action)
case ACTION_MPD_NEXT: return MPD_SIMPLE ("next");
case ACTION_MPD_FORWARD: return MPD_SIMPLE ("seekcur", "+10");
case ACTION_MPD_BACKWARD: return MPD_SIMPLE ("seekcur", "-10");
+ case ACTION_MPD_REPEAT: return app_mpd_toggle ("repeat");
+ case ACTION_MPD_RANDOM: return app_mpd_toggle ("random");
+ case ACTION_MPD_SINGLE: return app_mpd_toggle ("single");
+ case ACTION_MPD_CONSUME: return app_mpd_toggle ("consume");
case ACTION_MPD_UPDATE_DB: return MPD_SIMPLE ("update");
case ACTION_MPD_VOLUME_UP: return app_setvol (g.volume + 10);