browser: if current dir doesn't exists, go down one level automatically

This commit is contained in:
Andrzej Rybczak
2010-08-10 00:11:44 +02:00
parent a93096fbda
commit 7c75be82bd
4 changed files with 18 additions and 0 deletions

View File

@@ -372,6 +372,12 @@ std::string ExtractTopName(const std::string &s)
return slash != std::string::npos ? s.substr(++slash) : s;
}
std::string PathGoDownOneLevel(const std::string &path)
{
size_t i = path.rfind('/');
return i == std::string::npos ? "/" : path.substr(0, i);
}
std::basic_string<my_char_t> Scroller(const std::basic_string<my_char_t> &str, size_t &pos, size_t width)
{
std::basic_string<my_char_t> s(str);

View File

@@ -213,6 +213,7 @@ std::string FindSharedDir(const MPD::SongList &);
#endif // HAVE_TAGLIB_H
std::string FindSharedDir(const std::string &, const std::string &);
std::string ExtractTopName(const std::string &);
std::string PathGoDownOneLevel(const std::string &path);
std::string GetLineValue(std::string &, char = '"', char = '"', bool = 0);

View File

@@ -191,7 +191,13 @@ void MPD::Connection::UpdateStatus()
}
}
// if CheckForErrors() invokes callback, it can do some communication with mpd.
// the problem is, we *have* to be out from idle mode here and issuing commands
// will enter it again, which certainly is not desired, so let's block it for
// a while.
BlockIdle(true);
CheckForErrors();
BlockIdle(false);
if (!itsConnection)
return;

View File

@@ -205,6 +205,11 @@ void NcmpcppErrorCallback(MPD::Connection *, int errorid, const char *msg, void
ShowMessage("Password accepted!");
wFooter->SetGetStringHelper(StatusbarGetStringHelper);
}
else if ((errorid >> 8) == MPD_SERVER_ERROR_NO_EXIST && myScreen == myBrowser)
{
myBrowser->GetDirectory(PathGoDownOneLevel(myBrowser->CurrentDir()));
myBrowser->Refresh();
}
else
ShowMessage("%s", msg);
}