lyrics: move code that saves lyrics to separate function

This commit is contained in:
Andrzej Rybczak
2010-08-10 00:30:41 +02:00
parent 443516acbf
commit d7f862ce86
2 changed files with 15 additions and 8 deletions

View File

@@ -229,15 +229,11 @@ void *Lyrics::Get(void *screen_void_ptr)
if (result.first == true)
{
screen->w->Clear();
*screen->w << utf_to_locale_cpy(result.second);
screen->Save(result.second);
std::ofstream output(screen->itsFilenamePath.c_str());
if (output.is_open())
{
output << result.second;
output.close();
}
utf_to_locale(result.second);
screen->w->Clear();
*screen->w << result.second;
}
else
*screen->w << "\nLyrics weren't found.";
@@ -273,6 +269,16 @@ void Lyrics::Edit()
system(("nohup " + Config.external_editor + " \"" + itsFilenamePath + "\" > /dev/null 2>&1 &").c_str());
}
void Lyrics::Save(const std::string &lyrics)
{
std::ofstream output(itsFilenamePath.c_str());
if (output.is_open())
{
output << lyrics;
output.close();
}
}
void Lyrics::FetchAgain()
{
std::string path = Folder + "/" + locale_to_utf_cpy(itsSong.GetArtist()) + " - " + locale_to_utf_cpy(itsSong.GetTitle()) + ".txt";

View File

@@ -46,6 +46,7 @@ class Lyrics : public Screen<Scrollpad>
virtual List *GetList() { return 0; }
void Edit();
void Save(const std::string &lyrics);
void FetchAgain();
static bool Reload;