Code

list_window: removed second column support
authorMax Kellermann <max@duempel.org>
Sun, 11 Oct 2009 17:46:11 +0000 (19:46 +0200)
committerMax Kellermann <max@duempel.org>
Sun, 11 Oct 2009 17:46:11 +0000 (19:46 +0200)
Not used anymore, because both screen_browser and screen_queue have a
row paint callback now.

src/list_window.c
src/list_window.h
src/screen_artist.c
src/screen_browser.c
src/screen_help.c
src/screen_keydef.c
src/screen_queue.c
src/screen_search.c
src/screen_song.c
src/screen_text.c
src/screen_text.h

index d1a6ce3ff2ca9f4d18b9046921317dbeb641037c..23e478f2d43f0855a1560b2bd30300b6e6787464 100644 (file)
@@ -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)) {
index 8ffe40f9bd5ca0cf79d11b3a82c11b16e51f0744..cf938f8ce1a793a312bfbb7875d5af61217941a4 100644 (file)
 #include <ncurses.h>
 #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,
index 847bed045286f3a73c3dc3d0d193ded91751a6f5..a12b26303c772a1e83bdb6dd434d8d3733dd4d0a 100644 (file)
@@ -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];
index 6070e6902ee94dcfe7097c880803ec7e8dcf98fe..455053c60a5bcab4e294079642818a01faa74ca1 100644 (file)
@@ -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 "..";
index 1a66b698fbf7915eeb9ed12a26271b9dd18776b4..a501aad045281cf818ab23c6e516c704879354aa 100644 (file)
@@ -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];
 
index cea71b49d6462fdc53a744e80e277ce3f983a39b..36472bf521cb8d424f886326377144eaeac4d933 100644 (file)
@@ -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)
index b36ba66c8f87d686d6c4fad0bbe3b5064508304b..750abb01d451b784bb1256c532406748d1a9f5dd 100644 (file)
@@ -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;
 }
index 7a8c01134582cf8a23044459ebc183699efd90b4..781dd0c24b1d7f5b075d367e9c5126ae03285512 100644 (file)
@@ -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));
 
index 121599eb97f2dd85f9a93bef1a9761cba7a517fb..3696cd23957fe6ca30efa88a74b0fa25995078b2 100644 (file)
@@ -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;
index a80b56240b09ecc18c22d21ce7b6ebf32ba4b175..b7d66838fa6a6de260a10894857c59628c499f27 100644 (file)
@@ -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];
index 5358feb82e9329f73c00e778d3596fe71f3ff63e..43ae3c66c9f5a3ff3a87303e612ff884bc78f8f7 100644 (file)
@@ -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)