summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej Rybczak <electricityispower@gmail.com>2010-08-10 00:30:41 +0200
committerAndrzej Rybczak <electricityispower@gmail.com>2010-08-10 00:30:41 +0200
commitd7f862ce86d7f43e13696afc6df837945f04a8a1 (patch)
treef68912d60528836dbf4d220278fdee848f383e34
parent443516acbfb5ce60f02801bbc9320066b2fefce5 (diff)
lyrics: move code that saves lyrics to separate function
-rw-r--r--src/lyrics.cpp22
-rw-r--r--src/lyrics.h1
2 files changed, 15 insertions, 8 deletions
diff --git a/src/lyrics.cpp b/src/lyrics.cpp
index b7190d19..185efef3 100644
--- a/src/lyrics.cpp
+++ b/src/lyrics.cpp
@@ -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";
diff --git a/src/lyrics.h b/src/lyrics.h
index 3e895244..aa86117d 100644
--- a/src/lyrics.h
+++ b/src/lyrics.h
@@ -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;