diff --git a/src/screen_browser.c b/src/screen_browser.c
index 16a2f5e7045c48233741e19aada820c76b1cdf02..49827647d6e8f0898032fbad629c3b69b6e3a6e9 100644 (file)
--- a/src/screen_browser.c
+++ b/src/screen_browser.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
#include "filelist.h"
#include "colors.h"
#include "paint.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];
@@ -89,21 +90,15 @@ browser_lw_callback(unsigned idx, bool *highlight, G_GNUC_UNUSED char **second_c
assert(entry != NULL);
entity = entry->entity;
-#ifndef NCMPC_MINI
- *highlight = (entry->flags & HIGHLIGHT) != 0;
-#else
- *highlight = false;
-#endif
if( entity == NULL )
- return "[..]";
+ return "..";
if (mpd_entity_get_type(entity) == MPD_ENTITY_TYPE_DIRECTORY) {
const struct mpd_directory *dir =
mpd_entity_get_directory(entity);
char *directory = utf8_to_locale(g_basename(mpd_directory_get_path(dir)));
-
- g_snprintf(buf, BUFSIZE, "[%s]", directory);
+ g_strlcpy(buf, directory, sizeof(buf));
g_free(directory);
return buf;
} else if (mpd_entity_get_type(entity) == MPD_ENTITY_TYPE_SONG) {
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;
}
{
struct list_window_range range;
struct filelist_entry *entry;
- bool success;
+ bool success = false;
list_window_get_range(browser->lw, &range);
for (unsigned i = range.start; i < range.end; ++i) {
{
struct list_window_range range;
struct filelist_entry *entry;
- bool success;
+ bool success = false;
list_window_get_range(browser->lw, &range);
for (unsigned i = range.start; i < range.end; ++i) {
entry = browser_get_index(browser, i);
if (entry != NULL && entry->entity != NULL)
- success = browser_select_entry(c, entry, FALSE);
+ success = browser_select_entry(c, entry, FALSE) ||
+ success;
}
return range.end == range.start + 1 && success;
return false;
}
-static void
+void
screen_browser_paint_directory(WINDOW *w, unsigned width,
bool selected, const char *name)
{
row_clear_to_eol(w, width, selected);
}
-static void
-screen_browser_paint_song(WINDOW *w, 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);
-}
-
static void
screen_browser_paint_playlist(WINDOW *w, unsigned width,
bool selected, const char *name)
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;
highlight = false;
#endif
- if (highlight)
- colors_use(w, COLOR_LIST_BOLD);
- else
- colors_use(w, COLOR_LIST);
-
switch (mpd_entity_get_type(entity)) {
case MPD_ENTITY_TYPE_DIRECTORY:
directory = mpd_entity_get_directory(entity);
break;
case MPD_ENTITY_TYPE_SONG:
- screen_browser_paint_song(w, width, selected, highlight,
- mpd_entity_get_song(entity));
+ paint_song_row(w, y, width, selected, highlight,
+ mpd_entity_get_song(entity), NULL);
break;
case MPD_ENTITY_TYPE_PLAYLIST:
break;
default:
- waddstr(w, "<unknown>");
+ row_paint_text(w, width, highlight ? COLOR_LIST_BOLD : COLOR_LIST,
+ selected, "<unknown>");
}
-
- whline(w, ' ', width);
-
- if (selected)
- wattroff(w, A_REVERSE);
}
void