X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fscreen_outputs.c;h=67cc4b86fbc0073e0d986f19e95b8f0d71d373cf;hb=bf5fc85f37af5698d477edc5dae250bf8984ed00;hp=5ec897dade076dfa2acbc01e6655fc797f2d7b25;hpb=d0d23a29f2f710e39ae14be009656f7fc2c30560;p=ncmpc.git diff --git a/src/screen_outputs.c b/src/screen_outputs.c index 5ec897d..67cc4b8 100644 --- a/src/screen_outputs.c +++ b/src/screen_outputs.c @@ -1,5 +1,5 @@ /* ncmpc (Ncurses MPD Client) - * (c) 2004-2010 The Music Player Daemon Project + * (c) 2004-2017 The Music Player Daemon Project * Project homepage: http://musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -34,33 +34,20 @@ static struct list_window *lw; static GPtrArray *mpd_outputs = NULL; -static void -outputs_paint(void); - -static void -outputs_repaint(void) -{ - outputs_paint(); - wrefresh(lw->w); -} - static bool toggle_output(struct mpdclient *c, unsigned int output_index) { - struct mpd_connection *connection; - struct mpd_output *output; - assert(mpd_outputs != NULL); if (output_index >= mpd_outputs->len) return false; - connection = mpdclient_get_connection(c); + struct mpd_connection *connection = mpdclient_get_connection(c); if (connection == NULL) return false; - output = g_ptr_array_index(mpd_outputs, output_index); - + struct mpd_output *output = + g_ptr_array_index(mpd_outputs, output_index); if (!mpd_output_get_enabled(output)) { if (!mpd_run_enable_output(connection, mpd_output_get_id(output))) { @@ -114,18 +101,17 @@ clear_outputs_list(void) static void fill_outputs_list(struct mpdclient *c) { - struct mpd_connection *connection; - struct mpd_output *output; - assert(mpd_outputs != NULL); - connection = mpdclient_get_connection(c); + struct mpd_connection *connection = mpdclient_get_connection(c); if (connection == NULL) { list_window_set_length(lw, 0); return; } mpd_send_outputs(connection); + + struct mpd_output *output; while ((output = mpd_recv_output(connection)) != NULL) { g_ptr_array_add(mpd_outputs, output); } @@ -136,7 +122,7 @@ fill_outputs_list(struct mpdclient *c) } static void -outputs_init(WINDOW *w, int cols, int rows) +outputs_init(WINDOW *w, unsigned cols, unsigned rows) { lw = list_window_init(w, cols, rows); @@ -144,7 +130,7 @@ outputs_init(WINDOW *w, int cols, int rows) } static void -outputs_resize(int cols, int rows) +outputs_resize(unsigned cols, unsigned rows) { list_window_resize(lw, cols, rows); } @@ -178,7 +164,7 @@ outputs_title(gcc_unused char *str, gcc_unused size_t size) static void screen_outputs_paint_callback(WINDOW *w, unsigned i, gcc_unused unsigned y, unsigned width, - bool selected, gcc_unused void *data) + bool selected, gcc_unused const void *data) { const struct mpd_output *output; @@ -205,7 +191,7 @@ screen_outputs_update(struct mpdclient *c) if (c->events & MPD_IDLE_OUTPUT) { clear_outputs_list(); fill_outputs_list(c); - outputs_repaint(); + outputs_paint(); } } @@ -215,7 +201,7 @@ outputs_cmd(struct mpdclient *c, command_t cmd) assert(mpd_outputs != NULL); if (list_window_cmd(lw, cmd)) { - outputs_repaint(); + outputs_paint(); return true; } @@ -227,7 +213,7 @@ outputs_cmd(struct mpdclient *c, command_t cmd) case CMD_SCREEN_UPDATE: clear_outputs_list(); fill_outputs_list(c); - outputs_repaint(); + outputs_paint(); return true; default: