diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2011-11-19 12:03:17 +0100 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2011-11-19 12:03:17 +0100 |
commit | 3e527e95e6981856e9aee867a2cd1cd2f19a1276 (patch) | |
tree | fcc47ecda95cff328cabd15e758acaa26ff826e2 /src | |
parent | 08ce71d647acaa282b6a9928ff85c794c02c8b29 (diff) | |
download | pianobar-windows-3e527e95e6981856e9aee867a2cd1cd2f19a1276.tar.gz pianobar-windows-3e527e95e6981856e9aee867a2cd1cd2f19a1276.tar.bz2 pianobar-windows-3e527e95e6981856e9aee867a2cd1cd2f19a1276.zip |
Dymanic station management question
Enable/disable delete options depending on availability.
Diffstat (limited to 'src')
-rw-r--r-- | src/ui_act.c | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/src/ui_act.c b/src/ui_act.c index 80e3b71..c6fb01c 100644 --- a/src/ui_act.c +++ b/src/ui_act.c @@ -577,7 +577,8 @@ BarUiActCallback(BarUiActManageStation) { PianoReturn_t pRet; WaitressReturn_t wRet; PianoRequestDataGetStationInfo_t reqData; - char selectBuf[2]; + char selectBuf[2], allowedActions[6], *allowedPos = allowedActions; + char question[64]; memset (&reqData, 0, sizeof (reqData)); reqData.station = selStation; @@ -586,9 +587,50 @@ BarUiActCallback(BarUiActManageStation) { BarUiActDefaultPianoCall (PIANO_REQUEST_GET_STATION_INFO, &reqData); BarUiActDefaultEventcmd ("stationfetchinfo"); - BarUiMsg (&app->settings, MSG_QUESTION, "Delete [a]rtist/[s]ong/s[t]ation " - "seeds or [f]eedback? "); - if (BarReadline (selectBuf, sizeof (selectBuf), "astf", &app->input, + /* enable submenus depending on data availability */ + strcpy (question, "Delete "); + if (reqData.info.artistSeeds != NULL) { + strcat (question, "[a]rtist"); + *allowedPos++ = 'a'; + } + if (reqData.info.songSeeds != NULL) { + if (allowedPos != allowedActions) { + strcat (question, "/"); + } + strcat (question, "[s]ong"); + *allowedPos++ = 's'; + } + if (reqData.info.stationSeeds != NULL) { + if (allowedPos != allowedActions) { + strcat (question, "/"); + } + strcat (question, "s[t]ation"); + *allowedPos++ = 't'; + } + if (allowedPos != allowedActions) { + strcat (question, " seeds"); + } + if (reqData.info.feedback != NULL) { + if (allowedPos != allowedActions) { + strcat (question, " or "); + } + strcat (question, "[f]eedback"); + *allowedPos++ = 'f'; + } + *allowedPos = '\0'; + strcat (question, "? "); + + assert (strlen (question) < sizeof (question) / sizeof (*question)); + + /* nothing to see? */ + if (allowedPos == allowedActions) { + BarUiMsg (&app->settings, MSG_ERR, "No seeds or feedback available yet.\n"); + PianoDestroyStationInfo (&reqData.info); + return; + } + + BarUiMsg (&app->settings, MSG_QUESTION, question); + if (BarReadline (selectBuf, sizeof (selectBuf), allowedActions, &app->input, BAR_RL_FULLRETURN, -1)) { if (selectBuf[0] == 'a') { PianoArtist_t *artist = BarUiSelectArtist (app, |