Code

mpdclient: update mpdclient.playlist in mpdclient_cmd_clear()
[ncmpc.git] / src / song_paint.c
1 /* ncmpc (Ncurses MPD Client)
2  * (c) 2004-2009 The Music Player Daemon Project
3  * Project homepage: http://musicpd.org
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
20 #include "song_paint.h"
21 #include "paint.h"
22 #include "strfsong.h"
23 #include "utils.h"
24 #include "config.h"
26 #include <mpd/client.h>
28 #include <glib.h>
30 #include <string.h>
32 void
33 paint_song_row(WINDOW *w, G_GNUC_UNUSED unsigned y, unsigned width,
34                bool selected, bool highlight, const struct mpd_song *song)
35 {
36         char buffer[width * 4];
38         strfsong(buffer, sizeof(buffer), options.list_format, song);
39         row_paint_text(w, width, highlight ? COLOR_LIST_BOLD : COLOR_LIST,
40                        selected, buffer);
42 #ifndef NCMPC_MINI
43         if (mpd_song_get_duration(song) > 0) {
44                 char duration[32];
45                 format_duration_short(duration, sizeof(duration),
46                                       mpd_song_get_duration(song));
47                 wmove(w, y, width - strlen(duration) - 1);
48                 waddch(w, ' ');
49                 waddstr(w, duration);
50         }
51 #endif
52 }