support for switching between supported lyrics databases at runtime

This commit is contained in:
Andrzej Rybczak
2009-02-02 23:43:12 +01:00
parent baa1c9bf4f
commit b1817a0bc9
7 changed files with 37 additions and 4 deletions

View File

@@ -126,6 +126,8 @@
# #
#key_toggle_display_mode = 'p' #key_toggle_display_mode = 'p'
# #
#key_toggle_lyrics_db = 'L'
#
#key_go_to_containing_directory = 'G' #key_go_to_containing_directory = 'G'
# #
#key_start_searching = 'y' #key_start_searching = 'y'

View File

@@ -151,6 +151,7 @@ void GetKeybindings(Scrollpad &help)
help << DisplayKeys(Key.SongInfo) << "Show song's info\n"; help << DisplayKeys(Key.SongInfo) << "Show song's info\n";
# ifdef HAVE_CURL_CURL_H # ifdef HAVE_CURL_CURL_H
help << DisplayKeys(Key.ArtistInfo) << "Show artist's info\n"; help << DisplayKeys(Key.ArtistInfo) << "Show artist's info\n";
help << DisplayKeys(Key.ToggleLyricsDB) << "Toggle lyrics database\n";
# endif // HAVE_CURL_CURL_H # endif // HAVE_CURL_CURL_H
help << DisplayKeys(Key.Lyrics) << "Show/hide song's lyrics\n\n"; help << DisplayKeys(Key.Lyrics) << "Show/hide song's lyrics\n\n";

View File

@@ -285,13 +285,20 @@ namespace
lyricsplugin_not_found lyricsplugin_not_found
}; };
const char *lyricsplugins_list[] =
{
"lyricwiki.org",
"lyricsplugin.com",
0
};
const LyricsPlugin *ChooseLyricsPlugin(int i) const LyricsPlugin *ChooseLyricsPlugin(int i)
{ {
switch (i) switch (i)
{ {
case 1: case 0:
return &lyricwiki; return &lyricwiki;
case 2: case 1:
return &lyricsplugin; return &lyricsplugin;
default: default:
return &lyricwiki; return &lyricwiki;
@@ -299,6 +306,11 @@ namespace
} }
} }
const char *GetLyricsPluginName(int offset)
{
return lyricsplugins_list[offset];
}
#endif // HAVE_CURL_CURL_H #endif // HAVE_CURL_CURL_H
void *GetLyrics(void *song) void *GetLyrics(void *song)

View File

@@ -36,6 +36,8 @@ struct LyricsPlugin
bool (*not_found)(const string &); bool (*not_found)(const string &);
}; };
const char *GetLyricsPluginName(int);
#endif #endif
void * GetLyrics(void *); void * GetLyrics(void *);

View File

@@ -2562,6 +2562,17 @@ int main(int argc, char *argv[])
} }
// redraw_screen = 1; // redraw_screen = 1;
} }
# ifdef HAVE_CURL_CURL_H
else if (Keypressed(input, Key.ToggleLyricsDB))
{
const char *current_lyrics_plugin = GetLyricsPluginName(++Config.lyrics_db);
if (!current_lyrics_plugin)
{
current_lyrics_plugin = GetLyricsPluginName(Config.lyrics_db = 0);
}
ShowMessage("Using lyrics database: %s", current_lyrics_plugin);
}
# endif // HAVE_CURL_CURL_H
else if (Keypressed(input, Key.ToggleAutoCenter)) else if (Keypressed(input, Key.ToggleAutoCenter))
{ {
Config.autocenter_mode = !Config.autocenter_mode; Config.autocenter_mode = !Config.autocenter_mode;

View File

@@ -160,6 +160,7 @@ void DefaultKeys(ncmpcpp_keys &keys)
keys.StartSearching[0] = 'y'; keys.StartSearching[0] = 'y';
keys.ToggleAutoCenter[0] = 'U'; keys.ToggleAutoCenter[0] = 'U';
keys.ToggleDisplayMode[0] = 'p'; keys.ToggleDisplayMode[0] = 'p';
keys.ToggleLyricsDB[0] = 'L';
keys.GoToParentDir[0] = 263; keys.GoToParentDir[0] = 263;
keys.SwitchTagTypeList[0] = '`'; keys.SwitchTagTypeList[0] = '`';
keys.Quit[0] = 'q'; keys.Quit[0] = 'q';
@@ -223,6 +224,7 @@ void DefaultKeys(ncmpcpp_keys &keys)
keys.StartSearching[1] = null_key; keys.StartSearching[1] = null_key;
keys.ToggleAutoCenter[1] = null_key; keys.ToggleAutoCenter[1] = null_key;
keys.ToggleDisplayMode[1] = null_key; keys.ToggleDisplayMode[1] = null_key;
keys.ToggleLyricsDB[1] = null_key;
keys.GoToParentDir[1] = 127; keys.GoToParentDir[1] = 127;
keys.SwitchTagTypeList[1] = null_key; keys.SwitchTagTypeList[1] = null_key;
keys.Quit[1] = 'Q'; keys.Quit[1] = 'Q';
@@ -284,7 +286,7 @@ void DefaultConfiguration(ncmpcpp_config &conf)
conf.seek_time = 1; conf.seek_time = 1;
conf.playlist_disable_highlight_delay = 5; conf.playlist_disable_highlight_delay = 5;
conf.message_delay_time = 4; conf.message_delay_time = 4;
conf.lyrics_db = 1; conf.lyrics_db = 0;
} }
string GetLineValue(string &line, char a, char b, bool once) string GetLineValue(string &line, char a, char b, bool once)
@@ -481,6 +483,8 @@ void ReadKeys(ncmpcpp_keys &keys)
GetKeys(key, keys.ToggleAutoCenter); GetKeys(key, keys.ToggleAutoCenter);
else if (key.find("key_toggle_display_mode ") != string::npos) else if (key.find("key_toggle_display_mode ") != string::npos)
GetKeys(key, keys.ToggleDisplayMode); GetKeys(key, keys.ToggleDisplayMode);
else if (key.find("key_toggle_lyrics_db ") != string::npos)
GetKeys(key, keys.ToggleLyricsDB);
else if (key.find("key_go_to_containing_directory ") != string::npos) else if (key.find("key_go_to_containing_directory ") != string::npos)
GetKeys(key, keys.GoToContainingDir); GetKeys(key, keys.GoToContainingDir);
else if (key.find("key_start_searching ") != string::npos) else if (key.find("key_start_searching ") != string::npos)
@@ -703,7 +707,7 @@ void ReadConfiguration(ncmpcpp_config &conf)
else if (cl.find("lyrics_database") != string::npos) else if (cl.find("lyrics_database") != string::npos)
{ {
if (!v.empty()) if (!v.empty())
conf.lyrics_db = StrToInt(v); conf.lyrics_db = StrToInt(v)-1;
} }
else if (cl.find("song_window_title_format") != string::npos) else if (cl.find("song_window_title_format") != string::npos)
{ {

View File

@@ -88,6 +88,7 @@ struct ncmpcpp_keys
int StartSearching[2]; int StartSearching[2];
int ToggleAutoCenter[2]; int ToggleAutoCenter[2];
int ToggleDisplayMode[2]; int ToggleDisplayMode[2];
int ToggleLyricsDB[2];
int GoToParentDir[2]; int GoToParentDir[2];
int SwitchTagTypeList[2]; int SwitchTagTypeList[2];
int Quit[2]; int Quit[2];