get rid of locale_to_utf where it's not needed anymore
This commit is contained in:
@@ -901,7 +901,6 @@ void SavePlaylist::Run()
|
|||||||
Statusbar::lock();
|
Statusbar::lock();
|
||||||
Statusbar::put() << "Save playlist as: ";
|
Statusbar::put() << "Save playlist as: ";
|
||||||
std::string playlist_name = wFooter->getString();
|
std::string playlist_name = wFooter->getString();
|
||||||
std::string real_playlist_name = locale_to_utf_cpy(playlist_name);
|
|
||||||
Statusbar::unlock();
|
Statusbar::unlock();
|
||||||
if (playlist_name.find("/") != std::string::npos)
|
if (playlist_name.find("/") != std::string::npos)
|
||||||
{
|
{
|
||||||
@@ -914,14 +913,14 @@ void SavePlaylist::Run()
|
|||||||
{
|
{
|
||||||
Mpd.StartCommandsList();
|
Mpd.StartCommandsList();
|
||||||
for (size_t i = 0; i < myPlaylist->Items->size(); ++i)
|
for (size_t i = 0; i < myPlaylist->Items->size(); ++i)
|
||||||
Mpd.AddToPlaylist(real_playlist_name, (*myPlaylist->Items)[i].value());
|
Mpd.AddToPlaylist(playlist_name, (*myPlaylist->Items)[i].value());
|
||||||
Mpd.CommitCommandsList();
|
Mpd.CommitCommandsList();
|
||||||
if (Mpd.GetErrorMessage().empty())
|
if (Mpd.GetErrorMessage().empty())
|
||||||
Statusbar::msg("Filtered items added to playlist \"%s\"", playlist_name.c_str());
|
Statusbar::msg("Filtered items added to playlist \"%s\"", playlist_name.c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int result = Mpd.SavePlaylist(real_playlist_name);
|
int result = Mpd.SavePlaylist(playlist_name);
|
||||||
if (result == MPD_ERROR_SUCCESS)
|
if (result == MPD_ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
Statusbar::msg("Playlist saved as \"%s\"", playlist_name.c_str());
|
Statusbar::msg("Playlist saved as \"%s\"", playlist_name.c_str());
|
||||||
@@ -933,8 +932,8 @@ void SavePlaylist::Run()
|
|||||||
bool yes = AskYesNoQuestion("Playlist \"" + playlist_name + "\" already exists, overwrite?", TraceMpdStatus);
|
bool yes = AskYesNoQuestion("Playlist \"" + playlist_name + "\" already exists, overwrite?", TraceMpdStatus);
|
||||||
if (yes)
|
if (yes)
|
||||||
{
|
{
|
||||||
Mpd.DeletePlaylist(real_playlist_name);
|
Mpd.DeletePlaylist(playlist_name);
|
||||||
if (Mpd.SavePlaylist(real_playlist_name) == MPD_ERROR_SUCCESS)
|
if (Mpd.SavePlaylist(playlist_name) == MPD_ERROR_SUCCESS)
|
||||||
Statusbar::msg("Playlist overwritten");
|
Statusbar::msg("Playlist overwritten");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1062,7 +1061,6 @@ void Add::Run()
|
|||||||
Statusbar::lock();
|
Statusbar::lock();
|
||||||
Statusbar::put() << (myScreen == myPlaylistEditor ? "Add to playlist: " : "Add: ");
|
Statusbar::put() << (myScreen == myPlaylistEditor ? "Add to playlist: " : "Add: ");
|
||||||
std::string path = wFooter->getString();
|
std::string path = wFooter->getString();
|
||||||
locale_to_utf(path);
|
|
||||||
Statusbar::unlock();
|
Statusbar::unlock();
|
||||||
if (!path.empty())
|
if (!path.empty())
|
||||||
{
|
{
|
||||||
@@ -1210,7 +1208,7 @@ void TogglePlayingSongCentering::Run()
|
|||||||
void UpdateDatabase::Run()
|
void UpdateDatabase::Run()
|
||||||
{
|
{
|
||||||
if (myScreen == myBrowser)
|
if (myScreen == myBrowser)
|
||||||
Mpd.UpdateDirectory(locale_to_utf_cpy(myBrowser->CurrentDir()));
|
Mpd.UpdateDirectory(myBrowser->CurrentDir());
|
||||||
# ifdef HAVE_TAGLIB_H
|
# ifdef HAVE_TAGLIB_H
|
||||||
else if (myScreen == myTagEditor)
|
else if (myScreen == myTagEditor)
|
||||||
Mpd.UpdateDirectory(myTagEditor->CurrentDir());
|
Mpd.UpdateDirectory(myTagEditor->CurrentDir());
|
||||||
@@ -1370,7 +1368,7 @@ void EditLibraryTag::Run()
|
|||||||
{
|
{
|
||||||
Statusbar::msg("Updating tags...");
|
Statusbar::msg("Updating tags...");
|
||||||
Mpd.StartSearch(1);
|
Mpd.StartSearch(1);
|
||||||
Mpd.AddSearch(Config.media_lib_primary_tag, locale_to_utf_cpy(myLibrary->Tags->current().value()));
|
Mpd.AddSearch(Config.media_lib_primary_tag, myLibrary->Tags->current().value());
|
||||||
MPD::MutableSong::SetFunction set = tagTypeToSetFunction(Config.media_lib_primary_tag);
|
MPD::MutableSong::SetFunction set = tagTypeToSetFunction(Config.media_lib_primary_tag);
|
||||||
assert(set);
|
assert(set);
|
||||||
bool success = true;
|
bool success = true;
|
||||||
@@ -1482,18 +1480,18 @@ void EditDirectoryName::Run()
|
|||||||
std::string full_old_dir;
|
std::string full_old_dir;
|
||||||
if (!myBrowser->isLocal())
|
if (!myBrowser->isLocal())
|
||||||
full_old_dir += Config.mpd_music_dir;
|
full_old_dir += Config.mpd_music_dir;
|
||||||
full_old_dir += locale_to_utf_cpy(old_dir);
|
full_old_dir += old_dir;
|
||||||
std::string full_new_dir;
|
std::string full_new_dir;
|
||||||
if (!myBrowser->isLocal())
|
if (!myBrowser->isLocal())
|
||||||
full_new_dir += Config.mpd_music_dir;
|
full_new_dir += Config.mpd_music_dir;
|
||||||
full_new_dir += locale_to_utf_cpy(new_dir);
|
full_new_dir += new_dir;
|
||||||
int rename_result = rename(full_old_dir.c_str(), full_new_dir.c_str());
|
int rename_result = rename(full_old_dir.c_str(), full_new_dir.c_str());
|
||||||
if (rename_result == 0)
|
if (rename_result == 0)
|
||||||
{
|
{
|
||||||
const char msg[] = "Directory renamed to \"%ls\"";
|
const char msg[] = "Directory renamed to \"%ls\"";
|
||||||
Statusbar::msg(msg, wideShorten(ToWString(new_dir), COLS-const_strlen(msg)).c_str());
|
Statusbar::msg(msg, wideShorten(ToWString(new_dir), COLS-const_strlen(msg)).c_str());
|
||||||
if (!myBrowser->isLocal())
|
if (!myBrowser->isLocal())
|
||||||
Mpd.UpdateDirectory(locale_to_utf_cpy(getSharedDirectory(old_dir, new_dir)));
|
Mpd.UpdateDirectory(getSharedDirectory(old_dir, new_dir));
|
||||||
myBrowser->GetDirectory(myBrowser->CurrentDir());
|
myBrowser->GetDirectory(myBrowser->CurrentDir());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1513,8 +1511,8 @@ void EditDirectoryName::Run()
|
|||||||
Statusbar::unlock();
|
Statusbar::unlock();
|
||||||
if (!new_dir.empty() && new_dir != old_dir)
|
if (!new_dir.empty() && new_dir != old_dir)
|
||||||
{
|
{
|
||||||
std::string full_old_dir = Config.mpd_music_dir + myTagEditor->CurrentDir() + "/" + locale_to_utf_cpy(old_dir);
|
std::string full_old_dir = Config.mpd_music_dir + myTagEditor->CurrentDir() + "/" + old_dir;
|
||||||
std::string full_new_dir = Config.mpd_music_dir + myTagEditor->CurrentDir() + "/" + locale_to_utf_cpy(new_dir);
|
std::string full_new_dir = Config.mpd_music_dir + myTagEditor->CurrentDir() + "/" + new_dir;
|
||||||
if (rename(full_old_dir.c_str(), full_new_dir.c_str()) == 0)
|
if (rename(full_old_dir.c_str(), full_new_dir.c_str()) == 0)
|
||||||
{
|
{
|
||||||
const char msg[] = "Directory renamed to \"%ls\"";
|
const char msg[] = "Directory renamed to \"%ls\"";
|
||||||
@@ -1555,7 +1553,7 @@ void EditPlaylistName::Run()
|
|||||||
Statusbar::unlock();
|
Statusbar::unlock();
|
||||||
if (!new_name.empty() && new_name != old_name)
|
if (!new_name.empty() && new_name != old_name)
|
||||||
{
|
{
|
||||||
if (Mpd.Rename(locale_to_utf_cpy(old_name), locale_to_utf_cpy(new_name)))
|
if (Mpd.Rename(old_name, new_name))
|
||||||
{
|
{
|
||||||
const char msg[] = "Playlist renamed to \"%ls\"";
|
const char msg[] = "Playlist renamed to \"%ls\"";
|
||||||
Statusbar::msg(msg, wideShorten(ToWString(new_name), COLS-const_strlen(msg)).c_str());
|
Statusbar::msg(msg, wideShorten(ToWString(new_name), COLS-const_strlen(msg)).c_str());
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ void Browser::EnterPressed()
|
|||||||
}
|
}
|
||||||
case itPlaylist:
|
case itPlaylist:
|
||||||
{
|
{
|
||||||
if (Mpd.LoadPlaylist(locale_to_utf_cpy(item.name)))
|
if (Mpd.LoadPlaylist(item.name))
|
||||||
{
|
{
|
||||||
Statusbar::msg("Playlist \"%s\" loaded", item.name.c_str());
|
Statusbar::msg("Playlist \"%s\" loaded", item.name.c_str());
|
||||||
myPlaylist->PlayNewlyAddedSongs();
|
myPlaylist->PlayNewlyAddedSongs();
|
||||||
@@ -204,7 +204,7 @@ void Browser::SpacePressed()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
# endif // !WIN32
|
# endif // !WIN32
|
||||||
result = Mpd.Add(locale_to_utf_cpy(item.name));
|
result = Mpd.Add(item.name);
|
||||||
if (result)
|
if (result)
|
||||||
Statusbar::msg("Directory \"%s\" added", item.name.c_str());
|
Statusbar::msg("Directory \"%s\" added", item.name.c_str());
|
||||||
break;
|
break;
|
||||||
@@ -216,7 +216,7 @@ void Browser::SpacePressed()
|
|||||||
}
|
}
|
||||||
case itPlaylist:
|
case itPlaylist:
|
||||||
{
|
{
|
||||||
if (Mpd.LoadPlaylist(locale_to_utf_cpy(item.name)))
|
if (Mpd.LoadPlaylist(item.name))
|
||||||
Statusbar::msg("Playlist \"%s\" loaded", item.name.c_str());
|
Statusbar::msg("Playlist \"%s\" loaded", item.name.c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -403,8 +403,6 @@ void Browser::GetDirectory(std::string dir, std::string subdir)
|
|||||||
w->reset();
|
w->reset();
|
||||||
itsBrowsedDir = dir;
|
itsBrowsedDir = dir;
|
||||||
|
|
||||||
locale_to_utf(dir);
|
|
||||||
|
|
||||||
w->clear();
|
w->clear();
|
||||||
|
|
||||||
if (dir != "/")
|
if (dir != "/")
|
||||||
@@ -434,13 +432,11 @@ void Browser::GetDirectory(std::string dir, std::string subdir)
|
|||||||
{
|
{
|
||||||
case itPlaylist:
|
case itPlaylist:
|
||||||
{
|
{
|
||||||
utf_to_locale(it->name);
|
|
||||||
w->addItem(*it);
|
w->addItem(*it);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case itDirectory:
|
case itDirectory:
|
||||||
{
|
{
|
||||||
utf_to_locale(it->name);
|
|
||||||
if (it->name == subdir)
|
if (it->name == subdir)
|
||||||
highlightme = w->size();
|
highlightme = w->size();
|
||||||
w->addItem(*it);
|
w->addItem(*it);
|
||||||
@@ -589,7 +585,7 @@ bool Browser::deleteItem(const MPD::Item &item)
|
|||||||
|
|
||||||
// playlist created by mpd
|
// playlist created by mpd
|
||||||
if (!isLocal() && item.type == itPlaylist && CurrentDir() == "/")
|
if (!isLocal() && item.type == itPlaylist && CurrentDir() == "/")
|
||||||
return Mpd.DeletePlaylist(locale_to_utf_cpy(item.name));
|
return Mpd.DeletePlaylist(item.name);
|
||||||
|
|
||||||
std::string path;
|
std::string path;
|
||||||
if (!isLocal())
|
if (!isLocal())
|
||||||
|
|||||||
@@ -31,10 +31,10 @@
|
|||||||
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
namespace
|
namespace {//
|
||||||
|
|
||||||
|
bool is_utf8(const char *s)
|
||||||
{
|
{
|
||||||
bool is_utf8(const char *s)
|
|
||||||
{
|
|
||||||
for (; *s; ++s)
|
for (; *s; ++s)
|
||||||
{
|
{
|
||||||
if (*s & 0x80) // 1xxxxxxx
|
if (*s & 0x80) // 1xxxxxxx
|
||||||
@@ -51,46 +51,53 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool has_non_ascii_chars(const char *s)
|
bool has_non_ascii_chars(const char *s)
|
||||||
{
|
{
|
||||||
for (; *s; ++s)
|
for (; *s; ++s)
|
||||||
if (*s & 0x80)
|
if (*s & 0x80)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void charset_convert(const char *from, const char *to, const char *&inbuf, bool delete_old, size_t len = 0)
|
void charset_convert(const char *from, const char *to, const char *&inbuf,
|
||||||
{
|
bool delete_old, size_t len = 0)
|
||||||
if (!inbuf || !from || !to)
|
{
|
||||||
return;
|
assert(inbuf);
|
||||||
|
assert(from);
|
||||||
|
assert(to);
|
||||||
|
|
||||||
iconv_t cd = iconv_open(to, from);
|
iconv_t cd = iconv_open(to, from);
|
||||||
|
|
||||||
if (cd == iconv_t(-1))
|
if (cd == iconv_t(-1))
|
||||||
|
{
|
||||||
|
std::cerr << "Error while executing iconv_open: " << strerror(errno) << "\n";
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!len)
|
if (!len)
|
||||||
len = strlen(inbuf);
|
len = strlen(inbuf);
|
||||||
size_t buflen = len*6+1;
|
size_t buflen = len*MB_CUR_MAX+1;
|
||||||
char *outbuf = new char[buflen];
|
char *outbuf = static_cast<char *>(malloc(buflen));
|
||||||
char *outstart = outbuf;
|
char *outstart = outbuf;
|
||||||
const char *instart = inbuf;
|
const char *instart = inbuf;
|
||||||
|
|
||||||
if (iconv(cd, const_cast<ICONV_CONST char **>(&inbuf), &len, &outbuf, &buflen) == size_t(-1))
|
if (iconv(cd, const_cast<ICONV_CONST char **>(&inbuf), &len, &outbuf, &buflen) == size_t(-1))
|
||||||
{
|
{
|
||||||
|
std::cerr << "Error while executing iconv: " << strerror(errno) << "\n";
|
||||||
inbuf = instart;
|
inbuf = instart;
|
||||||
delete [] outstart;
|
delete [] outstart;
|
||||||
iconv_close(cd);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
iconv_close(cd);
|
else
|
||||||
|
{
|
||||||
*outbuf = 0;
|
*outbuf = 0;
|
||||||
if (delete_old)
|
if (delete_old)
|
||||||
free(const_cast<char *>(instart));
|
free(const_cast<char *>(instart));
|
||||||
inbuf = outstart;
|
inbuf = outstart;
|
||||||
}
|
}
|
||||||
|
iconv_close(cd);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void iconv_convert_from_to(const char *from, const char *to, std::string &s)
|
void iconv_convert_from_to(const char *from, const char *to, std::string &s)
|
||||||
@@ -103,7 +110,7 @@ void iconv_convert_from_to(const char *from, const char *to, std::string &s)
|
|||||||
|
|
||||||
void utf_to_locale(std::string &s)
|
void utf_to_locale(std::string &s)
|
||||||
{
|
{
|
||||||
if (s.empty() || Config.system_encoding.empty() || !has_non_ascii_chars(s.c_str()))
|
if (Config.system_encoding.empty() || !has_non_ascii_chars(s.c_str()))
|
||||||
return;
|
return;
|
||||||
const char *tmp = strdup(s.c_str());
|
const char *tmp = strdup(s.c_str());
|
||||||
charset_convert("utf-8", Config.system_encoding.c_str(), tmp, 1, s.length());
|
charset_convert("utf-8", Config.system_encoding.c_str(), tmp, 1, s.length());
|
||||||
@@ -120,7 +127,7 @@ std::string utf_to_locale_cpy(const std::string &s)
|
|||||||
|
|
||||||
void locale_to_utf(std::string &s)
|
void locale_to_utf(std::string &s)
|
||||||
{
|
{
|
||||||
if (s.empty() || Config.system_encoding.empty() || !has_non_ascii_chars(s.c_str()) || is_utf8(s.c_str()))
|
if (Config.system_encoding.empty() || !has_non_ascii_chars(s.c_str()) || is_utf8(s.c_str()))
|
||||||
return;
|
return;
|
||||||
const char *tmp = strdup(s.c_str());
|
const char *tmp = strdup(s.c_str());
|
||||||
charset_convert(Config.system_encoding.c_str(), "utf-8", tmp, 1, s.length());
|
charset_convert(Config.system_encoding.c_str(), "utf-8", tmp, 1, s.length());
|
||||||
|
|||||||
@@ -21,9 +21,7 @@
|
|||||||
#ifndef _CHARSET_H
|
#ifndef _CHARSET_H
|
||||||
#define _CHARSET_H
|
#define _CHARSET_H
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#include "config.h"
|
||||||
#include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_ICONV_H
|
#ifdef HAVE_ICONV_H
|
||||||
|
|
||||||
|
|||||||
@@ -123,8 +123,6 @@ void Lastfm::Load()
|
|||||||
w->reset();
|
w->reset();
|
||||||
|
|
||||||
std::string artist = itsArgs.find("artist")->second;
|
std::string artist = itsArgs.find("artist")->second;
|
||||||
locale_to_utf(artist);
|
|
||||||
|
|
||||||
std::string file = lowercase(artist + ".txt");
|
std::string file = lowercase(artist + ".txt");
|
||||||
removeInvalidCharsFromFilename(file);
|
removeInvalidCharsFromFilename(file);
|
||||||
|
|
||||||
|
|||||||
@@ -244,8 +244,8 @@ void Lyrics::DownloadInBackgroundImplHelper(const MPD::Song &s)
|
|||||||
|
|
||||||
void *Lyrics::Download()
|
void *Lyrics::Download()
|
||||||
{
|
{
|
||||||
std::string artist = Curl::escape(locale_to_utf_cpy(itsSong.getArtist()));
|
std::string artist = Curl::escape(itsSong.getArtist());
|
||||||
std::string title = Curl::escape(locale_to_utf_cpy(itsSong.getTitle()));
|
std::string title = Curl::escape(itsSong.getTitle());
|
||||||
|
|
||||||
LyricsFetcher::Result result;
|
LyricsFetcher::Result result;
|
||||||
|
|
||||||
@@ -267,9 +267,8 @@ void *Lyrics::Download()
|
|||||||
if (result.first == true)
|
if (result.first == true)
|
||||||
{
|
{
|
||||||
Save(itsFilename, result.second);
|
Save(itsFilename, result.second);
|
||||||
|
|
||||||
utf_to_locale(result.second);
|
|
||||||
w->clear();
|
w->clear();
|
||||||
|
utf_to_locale(result.second);
|
||||||
*w << result.second;
|
*w << result.second;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -306,9 +305,9 @@ std::string Lyrics::GenerateFilename(const MPD::Song &s)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string file = locale_to_utf_cpy(s.getArtist());
|
std::string file = s.getArtist();
|
||||||
file += " - ";
|
file += " - ";
|
||||||
file += locale_to_utf_cpy(s.getTitle());
|
file += s.getTitle();
|
||||||
file += ".txt";
|
file += ".txt";
|
||||||
removeInvalidCharsFromFilename(file);
|
removeInvalidCharsFromFilename(file);
|
||||||
filename = Config.lyrics_directory;
|
filename = Config.lyrics_directory;
|
||||||
|
|||||||
@@ -350,12 +350,12 @@ void MediaLibrary::Update()
|
|||||||
Songs->reset();
|
Songs->reset();
|
||||||
|
|
||||||
Mpd.StartSearch(1);
|
Mpd.StartSearch(1);
|
||||||
Mpd.AddSearch(Config.media_lib_primary_tag, locale_to_utf_cpy(hasTwoColumns ? Albums->current().value().PrimaryTag : Tags->current().value()));
|
Mpd.AddSearch(Config.media_lib_primary_tag, hasTwoColumns ? Albums->current().value().PrimaryTag : Tags->current().value());
|
||||||
if (Albums->current().value().Date != AllTracksMarker)
|
if (Albums->current().value().Date != AllTracksMarker)
|
||||||
{
|
{
|
||||||
Mpd.AddSearch(MPD_TAG_ALBUM, locale_to_utf_cpy(Albums->current().value().Album));
|
Mpd.AddSearch(MPD_TAG_ALBUM, Albums->current().value().Album);
|
||||||
if (Config.media_library_display_date)
|
if (Config.media_library_display_date)
|
||||||
Mpd.AddSearch(MPD_TAG_DATE, locale_to_utf_cpy(Albums->current().value().Date));
|
Mpd.AddSearch(MPD_TAG_DATE, Albums->current().value().Date);
|
||||||
}
|
}
|
||||||
auto songs = Mpd.CommitSearchSongs();
|
auto songs = Mpd.CommitSearchSongs();
|
||||||
for (auto s = songs.begin(); s != songs.end(); ++s)
|
for (auto s = songs.begin(); s != songs.end(); ++s)
|
||||||
|
|||||||
@@ -277,7 +277,7 @@ void PlaylistEditor::AddToPlaylist(bool add_n_play)
|
|||||||
|
|
||||||
if (w == Playlists && !Playlists->empty())
|
if (w == Playlists && !Playlists->empty())
|
||||||
{
|
{
|
||||||
if (Mpd.LoadPlaylist(utf_to_locale_cpy(Playlists->current().value())))
|
if (Mpd.LoadPlaylist(Playlists->current().value()))
|
||||||
{
|
{
|
||||||
Statusbar::msg("Playlist \"%s\" loaded", Playlists->current().value().c_str());
|
Statusbar::msg("Playlist \"%s\" loaded", Playlists->current().value().c_str());
|
||||||
if (add_n_play)
|
if (add_n_play)
|
||||||
|
|||||||
@@ -179,17 +179,16 @@ void SelectedItemsAdder::EnterPressed()
|
|||||||
Statusbar::unlock();
|
Statusbar::unlock();
|
||||||
if (!playlist.empty())
|
if (!playlist.empty())
|
||||||
{
|
{
|
||||||
std::string utf_playlist = locale_to_utf_cpy(playlist);
|
|
||||||
Mpd.StartCommandsList();
|
Mpd.StartCommandsList();
|
||||||
for (auto it = list.begin(); it != list.end(); ++it)
|
for (auto it = list.begin(); it != list.end(); ++it)
|
||||||
Mpd.AddToPlaylist(utf_playlist, *it);
|
Mpd.AddToPlaylist(playlist, *it);
|
||||||
if (Mpd.CommitCommandsList())
|
if (Mpd.CommitCommandsList())
|
||||||
Statusbar::msg("Selected item(s) added to playlist \"%s\"", playlist.c_str());
|
Statusbar::msg("Selected item(s) added to playlist \"%s\"", playlist.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (pos > 1 && pos < w->size()-1) // add items to existing playlist
|
else if (pos > 1 && pos < w->size()-1) // add items to existing playlist
|
||||||
{
|
{
|
||||||
std::string playlist = locale_to_utf_cpy(w->current().value());
|
std::string playlist = w->current().value();
|
||||||
Mpd.StartCommandsList();
|
Mpd.StartCommandsList();
|
||||||
for (auto it = list.begin(); it != list.end(); ++it)
|
for (auto it = list.begin(); it != list.end(); ++it)
|
||||||
Mpd.AddToPlaylist(playlist, *it);
|
Mpd.AddToPlaylist(playlist, *it);
|
||||||
|
|||||||
@@ -1078,7 +1078,6 @@ bool TagEditor::WriteTags(MPD::MutableSong &s)
|
|||||||
if (file_is_from_db)
|
if (file_is_from_db)
|
||||||
new_name += Config.mpd_music_dir;
|
new_name += Config.mpd_music_dir;
|
||||||
new_name += s.getDirectory() + "/" + s.getNewURI();
|
new_name += s.getDirectory() + "/" + s.getNewURI();
|
||||||
locale_to_utf(new_name);
|
|
||||||
if (rename(path_to_file.c_str(), new_name.c_str()) == 0 && !file_is_from_db)
|
if (rename(path_to_file.c_str(), new_name.c_str()) == 0 && !file_is_from_db)
|
||||||
{
|
{
|
||||||
if (Global::myOldScreen == myPlaylist)
|
if (Global::myOldScreen == myPlaylist)
|
||||||
|
|||||||
Reference in New Issue
Block a user