From: Max Kellermann Date: Sun, 25 Jul 2010 12:48:31 +0000 (+0200) Subject: screen_song: show song range X-Git-Tag: release-0.18~8 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=d0ae7442c7b8460f00b23156d27633c0ee454ab9;p=ncmpc.git screen_song: show song range --- diff --git a/NEWS b/NEWS index b3269ed..775a645 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,5 @@ ncmpc 0.18 - not yet released +* screen_song: show song range * po: added Italian translation diff --git a/src/screen_song.c b/src/screen_song.c index 2c451c1..e738fc2 100644 --- a/src/screen_song.c +++ b/src/screen_song.c @@ -269,7 +269,34 @@ screen_song_add_song(const struct mpd_song *song, const struct mpdclient *c) char length[16]; format_duration_short(length, sizeof(length), mpd_song_get_duration(song)); - screen_song_append(_(tag_labels[LABEL_LENGTH]), length, + + const char *value = length; + +#if LIBMPDCLIENT_CHECK_VERSION(2,3,0) + char buffer[64]; + + if (mpd_song_get_end(song) > 0) { + char start[16], end[16]; + format_duration_short(start, sizeof(start), + mpd_song_get_start(song)); + format_duration_short(end, sizeof(end), + mpd_song_get_end(song)); + + snprintf(buffer, sizeof(buffer), "%s [%s-%s]\n", + length, start, end); + value = buffer; + } else if (mpd_song_get_start(song) > 0) { + char start[16]; + format_duration_short(start, sizeof(start), + mpd_song_get_start(song)); + + snprintf(buffer, sizeof(buffer), "%s [%s-]\n", + length, start); + value = buffer; + } +#endif + + screen_song_append(_(tag_labels[LABEL_LENGTH]), value, max_tag_label_width); }