summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2013-03-27 22:20:17 +0100
committerLars-Dominik Braun <lars@6xq.net>2013-03-27 22:20:17 +0100
commit8e662ba273cbc59eff94ad0815bb7136d8890065 (patch)
tree0da086da809be756c83a2330aa06f13e723a5e36 /src
parentb849ea7ed9c86ee48a90ffea4991f8f8500427e8 (diff)
downloadpianobar-windows-8e662ba273cbc59eff94ad0815bb7136d8890065.tar.gz
pianobar-windows-8e662ba273cbc59eff94ad0815bb7136d8890065.tar.bz2
pianobar-windows-8e662ba273cbc59eff94ad0815bb7136d8890065.zip
Add missing events to genre station selection
Two new events: stationfetchgenre, stationaddgenre
Diffstat (limited to 'src')
-rw-r--r--src/ui.c70
-rw-r--r--src/ui.h1
-rw-r--r--src/ui_act.c70
3 files changed, 68 insertions, 73 deletions
diff --git a/src/ui.c b/src/ui.c
index d5def60..ae0d880 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -548,76 +548,6 @@ char *BarUiSelectMusicId (BarApp_t *app, PianoStation_t *station,
return musicId;
}
-/* browse genre stations and create shared station
- * @param app handle
- */
-void BarStationFromGenre (BarApp_t *app) {
- PianoReturn_t pRet;
- WaitressReturn_t wRet;
- PianoGenreCategory_t *curCat;
- PianoGenre_t *curGenre;
- int i;
-
- /* receive genre stations list if not yet available */
- if (app->ph.genreStations == NULL) {
- BarUiMsg (&app->settings, MSG_INFO, "Receiving genre stations... ");
- if (!BarUiPianoCall (app, PIANO_REQUEST_GET_GENRE_STATIONS, NULL,
- &pRet, &wRet)) {
- return;
- }
- }
-
- /* print all available categories */
- curCat = app->ph.genreStations;
- i = 0;
- while (curCat != NULL) {
- BarUiMsg (&app->settings, MSG_LIST, "%2i) %s\n", i, curCat->name);
- i++;
- curCat = curCat->next;
- }
-
- do {
- /* select category or exit */
- BarUiMsg (&app->settings, MSG_QUESTION, "Select category: ");
- if (BarReadlineInt (&i, &app->input) == 0) {
- return;
- }
- curCat = app->ph.genreStations;
- while (curCat != NULL && i > 0) {
- curCat = curCat->next;
- i--;
- }
- } while (curCat == NULL);
-
- /* print all available stations */
- curGenre = curCat->genres;
- i = 0;
- while (curGenre != NULL) {
- BarUiMsg (&app->settings, MSG_LIST, "%2i) %s\n", i, curGenre->name);
- i++;
- curGenre = curGenre->next;
- }
-
- do {
- BarUiMsg (&app->settings, MSG_QUESTION, "Select genre: ");
- if (BarReadlineInt (&i, &app->input) == 0) {
- return;
- }
- curGenre = curCat->genres;
- while (curGenre != NULL && i > 0) {
- curGenre = curGenre->next;
- i--;
- }
- } while (curGenre == NULL);
-
- /* create station */
- PianoRequestDataCreateStation_t reqData;
- reqData.token = curGenre->musicId;
- reqData.type = PIANO_MUSICTYPE_INVALID;
- BarUiMsg (&app->settings, MSG_INFO, "Adding shared station \"%s\"... ", curGenre->name);
- BarUiPianoCall (app, PIANO_REQUEST_CREATE_STATION, &reqData, &pRet, &wRet);
-}
-
/* replaces format characters (%x) in format string with custom strings
* @param destination buffer
* @param dest buffer size
diff --git a/src/ui.h b/src/ui.h
index ddef633..4fba9ba 100644
--- a/src/ui.h
+++ b/src/ui.h
@@ -44,7 +44,6 @@ PianoSong_t *BarUiSelectSong (const BarSettings_t *, PianoSong_t *,
BarReadlineFds_t *);
PianoArtist_t *BarUiSelectArtist (BarApp_t *, PianoArtist_t *);
char *BarUiSelectMusicId (BarApp_t *, PianoStation_t *, const char *);
-void BarStationFromGenre (BarApp_t *);
void BarUiPrintStation (const BarSettings_t *, PianoStation_t *);
void BarUiPrintSong (const BarSettings_t *, const PianoSong_t *,
const PianoStation_t *);
diff --git a/src/ui_act.c b/src/ui_act.c
index 9af34bf..0f73018 100644
--- a/src/ui_act.c
+++ b/src/ui_act.c
@@ -263,8 +263,74 @@ BarUiActCallback(BarUiActExplain) {
/* choose genre station and add it as shared station
*/
BarUiActCallback(BarUiActStationFromGenre) {
- /* use genre station */
- BarStationFromGenre (app);
+ PianoReturn_t pRet;
+ WaitressReturn_t wRet;
+ const PianoGenreCategory_t *curCat;
+ const PianoGenre_t *curGenre;
+ int i;
+
+ /* receive genre stations list if not yet available */
+ if (app->ph.genreStations == NULL) {
+ BarUiMsg (&app->settings, MSG_INFO, "Receiving genre stations... ");
+ const bool ret = BarUiActDefaultPianoCall (
+ PIANO_REQUEST_GET_GENRE_STATIONS, NULL);
+ BarUiActDefaultEventcmd ("stationfetchgenre");
+ if (!ret) {
+ return;
+ }
+ }
+
+ /* print all available categories */
+ curCat = app->ph.genreStations;
+ i = 0;
+ while (curCat != NULL) {
+ BarUiMsg (&app->settings, MSG_LIST, "%2i) %s\n", i, curCat->name);
+ i++;
+ curCat = curCat->next;
+ }
+
+ do {
+ /* select category or exit */
+ BarUiMsg (&app->settings, MSG_QUESTION, "Select category: ");
+ if (BarReadlineInt (&i, &app->input) == 0) {
+ return;
+ }
+ curCat = app->ph.genreStations;
+ while (curCat != NULL && i > 0) {
+ curCat = curCat->next;
+ i--;
+ }
+ } while (curCat == NULL);
+
+ /* print all available stations */
+ curGenre = curCat->genres;
+ i = 0;
+ while (curGenre != NULL) {
+ BarUiMsg (&app->settings, MSG_LIST, "%2i) %s\n", i, curGenre->name);
+ i++;
+ curGenre = curGenre->next;
+ }
+
+ do {
+ BarUiMsg (&app->settings, MSG_QUESTION, "Select genre: ");
+ if (BarReadlineInt (&i, &app->input) == 0) {
+ return;
+ }
+ curGenre = curCat->genres;
+ while (curGenre != NULL && i > 0) {
+ curGenre = curGenre->next;
+ i--;
+ }
+ } while (curGenre == NULL);
+
+ /* create station */
+ PianoRequestDataCreateStation_t reqData;
+ reqData.token = curGenre->musicId;
+ reqData.type = PIANO_MUSICTYPE_INVALID;
+ BarUiMsg (&app->settings, MSG_INFO, "Adding genre station \"%s\"... ",
+ curGenre->name);
+ BarUiActDefaultPianoCall (PIANO_REQUEST_CREATE_STATION, &reqData);
+ BarUiActDefaultEventcmd ("stationaddgenre");
}
/* print verbose song information