From a53800489a1721c657e96b019e10e99d6b8d0b5f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 30 Sep 2009 21:13:21 +0200 Subject: [PATCH] screen_outputs: added update() method Automatically queue the "output" idle event when the user enables/disables an output. --- src/screen_outputs.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/screen_outputs.c b/src/screen_outputs.c index 7ecc353..7f19ce2 100644 --- a/src/screen_outputs.c +++ b/src/screen_outputs.c @@ -61,7 +61,7 @@ toggle_output(struct mpdclient *c, unsigned int output_index) return -1; } - /* XXX reload */ + c->events |= MPD_IDLE_OUTPUT; screen_status_printf(_("Output '%s' enabled"), mpd_output_get_name(output)); @@ -72,14 +72,12 @@ toggle_output(struct mpdclient *c, unsigned int output_index) return -1; } - /* XXX reload */ + c->events |= MPD_IDLE_OUTPUT; screen_status_printf(_("Output '%s' disabled"), mpd_output_get_name(output)); } - outputs_repaint(); - return 0; } @@ -186,6 +184,16 @@ outputs_paint(void) list_window_paint(lw, outputs_list_callback, NULL); } +static void +screen_outputs_update(struct mpdclient *c) +{ + if (c->events & MPD_IDLE_OUTPUT) { + clear_outputs_list(); + fill_outputs_list(c); + outputs_repaint(); + } +} + static bool outputs_cmd(struct mpdclient *c, command_t cmd) { @@ -211,6 +219,7 @@ const struct screen_functions screen_outputs = { .close = outputs_close, .resize = outputs_resize, .paint = outputs_paint, + .update = screen_outputs_update, .cmd = outputs_cmd, .get_title = outputs_title, }; -- 2.30.2