summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@lavabit.com>2009-08-07 13:20:45 +0200
committerLars-Dominik Braun <PromyLOPh@lavabit.com>2009-08-07 13:20:45 +0200
commit6a9579be3afecaae2f62baacca10335de1371cf1 (patch)
treeb4937510e443d5c8aa41e63a93f4860a1668e8e4 /src
parentfcb0130deaf8483fa130a3af7a2bb3451c2206a9 (diff)
downloadpianobar-6a9579be3afecaae2f62baacca10335de1371cf1.tar.gz
pianobar-6a9579be3afecaae2f62baacca10335de1371cf1.tar.bz2
pianobar-6a9579be3afecaae2f62baacca10335de1371cf1.zip
New feature: Seed suggestions
Diffstat (limited to 'src')
-rw-r--r--src/ui.c20
-rw-r--r--src/ui.h2
-rw-r--r--src/ui_act.c4
3 files changed, 18 insertions, 8 deletions
diff --git a/src/ui.c b/src/ui.c
index f2630e3..c69a65c 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -239,9 +239,11 @@ PianoArtist_t *BarUiSelectArtist (PianoArtist_t *startArtist, FILE *curFd) {
/* search music: query, search request, return music id
* @param piano handle
+ * @param read data from fd
+ * @param allow seed suggestions if != NULL
* @return musicId or NULL on abort/error
*/
-char *BarUiSelectMusicId (PianoHandle_t *ph, FILE *curFd) {
+char *BarUiSelectMusicId (PianoHandle_t *ph, FILE *curFd, char *similarToId) {
char *musicId = NULL;
char lineBuf[100], selectBuf[2];
PianoSearchResult_t searchResult;
@@ -250,10 +252,18 @@ char *BarUiSelectMusicId (PianoHandle_t *ph, FILE *curFd) {
BarUiMsg (MSG_QUESTION, "Search for artist/title: ");
if (BarReadlineStr (lineBuf, sizeof (lineBuf), 0, curFd) > 0) {
- BarUiMsg (MSG_INFO, "Searching... ");
- if (BarUiPrintPianoStatus (PianoSearchMusic (ph, lineBuf,
- &searchResult)) != PIANO_RET_OK) {
- return NULL;
+ if (strcmp ("?", lineBuf) == 0 && similarToId != NULL) {
+ BarUiMsg (MSG_INFO, "Receiving suggestions... ");
+ if (BarUiPrintPianoStatus (PianoSeedSuggestions (ph, similarToId,
+ 20, &searchResult)) != PIANO_RET_OK) {
+ return NULL;
+ }
+ } else {
+ BarUiMsg (MSG_INFO, "Searching... ");
+ if (BarUiPrintPianoStatus (PianoSearchMusic (ph, lineBuf,
+ &searchResult)) != PIANO_RET_OK) {
+ return NULL;
+ }
}
BarUiMsg (MSG_NONE, "\r");
if (searchResult.songs != NULL && searchResult.artists != NULL) {
diff --git a/src/ui.h b/src/ui.h
index 90b5b28..8726a13 100644
--- a/src/ui.h
+++ b/src/ui.h
@@ -37,7 +37,7 @@ PianoStation_t *BarUiSelectStation (PianoHandle_t *ph, const char *prompt,
FILE *curFd);
PianoSong_t *BarUiSelectSong (PianoSong_t *startSong, FILE *curFd);
PianoArtist_t *BarUiSelectArtist (PianoArtist_t *startArtist, FILE *curFd);
-char *BarUiSelectMusicId (PianoHandle_t *ph, FILE *curFd);
+char *BarUiSelectMusicId (PianoHandle_t *ph, FILE *curFd, char *);
void BarStationFromGenre (PianoHandle_t *ph, FILE *curFd);
inline void BarUiPrintStation (PianoStation_t *);
inline void BarUiPrintSong (PianoSong_t *, PianoStation_t *);
diff --git a/src/ui_act.c b/src/ui_act.c
index ea7a235..a3d33ed 100644
--- a/src/ui_act.c
+++ b/src/ui_act.c
@@ -87,7 +87,7 @@ void BarUiActAddMusic (BAR_KS_ARGS) {
RETURN_IF_NO_STATION;
- musicId = BarUiSelectMusicId (ph, curFd);
+ musicId = BarUiSelectMusicId (ph, curFd, (*curSong)->musicId);
if (musicId != NULL) {
if (!BarTransformIfShared (ph, *curStation)) {
return;
@@ -124,7 +124,7 @@ void BarUiActCreateStation (BAR_KS_ARGS) {
char *musicId;
PianoReturn_t pRet = PIANO_RET_ERR;
- musicId = BarUiSelectMusicId (ph, curFd);
+ musicId = BarUiSelectMusicId (ph, curFd, NULL);
if (musicId != NULL) {
BarUiMsg (MSG_INFO, "Creating station... ");
pRet = BarUiPrintPianoStatus (PianoCreateStation (ph, "mi", musicId));