Code

screen_browser: display song duration
authorMax Kellermann <max@duempel.org>
Sun, 11 Oct 2009 13:41:34 +0000 (15:41 +0200)
committerMax Kellermann <max@duempel.org>
Sun, 11 Oct 2009 13:41:34 +0000 (15:41 +0200)
NEWS
src/screen_browser.c

diff --git a/NEWS b/NEWS
index 15ed5c3ed3da214cab19d742380e8b35f3563267..7b12cbec5f0cd462cf66e0bc2d8beca5f0737c2f 100644 (file)
--- 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
index edcd2d93bbbc9c820eac4701be8e1fcfb7fd46ef..922e4de52fe2e8d2b316a15934d3f068fb4fc74a 100644 (file)
@@ -32,6 +32,7 @@
 #include "filelist.h"
 #include "colors.h"
 #include "paint.h"
+#include "utils.h"
 
 #include <mpd/client.h>
 
@@ -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;