X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fscreen_browser.c;h=04673f4e85a7e5632525a3cf19820fcab1d80ad6;hb=7fa7a969f4a78792ecfe2c395c02b1d119c1bc48;hp=ed07b6957a0fbbaaf8f2ade06539c13d0d40d902;hpb=9a0647e0647d7530fb6db7d8c1647bffb420d08a;p=ncmpc.git diff --git a/src/screen_browser.c b/src/screen_browser.c index ed07b69..04673f4 100644 --- a/src/screen_browser.c +++ b/src/screen_browser.c @@ -1,5 +1,5 @@ /* 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 @@ -17,6 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "config.h" #include "screen_browser.h" #include "screen_file.h" #include "screen_song.h" @@ -44,8 +45,6 @@ #define HIGHLIGHT (0x01) #endif -static const char playlist_format[] = "*%s*"; - #ifndef NCMPC_MINI /* sync highlight flags with playlist */ @@ -111,7 +110,7 @@ browser_lw_callback(unsigned idx, void *data) mpd_entity_get_playlist(entity); char *filename = utf8_to_locale(g_basename(mpd_playlist_get_path(playlist))); - g_snprintf(buf, BUFSIZE, playlist_format, filename); + g_strlcpy(buf, filename, sizeof(buf)); g_free(filename); return buf; } @@ -144,6 +143,9 @@ static bool enqueue_and_play(struct mpdclient *c, struct filelist_entry *entry) { struct mpd_connection *connection = mpdclient_get_connection(c); + if (connection == NULL) + return false; + const struct mpd_song *song = mpd_entity_get_song(entry->entity); int id; @@ -312,7 +314,7 @@ browser_handle_select(struct screen_browser *browser, struct mpdclient *c) { 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) { @@ -330,14 +332,15 @@ browser_handle_add(struct screen_browser *browser, struct mpdclient *c) { 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; @@ -484,7 +487,7 @@ browser_cmd(struct screen_browser *browser, return false; } -static void +void screen_browser_paint_directory(WINDOW *w, unsigned width, bool selected, const char *name) { @@ -536,11 +539,6 @@ screen_browser_paint_callback(WINDOW *w, unsigned i, 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); @@ -551,7 +549,7 @@ screen_browser_paint_callback(WINDOW *w, unsigned i, case MPD_ENTITY_TYPE_SONG: paint_song_row(w, y, width, selected, highlight, - mpd_entity_get_song(entity)); + mpd_entity_get_song(entity), NULL); break; case MPD_ENTITY_TYPE_PLAYLIST: @@ -562,13 +560,9 @@ screen_browser_paint_callback(WINDOW *w, unsigned i, break; default: - waddstr(w, ""); + row_paint_text(w, width, highlight ? COLOR_LIST_BOLD : COLOR_LIST, + selected, ""); } - - whline(w, ' ', width); - - if (selected) - wattroff(w, A_REVERSE); } void