diff --git a/src/screen_browser.c b/src/screen_browser.c
index 922e4de52fe2e8d2b316a15934d3f068fb4fc74a..ed07b6957a0fbbaaf8f2ade06539c13d0d40d902 100644 (file)
--- a/src/screen_browser.c
+++ b/src/screen_browser.c
#include "filelist.h"
#include "colors.h"
#include "paint.h"
-#include "utils.h"
+#include "song_paint.h"
#include <mpd/client.h>
/* list_window callback */
static const char *
-browser_lw_callback(unsigned idx, bool *highlight, G_GNUC_UNUSED char **second_column, void *data)
+browser_lw_callback(unsigned idx, void *data)
{
const struct filelist *fl = (const struct filelist *) data;
static char buf[BUFSIZE];
assert(entry != NULL);
entity = entry->entity;
-#ifndef NCMPC_MINI
- *highlight = (entry->flags & HIGHLIGHT) != 0;
-#else
- *highlight = false;
-#endif
if( entity == NULL )
return "..";
mpd_entity_get_directory(entity);
char *directory = utf8_to_locale(g_basename(mpd_directory_get_path(dir)));
g_strlcpy(buf, directory, sizeof(buf));
+ g_free(directory);
return buf;
} else if (mpd_entity_get_type(entity) == MPD_ENTITY_TYPE_SONG) {
const struct mpd_song *song = mpd_entity_get_song(entity);
load_playlist(struct mpdclient *c, const struct mpd_playlist *playlist)
{
struct mpd_connection *connection = mpdclient_get_connection(c);
- char *filename = utf8_to_locale(mpd_playlist_get_path(playlist));
+
+ if (connection == NULL)
+ return false;
if (mpd_run_load(connection, mpd_playlist_get_path(playlist))) {
+ char *filename = utf8_to_locale(mpd_playlist_get_path(playlist));
screen_status_printf(_("Loading playlist %s..."),
g_basename(filename));
+ g_free(filename);
+
c->events |= MPD_IDLE_QUEUE;
} else
mpdclient_handle_error(c);
- g_free(filename);
return true;
}
row_clear_to_eol(w, width, selected);
}
-static void
-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];
-
- 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
screen_browser_paint_playlist(WINDOW *w, unsigned width,
bool selected, const char *name)
break;
case MPD_ENTITY_TYPE_SONG:
- screen_browser_paint_song(w, y, width, selected, highlight,
- mpd_entity_get_song(entity));
+ paint_song_row(w, y, width, selected, highlight,
+ mpd_entity_get_song(entity));
break;
case MPD_ENTITY_TYPE_PLAYLIST: