new screen: mpd server info

This commit is contained in:
Andrzej Rybczak
2009-10-11 17:03:00 +02:00
parent aebc5db0e1
commit 03f6fd904f
14 changed files with 322 additions and 52 deletions

View File

@@ -162,6 +162,49 @@ template <typename C> void String2Buffer(const std::basic_string<C> &s, basic_bu
}
}
template <typename T> void ShowTime(T &buf, size_t length, bool short_names)
{
const unsigned MINUTE = 60;
const unsigned HOUR = 60*MINUTE;
const unsigned DAY = 24*HOUR;
const unsigned YEAR = 365*DAY;
unsigned years = length/YEAR;
if (years)
{
buf << years << (short_names ? "y" : (years == 1 ? " year" : " years"));
length -= years*YEAR;
if (length)
buf << ", ";
}
unsigned days = length/DAY;
if (days)
{
buf << days << (short_names ? "d" : (days == 1 ? " day" : " days"));
length -= days*DAY;
if (length)
buf << ", ";
}
unsigned hours = length/HOUR;
if (hours)
{
buf << hours << (short_names ? "h" : (hours == 1 ? " hour" : " hours"));
length -= hours*HOUR;
if (length)
buf << ", ";
}
unsigned minutes = length/MINUTE;
if (minutes)
{
buf << minutes << (short_names ? "m" : (minutes == 1 ? " minute" : " minutes"));
length -= minutes*MINUTE;
if (length)
buf << ", ";
}
if (length)
buf << length << (short_names ? "s" : (length == 1 ? " second" : " seconds"));
}
template <typename T> void ShowTag(T &buf, const std::string &tag)
{
if (tag.empty())
@@ -175,6 +218,8 @@ inline bool Keypressed(int in, const int *key)
return in == key[0] || in == key[1];
}
std::string Timestamp(time_t t);
void UpdateSongList(Menu<MPD::Song> *);
#ifdef HAVE_TAGLIB_H