diff --git a/src/strfsong.c b/src/strfsong.c
index ff1d6ad6b31931bea0cb9ea22e38ee47e00df099..3d5abd5797dfd78e50e9515f72763efabf5ee7cc 100644 (file)
--- a/src/strfsong.c
+++ b/src/strfsong.c
/* ncmpc (Ncurses MPD Client)
- * (c) 2004-2009 The Music Player Daemon Project
+ * (c) 2004-2010 The Music Player Daemon Project
* Project homepage: http://musicpd.org
-
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
-
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-
+ *
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
+ */
#include "strfsong.h"
#include "charset.h"
+#include "utils.h"
#include <mpd/client.h>
return p;
}
+#ifndef NCMPC_MINI
+
+static char *
+concat_tag_values(const char *a, const char *b)
+{
+ return g_strconcat(a, ", ", b, NULL);
+}
+
+static char *
+song_more_tag_values(const struct mpd_song *song, enum mpd_tag_type tag,
+ const char *first)
+{
+ const char *p = mpd_song_get_tag(song, tag, 1);
+ char *buffer, *prev;
+
+ if (p == NULL)
+ return NULL;
+
+ buffer = concat_tag_values(first, p);
+ for (unsigned i = 2; (p = mpd_song_get_tag(song, tag, i)) != NULL;
+ ++i) {
+ prev = buffer;
+ buffer = concat_tag_values(buffer, p);
+ g_free(prev);
+ }
+
+ return buffer;
+}
+
+#endif /* !NCMPC_MINI */
+
static char *
song_tag_locale(const struct mpd_song *song, enum mpd_tag_type tag)
{
const char *value = mpd_song_get_tag(song, tag, 0);
+ char *result;
+#ifndef NCMPC_MINI
+ char *all;
+#endif /* !NCMPC_MINI */
+
if (value == NULL)
return NULL;
- return utf8_to_locale(value);
+#ifndef NCMPC_MINI
+ all = song_more_tag_values(song, tag, value);
+ if (all != NULL)
+ value = all;
+#endif /* !NCMPC_MINI */
+
+ result = utf8_to_locale(value);
+
+#ifndef NCMPC_MINI
+ g_free(all);
+#endif /* !NCMPC_MINI */
+
+ return result;
}
static gsize
unsigned duration = mpd_song_get_duration(song);
if (duration > 0) {
- if (duration > 3600) {
- temp = g_strdup_printf("%d:%02d:%02d",
- duration / 3600,
- (duration % 3600) / 60,
- duration % 60);
- } else {
- temp = g_strdup_printf("%d:%02d",
- duration / 60,
- duration % 60);
- }
+ char buffer[32];
+ format_duration_short(buffer, sizeof(buffer),
+ duration);
+ temp = g_strdup(buffer);
}
}