From 2c7c4c29ff94c9a67ecbe3eeac86fa147f9f87f4 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 11 Oct 2009 15:41:34 +0200 Subject: [PATCH] screen_browser: display song duration --- NEWS | 1 + src/screen_browser.c | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 15ed5c3..7b12cbe 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,7 @@ ncmpc 0.16 - not yet released * screen_text: start searching at window origin, not bottom * strfsong: support multiple values for a tag * screen_browser: different colors for directories and playlists +* screen_browser: display song duration ncmpc 0.15 - 2009-09-24 diff --git a/src/screen_browser.c b/src/screen_browser.c index edcd2d9..922e4de 100644 --- a/src/screen_browser.c +++ b/src/screen_browser.c @@ -32,6 +32,7 @@ #include "filelist.h" #include "colors.h" #include "paint.h" +#include "utils.h" #include @@ -498,7 +499,8 @@ screen_browser_paint_directory(WINDOW *w, unsigned width, } static void -screen_browser_paint_song(WINDOW *w, unsigned width, bool selected, +screen_browser_paint_song(WINDOW *w, G_GNUC_UNUSED unsigned y, + unsigned width, bool selected, bool highlight, const struct mpd_song *song) { char buffer[width * 4]; @@ -506,6 +508,17 @@ screen_browser_paint_song(WINDOW *w, unsigned width, bool selected, strfsong(buffer, sizeof(buffer), options.list_format, song); row_paint_text(w, width, highlight ? COLOR_LIST_BOLD : COLOR_LIST, selected, buffer); + +#ifndef NCMPC_MINI + if (mpd_song_get_duration(song) > 0) { + char duration[32]; + format_duration_short(duration, sizeof(duration), + mpd_song_get_duration(song)); + wmove(w, y, width - strlen(duration) - 1); + waddch(w, ' '); + waddstr(w, duration); + } +#endif } static void @@ -517,7 +530,7 @@ screen_browser_paint_playlist(WINDOW *w, unsigned width, static void screen_browser_paint_callback(WINDOW *w, unsigned i, - G_GNUC_UNUSED unsigned y, unsigned width, + unsigned y, unsigned width, bool selected, void *data) { const struct filelist *fl = (const struct filelist *) data; @@ -560,7 +573,7 @@ screen_browser_paint_callback(WINDOW *w, unsigned i, break; case MPD_ENTITY_TYPE_SONG: - screen_browser_paint_song(w, width, selected, highlight, + screen_browser_paint_song(w, y, width, selected, highlight, mpd_entity_get_song(entity)); break; -- 2.30.2