From 447adfd0291eaeccef5661431f6d62811fa23c57 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 11 Oct 2009 19:46:11 +0200 Subject: [PATCH] list_window: removed second column support Not used anymore, because both screen_browser and screen_queue have a row paint callback now. --- src/list_window.c | 61 ++++++++------------------------------------ src/list_window.h | 6 ++--- src/screen_artist.c | 3 +-- src/screen_browser.c | 7 +---- src/screen_help.c | 4 +-- src/screen_keydef.c | 4 +-- src/screen_queue.c | 26 ++++++------------- src/screen_search.c | 3 +-- src/screen_song.c | 3 +-- src/screen_text.c | 3 +-- src/screen_text.h | 2 +- 11 files changed, 28 insertions(+), 94 deletions(-) diff --git a/src/list_window.c b/src/list_window.c index d1a6ce3..23e478f 100644 --- a/src/list_window.c +++ b/src/list_window.c @@ -322,38 +322,11 @@ list_window_scroll_down(struct list_window *lw, unsigned n) } static void -list_window_paint_row(WINDOW *w, unsigned y, unsigned width, - bool selected, bool highlight, - const char *text, const char *second_column) +list_window_paint_row(WINDOW *w, unsigned width, bool selected, + const char *text) { - unsigned second_column_width; - -#ifdef NCMPC_MINI - second_column = NULL; - highlight = false; -#endif /* NCMPC_MINI */ - - if (second_column != NULL) { - second_column_width = utf8_width(second_column) + 1; - if (second_column_width < width) - width -= second_column_width; - else - second_column_width = 0; - } else - second_column_width = 0; - - row_color(w, highlight ? COLOR_LIST_BOLD : COLOR_LIST, selected); - - waddstr(w, text); - - /* erase the unused space after the text */ - row_clear_to_eol(w, width, selected); - - if (second_column_width > 0) { - wmove(w, y, width); - waddch(w, ' '); - waddstr(w, second_column); - } + row_paint_text(w, width, COLOR_LIST, + selected, text); } void @@ -370,8 +343,6 @@ list_window_paint(const struct list_window *lw, for (unsigned i = 0; i < lw->rows; i++) { const char *label; - bool highlight = false; - char *second_column = NULL; wmove(lw->w, i, 0); @@ -380,23 +351,14 @@ list_window_paint(const struct list_window *lw, break; } - label = callback(lw->start + i, &highlight, &second_column, callback_data); + label = callback(lw->start + i, callback_data); assert(label != NULL); -#ifdef NCMPC_MINI - highlight = false; - second_column = NULL; -#endif /* NCMPC_MINI */ - - list_window_paint_row(lw->w, i, lw->cols, + list_window_paint_row(lw->w, lw->cols, show_cursor && lw->start + i >= range.start && lw->start + i < range.end, - highlight, - label, second_column); - - if (second_column != NULL) - g_free(second_column); + label); } row_color_end(lw->w); @@ -456,7 +418,6 @@ list_window_find(struct list_window *lw, bool wrap, bool bell_on_wrap) { - bool h; unsigned i = lw->selected + 1; const char *label; @@ -464,7 +425,7 @@ list_window_find(struct list_window *lw, do { while (i < lw->length) { - label = callback(i, &h, NULL, callback_data); + label = callback(i, callback_data); assert(label != NULL); if (match_line(label, str)) { @@ -496,7 +457,6 @@ list_window_rfind(struct list_window *lw, bool wrap, bool bell_on_wrap) { - bool h; int i = lw->selected - 1; const char *label; @@ -507,7 +467,7 @@ list_window_rfind(struct list_window *lw, do { while (i >= 0) { - label = callback(i, &h, NULL, callback_data); + label = callback(i, callback_data); assert(label != NULL); if (match_line(label, str)) { @@ -552,13 +512,12 @@ list_window_jump(struct list_window *lw, void *callback_data, const char *str) { - bool h; const char *label; assert(str != NULL); for (unsigned i = 0; i < lw->length; ++i) { - label = callback(i, &h, NULL, callback_data); + label = callback(i, callback_data); assert(label != NULL); if (jump_match(label, str)) { diff --git a/src/list_window.h b/src/list_window.h index 8ffe40f..cf938f8 100644 --- a/src/list_window.h +++ b/src/list_window.h @@ -33,10 +33,8 @@ #include #endif -typedef const char *(*list_window_callback_fn_t)(unsigned index, - bool *highlight, - char **second_column, - void *data); +typedef const char * +(*list_window_callback_fn_t)(unsigned i, void *data); typedef void (*list_window_paint_callback_t)(WINDOW *w, unsigned i, diff --git a/src/screen_artist.c b/src/screen_artist.c index 847bed0..a12b263 100644 --- a/src/screen_artist.c +++ b/src/screen_artist.c @@ -60,8 +60,7 @@ compare_utf8(gconstpointer s1, gconstpointer s2) /* list_window callback */ static const char * -screen_artist_lw_callback(unsigned idx, G_GNUC_UNUSED bool *highlight, - G_GNUC_UNUSED char** sc, G_GNUC_UNUSED void *data) +screen_artist_lw_callback(unsigned idx, void *data) { GPtrArray *list = data; static char buf[BUFSIZE]; diff --git a/src/screen_browser.c b/src/screen_browser.c index 6070e69..455053c 100644 --- a/src/screen_browser.c +++ b/src/screen_browser.c @@ -76,7 +76,7 @@ screen_browser_sync_highlights(struct filelist *fl, /* 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]; @@ -90,11 +90,6 @@ 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 ".."; diff --git a/src/screen_help.c b/src/screen_help.c index 1a66b69..a501aad 100644 --- a/src/screen_help.c +++ b/src/screen_help.c @@ -184,9 +184,7 @@ static const struct help_text_row help_text[] = { static struct list_window *lw; static const char * -list_callback(unsigned i, - G_GNUC_UNUSED bool *highlight, G_GNUC_UNUSED char** second_column, - G_GNUC_UNUSED void *data) +list_callback(unsigned i, G_GNUC_UNUSED void *data) { const struct help_text_row *row = &help_text[i]; diff --git a/src/screen_keydef.c b/src/screen_keydef.c index cea71b4..36472bf 100644 --- a/src/screen_keydef.c +++ b/src/screen_keydef.c @@ -190,7 +190,7 @@ assign_new_key(int cmd_index, int key_index) } static const char * -list_callback(unsigned idx, bool *highlight, G_GNUC_UNUSED char** sc, G_GNUC_UNUSED void *data) +list_callback(unsigned idx, G_GNUC_UNUSED void *data) { static char buf[BUFSIZE]; @@ -202,8 +202,6 @@ list_callback(unsigned idx, bool *highlight, G_GNUC_UNUSED char** sc, G_GNUC_UNU assert(idx < (unsigned)command_list_length); - if (cmds[idx].flags & COMMAND_KEY_CONFLICT) - *highlight = true; return cmds[idx].name; } else { if (idx == 0) diff --git a/src/screen_queue.c b/src/screen_queue.c index b36ba66..750abb0 100644 --- a/src/screen_queue.c +++ b/src/screen_queue.c @@ -56,8 +56,10 @@ typedef struct struct mpdclient *c; } completion_callback_data_t; +/* static struct hscroll hscroll; static guint scroll_source_id; +*/ #endif static struct mpdclient_playlist *playlist; @@ -118,6 +120,7 @@ screen_queue_restore_selection(void) screen_queue_save_selection(); } +/* #ifndef NCMPC_MINI static gboolean scroll_timer_callback(G_GNUC_UNUSED gpointer data) @@ -129,10 +132,10 @@ scroll_timer_callback(G_GNUC_UNUSED gpointer data) return false; } #endif +*/ static const char * -screen_queue_lw_callback(unsigned idx, bool *highlight, char **second_column, - G_GNUC_UNUSED void *data) +screen_queue_lw_callback(unsigned idx, G_GNUC_UNUSED void *data) { static char songname[MAX_SONG_LENGTH]; struct mpd_song *song; @@ -141,26 +144,14 @@ screen_queue_lw_callback(unsigned idx, bool *highlight, char **second_column, assert(idx < playlist_length(playlist)); song = playlist_get(playlist, idx); - if ((int)mpd_song_get_id(song) == current_song_id) - *highlight = true; strfsong(songname, MAX_SONG_LENGTH, options.list_format, song); + /* #ifndef NCMPC_MINI - if (second_column != NULL && mpd_song_get_duration(song) > 0) { - char duration[32]; - format_duration_short(duration, sizeof(duration), - mpd_song_get_duration(song)); - *second_column = g_strdup(duration); - } - if (idx == lw->selected) { - int second_column_len = 0; - if (second_column != NULL && *second_column != NULL) - second_column_len = strlen(*second_column); - if (options.scroll && utf8_width(songname) > (unsigned)(COLS - second_column_len - 1) ) - { + if (options.scroll && utf8_width(songname) > (unsigned)COLS) { static unsigned current_song; char *tmp; @@ -188,9 +179,8 @@ screen_queue_lw_callback(unsigned idx, bool *highlight, char **second_column, } } } -#else - (void)second_column; #endif + */ return songname; } diff --git a/src/screen_search.c b/src/screen_search.c index 7a8c011..781dd0c 100644 --- a/src/screen_search.c +++ b/src/screen_search.c @@ -108,8 +108,7 @@ static const char *const help_text[] = { /* search info */ static const char * -lw_search_help_callback(unsigned idx, G_GNUC_UNUSED bool *highlight, - G_GNUC_UNUSED char** sc, G_GNUC_UNUSED void *data) +lw_search_help_callback(unsigned idx, G_GNUC_UNUSED void *data) { assert(idx < G_N_ELEMENTS(help_text)); diff --git a/src/screen_song.c b/src/screen_song.c index 121599e..3696cd2 100644 --- a/src/screen_song.c +++ b/src/screen_song.c @@ -76,8 +76,7 @@ screen_song_repaint(void) } static const char * -screen_song_list_callback(unsigned idx, G_GNUC_UNUSED bool *highlight, - G_GNUC_UNUSED char** sc, G_GNUC_UNUSED void *data) +screen_song_list_callback(unsigned idx, G_GNUC_UNUSED void *data) { static char buffer[256]; char *value; diff --git a/src/screen_text.c b/src/screen_text.c index a80b562..b7d6683 100644 --- a/src/screen_text.c +++ b/src/screen_text.c @@ -80,8 +80,7 @@ screen_text_set(struct screen_text *text, const GString *str) } const char * -screen_text_list_callback(unsigned idx, G_GNUC_UNUSED bool *highlight, - G_GNUC_UNUSED char** sc, void *data) +screen_text_list_callback(unsigned idx, void *data) { const struct screen_text *text = data; static char buffer[256]; diff --git a/src/screen_text.h b/src/screen_text.h index 5358feb..43ae3c6 100644 --- a/src/screen_text.h +++ b/src/screen_text.h @@ -69,7 +69,7 @@ void screen_text_set(struct screen_text *text, const GString *str); const char * -screen_text_list_callback(unsigned idx, bool *highlight, char** sc, void *data); +screen_text_list_callback(unsigned idx, void *data); static inline void screen_text_paint(struct screen_text *text) -- 2.30.2