From 7eba7e939b87b6bebc16ddca94f799e46b2b0aae Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sat, 13 Feb 2010 13:17:00 +0100 Subject: New feature: Bookmark song/artist (keybinding 'b') --- src/main.c | 2 +- src/pianobar.1 | 4 ++++ src/settings.c | 6 ++++-- src/settings.h | 3 ++- src/ui_act.c | 22 ++++++++++++++++++++++ src/ui_act.h | 1 + 6 files changed, 34 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index ce4c76c..d842179 100644 --- a/src/main.c +++ b/src/main.c @@ -321,7 +321,7 @@ int main (int argc, char **argv) { BarUiActQuit, BarUiActRenameStation, BarUiActSelectStation, BarUiActTempBanSong, BarUiActPrintUpcoming, BarUiActSelectQuickMix, - BarUiActDebug}; + BarUiActDebug, BarUiActBookmark}; idToF[i] (&ph, &player, &settings, &playlist, &curStation, &songHistory, &doQuit, curFd); break; diff --git a/src/pianobar.1 b/src/pianobar.1 index b8f5446..6112bce 100644 --- a/src/pianobar.1 +++ b/src/pianobar.1 @@ -45,6 +45,10 @@ pandora.com web interface. Add more music to current station. You will be asked for a search string. Just follow the instructions. If you're clueless try '?' (without quotes). +.TP +.B act_bookmark = b +Bookmark current song or artist. + .TP .B act_stationcreate = c Create new station. You have to enter a search string and select the song or diff --git a/src/settings.c b/src/settings.c index 527a150..1136a3a 100644 --- a/src/settings.c +++ b/src/settings.c @@ -92,7 +92,9 @@ void BarSettingsRead (BarSettings_t *settings) { FILE *configfd; /* _must_ have same order as in BarKeyShortcutId_t */ const char defaultKeys[] = {'?', '+', '-', 'a', 'c', 'd', 'e', 'g', - 'h', 'i', 'j', 'm', 'n', 'p', 'q', 'r', 's', 't', 'u', 'x', '$'}; + 'h', 'i', 'j', 'm', 'n', 'p', 'q', 'r', 's', 't', 'u', 'x', '$', + 'b', + }; const char *shortcutFileKeys[] = { "act_help", "act_songlove", "act_songban", "act_stationaddmusic", "act_stationcreate", "act_stationdelete", "act_songexplain", @@ -100,7 +102,7 @@ void BarSettingsRead (BarSettings_t *settings) { "act_addshared", "act_songmove", "act_songnext", "act_songpause", "act_quit", "act_stationrename", "act_stationchange", "act_songtired", "act_upcoming", "act_stationselectquickmix", - "act_debug" + "act_debug", "act_bookmark", }; /* apply defaults */ diff --git a/src/settings.h b/src/settings.h index 2c6f228..4ecc7b2 100644 --- a/src/settings.h +++ b/src/settings.h @@ -57,8 +57,9 @@ typedef enum { BAR_KS_UPCOMING = 18, BAR_KS_SELECTQUICKMIX = 19, BAR_KS_DEBUG = 20, + BAR_KS_BOOKMARK = 21, /* insert new shortcuts _before_ this element and increase its value */ - BAR_KS_COUNT = 21, + BAR_KS_COUNT = 22, } BarKeyShortcutId_t; typedef struct { diff --git a/src/ui_act.c b/src/ui_act.c index 358029e..80f45c4 100644 --- a/src/ui_act.c +++ b/src/ui_act.c @@ -466,3 +466,25 @@ void BarUiActHistory (BAR_KS_ARGS) { "No history yet.\n"); } } + +/* create song bookmark + */ +void BarUiActBookmark (BAR_KS_ARGS) { + char selectBuf[2]; + PianoReturn_t pRet = PIANO_RET_ERR; + + RETURN_IF_NO_SONG; + + BarUiMsg (MSG_QUESTION, "Bookmark [s]ong or [a]rtist? "); + BarReadline (selectBuf, sizeof (selectBuf), "sa", 1, 0, curFd); + if (selectBuf[0] == 's') { + BarUiMsg (MSG_INFO, "Bookmarking song... "); + pRet = BarUiPrintPianoStatus (PianoBookmarkSong (ph, *curSong)); + BarUiStartEventCmd (settings, "songbookmark", *curStation, *curSong, pRet); + } else if (selectBuf[0] == 'a') { + BarUiMsg (MSG_INFO, "Bookmarking artist... "); + pRet = BarUiPrintPianoStatus (PianoBookmarkArtist (ph, *curSong)); + BarUiStartEventCmd (settings, "artistbookmark", *curStation, *curSong, pRet); + } +} + diff --git a/src/ui_act.h b/src/ui_act.h index 4f0945b..2da5883 100644 --- a/src/ui_act.h +++ b/src/ui_act.h @@ -47,5 +47,6 @@ void BarUiActSelectQuickMix (BAR_KS_ARGS); void BarUiActQuit (BAR_KS_ARGS); void BarUiActDebug (BAR_KS_ARGS); void BarUiActHistory (BAR_KS_ARGS); +void BarUiActBookmark (BAR_KS_ARGS); #endif /* _UI_ACT_H */ -- cgit v1.2.3